@event-driven-io/emmett-sqlite 0.34.0 → 0.35.0-alpha.2

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.d.cts CHANGED
@@ -1,16 +1,20 @@
1
- import { EventStore, ReadEventMetadataWithGlobalPosition, Event, ReadEvent, ProjectionRegistration, BeforeEventStoreCommitHandler, AppendToStreamOptions, ReadStreamOptions, ReadStreamResult } from '@event-driven-io/emmett';
1
+ import sqlite3 from 'sqlite3';
2
+ import { Event, ProjectionDefinition, ReadEvent, ReadEventMetadataWithGlobalPosition, EmmettError, EventStore, AppendToStreamOptions, AppendToStreamResultWithGlobalPosition, ProjectionRegistration, BeforeEventStoreCommitHandler, ReadEventMetadata, ReadStreamOptions, ReadStreamResult } from '@event-driven-io/emmett';
2
3
 
3
4
  type Parameters = object | string | bigint | number | boolean | null;
4
5
  type SQLiteConnection = {
5
6
  close: () => void;
6
- command: (sql: string, values?: Parameters[]) => Promise<void>;
7
+ command: (sql: string, values?: Parameters[]) => Promise<sqlite3.RunResult>;
7
8
  query: <T>(sql: string, values?: Parameters[]) => Promise<T[]>;
8
9
  querySingle: <T>(sql: string, values?: Parameters[]) => Promise<T | null>;
10
+ withTransaction: <T>(fn: () => Promise<T>) => Promise<T>;
9
11
  };
10
12
  interface SQLiteError extends Error {
11
13
  errno: number;
12
14
  }
13
15
  declare const isSQLiteError: (error: unknown) => error is SQLiteError;
16
+ type InMemorySharedCacheSQLiteDatabase = 'file::memory:?cache=shared';
17
+ declare const InMemorySharedCacheSQLiteDatabase = "file::memory:?cache=shared";
14
18
  type InMemorySQLiteDatabase = ':memory:';
15
19
  declare const InMemorySQLiteDatabase = ":memory:";
