import type { Envelope } from './envelope.ts' import type { Reason } from './reason.ts' export type FailedNotification = { event: 'failed' reason: Reason } export type CommonNotification = { // The official documentation is not up to date, so we need to check the source code // https://github.com/takenet/lime-csharp/blob/master/src/Lime.Protocol/Notification.cs#L47 event: 'accepted' | 'consumed' | 'dispatched' | 'received' | 'deleted' } export type Notification = Envelope & (FailedNotification | CommonNotification) export const isNotification = (envelope: Envelope): envelope is Notification => 'event' in envelope && typeof envelope.event === 'string'