| 48 | ) {} |
| 49 | |
| 50 | const decodeSerializedEvent = (event: SerializedEvent): Payload => { |
| 51 | const definition = Durable.get(event.type) |
| 52 | if (!definition?.durable) { |
| 53 | throw new InvalidDurableEventError({ type: event.type, message: `Unknown durable event type ${event.type}` }) |
| 54 | } |
| 55 | return { |
| 56 | id: event.id, |
| 57 | type: definition.type, |
| 58 | durable: { aggregateID: event.aggregateID, seq: event.seq, version: definition.durable.version }, |
| 59 | data: Schema.decodeUnknownSync(definition.data)(event.data), |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | export const readAggregate = Effect.fn("EventV2.readAggregate")(function* <A>( |
| 64 | db: Database.Interface["db"], |