16
20
  type SQLiteConnectionOptions = {
@@ -18,17 +22,101 @@ type SQLiteConnectionOptions = {
18
22
  };
19
23
  declare const sqliteConnection: (options: SQLiteConnectionOptions) => SQLiteConnection;
20
24
 
25
+ type SQLiteEventStoreMessageBatchPullerStartFrom = {
26
+ globalPosition: bigint;
27
+ } | 'BEGINNING' | 'END';
28
+
21
29
  type SQLiteProjectionHandlerContext = {
22
- connection: SQLiteConnection;
30
+ db: SQLiteConnection;
31
+ };
32
+ type SQLiteProjectionDefinition<EventType extends Event = Event> = ProjectionDefinition<EventType, SQLiteReadEventMetadata, SQLiteProjectionHandlerContext>;
33
+
34
+ type SQLiteProcessorEventsBatch<EventType extends Event = Event> = {
35
+ messages: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>[];
36
+ };
37
+ type SQLiteProcessorHandlerContext = {
38
+ db: SQLiteConnection;
39
+ fileName: string;
40
+ };
41
+ type SQLiteProcessor<EventType extends Event = Event> = {
42
+ id: string;
43
+ start: (db: SQLiteConnection) => Promise<SQLiteEventStoreMessageBatchPullerStartFrom | undefined>;
44
+ isActive: boolean;
45
+ handle: (messagesBatch: SQLiteProcessorEventsBatch<EventType>, context: {
46
+ db?: SQLiteConnection;
47
+ fileName?: string;
48
+ }) => Promise<SQLiteProcessorMessageHandlerResult>;
49
+ };
50
+ declare const SQLiteProcessor: {
51
+ result: {
52
+ skip: (options?: {
53
+ reason?: string;
54
+ }) => SQLiteProcessorMessageHandlerResult;
55
+ stop: (options?: {
56
+ reason?: string;
57
+ error?: EmmettError;
58
+ }) => SQLiteProcessorMessageHandlerResult;
59
+ };
60
+ };
61
+ type SQLiteProcessorMessageHandlerResult = void | {
62
+ type: 'SKIP';
63
+ reason?: string;
64
+ } | {
65
+ type: 'STOP';
66
+ reason?: string;
67
+ error?: EmmettError;
68
+ };
69
+ type SQLiteProcessorEachMessageHandler<EventType extends Event = Event> = (event: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>, context: SQLiteProcessorHandlerContext) => Promise<SQLiteProcessorMessageHandlerResult> | SQLiteProcessorMessageHandlerResult;
70
+ type SQLiteProcessorStartFrom = SQLiteEventStoreMessageBatchPullerStartFrom | 'CURRENT';
71
+ type SQLiteProcessorConnectionOptions = {
72
+ fileName: string;
73
+ db?: SQLiteConnection;
23
74
  };
75
+ type GenericSQLiteProcessorOptions<EventType extends Event = Event> = {
76
+ processorId: string;
77
+ version?: number;
78
+ partition?: string;
79
+ startFrom?: SQLiteProcessorStartFrom;
80
+ stopAfter?: (message: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>) => boolean;
81
+ eachMessage: SQLiteProcessorEachMessageHandler<EventType>;
82
+ connectionOptions?: SQLiteProcessorConnectionOptions;
83
+ };
84
+ type SQLiteProjectionProcessorOptions<EventType extends Event = Event> = {
85
+ processorId?: string;
86
+ version?: number;
87
+ projection: SQLiteProjectionDefinition<EventType>;
88
+ partition?: string;
89
+ startFrom?: SQLiteProcessorStartFrom;
90
+ stopAfter?: (message: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>) => boolean;
91
+ };
92
+ type SQLiteProcessorOptions<EventType extends Event = Event> = GenericSQLiteProcessorOptions<EventType> | SQLiteProjectionProcessorOptions<EventType>;
93
+
94
+ type SQLiteEventStoreConsumerConfig<ConsumerEventType extends Event = Event> = {
95
+ processors?: SQLiteProcessor<ConsumerEventType>[];
96
+ pulling?: {
97
+ batchSize?: number;
98
+ pullingFrequencyInMs?: number;
99
+ };
100
+ };
101
+ type SQLiteEventStoreConsumer<ConsumerEventType extends Event = Event> = Readonly<{
102
+ isRunning: boolean;
103
+ processors: SQLiteProcessor<ConsumerEventType>[];
104
+ processor: <EventType extends ConsumerEventType = ConsumerEventType>(options: SQLiteProcessorOptions<EventType>) => SQLiteProcessor<EventType>;
105
+ start: () => Promise<void>;
106
+ stop: () => Promise<void>;
107
+ close: () => Promise<void>;
108
+ }>;
24
109
 
25
110
  type EventHandler<E extends Event = Event> = (eventEnvelope: ReadEvent<E>) => void;
26
111
  declare const SQLiteEventStoreDefaultStreamVersion = 0n;
27
- type SQLiteEventStore = EventStore<SQLiteReadEventMetadata>;
112
+ interface SQLiteEventStore extends EventStore<SQLiteReadEventMetadata> {
113
+ appendToStream<EventType extends Event>(streamName: string, events: EventType[], options?: AppendToStreamOptions): Promise<AppendToStreamResultWithGlobalPosition>;
114
+ consumer<ConsumerEventType extends Event = Event>(options?: SQLiteEventStoreConsumerConfig<ConsumerEventType>): SQLiteEventStoreConsumer<ConsumerEventType>;
115
+ }
28
116
  type SQLiteReadEventMetadata = ReadEventMetadataWithGlobalPosition;
29
117
  type SQLiteReadEvent<EventType extends Event = Event> = ReadEvent<EventType, SQLiteReadEventMetadata>;
30
118
  type SQLiteEventStoreOptions = {
31
- fileName: InMemorySQLiteDatabase | string | undefined;
119
+ fileName: InMemorySQLiteDatabase | InMemorySharedCacheSQLiteDatabase | string | undefined;
32
120
  projections?: ProjectionRegistration<'inline', SQLiteReadEventMetadata, SQLiteProjectionHandlerContext>[];
33
121
  schema?: {
34
122
  autoMigration?: 'None' | 'CreateOrUpdate';
@@ -39,7 +127,7 @@ type SQLiteEventStoreOptions = {
39
127
  * @type {BeforeEventStoreCommitHandler<SQLiteEventStore, HandlerContext>}
40
128
  */
41
129
  onBeforeCommit?: BeforeEventStoreCommitHandler<SQLiteEventStore, {
42
- connection: SQLiteConnection;
130
+ db: SQLiteConnection;
43
131
  }>;
44
132
  };
45
133
  };
@@ -55,17 +143,70 @@ type AppendEventResult = {
55
143
  declare const appendToStream: <MessageType extends Event>(db: SQLiteConnection, streamName: string, streamType: string, messages: MessageType[], options?: AppendToStreamOptions & {
56
144
  partition?: string;
57
145
  onBeforeCommit?: BeforeEventStoreCommitHandler<SQLiteEventStore, {
58
- connection: SQLiteConnection;
146
+ db: SQLiteConnection;
59
147
  }>;
60
148
  }) => Promise<AppendEventResult>;
61
149
 
150
+ type ReadLastMessageGlobalPositionResult = {
151
+ currentGlobalPosition: bigint | null;
152
+ };
153
+ declare const readLastMessageGlobalPosition: (db: SQLiteConnection, options?: {
154
+ partition?: string;
155
+ }) => Promise<ReadLastMessageGlobalPositionResult>;
156
+
157
+ type ReadMessagesBatchOptions = {
158
+ after: bigint;
159
+ batchSize: number;
160
+ } | {
161
+ from: bigint;
162
+ batchSize: number;
163
+ } | {
164
+ to: bigint;
165
+ batchSize: number;
166
+ } | {
167
+ from: bigint;
168
+ to: bigint;
169
+ };
170
+ type ReadMessagesBatchResult<EventType extends Event, ReadEventMetadataType extends ReadEventMetadata = ReadEventMetadata> = {
171
+ currentGlobalPosition: bigint;
172
+ messages: ReadEvent<EventType, ReadEventMetadataType>[];
173
+ areEventsLeft: boolean;
174
+ };
175
+ declare const readMessagesBatch: <MessageType extends Event, ReadEventMetadataType extends ReadEventMetadataWithGlobalPosition = ReadEventMetadataWithGlobalPosition>(db: SQLiteConnection, options: ReadMessagesBatchOptions & {
176
+ partition?: string;
177
+ }) => Promise<ReadMessagesBatchResult<MessageType, ReadEventMetadataType>>;
178
+
179
+ type ReadProcessorCheckpointResult = {
180
+ lastProcessedPosition: bigint | null;
181
+ };
182
+ declare const readProcessorCheckpoint: (db: SQLiteConnection, options: {
183
+ processorId: string;
184
+ partition?: string;
185
+ }) => Promise<ReadProcessorCheckpointResult>;
186
+
62
187
  declare const readStream: <EventType extends Event>(db: SQLiteConnection, streamId: string, options?: ReadStreamOptions & {
63
188
  partition?: string;
64
189
  }) => Promise<ReadStreamResult<EventType, ReadEventMetadataWithGlobalPosition>>;
65
190
 
191
+ type StoreLastProcessedProcessorPositionResult<Position extends bigint | null = bigint> = {
192
+ success: true;
193
+ newPosition: Position;
194
+ } | {
195
+ success: false;
196
+ reason: 'IGNORED' | 'MISMATCH';
197
+ };
198
+ declare function storeProcessorCheckpoint(db: SQLiteConnection, options: {
199
+ processorId: string;
200
+ version: number | undefined;
201
+ newPosition: bigint | null;
202
+ lastProcessedPosition: bigint | null;
203
+ partition?: string;
204
+ }): Promise<StoreLastProcessedProcessorPositionResult<bigint | null>>;
205
+
66
206
  declare const sql: (sql: string) => string;
67
207
  declare const streamsTableSQL: string;
68
208
  declare const messagesTableSQL: string;
209
+ declare const subscriptionsTableSQL: string;
69
210
  declare const schemaSQL: string[];
70
211
  declare const createEventStoreSchema: (db: SQLiteConnection) => Promise<void>;
71
212
 
@@ -97,5 +238,8 @@ declare const messagesTable: {
97
238
  };
98
239
  };
99
240
  };
241
+ declare const subscriptionsTable: {
242
+ name: string;
243
+ };
100
244
 
101
- export { type AppendEventResult, type EventHandler, InMemorySQLiteDatabase, type Parameters, type SQLiteConnection, type SQLiteError, type SQLiteEventStore, SQLiteEventStoreDefaultStreamVersion, type SQLiteEventStoreOptions, type SQLiteReadEvent, type SQLiteReadEventMetadata, appendToStream, createEventStoreSchema, defaultTag, emmettPrefix, getSQLiteEventStore, globalNames, globalTag, isSQLiteError, messagesTable, messagesTableSQL, readStream, schemaSQL, sql, sqliteConnection, streamsTable, streamsTableSQL };
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 };
package/dist/index.d.ts CHANGED
@@ -1,16 +1,20 @@
1
- import { EventStore, ReadEventMetadataWithGlobalPosition, Event, ReadEvent, ProjectionRegistration, BeforeEventStoreCommitHandler, AppendToStreamOptions, ReadStreamOptions, ReadStreamResult } from '@event-driven-io/emmett';
1
+ import sqlite3 from 'sqlite3';
2
+ import { Event, ProjectionDefinition, ReadEvent, ReadEventMetadataWithGlobalPosition, EmmettError, EventStore, AppendToStreamOptions, AppendToStreamResultWithGlobalPosition, ProjectionRegistration, BeforeEventStoreCommitHandler, ReadEventMetadata, ReadStreamOptions, ReadStreamResult } from '@event-driven-io/emmett';
2
3
 
