@event-driven-io/emmett-sqlite 0.43.0-beta.13 → 0.43.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,415 @@
1
+ import * as _$_event_driven_io_emmett0 from "@event-driven-io/emmett";
2
+ import { AnyCommand, AnyEvent, AnyMessage, AnyRecordedMessageMetadata, AppendToStreamOptions, AppendToStreamResultWithGlobalPosition, BeforeEventStoreCommitHandler, CanHandle, Event, EventStore, EventStoreReadSchemaOptions, EventStoreSessionFactory, JSONSerializationOptions, JSONSerializer, Message, MessageConsumer, MessageConsumerOptions, MessageProcessor, ProcessorCheckpoint, ProjectionDefinition, ProjectionHandler, ProjectionInitOptions, ProjectionRegistration, ProjectorOptions, ReactorOptions, ReadEvent, ReadEventMetadataWithGlobalPosition, ReadStreamOptions, ReadStreamResult, RecordedMessage, RecordedMessageMetadata, RecordedMessageMetadataWithGlobalPosition, StreamExistsResult, ThenThrows, TruncateProjection, WorkflowProcessorContext, WorkflowProcessorOptions } from "@event-driven-io/emmett";
3
+ import { PongoClient, PongoDBCollectionOptions, PongoDocument, PongoFilter, WithId } from "@event-driven-io/pongo";
4
+ import { AnyDumboDatabaseDriver, DatabaseDriverType, Dumbo, ExtractDumboDatabaseDriverOptions, QueryResultRow, SQL, SQLExecutor } from "@event-driven-io/dumbo";
5
+ import { AnySQLiteConnection } from "@event-driven-io/dumbo/sqlite";
6
+
7
+ //#region src/eventStore/eventStoreDriver.d.ts
8
+ interface EventStoreDriver<DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, DriverOptions extends AnyEventStoreDriverOptions = AnyEventStoreDriverOptions> {
9
+ driverType: DatabaseDriver['driverType'];
10
+ dumboDriver: DatabaseDriver;
11
+ mapToDumboOptions(driverOptions: DriverOptions): ExtractDumboDatabaseDriverOptions<DatabaseDriver>;
12
+ }
13
+ type EventStoreDriverOptions<Driver extends AnyEventStoreDriver = AnyEventStoreDriver> = {
14
+ connectionOptions?: ExtractDumboDatabaseDriverOptions<Driver['dumboDriver']> | undefined;
15
+ };
16
+ type AnyEventStoreDriverOptions = EventStoreDriverOptions<any>;
17
+ type AnyEventStoreDriver = EventStoreDriver<AnyDumboDatabaseDriver, AnyEventStoreDriverOptions>;
18
+ type InferOptionsFromEventStoreDriver<C extends AnyEventStoreDriver> = C extends EventStoreDriver<any, infer DO> ? DO : never;
19
+ //#endregion
20
+ //#region src/eventStore/schema/appendToStream.d.ts
21
+ type AppendEventResult = {
22
+ success: true;
23
+ nextStreamPosition: bigint;
24
+ lastGlobalPosition: bigint;
25
+ } | {
26
+ success: false;
27
+ };
28
+ declare const appendToStream: <MessageType extends Event>(connection: AnySQLiteConnection, streamName: string, streamType: string, messages: MessageType[], options?: AppendToStreamOptions & {
29
+ partition?: string;
30
+ onBeforeCommit?: BeforeEventStoreCommitHandler<SQLiteEventStore, {
31
+ connection: AnySQLiteConnection;
32
+ }>;
33
+ }) => Promise<AppendEventResult>;
34
+ //#endregion
35
+ //#region src/eventStore/schema/migrations/0_41_0/0_41_0.snapshot.d.ts
36
+ declare const schema_0_41_0: SQL[];
37
+ //#endregion
38
+ //#region src/eventStore/schema/migrations/0_42_0/0_42_0.migration.d.ts
39
+ declare const migration_0_42_0_SQLs: SQL[];
40
+ declare const migration_0_42_0_FromSubscriptionsToProcessors: (execute: SQLExecutor) => Promise<void>;
41
+ //#endregion
42
+ //#region src/eventStore/schema/migrations/0_42_0/0_42_0.snapshot.d.ts
43
+ declare const schema_0_42_0: SQL[];
44
+ //#endregion
45
+ //#region src/eventStore/schema/readLastMessageGlobalPosition.d.ts
46
+ type ReadLastMessageGlobalPositionResult = {
47
+ currentGlobalPosition: bigint | null;
48
+ };
49
+ declare const readLastMessageGlobalPosition: (execute: SQLExecutor, options?: {
50
+ partition?: string;
51
+ }) => Promise<ReadLastMessageGlobalPositionResult>;
52
+ //#endregion
53
+ //#region src/eventStore/schema/readMessagesBatch.d.ts
54
+ type ReadMessagesBatchOptions = ({
55
+ after: bigint;
56
+ batchSize: number;
57
+ } | {
58
+ from: bigint;
59
+ batchSize: number;
60
+ } | {
61
+ to: bigint;
62
+ batchSize: number;
63
+ } | {
64
+ from: bigint;
65
+ to: bigint;
66
+ }) & {
67
+ partition?: string;
68
+ serializer: JSONSerializer;
69
+ };
70
+ type ReadMessagesBatchResult<MessageType extends Message, MessageMetadataType extends RecordedMessageMetadata = RecordedMessageMetadata> = {
71
+ currentGlobalPosition: bigint;
72
+ messages: RecordedMessage<MessageType, MessageMetadataType>[];
73
+ areMessagesLeft: boolean;
74
+ };
75
+ declare const readMessagesBatch: <MessageType extends Message, RecordedMessageMetadataType extends RecordedMessageMetadataWithGlobalPosition = RecordedMessageMetadataWithGlobalPosition>(execute: SQLExecutor, options: ReadMessagesBatchOptions) => Promise<ReadMessagesBatchResult<MessageType, RecordedMessageMetadataType>>;
76
+ //#endregion
77
+ //#region src/eventStore/schema/readProcessorCheckpoint.d.ts
78
+ type ReadProcessorCheckpointResult = {
79
+ lastProcessedCheckpoint: ProcessorCheckpoint | null;
80
+ };
81
+ declare const readProcessorCheckpoint: (execute: SQLExecutor, options: {
82
+ processorId: string;
83
+ partition?: string;
84
+ }) => Promise<ReadProcessorCheckpointResult>;
85
+ //#endregion
86
+ //#region src/eventStore/schema/readStream.d.ts
87
+ declare const readStream: <EventType extends Event, EventPayloadType extends Event = EventType>(execute: SQLExecutor, streamId: string, options: ReadStreamOptions<EventType, EventPayloadType> & {
88
+ partition?: string;
89
+ serializer: JSONSerializer;
90
+ }) => Promise<ReadStreamResult<EventType, ReadEventMetadataWithGlobalPosition>>;
91
+ //#endregion
92
+ //#region src/eventStore/schema/storeProcessorCheckpoint.d.ts
93
+ type StoreProcessorCheckpointResult = {
94
+ success: true;
95
+ newCheckpoint: ProcessorCheckpoint | null;
96
+ } | {
97
+ success: false;
98
+ reason: 'IGNORED' | 'MISMATCH';
99
+ };
100
+ declare function storeProcessorCheckpoint(execute: SQLExecutor, options: {
101
+ processorId: string;
102
+ version: number | undefined;
103
+ newCheckpoint: ProcessorCheckpoint | null;
104
+ lastProcessedCheckpoint: ProcessorCheckpoint | null;
105
+ partition?: string;
106
+ processorInstanceId?: string;
107
+ }): Promise<StoreProcessorCheckpointResult>;
108
+ //#endregion
109
+ //#region src/eventStore/schema/streamExists.d.ts
110
+ type SQLiteStreamExistsOptions = {
111
+ partition: string;
112
+ };
113
+ declare const streamExists: (execute: SQLExecutor, streamId: string, options?: SQLiteStreamExistsOptions) => Promise<StreamExistsResult>;
114
+ //#endregion
115
+ //#region src/eventStore/schema/tables.d.ts
116
+ declare const streamsTableSQL: SQL;
117
+ declare const messagesTableSQL: SQL;
118
+ declare const processorsTableSQL: SQL;
119
+ declare const projectionsTableSQL: SQL;
120
+ declare const schemaSQL: SQL[];
121
+ type CreateEventStoreSchemaOptions = {
122
+ dryRun?: boolean | undefined;
123
+ ignoreMigrationHashMismatch?: boolean | undefined;
124
+ migrationTimeoutMs?: number | undefined;
125
+ };
126
+ type EventStoreSchemaMigrationOptions = {
127
+ migrationOptions?: CreateEventStoreSchemaOptions;
128
+ };
129
+ declare const createEventStoreSchema: (pool: AnySQLiteConnection, hooks?: SQLiteEventStoreOptions["hooks"]) => Promise<void>;
130
+ //#endregion
131
+ //#region src/eventStore/schema/typing.d.ts
132
+ declare const emmettPrefix = "emt";
133
+ declare const globalTag = "global";
134
+ declare const defaultTag = "emt:default";
135
+ declare const unknownTag = "emt:unknown";
136
+ declare const globalNames: {
137
+ module: string;
138
+ };
139
+ declare const streamsTable: {
140
+ name: string;
141
+ columns: {
142
+ partition: {
143
+ name: string;
144
+ };
145
+ isArchived: {
146
+ name: string;
147
+ };
148
+ };
149
+ };
150
+ declare const messagesTable: {
151
+ name: string;
152
+ columns: {
153
+ partition: {
154
+ name: string;
155
+ };
156
+ isArchived: {
157
+ name: string;
158
+ };
159
+ };
160
+ };
161
+ declare const processorsTable: {
162
+ name: string;
163
+ };
164
+ declare const projectionsTable: {
165
+ name: string;
166
+ };
167
+ //#endregion
168
+ //#region src/eventStore/consumers/sqliteProcessor.d.ts
169
+ type SQLiteProcessorHandlerContext = {
170
+ execute: SQLExecutor;
171
+ connection: AnySQLiteConnection;
172
+ } & EventStoreSchemaMigrationOptions;
173
+ type SQLiteProcessor<MessageType extends Message = AnyMessage> = MessageProcessor<MessageType, ReadEventMetadataWithGlobalPosition, SQLiteProcessorHandlerContext>;
174
+ type SQLiteProcessorConnectionOptions = {
175
+ connection?: AnySQLiteConnection;
176
+ };
177
+ type SQLiteReactorOptions<MessageType extends Message = Message, MessagePayloadType extends AnyMessage = MessageType> = ReactorOptions<MessageType, ReadEventMetadataWithGlobalPosition, SQLiteProcessorHandlerContext, MessagePayloadType> & SQLiteProcessorConnectionOptions;
178
+ type SQLiteProjectorOptions<EventType extends AnyEvent = AnyEvent, EventPayloadType extends Event = EventType> = ProjectorOptions<EventType, ReadEventMetadataWithGlobalPosition, SQLiteProcessorHandlerContext, EventPayloadType> & SQLiteProcessorConnectionOptions & EventStoreSchemaMigrationOptions;
179
+ type SQLiteWorkflowProcessorOptions<Input extends AnyEvent | AnyCommand, State, Output extends AnyEvent | AnyCommand, MetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata, HandlerContext extends WorkflowProcessorContext = WorkflowProcessorContext, StoredMessage extends AnyEvent | AnyCommand = Output> = WorkflowProcessorOptions<Input, State, Output, MetaDataType, HandlerContext, StoredMessage> & SQLiteProcessorConnectionOptions & {
180
+ messageStore: WorkflowProcessorContext['connection']['messageStore'];
181
+ };
182
+ //#endregion
183
+ //#region src/eventStore/consumers/sqliteEventStoreConsumer.d.ts
184
+ type SQLiteEventStoreConsumerConfig<ConsumerMessageType extends Message = any> = MessageConsumerOptions<ConsumerMessageType> & {
185
+ stopWhen?: {
186
+ noMessagesLeft?: boolean;
187
+ };
188
+ pulling?: {
189
+ batchSize?: number;
190
+ pullingFrequencyInMs?: number;
191
+ };
192
+ };
193
+ type SQLiteEventStoreConsumer<ConsumerMessageType extends AnyMessage = any> = MessageConsumer<ConsumerMessageType> & Readonly<{
194
+ reactor: <MessageType extends AnyMessage = ConsumerMessageType>(options: SQLiteReactorOptions<MessageType>) => SQLiteProcessor<MessageType>;
195
+ workflowProcessor: <Input extends AnyEvent | AnyCommand, State, Output extends AnyEvent | AnyCommand, MetaDataType extends AnyRecordedMessageMetadata = AnyRecordedMessageMetadata, HandlerContext extends SQLiteProcessorHandlerContext & WorkflowProcessorContext = SQLiteProcessorHandlerContext & WorkflowProcessorContext, StoredMessage extends AnyEvent | AnyCommand = Output>(options: Omit<SQLiteWorkflowProcessorOptions<Input, State, Output, MetaDataType, HandlerContext, StoredMessage>, 'messageStore'>) => SQLiteProcessor<Input | Output>;
196
+ }> & (AnyEvent extends ConsumerMessageType ? Readonly<{
197
+ projector: <EventType extends AnyEvent = ConsumerMessageType & AnyEvent>(options: SQLiteProjectorOptions<EventType>) => SQLiteProcessor<EventType>;
198
+ }> : object);
199
+ //#endregion
200
+ //#region src/eventStore/SQLiteEventStore.d.ts
201
+ type EventHandler<E extends Event = Event> = (eventEnvelope: ReadEvent<E>) => void;
202
+ declare const SQLiteEventStoreDefaultStreamVersion = 0n;
203
+ interface SQLiteEventStore extends EventStore<SQLiteReadEventMetadata>, EventStoreSessionFactory<SQLiteEventStore> {
204
+ appendToStream<EventType extends Event, EventPayloadType extends Event = EventType>(streamName: string, events: EventType[], options?: AppendToStreamOptions<EventType, EventPayloadType>): Promise<AppendToStreamResultWithGlobalPosition>;
205
+ consumer<ConsumerEventType extends Event = Event>(options?: SQLiteEventStoreConsumerConfig<ConsumerEventType>): SQLiteEventStoreConsumer<ConsumerEventType>;
206
+ streamExists(streamName: string, options?: SQLiteStreamExistsOptions): Promise<StreamExistsResult>;
207
+ close(): Promise<void>;
208
+ schema: {
209
+ sql(): string;
210
+ print(): void;
211
+ migrate(): Promise<void>;
212
+ };
213
+ }
214
+ type SQLiteReadEventMetadata = ReadEventMetadataWithGlobalPosition;
215
+ type SQLiteReadEvent<EventType extends Event = Event> = ReadEvent<EventType, SQLiteReadEventMetadata>;
216
+ type SQLiteEventStoreOptions<EventStoreDriver extends AnyEventStoreDriver = AnyEventStoreDriver> = {
217
+ driver: EventStoreDriver;
218
+ projections?: ProjectionRegistration<'inline', SQLiteReadEventMetadata, SQLiteProjectionHandlerContext>[];
219
+ schema?: {
220
+ autoMigration?: 'None' | 'CreateOrUpdate';
221
+ };
222
+ hooks?: {
223
+ /**
224
+ * This hook will be called **BEFORE** event store schema is created
225
+ */
226
+ onBeforeSchemaCreated?: (context: {
227
+ connection: AnySQLiteConnection;
228
+ }) => Promise<void> | void;
229
+ /**
230
+ * This hook will be called **BEFORE** events were stored in the event store.
231
+ * @type {BeforeEventStoreCommitHandler<SQLiteEventStore, HandlerContext>}
232
+ */
233
+ onBeforeCommit?: BeforeEventStoreCommitHandler<SQLiteEventStore, {
234
+ connection: AnySQLiteConnection;
235
+ }>;
236
+ /**
237
+ * This hook will be called **AFTER** event store schema was created
238
+ */
239
+ onAfterSchemaCreated?: () => Promise<void> | void;
240
+ };
241
+ } & {
242
+ pool?: Dumbo;
243
+ } & InferOptionsFromEventStoreDriver<EventStoreDriver> & JSONSerializationOptions;
244
+ declare const getSQLiteEventStore: <Driver extends AnyEventStoreDriver = AnyEventStoreDriver>(options: SQLiteEventStoreOptions<Driver>) => SQLiteEventStore;
245
+ //#endregion
246
+ //#region src/eventStore/projections/pongo/pongoProjections.d.ts
247
+ type PongoProjectionHandlerContext = SQLiteProjectionHandlerContext & {
248
+ pongo: PongoClient;
249
+ };
250
+ type PongoWithNotNullDocumentEvolve<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata> = ((document: Document, event: ReadEvent<EventType, EventMetaDataType>) => Document | null) | ((document: Document, event: ReadEvent<EventType>) => Promise<Document | null>);
251
+ type PongoWithNullableDocumentEvolve<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata> = ((document: Document | null, event: ReadEvent<EventType, EventMetaDataType>) => Document | null) | ((document: Document | null, event: ReadEvent<EventType>) => Promise<Document | null>);
252
+ type PongoDocumentEvolve<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata> = PongoWithNotNullDocumentEvolve<Document, EventType, EventMetaDataType> | PongoWithNullableDocumentEvolve<Document, EventType, EventMetaDataType>;
253
+ type PongoProjectionOptions<EventType extends Event, EventPayloadType extends Event = EventType> = {
254
+ name: string;
255
+ kind?: string;
256
+ version?: number;
257
+ handle: (events: ReadEvent<EventType, SQLiteReadEventMetadata>[], context: PongoProjectionHandlerContext) => Promise<void>;
258
+ canHandle: CanHandle<EventType>;
259
+ truncate?: TruncateProjection<PongoProjectionHandlerContext>;
260
+ init?: (context: PongoProjectionHandlerContext) => void | Promise<void>;
261
+ eventsOptions?: {
262
+ schema?: EventStoreReadSchemaOptions<EventType, EventPayloadType>;
263
+ };
264
+ } & JSONSerializationOptions;
265
+ declare const pongoProjection: <EventType extends Event, EventPayloadType extends Event = EventType>({
266
+ name,
267
+ kind,
268
+ version,
269
+ truncate,
270
+ handle,
271
+ canHandle,
272
+ eventsOptions
273
+ }: PongoProjectionOptions<EventType, EventPayloadType>) => SQLiteProjectionDefinition<EventType, EventPayloadType>;
274
+ type PongoMultiStreamProjectionOptions<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata, EventPayloadType extends Event = EventType, DocumentPayload extends PongoDocument = Document> = {
275
+ kind?: string;
276
+ canHandle: CanHandle<EventType>;
277
+ version?: number;
278
+ collectionName: string;
279
+ collectionOptions?: PongoDBCollectionOptions<Document, DocumentPayload>;
280
+ eventsOptions?: {
281
+ schema?: EventStoreReadSchemaOptions<EventType, EventPayloadType>;
282
+ };
283
+ getDocumentId: (event: ReadEvent<EventType>) => string;
284
+ } & ({
285
+ evolve: PongoWithNullableDocumentEvolve<Document, EventType, EventMetaDataType>;
286
+ } | {
287
+ evolve: PongoWithNotNullDocumentEvolve<Document, EventType, EventMetaDataType>;
288
+ initialState: () => Document;
289
+ }) & JSONSerializationOptions;
290
+ declare const pongoMultiStreamProjection: <Document extends PongoDocument, EventType extends Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata, EventPayloadType extends Event = EventType>(options: PongoMultiStreamProjectionOptions<Document, EventType, EventMetaDataType, EventPayloadType>) => SQLiteProjectionDefinition<EventType, EventPayloadType>;
291
+ type PongoSingleStreamProjectionOptions<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata, EventPayloadType extends Event = EventType, DocumentPayload extends PongoDocument = Document> = {
292
+ canHandle: CanHandle<EventType>;
293
+ getDocumentId?: (event: ReadEvent<EventType>) => string;
294
+ version?: number;
295
+ collectionName: string;
296
+ collectionOptions?: PongoDBCollectionOptions<Document, DocumentPayload>;
297
+ eventsOptions?: {
298
+ schema?: EventStoreReadSchemaOptions<EventType, EventPayloadType>;
299
+ };
300
+ } & ({
301
+ evolve: PongoWithNullableDocumentEvolve<Document, EventType, EventMetaDataType>;
302
+ } | {
303
+ evolve: PongoWithNotNullDocumentEvolve<Document, EventType, EventMetaDataType>;
304
+ initialState: () => Document;
305
+ }) & JSONSerializationOptions;
306
+ declare const pongoSingleStreamProjection: <Document extends PongoDocument, EventType extends Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata, EventPayloadType extends Event = EventType>(options: PongoSingleStreamProjectionOptions<Document, EventType, EventMetaDataType, EventPayloadType>) => SQLiteProjectionDefinition<EventType, EventPayloadType>;
307
+ //#endregion
308
+ //#region src/eventStore/projections/pongo/pongoProjectionSpec.d.ts
309
+ type PongoAssertOptions = {
310
+ inCollection: string;
311
+ inDatabase?: string;
312
+ };
313
+ type FilterOrId<Doc extends PongoDocument | WithId<PongoDocument>> = {
314
+ withId: string;
315
+ } | {
316
+ matchingFilter: PongoFilter<Doc>;
317
+ };
318
+ declare const documentExists: <Doc extends PongoDocument | WithId<PongoDocument>>(document: Doc, options: PongoAssertOptions & FilterOrId<Doc>) => SQLiteProjectionAssert;
319
+ declare const documentsAreTheSame: <Doc extends PongoDocument | WithId<PongoDocument>>(documents: Doc[], options: PongoAssertOptions & FilterOrId<Doc>) => SQLiteProjectionAssert;
320
+ declare const documentsMatchingHaveCount: <Doc extends PongoDocument | WithId<PongoDocument>>(expectedCount: number, options: PongoAssertOptions & FilterOrId<Doc>) => SQLiteProjectionAssert;
321
+ declare const documentMatchingExists: <Doc extends PongoDocument | WithId<PongoDocument>>(options: PongoAssertOptions & FilterOrId<Doc>) => SQLiteProjectionAssert;
322
+ declare const documentDoesNotExist: <Doc extends PongoDocument | WithId<PongoDocument>>(options: PongoAssertOptions & FilterOrId<Doc>) => SQLiteProjectionAssert;
323
+ declare const expectPongoDocuments: {
324
+ fromCollection: <Doc extends PongoDocument | WithId<PongoDocument>>(collectionName: string) => {
325
+ withId: (id: string) => {
326
+ toBeEqual: (document: Doc) => SQLiteProjectionAssert;
327
+ toExist: () => SQLiteProjectionAssert;
328
+ notToExist: () => SQLiteProjectionAssert;
329
+ };
330
+ matching: <Doc_1 extends PongoDocument | WithId<PongoDocument>>(filter: PongoFilter<Doc_1>) => {
331
+ toBeTheSame: (documents: Doc_1[]) => SQLiteProjectionAssert;
332
+ toHaveCount: (expectedCount: number) => SQLiteProjectionAssert;
333
+ toExist: () => SQLiteProjectionAssert;
334
+ notToExist: () => SQLiteProjectionAssert;
335
+ };
336
+ };
337
+ };
338
+ //#endregion
339
+ //#region src/eventStore/projections/sqliteProjection.d.ts
340
+ type SQLiteProjectionHandlerContext = {
341
+ execute: SQLExecutor;
342
+ connection: AnySQLiteConnection;
343
+ driverType: DatabaseDriverType;
344
+ };
345
+ type SQLiteProjectionHandler<EventType extends Event = Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata> = ProjectionHandler<EventType, EventMetaDataType, SQLiteProjectionHandlerContext>;
346
+ type SQLiteProjectionDefinition<EventType extends Event = Event, EventPayloadType extends Event = EventType> = ProjectionDefinition<EventType, SQLiteReadEventMetadata, SQLiteProjectionHandlerContext, EventPayloadType>;
347
+ type SQLiteProjectionHandlerOptions<EventType extends Event = Event> = {
348
+ events: ReadEvent<EventType, SQLiteReadEventMetadata>[];
349
+ projections: SQLiteProjectionDefinition<EventType>[];
350
+ } & SQLiteProjectionHandlerContext;
351
+ declare const handleProjections: <EventType extends Event = Event>(options: SQLiteProjectionHandlerOptions<EventType>) => Promise<void>;
352
+ declare const sqliteProjection: <EventType extends Event, EventPayloadType extends Event = EventType>(definition: SQLiteProjectionDefinition<EventType, EventPayloadType>) => SQLiteProjectionDefinition<EventType, EventPayloadType>;
353
+ type SQLiteRawBatchSQLProjection<EventType extends Event, EventPayloadType extends Event = EventType> = {
354
+ name: string;
355
+ kind?: string;
356
+ version?: number;
357
+ evolve: (events: EventType[], context: SQLiteProjectionHandlerContext) => Promise<SQL[]> | SQL[];
358
+ canHandle: CanHandle<EventType>;
359
+ init?: (context: ProjectionInitOptions<SQLiteProjectionHandlerContext>) => void | Promise<void> | SQL | Promise<SQL> | Promise<SQL[]> | SQL[];
360
+ eventsOptions?: {
361
+ schema?: EventStoreReadSchemaOptions<EventType, EventPayloadType>;
362
+ };
363
+ } & JSONSerializationOptions;
364
+ declare const sqliteRawBatchSQLProjection: <EventType extends Event, EventPayloadType extends Event = EventType>(options: SQLiteRawBatchSQLProjection<EventType, EventPayloadType>) => SQLiteProjectionDefinition<EventType, EventPayloadType>;
365
+ type SQLiteRawSQLProjection<EventType extends Event, EventPayloadType extends Event = EventType> = {
366
+ name: string;
367
+ kind?: string;
368
+ version?: number;
369
+ evolve: (events: EventType, context: SQLiteProjectionHandlerContext) => Promise<SQL[]> | SQL[] | Promise<SQL> | SQL;
370
+ canHandle: CanHandle<EventType>;
371
+ init?: (context: ProjectionInitOptions<SQLiteProjectionHandlerContext>) => void | Promise<void> | SQL | Promise<SQL> | Promise<SQL[]> | SQL[];
372
+ eventsOptions?: {
373
+ schema?: EventStoreReadSchemaOptions<EventType, EventPayloadType>;
374
+ };
375
+ } & JSONSerializationOptions;
376
+ declare const sqliteRawSQLProjection: <EventType extends Event, EventPayloadType extends Event = EventType>(options: SQLiteRawSQLProjection<EventType, EventPayloadType>) => SQLiteProjectionDefinition<EventType, EventPayloadType>;
377
+ //#endregion
378
+ //#region src/eventStore/projections/sqliteProjectionSpec.d.ts
379
+ type SQLiteProjectionSpecEvent<EventType extends Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata> = EventType & {
380
+ metadata?: Partial<EventMetaDataType>;
381
+ };
382
+ type SQLiteProjectionSpecWhenOptions = {
383
+ numberOfTimes: number;
384
+ };
385
+ type SQLiteProjectionSpec<EventType extends Event> = (givenEvents: SQLiteProjectionSpecEvent<EventType>[]) => {
386
+ when: (events: SQLiteProjectionSpecEvent<EventType>[], options?: SQLiteProjectionSpecWhenOptions) => {
387
+ then: (assert: SQLiteProjectionAssert, message?: string) => Promise<void>;
388
+ thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => Promise<void>;
389
+ };
390
+ };
391
+ type SQLiteProjectionAssert = (options: {
392
+ connection: AnySQLiteConnection;
393
+ }) => Promise<void | boolean>;
394
+ type SQLiteProjectionSpecOptions<EventType extends Event, Driver extends AnyEventStoreDriver = AnyEventStoreDriver> = {
395
+ projection: SQLiteProjectionDefinition<EventType>;
396
+ driver: Driver;
397
+ pool?: Dumbo;
398
+ } & InferOptionsFromEventStoreDriver<Driver> & JSONSerializationOptions;
399
+ declare const SQLiteProjectionSpec: {
400
+ for: <EventType extends Event, Driver extends AnyEventStoreDriver = AnyEventStoreDriver>(options: SQLiteProjectionSpecOptions<EventType, Driver>) => SQLiteProjectionSpec<EventType>;
401
+ };
402
+ declare const eventInStream: <EventType extends Event = Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata>(streamName: string, event: SQLiteProjectionSpecEvent<EventType, EventMetaDataType>) => SQLiteProjectionSpecEvent<EventType, EventMetaDataType>;
403
+ declare const eventsInStream: <EventType extends Event = Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata>(streamName: string, events: SQLiteProjectionSpecEvent<EventType, EventMetaDataType>[]) => SQLiteProjectionSpecEvent<EventType, EventMetaDataType>[];
404
+ declare const newEventsInStream: <EventType extends Event = Event, EventMetaDataType extends SQLiteReadEventMetadata = _$_event_driven_io_emmett0.RecordedMessageMetadataWithGlobalPosition>(streamName: string, events: SQLiteProjectionSpecEvent<EventType, EventMetaDataType>[]) => SQLiteProjectionSpecEvent<EventType, EventMetaDataType>[];
405
+ declare const assertSQLQueryResultMatches: <T extends QueryResultRow>(sql: SQL, rows: T[]) => SQLiteProjectionAssert;
406
+ declare const expectSQL: {
407
+ query: (sql: SQL) => {
408
+ resultRows: {
409
+ toBeTheSame: <T extends QueryResultRow>(rows: T[]) => SQLiteProjectionAssert;
410
+ };
411
+ };
412
+ };
413
+ //#endregion
414
+ export { unknownTag as $, PongoProjectionHandlerContext as A, SQLiteEventStoreDefaultStreamVersion as B, documentExists as C, schema_0_41_0 as Ct, expectPongoDocuments as D, documentsMatchingHaveCount as E, EventStoreDriver as Et, pongoMultiStreamProjection as F, defaultTag as G, SQLiteReadEvent as H, pongoProjection as I, globalTag as J, emmettPrefix as K, pongoSingleStreamProjection as L, PongoSingleStreamProjectionOptions as M, PongoWithNotNullDocumentEvolve as N, PongoDocumentEvolve as O, PongoWithNullableDocumentEvolve as P, streamsTable as Q, EventHandler as R, documentDoesNotExist as S, migration_0_42_0_SQLs as St, documentsAreTheSame as T, appendToStream as Tt, SQLiteReadEventMetadata as U, SQLiteEventStoreOptions as V, getSQLiteEventStore as W, processorsTable as X, messagesTable as Y, projectionsTable as Z, handleProjections as _, readMessagesBatch as _t, SQLiteProjectionSpecWhenOptions as a, projectionsTableSQL as at, sqliteRawSQLProjection as b, schema_0_42_0 as bt, eventsInStream as c, SQLiteStreamExistsOptions as ct, SQLiteProjectionDefinition as d, storeProcessorCheckpoint as dt, CreateEventStoreSchemaOptions as et, SQLiteProjectionHandler as f, readStream as ft, SQLiteRawSQLProjection as g, ReadMessagesBatchResult as gt, SQLiteRawBatchSQLProjection as h, ReadMessagesBatchOptions as ht, SQLiteProjectionSpecOptions as i, processorsTableSQL as it, PongoProjectionOptions as j, PongoMultiStreamProjectionOptions as k, expectSQL as l, streamExists as lt, SQLiteProjectionHandlerOptions as m, readProcessorCheckpoint as mt, SQLiteProjectionSpec as n, createEventStoreSchema as nt, assertSQLQueryResultMatches as o, schemaSQL as ot, SQLiteProjectionHandlerContext as p, ReadProcessorCheckpointResult as pt, globalNames as q, SQLiteProjectionSpecEvent as r, messagesTableSQL as rt, eventInStream as s, streamsTableSQL as st, SQLiteProjectionAssert as t, EventStoreSchemaMigrationOptions as tt, newEventsInStream as u, StoreProcessorCheckpointResult as ut, sqliteProjection as v, ReadLastMessageGlobalPositionResult as vt, documentMatchingExists as w, AppendEventResult as wt, PongoAssertOptions as x, migration_0_42_0_FromSubscriptionsToProcessors as xt, sqliteRawBatchSQLProjection as y, readLastMessageGlobalPosition as yt, SQLiteEventStore as z };
415
+ //# sourceMappingURL=index-CqxXzmd1.d.cts.map