( input: TInput )
| 37 | } as const |
| 38 | |
| 39 | export function createEvent<TInput extends CreateEventInput>( |
| 40 | input: TInput |
| 41 | ): CreateEventResult<TInput> { |
| 42 | const { streamId, chatId, cursor, seq, requestId, type, payload, scope, ts } = input |
| 43 | |
| 44 | return { |
| 45 | v: 1, |
| 46 | type, |
| 47 | seq, |
| 48 | ts: ts ?? new Date().toISOString(), |
| 49 | stream: { |
| 50 | streamId, |
| 51 | ...(chatId ? { chatId } : {}), |
| 52 | cursor, |
| 53 | }, |
| 54 | trace: { |
| 55 | requestId, |
| 56 | }, |
| 57 | ...(scope ? { scope } : {}), |
| 58 | payload, |
| 59 | } as CreateEventResult<TInput> |
| 60 | } |
| 61 | |
| 62 | export function isEventRecord(value: unknown): value is PersistedStreamEventEnvelope { |
| 63 | return parsePersistedStreamEventEnvelope(value).ok |
no outgoing calls
no test coverage detected