3
4
  type Parameters = object | string | bigint | number | boolean | null;
4
5
  type SQLiteConnection = {
5
6
  close: () => void;
6
- command: (sql: string, values?: Parameters[]) => Promise<void>;
7
+ command: (sql: string, values?: Parameters[]) => Promise<sqlite3.RunResult>;
7
8
  query: <T>(sql: string, values?: Parameters[]) => Promise<T[]>;
8
9
  querySingle: <T>(sql: string, values?: Parameters[]) => Promise<T | null>;
10
+ withTransaction: <T>(fn: () => Promise<T>) => Promise<T>;
9
11
  };
10
12
  interface SQLiteError extends Error {
11
13
  errno: number;
12
14
  }
13
15
  declare const isSQLiteError: (error: unknown) => error is SQLiteError;
16
+ type InMemorySharedCacheSQLiteDatabase = 'file::memory:?cache=shared';
17
+ declare const InMemorySharedCacheSQLiteDatabase = "file::memory:?cache=shared";
14
18
  type InMemorySQLiteDatabase = ':memory:';
15
19
  declare const InMemorySQLiteDatabase = ":memory:";
16
20
  type SQLiteConnectionOptions = {
@@ -18,17 +22,101 @@ type SQLiteConnectionOptions = {
18
22
  };
19
23
  declare const sqliteConnection: (options: SQLiteConnectionOptions) => SQLiteConnection;
20
24
 
25
+ type SQLiteEventStoreMessageBatchPullerStartFrom = {
26
+ globalPosition: bigint;
27
+ } | 'BEGINNING' | 'END';
28
+
21
29
  type SQLiteProjectionHandlerContext = {
22
- connection: SQLiteConnection;
30
+ db: SQLiteConnection;
31
+ };
32
+ type SQLiteProjectionDefinition<EventType extends Event = Event> = ProjectionDefinition<EventType, SQLiteReadEventMetadata, SQLiteProjectionHandlerContext>;
33
+
34
+ type SQLiteProcessorEventsBatch<EventType extends Event = Event> = {
35
+ messages: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>[];
36
+ };
37
+ type SQLiteProcessorHandlerContext = {
38
+ db: SQLiteConnection;
39
+ fileName: string;
40
+ };
41
+ type SQLiteProcessor<EventType extends Event = Event> = {
42
+ id: string;
43
+ start: (db: SQLiteConnection) => Promise<SQLiteEventStoreMessageBatchPullerStartFrom | undefined>;
44
+ isActive: boolean;
45
+ handle: (messagesBatch: SQLiteProcessorEventsBatch<EventType>, context: {
46
+ db?: SQLiteConnection;
47
+ fileName?: string;
48
+ }) => Promise<SQLiteProcessorMessageHandlerResult>;
49
+ };
50
+ declare const SQLiteProcessor: {
51
+ result: {
52
+ skip: (options?: {
53
+ reason?: string;
54
+ }) => SQLiteProcessorMessageHandlerResult;
55
+ stop: (options?: {
56
+ reason?: string;
57
+ error?: EmmettError;
58
+ }) => SQLiteProcessorMessageHandlerResult;
59
+ };
60
+ };
61
+ type SQLiteProcessorMessageHandlerResult = void | {
62
+ type: 'SKIP';
63
+ reason?: string;
64
+ } | {
65
+ type: 'STOP';
66
+ reason?: string;
67
+ error?: EmmettError;
68
+ };
69
+ type SQLiteProcessorEachMessageHandler<EventType extends Event = Event> = (event: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>, context: SQLiteProcessorHandlerContext) => Promise<SQLiteProcessorMessageHandlerResult> | SQLiteProcessorMessageHandlerResult;
70
+ type SQLiteProcessorStartFrom = SQLiteEventStoreMessageBatchPullerStartFrom | 'CURRENT';
71
+ type SQLiteProcessorConnectionOptions = {
72
+ fileName: string;
73
+ db?: SQLiteConnection;
23
74
  };
75
+ type GenericSQLiteProcessorOptions<EventType extends Event = Event> = {
76
+ processorId: string;
77
+ version?: number;
78
+ partition?: string;
79
+ startFrom?: SQLiteProcessorStartFrom;
80
+ stopAfter?: (message: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>) => boolean;
81
+ eachMessage: SQLiteProcessorEachMessageHandler<EventType>;
82
+ connectionOptions?: SQLiteProcessorConnectionOptions;
83
+ };
84
+ type SQLiteProjectionProcessorOptions<EventType extends Event = Event> = {
85
+ processorId?: string;
86
+ version?: number;
87
+ projection: SQLiteProjectionDefinition<EventType>;
88
+ partition?: string;
89
+ startFrom?: SQLiteProcessorStartFrom;
90
+ stopAfter?: (message: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>) => boolean;
91
+ };
92
+ type SQLiteProcessorOptions<EventType extends Event = Event> = GenericSQLiteProcessorOptions<EventType> | SQLiteProjectionProcessorOptions<EventType>;
93
+
94
+ type SQLiteEventStoreConsumerConfig<ConsumerEventType extends Event = Event> = {
95
+ processors?: SQLiteProcessor<ConsumerEventType>[];
96
+ pulling?: {
97
+ batchSize?: number;
98
+ pullingFrequencyInMs?: number;
99
+ };
100
+ };
101
+ type SQLiteEventStoreConsumer<ConsumerEventType extends Event = Event> = Readonly<{
102
+ isRunning: boolean;
103
+ processors: SQLiteProcessor<ConsumerEventType>[];
104
+ processor: <EventType extends ConsumerEventType = ConsumerEventType>(options: SQLiteProcessorOptions<EventType>) => SQLiteProcessor<EventType>;
105
+ start: () => Promise<void>;
106
+ stop: () => Promise<void>;
107
+ close: () => Promise<void>;
108
+ }>;
24
109
 
25
110
  type EventHandler<E extends Event = Event> = (eventEnvelope: ReadEvent<E>) => void;
26
111
  declare const SQLiteEventStoreDefaultStreamVersion = 0n;
27
- type SQLiteEventStore = EventStore<SQLiteReadEventMetadata>;
112
+ interface SQLiteEventStore extends EventStore<SQLiteReadEventMetadata> {
113
+ appendToStream<EventType extends Event>(streamName: string, events: EventType[], options?: AppendToStreamOptions): Promise<AppendToStreamResultWithGlobalPosition>;
114
+ consumer<ConsumerEventType extends Event = Event>(options?: SQLiteEventStoreConsumerConfig<ConsumerEventType>): SQLiteEventStoreConsumer<ConsumerEventType>;
115
+ }
28
116
  type SQLiteReadEventMetadata = ReadEventMetadataWithGlobalPosition;
29
117
  type SQLiteReadEvent<EventType extends Event = Event> = ReadEvent<EventType, SQLiteReadEventMetadata>;
30
118
  type SQLiteEventStoreOptions = {
31
- fileName: InMemorySQLiteDatabase | string | undefined;
119
+ fileName: InMemorySQLiteDatabase | InMemorySharedCacheSQLiteDatabase | string | undefined;
32
120
  projections?: ProjectionRegistration<'inline', SQLiteReadEventMetadata, SQLiteProjectionHandlerContext>[];
33
121
  schema?: {
34
122
  autoMigration?: 'None' | 'CreateOrUpdate';
@@ -39,7 +127,7 @@ type SQLiteEventStoreOptions = {
39
127
  * @type {BeforeEventStoreCommitHandler<SQLiteEventStore, HandlerContext>}
40
128
  */
41
129
  onBeforeCommit?: BeforeEventStoreCommitHandler<SQLiteEventStore, {
42
- connection: SQLiteConnection;
130
+ db: SQLiteConnection;
43
131
  }>;
44
132
  };
45
133
  };
@@ -55,17 +143,70 @@ type AppendEventResult = {
55
143
  declare const appendToStream: <MessageType extends Event>(db: SQLiteConnection, streamName: string, streamType: string, messages: MessageType[], options?: AppendToStreamOptions & {
56
144
  partition?: string;
57
145
  onBeforeCommit?: BeforeEventStoreCommitHandler<SQLiteEventStore, {
58
- connection: SQLiteConnection;
146
+ db: SQLiteConnection;
59
147
  }>;
60
148
  }) => Promise<AppendEventResult>;
61
149
 
150
+ type ReadLastMessageGlobalPositionResult = {
151
+ currentGlobalPosition: bigint | null;
152
+ };
153
+ declare const readLastMessageGlobalPosition: (db: SQLiteConnection, options?: {
154
+ partition?: string;
155
+ }) => Promise<ReadLastMessageGlobalPositionResult>;
156
+
157
+ type ReadMessagesBatchOptions = {
158
+ after: bigint;
159
+ batchSize: number;
160
+ } | {
161
+ from: bigint;
162
+ batchSize: number;
163
+ } | {
164
+ to: bigint;
165
+ batchSize: number;
166
+ } | {
167
+ from: bigint;
168
+ to: bigint;
169
+ };
170
+ type ReadMessagesBatchResult<EventType extends Event, ReadEventMetadataType extends ReadEventMetadata = ReadEventMetadata> = {
171
+ currentGlobalPosition: bigint;
172
+ messages: ReadEvent<EventType, ReadEventMetadataType>[];
173
+ areEventsLeft: boolean;
174
+ };
175
+ declare const readMessagesBatch: <MessageType extends Event, ReadEventMetadataType extends ReadEventMetadataWithGlobalPosition = ReadEventMetadataWithGlobalPosition>(db: SQLiteConnection, options: ReadMessagesBatchOptions & {
176
+ partition?: string;
177
+ }) => Promise<ReadMessagesBatchResult<MessageType, ReadEventMetadataType>>;
178
+
179
+ type ReadProcessorCheckpointResult = {
180
+ lastProcessedPosition: bigint | null;
181
+ };
182
+ declare const readProcessorCheckpoint: (db: SQLiteConnection, options: {
183
+ processorId: string;
184
+ partition?: string;
185
+ }) => Promise<ReadProcessorCheckpointResult>;
186
+
62
187
  declare const readStream: <EventType extends Event>(db: SQLiteConnection, streamId: string, options?: ReadStreamOptions & {
63
188
  partition?: string;
64
189
  }) => Promise<ReadStreamResult<EventType, ReadEventMetadataWithGlobalPosition>>;
65
190
 
191
+ type StoreLastProcessedProcessorPositionResult<Position extends bigint | null = bigint> = {
192
+ success: true;
193
+ newPosition: Position;
194
+ } | {
195
+ success: false;
196
+ reason: 'IGNORED' | 'MISMATCH';
197
+ };
198
+ declare function storeProcessorCheckpoint(db: SQLiteConnection, options: {
199
+ processorId: string;
200
+ version: number | undefined;
201
+ newPosition: bigint | null;
202
+ lastProcessedPosition: bigint | null;
203
+ partition?: string;
204
+ }): Promise<StoreLastProcessedProcessorPositionResult<bigint | null>>;
205
+
66
206
  declare const sql: (sql: string) => string;
67
207
  declare const streamsTableSQL: string;
68
208
  declare const messagesTableSQL: string;
209
+ declare const subscriptionsTableSQL: string;
69
210
  declare const schemaSQL: string[];
70
211
  declare const createEventStoreSchema: (db: SQLiteConnection) => Promise<void>;
71
212
 
@@ -97,5 +238,8 @@ declare const messagesTable: {
97
238
  };
98
239
  };
99
240
  };
241
+ declare const subscriptionsTable: {
242
+ name: string;
243
+ };
100
244
 
101
- export { type AppendEventResult, type EventHandler, InMemorySQLiteDatabase, type Parameters, type SQLiteConnection, type SQLiteError, type SQLiteEventStore, SQLiteEventStoreDefaultStreamVersion, type SQLiteEventStoreOptions, type SQLiteReadEvent, type SQLiteReadEventMetadata, appendToStream, createEventStoreSchema, defaultTag, emmettPrefix, getSQLiteEventStore, globalNames, globalTag, isSQLiteError, messagesTable, messagesTableSQL, readStream, schemaSQL, sql, sqliteConnection, streamsTable, streamsTableSQL };
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 };