WebSocket Events

Below are the available WebSocket events, their payloads, return types, and descriptions.

EventDescriptionPayloadReturns
master:initCreates a new master file.{ data: MasterFileDto; apiKey: string }Promise<{ status: boolean; error?: string; data?: MasterFileDto }>
master:updateUpdates an existing master file and notifies subscribed clients.{ apiKey: string; masterFile: MasterFileDto }Promise<{ data?: MasterFileDto; error?: string }>
master:deleteDeletes a master file.{ apiKey: string; masterFile: MasterFileDto }Promise<{ status?: boolean; error?: string }>
master:getRetrieves all master files associated with the API key.{ apiKey: string }Promise<{ data?: MasterFileDto[]; error?: string }>
master:getOneRetrieves a single master file by ID or name and subscribes the client to its updates.{ apiKey: string; id?: number; name?: string }Promise<{ data?: MasterFileDto; error?: string }>
content:updateUpdates a content file within a master file and notifies subscribed clients.{ apiKey: string; data: ContentFileDto; masterFileId: number }Promise<{ data?: ContentFileDto; error?: string }>
content:deleteDeletes a content file within a master file and notifies subscribed clients.{ apiKey: string; contentFile: ContentFileDto; masterFileId: number }Promise<{ status?: boolean; error?: string }>
content:getRetrieves multiple content files by their IDs.{ apiKey: string; ids: number[] }Promise<ContentFileDto[]>
content:createCreates a new content file within a master file.{ data: ContentFileDto; apiKey: string }Promise<number>

Notes:

  • Payloads: The MasterFileDto and ContentFileDto types represent data transfer objects for master and content files, respectively. Their exact structure depends on the server implementation but typically includes fields like id, name, and content.
  • API Key: All events require an apiKey for authentication, obtainable from the 0 am Admin Portal.
  • WebSocket Connection: Events are emitted over a WebSocket connection established with the server at the default URL (https://api.0am.ch), configurable via the Ulda constructor's apiUrl parameter.
  • Error Handling: Responses often include an error field for failure cases (e.g., invalid host, server errors). Clients should handle these gracefully.
API