@event-driven-io/emmett-sqlite 0.39.1 → 0.40.0
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.
- package/dist/index.cjs +781 -329
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -11
- package/dist/index.d.ts +56 -11
- package/dist/index.js +761 -309
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import sqlite3 from 'sqlite3';
|
|
2
|
-
import { Event,
|
|
2
|
+
import { Event, ReadEvent, ReadEventMetadataWithGlobalPosition, EmmettError, EventStore, AppendToStreamOptions, AppendToStreamResultWithGlobalPosition, ProjectionRegistration, BeforeEventStoreCommitHandler, ProjectionHandler, ProjectionDefinition, CanHandle, ThenThrows, ReadEventMetadata, ReadStreamOptions, ReadStreamResult } from '@event-driven-io/emmett';
|
|
3
|
+
import { QueryResultRow, SQL } from '@event-driven-io/dumbo';
|
|
3
4
|
|
|
4
|
-
type Parameters = object | string | bigint | number | boolean | null;
|
|
5
|
+
type Parameters$1 = object | string | bigint | number | boolean | null;
|
|
5
6
|
type SQLiteConnection = {
|
|
6
7
|
close: () => void;
|
|
7
|
-
command: (sql: string, values?: Parameters[]) => Promise<sqlite3.RunResult>;
|
|
8
|
-
query: <T>(sql: string, values?: Parameters[]) => Promise<T[]>;
|
|
9
|
-
querySingle: <T>(sql: string, values?: Parameters[]) => Promise<T | null>;
|
|
8
|
+
command: (sql: string, values?: Parameters$1[]) => Promise<sqlite3.RunResult>;
|
|
9
|
+
query: <T>(sql: string, values?: Parameters$1[]) => Promise<T[]>;
|
|
10
|
+
querySingle: <T>(sql: string, values?: Parameters$1[]) => Promise<T | null>;
|
|
10
11
|
withTransaction: <T>(fn: () => Promise<T>) => Promise<T>;
|
|
11
12
|
};
|
|
12
13
|
interface SQLiteError extends Error {
|
|
@@ -26,11 +27,6 @@ type SQLiteEventStoreMessageBatchPullerStartFrom = {
|
|
|
26
27
|
globalPosition: bigint;
|
|
27
28
|
} | 'BEGINNING' | 'END';
|
|
28
29
|
|
|
29
|
-
type SQLiteProjectionHandlerContext = {
|
|
30
|
-
connection: SQLiteConnection;
|
|
31
|
-
};
|
|
32
|
-
type SQLiteProjectionDefinition<EventType extends Event = Event> = ProjectionDefinition<EventType, SQLiteReadEventMetadata, SQLiteProjectionHandlerContext>;
|
|
33
|
-
|
|
34
30
|
type SQLiteProcessorEventsBatch<EventType extends Event = Event> = {
|
|
35
31
|
messages: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>[];
|
|
36
32
|
};
|
|
@@ -133,6 +129,55 @@ type SQLiteEventStoreOptions = {
|
|
|
133
129
|
};
|
|
134
130
|
declare const getSQLiteEventStore: (options: SQLiteEventStoreOptions) => SQLiteEventStore;
|
|
135
131
|
|
|
132
|
+
type SQLiteProjectionHandlerContext = {
|
|
133
|
+
connection: SQLiteConnection;
|
|
134
|
+
};
|
|
135
|
+
type SQLiteProjectionHandler<EventType extends Event = Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata> = ProjectionHandler<EventType, EventMetaDataType, SQLiteProjectionHandlerContext>;
|
|
136
|
+
type SQLiteProjectionDefinition<EventType extends Event = Event> = ProjectionDefinition<EventType, SQLiteReadEventMetadata, SQLiteProjectionHandlerContext>;
|
|
137
|
+
type SQLiteProjectionHandlerOptions<EventType extends Event = Event> = {
|
|
138
|
+
events: ReadEvent<EventType, SQLiteReadEventMetadata>[];
|
|
139
|
+
projections: SQLiteProjectionDefinition<EventType>[];
|
|
140
|
+
connection: SQLiteConnection;
|
|
141
|
+
};
|
|
142
|
+
declare const handleProjections: <EventType extends Event = Event>(options: SQLiteProjectionHandlerOptions<EventType>) => Promise<void>;
|
|
143
|
+
declare const sqliteProjection: <EventType extends Event>(definition: SQLiteProjectionDefinition<EventType>) => SQLiteProjectionDefinition<EventType>;
|
|
144
|
+
declare const sqliteRawBatchSQLProjection: <EventType extends Event>(handle: (events: EventType[], context: SQLiteProjectionHandlerContext) => Promise<string[]> | string[], ...canHandle: CanHandle<EventType>) => SQLiteProjectionDefinition<EventType>;
|
|
145
|
+
declare const sqliteRawSQLProjection: <EventType extends Event>(handle: (event: EventType, context: SQLiteProjectionHandlerContext) => Promise<string> | string, ...canHandle: CanHandle<EventType>) => SQLiteProjectionDefinition<EventType>;
|
|
146
|
+
|
|
147
|
+
type SQLiteProjectionSpecEvent<EventType extends Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata> = EventType & {
|
|
148
|
+
metadata?: Partial<EventMetaDataType>;
|
|
149
|
+
};
|
|
150
|
+
type SQLiteProjectionSpecWhenOptions = {
|
|
151
|
+
numberOfTimes: number;
|
|
152
|
+
};
|
|
153
|
+
type SQLiteProjectionAssert = (options: {
|
|
154
|
+
connection: SQLiteConnection;
|
|
155
|
+
}) => Promise<void | boolean>;
|
|
156
|
+
type SQLiteProjectionSpecOptions<EventType extends Event> = {
|
|
157
|
+
connection: SQLiteConnection;
|
|
158
|
+
projection: SQLiteProjectionDefinition<EventType>;
|
|
159
|
+
};
|
|
160
|
+
type SQLiteProjectionSpec<EventType extends Event> = (givenEvents: SQLiteProjectionSpecEvent<EventType>[]) => {
|
|
161
|
+
when: (events: SQLiteProjectionSpecEvent<EventType>[], options?: SQLiteProjectionSpecWhenOptions) => {
|
|
162
|
+
then: (assert: SQLiteProjectionAssert, message?: string) => Promise<void>;
|
|
163
|
+
thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => Promise<void>;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
declare const SQLiteProjectionSpec: {
|
|
167
|
+
for: <EventType extends Event>(options: SQLiteProjectionSpecOptions<EventType>) => SQLiteProjectionSpec<EventType>;
|
|
168
|
+
};
|
|
169
|
+
declare const eventInStream: <EventType extends Event = Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata>(streamName: string, event: SQLiteProjectionSpecEvent<EventType, EventMetaDataType>) => SQLiteProjectionSpecEvent<EventType, EventMetaDataType>;
|
|
170
|
+
declare const eventsInStream: <EventType extends Event = Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata>(streamName: string, events: SQLiteProjectionSpecEvent<EventType, EventMetaDataType>[]) => SQLiteProjectionSpecEvent<EventType, EventMetaDataType>[];
|
|
171
|
+
declare const newEventsInStream: <EventType extends Event = Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata>(streamName: string, events: SQLiteProjectionSpecEvent<EventType, EventMetaDataType>[]) => SQLiteProjectionSpecEvent<EventType, EventMetaDataType>[];
|
|
172
|
+
declare const assertSQLQueryResultMatches: <T extends QueryResultRow>(sql: string, rows: T[]) => SQLiteProjectionAssert;
|
|
173
|
+
declare const expectSQL: {
|
|
174
|
+
query: (sql: SQL) => {
|
|
175
|
+
resultRows: {
|
|
176
|
+
toBeTheSame: <T extends QueryResultRow>(rows: T[]) => SQLiteProjectionAssert;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
|
|
136
181
|
type AppendEventResult = {
|
|
137
182
|
success: true;
|
|
138
183
|
nextStreamPosition: bigint;
|
|
@@ -242,4 +287,4 @@ declare const subscriptionsTable: {
|
|
|
242
287
|
name: string;
|
|
243
288
|
};
|
|
244
289
|
|
|
245
|
-
export { type AppendEventResult, type EventHandler, InMemorySQLiteDatabase, InMemorySharedCacheSQLiteDatabase, type Parameters, type ReadLastMessageGlobalPositionResult, type ReadMessagesBatchOptions, type ReadMessagesBatchResult, type ReadProcessorCheckpointResult, type SQLiteConnection, type SQLiteError, type SQLiteEventStore, SQLiteEventStoreDefaultStreamVersion, type SQLiteEventStoreOptions, type SQLiteReadEvent, type SQLiteReadEventMetadata, type StoreLastProcessedProcessorPositionResult, appendToStream, createEventStoreSchema, defaultTag, emmettPrefix, getSQLiteEventStore, globalNames, globalTag, isSQLiteError, messagesTable, messagesTableSQL, readLastMessageGlobalPosition, readMessagesBatch, readProcessorCheckpoint, readStream, schemaSQL, sql, sqliteConnection, storeProcessorCheckpoint, streamsTable, streamsTableSQL, subscriptionsTable, subscriptionsTableSQL };
|
|
290
|
+
export { type AppendEventResult, type EventHandler, InMemorySQLiteDatabase, InMemorySharedCacheSQLiteDatabase, type Parameters$1 as Parameters, type ReadLastMessageGlobalPositionResult, type ReadMessagesBatchOptions, type ReadMessagesBatchResult, type ReadProcessorCheckpointResult, type SQLiteConnection, type SQLiteError, type SQLiteEventStore, SQLiteEventStoreDefaultStreamVersion, type SQLiteEventStoreOptions, type SQLiteProjectionAssert, type SQLiteProjectionDefinition, type SQLiteProjectionHandler, type SQLiteProjectionHandlerContext, type SQLiteProjectionHandlerOptions, SQLiteProjectionSpec, type SQLiteProjectionSpecEvent, type SQLiteProjectionSpecOptions, type SQLiteProjectionSpecWhenOptions, type SQLiteReadEvent, type SQLiteReadEventMetadata, type StoreLastProcessedProcessorPositionResult, appendToStream, assertSQLQueryResultMatches, createEventStoreSchema, defaultTag, emmettPrefix, eventInStream, eventsInStream, expectSQL, getSQLiteEventStore, globalNames, globalTag, handleProjections, isSQLiteError, messagesTable, messagesTableSQL, newEventsInStream, readLastMessageGlobalPosition, readMessagesBatch, readProcessorCheckpoint, readStream, schemaSQL, sql, sqliteConnection, sqliteProjection, sqliteRawBatchSQLProjection, sqliteRawSQLProjection, storeProcessorCheckpoint, streamsTable, streamsTableSQL, subscriptionsTable, subscriptionsTableSQL };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import sqlite3 from 'sqlite3';
|
|
2
|
-
import { Event,
|
|
2
|
+
import { Event, ReadEvent, ReadEventMetadataWithGlobalPosition, EmmettError, EventStore, AppendToStreamOptions, AppendToStreamResultWithGlobalPosition, ProjectionRegistration, BeforeEventStoreCommitHandler, ProjectionHandler, ProjectionDefinition, CanHandle, ThenThrows, ReadEventMetadata, ReadStreamOptions, ReadStreamResult } from '@event-driven-io/emmett';
|
|
3
|
+
import { QueryResultRow, SQL } from '@event-driven-io/dumbo';
|
|
3
4
|
|
|
4
|
-
type Parameters = object | string | bigint | number | boolean | null;
|
|
5
|
+
type Parameters$1 = object | string | bigint | number | boolean | null;
|
|
5
6
|
type SQLiteConnection = {
|
|
6
7
|
close: () => void;
|
|
7
|
-
command: (sql: string, values?: Parameters[]) => Promise<sqlite3.RunResult>;
|
|
8
|
-
query: <T>(sql: string, values?: Parameters[]) => Promise<T[]>;
|
|
9
|
-
querySingle: <T>(sql: string, values?: Parameters[]) => Promise<T | null>;
|
|
8
|
+
command: (sql: string, values?: Parameters$1[]) => Promise<sqlite3.RunResult>;
|
|
9
|
+
query: <T>(sql: string, values?: Parameters$1[]) => Promise<T[]>;
|
|
10
|
+
querySingle: <T>(sql: string, values?: Parameters$1[]) => Promise<T | null>;
|
|
10
11
|
withTransaction: <T>(fn: () => Promise<T>) => Promise<T>;
|
|
11
12
|
};
|
|
12
13
|
interface SQLiteError extends Error {
|
|
@@ -26,11 +27,6 @@ type SQLiteEventStoreMessageBatchPullerStartFrom = {
|
|
|
26
27
|
globalPosition: bigint;
|
|
27
28
|
} | 'BEGINNING' | 'END';
|
|
28
29
|
|
|
29
|
-
type SQLiteProjectionHandlerContext = {
|
|
30
|
-
connection: SQLiteConnection;
|
|
31
|
-
};
|
|
32
|
-
type SQLiteProjectionDefinition<EventType extends Event = Event> = ProjectionDefinition<EventType, SQLiteReadEventMetadata, SQLiteProjectionHandlerContext>;
|
|
33
|
-
|
|
34
30
|
type SQLiteProcessorEventsBatch<EventType extends Event = Event> = {
|
|
35
31
|
messages: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>[];
|
|
36
32
|
};
|
|
@@ -133,6 +129,55 @@ type SQLiteEventStoreOptions = {
|
|
|
133
129
|
};
|
|
134
130
|
declare const getSQLiteEventStore: (options: SQLiteEventStoreOptions) => SQLiteEventStore;
|
|
135
131
|
|
|
132
|
+
type SQLiteProjectionHandlerContext = {
|
|
133
|
+
connection: SQLiteConnection;
|
|
134
|
+
};
|
|
135
|
+
type SQLiteProjectionHandler<EventType extends Event = Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata> = ProjectionHandler<EventType, EventMetaDataType, SQLiteProjectionHandlerContext>;
|
|
136
|
+
type SQLiteProjectionDefinition<EventType extends Event = Event> = ProjectionDefinition<EventType, SQLiteReadEventMetadata, SQLiteProjectionHandlerContext>;
|
|
137
|
+
type SQLiteProjectionHandlerOptions<EventType extends Event = Event> = {
|
|
138
|
+
events: ReadEvent<EventType, SQLiteReadEventMetadata>[];
|
|
139
|
+
projections: SQLiteProjectionDefinition<EventType>[];
|
|
140
|
+
connection: SQLiteConnection;
|
|
141
|
+
};
|
|
142
|
+
declare const handleProjections: <EventType extends Event = Event>(options: SQLiteProjectionHandlerOptions<EventType>) => Promise<void>;
|
|
143
|
+
declare const sqliteProjection: <EventType extends Event>(definition: SQLiteProjectionDefinition<EventType>) => SQLiteProjectionDefinition<EventType>;
|
|
144
|
+
declare const sqliteRawBatchSQLProjection: <EventType extends Event>(handle: (events: EventType[], context: SQLiteProjectionHandlerContext) => Promise<string[]> | string[], ...canHandle: CanHandle<EventType>) => SQLiteProjectionDefinition<EventType>;
|
|
145
|
+
declare const sqliteRawSQLProjection: <EventType extends Event>(handle: (event: EventType, context: SQLiteProjectionHandlerContext) => Promise<string> | string, ...canHandle: CanHandle<EventType>) => SQLiteProjectionDefinition<EventType>;
|
|
146
|
+
|
|
147
|
+
type SQLiteProjectionSpecEvent<EventType extends Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata> = EventType & {
|
|
148
|
+
metadata?: Partial<EventMetaDataType>;
|
|
149
|
+
};
|
|
150
|
+
type SQLiteProjectionSpecWhenOptions = {
|
|
151
|
+
numberOfTimes: number;
|
|
152
|
+
};
|
|
153
|
+
type SQLiteProjectionAssert = (options: {
|
|
154
|
+
connection: SQLiteConnection;
|
|
155
|
+
}) => Promise<void | boolean>;
|
|
156
|
+
type SQLiteProjectionSpecOptions<EventType extends Event> = {
|
|
157
|
+
connection: SQLiteConnection;
|
|
158
|
+
projection: SQLiteProjectionDefinition<EventType>;
|
|
159
|
+
};
|
|
160
|
+
type SQLiteProjectionSpec<EventType extends Event> = (givenEvents: SQLiteProjectionSpecEvent<EventType>[]) => {
|
|
161
|
+
when: (events: SQLiteProjectionSpecEvent<EventType>[], options?: SQLiteProjectionSpecWhenOptions) => {
|
|
162
|
+
then: (assert: SQLiteProjectionAssert, message?: string) => Promise<void>;
|
|
163
|
+
thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => Promise<void>;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
declare const SQLiteProjectionSpec: {
|
|
167
|
+
for: <EventType extends Event>(options: SQLiteProjectionSpecOptions<EventType>) => SQLiteProjectionSpec<EventType>;
|
|
168
|
+
};
|
|
169
|
+
declare const eventInStream: <EventType extends Event = Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata>(streamName: string, event: SQLiteProjectionSpecEvent<EventType, EventMetaDataType>) => SQLiteProjectionSpecEvent<EventType, EventMetaDataType>;
|
|
170
|
+
declare const eventsInStream: <EventType extends Event = Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata>(streamName: string, events: SQLiteProjectionSpecEvent<EventType, EventMetaDataType>[]) => SQLiteProjectionSpecEvent<EventType, EventMetaDataType>[];
|
|
171
|
+
declare const newEventsInStream: <EventType extends Event = Event, EventMetaDataType extends SQLiteReadEventMetadata = SQLiteReadEventMetadata>(streamName: string, events: SQLiteProjectionSpecEvent<EventType, EventMetaDataType>[]) => SQLiteProjectionSpecEvent<EventType, EventMetaDataType>[];
|
|
172
|
+
declare const assertSQLQueryResultMatches: <T extends QueryResultRow>(sql: string, rows: T[]) => SQLiteProjectionAssert;
|
|
173
|
+
declare const expectSQL: {
|
|
174
|
+
query: (sql: SQL) => {
|
|
175
|
+
resultRows: {
|
|
176
|
+
toBeTheSame: <T extends QueryResultRow>(rows: T[]) => SQLiteProjectionAssert;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
|
|
136
181
|
type AppendEventResult = {
|
|
137
182
|
success: true;
|
|
138
183
|
nextStreamPosition: bigint;
|
|
@@ -242,4 +287,4 @@ declare const subscriptionsTable: {
|
|
|
242
287
|
name: string;
|
|
243
288
|
};
|
|
244
289
|
|
|
245
|
-
export { type AppendEventResult, type EventHandler, InMemorySQLiteDatabase, InMemorySharedCacheSQLiteDatabase, type Parameters, type ReadLastMessageGlobalPositionResult, type ReadMessagesBatchOptions, type ReadMessagesBatchResult, type ReadProcessorCheckpointResult, type SQLiteConnection, type SQLiteError, type SQLiteEventStore, SQLiteEventStoreDefaultStreamVersion, type SQLiteEventStoreOptions, type SQLiteReadEvent, type SQLiteReadEventMetadata, type StoreLastProcessedProcessorPositionResult, appendToStream, createEventStoreSchema, defaultTag, emmettPrefix, getSQLiteEventStore, globalNames, globalTag, isSQLiteError, messagesTable, messagesTableSQL, readLastMessageGlobalPosition, readMessagesBatch, readProcessorCheckpoint, readStream, schemaSQL, sql, sqliteConnection, storeProcessorCheckpoint, streamsTable, streamsTableSQL, subscriptionsTable, subscriptionsTableSQL };
|
|
290
|
+
export { type AppendEventResult, type EventHandler, InMemorySQLiteDatabase, InMemorySharedCacheSQLiteDatabase, type Parameters$1 as Parameters, type ReadLastMessageGlobalPositionResult, type ReadMessagesBatchOptions, type ReadMessagesBatchResult, type ReadProcessorCheckpointResult, type SQLiteConnection, type SQLiteError, type SQLiteEventStore, SQLiteEventStoreDefaultStreamVersion, type SQLiteEventStoreOptions, type SQLiteProjectionAssert, type SQLiteProjectionDefinition, type SQLiteProjectionHandler, type SQLiteProjectionHandlerContext, type SQLiteProjectionHandlerOptions, SQLiteProjectionSpec, type SQLiteProjectionSpecEvent, type SQLiteProjectionSpecOptions, type SQLiteProjectionSpecWhenOptions, type SQLiteReadEvent, type SQLiteReadEventMetadata, type StoreLastProcessedProcessorPositionResult, appendToStream, assertSQLQueryResultMatches, createEventStoreSchema, defaultTag, emmettPrefix, eventInStream, eventsInStream, expectSQL, getSQLiteEventStore, globalNames, globalTag, handleProjections, isSQLiteError, messagesTable, messagesTableSQL, newEventsInStream, readLastMessageGlobalPosition, readMessagesBatch, readProcessorCheckpoint, readStream, schemaSQL, sql, sqliteConnection, sqliteProjection, sqliteRawBatchSQLProjection, sqliteRawSQLProjection, storeProcessorCheckpoint, streamsTable, streamsTableSQL, subscriptionsTable, subscriptionsTableSQL };
|