A collection of helper functions related to event processing, including:

- directory management
- event type determination
- subscription creation and setting callbacks
- event writing

### Hierarchy

- EventUtils

## Index

### Methods

- createEvent
- createSubscription
- ensureEventsDirExists
- ensureFileExists
- getEventContents
- getEventDir
- getListOfApps
- isSharedEvent
- isUserEvent
- setupWatcher
- validateAppName
- writeEvent

## Methods

### Static createEvent

- createEvent(eventName: string, appName: string): Event

- - Defined in @zowe/imperative/src/events/src/EventUtils.ts:155

  Create an event with minimal information

  internal

    This is not intended for application developers

  throws

    {ImperativeError} If the application name is not recognized.

  throws

    {ImperativeError} If we are unable to create the '.events' directory.

  throws

    {ImperativeError} If we are unable to create the event file required for event emission.

  #### Parameters

  - ##### eventName: string

    The name of the event.

  - ##### appName: string

    The name of the application.

  #### Returns Event

  The created event

### Static createSubscription

- createSubscription(eeInst: EventProcessor, eventName: string, eventType: EventTypes): IEventDisposable

- - Defined in @zowe/imperative/src/events/src/EventUtils.ts:183

  Creates and registers a new event subscription for a specific event processor.

  throws

    {ImperativeError} If the application name is not recognized.

  throws

    {ImperativeError} If we are unable to create the '.events' directory.

  throws

    {ImperativeError} If we are unable to create the event file required for event emission.

  #### Parameters

  - ##### eeInst: EventProcessor

    The event processor instance.

  - ##### eventName: string

    The name of the event.

  - ##### eventType: EventTypes

    The type of event.

  #### Returns IEventDisposable

  An interface for managing the subscription.

### Static ensureEventsDirExists

- ensureEventsDirExists(directoryPath: string): void

- - Defined in @zowe/imperative/src/events/src/EventUtils.ts:116

  Ensures that the specified directory for storing event files exists, creating it if necessary.

  throws

    {ImperativeError} If we are unable to create the '.events' directory.

  #### Parameters

  - ##### directoryPath: string

    The path to the directory.

  #### Returns void

### Static ensureFileExists

- ensureFileExists(filePath: string): void

- - Defined in @zowe/imperative/src/events/src/EventUtils.ts:132

  Ensures that the specified file path for storing event data exists, creating it if necessary.

  throws

    {ImperativeError} If we are unable to create the event file required for event emission.

  #### Parameters

  - ##### filePath: string

    The path to the file.

  #### Returns void

### Static getEventContents

- getEventContents(eventFilePath: string): IEventJson

- - Defined in @zowe/imperative/src/events/src/EventUtils.ts:90

  Retrieve the event contents form disk

  internal

    This is not intended for application developers

  throws

    {ImperativeError} If the contents of the event cannot be retrieved.

  #### Parameters

  - ##### eventFilePath: string

    The path to the event file

  #### Returns IEventJson

  The object representing the Event

### Static getEventDir

- getEventDir(appName: string): string

- - Defined in @zowe/imperative/src/events/src/EventUtils.ts:105

  Determines the directory path for storing event files based on the event type and application name.

  throws

    {ImperativeError} If the application name is not recognized.

  #### Parameters

  - ##### appName: string

    The name of the application.

  #### Returns string

  The directory path.

### Static getListOfApps

- getListOfApps(): string[]

- - Defined in @zowe/imperative/src/events/src/EventUtils.ts:39

  Retrieves a list of supported applications from configuration.

  static
  throws

    If the extenders.json file cannot be created when it does not exist.

  throws

    If the extenders.json file cannot be read.

  #### Returns string[]

  List of application names.

### Static isSharedEvent

- isSharedEvent(eventName: string): boolean

- - Defined in @zowe/imperative/src/events/src/EventUtils.ts:78

  Determines if the specified event name is associated with a shared event.

  #### Parameters

  - ##### eventName: string

    The name of the event.

  #### Returns boolean

  True if it is a shared event, otherwise false.

### Static isUserEvent

- isUserEvent(eventName: string): boolean

- - Defined in @zowe/imperative/src/events/src/EventUtils.ts:68

  Determines if the specified event name is associated with a user event.

  #### Parameters

  - ##### eventName: string

    The name of the event.

  #### Returns boolean

  True if it is a user event, otherwise false.

### Static setupWatcher

- setupWatcher(eeInst: EventProcessor, eventName: string, callbacks: EventCallback[] | EventCallback): FSWatcher

- - Defined in @zowe/imperative/src/events/src/EventUtils.ts:202

  Sets up a file watcher for a specific event, triggering callbacks when the event file is updated.

  throws

    {ImperativeError} If the event to be watched does not have an existing file to watch.

  throws

    {ImperativeError} Callbacks will fail if the contents of the event cannot be retrieved.

  #### Parameters

  - ##### eeInst: EventProcessor

    The event processor instance.

  - ##### eventName: string

    The name of the event.

  - ##### callbacks: EventCallback[] | EventCallback

    A single callback or an array of callbacks to execute.

  #### Returns FSWatcher

  A file system watcher.

### Static validateAppName

- validateAppName(appName: string): void

- - Defined in @zowe/imperative/src/events/src/EventUtils.ts:51

  Won't throw an error if user entered a valid appName

  static
  throws

    {ImperativeError} If the application name is not recognized.

  #### Parameters

  - ##### appName: string

    The name of the application.

  #### Returns void

### Static writeEvent

- writeEvent(event: Event): void

- - Defined in @zowe/imperative/src/events/src/EventUtils.ts:231

  Writes event data to the corresponding event file in JSON format.

  #### Parameters

  - ##### event: Event

    The event object.

  #### Returns void

Generated using TypeDoc