@event-driven-io/emmett-postgresql 0.35.0-alpha.2 → 0.36.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 +359 -188
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +144 -181
- package/dist/index.d.ts +144 -181
- package/dist/index.js +347 -176
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import * as _event_driven_io_dumbo from '@event-driven-io/dumbo';
|
|
2
|
-
import { SQLExecutor,
|
|
3
|
-
import {
|
|
2
|
+
import { SQLExecutor, NodePostgresClient, NodePostgresTransaction, Dumbo, NodePostgresConnector, NodePostgresPoolClientConnection, NodePostgresClientConnection, NodePostgresPool, DumboOptions, QueryResultRow, SQL, MigrationStyle } from '@event-driven-io/dumbo';
|
|
3
|
+
import { EmmettError, Message, BatchRecordedMessageHandlerWithoutContext, ReadEventMetadataWithGlobalPosition, ReactorOptions, Event, ProjectorOptions, AnyMessage, MessageProcessor, SingleRecordedMessageHandlerWithContext, BatchRecordedMessageHandlerWithContext, Checkpointer, MessageConsumerOptions, MessageConsumer, DefaultRecord, ReadEvent, CanHandle, TruncateProjection, ThenThrows, ProjectionDefinition, ProjectionHandler, EventStore, EventStoreSessionFactory, AppendToStreamOptions, AppendToStreamResultWithGlobalPosition, ProjectionRegistration, RecordedMessage, RecordedMessageMetadata, RecordedMessageMetadataWithGlobalPosition, ReadStreamOptions, ReadStreamResult } from '@event-driven-io/emmett';
|
|
4
4
|
import pg from 'pg';
|
|
5
|
-
import { PongoDocument, WithId, PongoFilter
|
|
5
|
+
import { PongoClient, PongoDocument, WithId, PongoFilter } from '@event-driven-io/pongo';
|
|
6
|
+
import { AnyEvent, ProjectorOptions as ProjectorOptions$1, ReadEventMetadataWithGlobalPosition as ReadEventMetadataWithGlobalPosition$1 } from '@event-driven-io/emmett/src';
|
|
6
7
|
|
|
7
8
|
declare const DefaultPostgreSQLEventStoreProcessorBatchSize = 100;
|
|
8
9
|
declare const DefaultPostgreSQLEventStoreProcessorPullingFrequencyInMs = 50;
|
|
9
|
-
type PostgreSQLEventStoreMessagesBatch<EventType extends Event = Event> = {
|
|
10
|
-
messages: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>[];
|
|
11
|
-
};
|
|
12
10
|
type PostgreSQLEventStoreMessagesBatchHandlerResult = void | {
|
|
13
11
|
type: 'STOP';
|
|
14
12
|
reason?: string;
|
|
15
13
|
error?: EmmettError;
|
|
16
14
|
};
|
|
17
|
-
type
|
|
18
|
-
type PostgreSQLEventStoreMessageBatchPullerOptions<EventType extends Event = Event> = {
|
|
15
|
+
type PostgreSQLEventStoreMessageBatchPullerOptions<MessageType extends Message = Message> = {
|
|
19
16
|
executor: SQLExecutor;
|
|
20
17
|
pullingFrequencyInMs: number;
|
|
21
18
|
batchSize: number;
|
|
22
|
-
eachBatch:
|
|
19
|
+
eachBatch: BatchRecordedMessageHandlerWithoutContext<MessageType, ReadEventMetadataWithGlobalPosition>;
|
|
20
|
+
stopWhen?: {
|
|
21
|
+
noMessagesLeft?: boolean;
|
|
22
|
+
};
|
|
23
23
|
};
|
|
24
24
|
type PostgreSQLEventStoreMessageBatchPullerStartFrom = {
|
|
25
|
-
|
|
25
|
+
lastCheckpoint: bigint;
|
|
26
26
|
} | 'BEGINNING' | 'END';
|
|
27
27
|
type PostgreSQLEventStoreMessageBatchPullerStartOptions = {
|
|
28
28
|
startFrom: PostgreSQLEventStoreMessageBatchPullerStartFrom;
|
|
@@ -32,38 +32,103 @@ type PostgreSQLEventStoreMessageBatchPuller = {
|
|
|
32
32
|
start(options: PostgreSQLEventStoreMessageBatchPullerStartOptions): Promise<void>;
|
|
33
33
|
stop(): Promise<void>;
|
|
34
34
|
};
|
|
35
|
-
declare const postgreSQLEventStoreMessageBatchPuller: <
|
|
35
|
+
declare const postgreSQLEventStoreMessageBatchPuller: <MessageType extends Message = Message>({ executor, batchSize, eachBatch, pullingFrequencyInMs, stopWhen, }: PostgreSQLEventStoreMessageBatchPullerOptions<MessageType>) => PostgreSQLEventStoreMessageBatchPuller;
|
|
36
36
|
declare const zipPostgreSQLEventStoreMessageBatchPullerStartFrom: (options: (PostgreSQLEventStoreMessageBatchPullerStartFrom | undefined)[]) => PostgreSQLEventStoreMessageBatchPullerStartFrom;
|
|
37
37
|
|
|
38
|
-
type
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
type PostgreSQLProcessorHandlerContext = {
|
|
39
|
+
execute: SQLExecutor;
|
|
40
|
+
connection: {
|
|
41
|
+
connectionString: string;
|
|
42
|
+
client: NodePostgresClient;
|
|
43
|
+
transaction: NodePostgresTransaction;
|
|
44
|
+
pool: Dumbo;
|
|
45
|
+
};
|
|
41
46
|
};
|
|
42
|
-
type
|
|
43
|
-
|
|
47
|
+
type PostgreSQLProcessor<MessageType extends Message = AnyMessage> = MessageProcessor<MessageType, ReadEventMetadataWithGlobalPosition, PostgreSQLProcessorHandlerContext>;
|
|
48
|
+
type PostgreSQLProcessorEachMessageHandler<MessageType extends Message = Message> = SingleRecordedMessageHandlerWithContext<MessageType, ReadEventMetadataWithGlobalPosition, PostgreSQLProcessorHandlerContext>;
|
|
49
|
+
type PostgreSQLProcessorEachBatchHandler<MessageType extends Message = Message> = BatchRecordedMessageHandlerWithContext<MessageType, ReadEventMetadataWithGlobalPosition, PostgreSQLProcessorHandlerContext>;
|
|
50
|
+
type PostgreSQLProcessorStartFrom = PostgreSQLEventStoreMessageBatchPullerStartFrom | 'CURRENT';
|
|
51
|
+
type PostgreSQLProcessorPooledOptions = {
|
|
52
|
+
connector?: NodePostgresConnector;
|
|
53
|
+
database?: string;
|
|
54
|
+
pooled: true;
|
|
55
|
+
pool: pg.Pool;
|
|
44
56
|
} | {
|
|
45
|
-
|
|
57
|
+
connector?: NodePostgresConnector;
|
|
58
|
+
database?: string;
|
|
59
|
+
pool: pg.Pool;
|
|
60
|
+
} | {
|
|
61
|
+
connector?: NodePostgresConnector;
|
|
62
|
+
database?: string;
|
|
63
|
+
pooled: true;
|
|
64
|
+
} | {
|
|
65
|
+
connector?: NodePostgresConnector;
|
|
66
|
+
database?: string;
|
|
46
67
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
type PostgreSQLProcessorNotPooledOptions = {
|
|
69
|
+
connector?: NodePostgresConnector;
|
|
70
|
+
database?: string;
|
|
71
|
+
pooled: false;
|
|
72
|
+
client: pg.Client;
|
|
73
|
+
} | {
|
|
74
|
+
connector?: NodePostgresConnector;
|
|
75
|
+
database?: string;
|
|
76
|
+
client: pg.Client;
|
|
77
|
+
} | {
|
|
78
|
+
connector?: NodePostgresConnector;
|
|
79
|
+
database?: string;
|
|
80
|
+
pooled: false;
|
|
81
|
+
} | {
|
|
82
|
+
connector?: NodePostgresConnector;
|
|
83
|
+
database?: string;
|
|
84
|
+
connection: NodePostgresPoolClientConnection | NodePostgresClientConnection;
|
|
85
|
+
pooled?: false;
|
|
86
|
+
} | {
|
|
87
|
+
connector?: NodePostgresConnector;
|
|
88
|
+
database?: string;
|
|
89
|
+
dumbo: NodePostgresPool;
|
|
90
|
+
pooled?: false;
|
|
91
|
+
};
|
|
92
|
+
type PostgreSQLProcessorConnectionOptions = {
|
|
93
|
+
connectionString: string;
|
|
94
|
+
} & (PostgreSQLProcessorPooledOptions | PostgreSQLProcessorNotPooledOptions);
|
|
95
|
+
type PostgreSQLCheckpointer<MessageType extends AnyMessage = AnyMessage> = Checkpointer<MessageType, ReadEventMetadataWithGlobalPosition, PostgreSQLProcessorHandlerContext>;
|
|
96
|
+
declare const postgreSQLCheckpointer: <MessageType extends Message = Message>() => PostgreSQLCheckpointer<MessageType>;
|
|
97
|
+
type PostgreSQLConnectionOptions = {
|
|
98
|
+
connectionOptions?: PostgreSQLProcessorConnectionOptions;
|
|
99
|
+
};
|
|
100
|
+
type PostgreSQLReactorOptions<MessageType extends Message = Message> = ReactorOptions<MessageType, ReadEventMetadataWithGlobalPosition, PostgreSQLProcessorHandlerContext> & PostgreSQLConnectionOptions;
|
|
101
|
+
type PostgreSQLProjectorOptions<EventType extends Event = Event> = ProjectorOptions<EventType, ReadEventMetadataWithGlobalPosition, PostgreSQLProcessorHandlerContext> & PostgreSQLConnectionOptions;
|
|
102
|
+
type PostgreSQLProcessorOptions<MessageType extends Message = Message> = PostgreSQLReactorOptions<MessageType> | PostgreSQLProjectorOptions<MessageType>;
|
|
103
|
+
declare const postgreSQLProjector: <EventType extends Event = Event>(options: PostgreSQLProjectorOptions<EventType>) => PostgreSQLProcessor<EventType>;
|
|
104
|
+
declare const postgreSQLReactor: <MessageType extends Message = Message>(options: PostgreSQLReactorOptions<MessageType>) => PostgreSQLProcessor<MessageType>;
|
|
105
|
+
declare const postgreSQLMessageProcessor: <MessageType extends Message = Message>(options: PostgreSQLProcessorOptions<MessageType>) => PostgreSQLProcessor<MessageType>;
|
|
106
|
+
|
|
107
|
+
type PostgreSQLConsumerContext = {
|
|
108
|
+
execute: SQLExecutor;
|
|
109
|
+
connection: {
|
|
110
|
+
connectionString: string;
|
|
111
|
+
pool: Dumbo;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
type ExtendableContext = Partial<PostgreSQLConsumerContext> & DefaultRecord;
|
|
115
|
+
type PostgreSQLEventStoreConsumerConfig<ConsumerMessageType extends Message = any> = MessageConsumerOptions<ConsumerMessageType> & {
|
|
116
|
+
stopWhen?: {
|
|
117
|
+
noMessagesLeft?: boolean;
|
|
65
118
|
};
|
|
119
|
+
pulling?: {
|
|
120
|
+
batchSize?: number;
|
|
121
|
+
pullingFrequencyInMs?: number;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
type PostgreSQLEventStoreConsumerOptions<ConsumerMessageType extends Message = Message> = PostgreSQLEventStoreConsumerConfig<ConsumerMessageType> & {
|
|
125
|
+
connectionString: string;
|
|
126
|
+
pool?: Dumbo;
|
|
66
127
|
};
|
|
128
|
+
type PostgreSQLEventStoreConsumer<ConsumerMessageType extends Message = any> = MessageConsumer<ConsumerMessageType> & Readonly<{
|
|
129
|
+
processor: <MessageType extends Message = ConsumerMessageType>(options: PostgreSQLProcessorOptions<MessageType>) => PostgreSQLProcessor<MessageType>;
|
|
130
|
+
}>;
|
|
131
|
+
declare const postgreSQLEventStoreConsumer: <ConsumerMessageType extends Message = AnyMessage>(options: PostgreSQLEventStoreConsumerOptions<ConsumerMessageType>) => PostgreSQLEventStoreConsumer<ConsumerMessageType>;
|
|
67
132
|
|
|
68
133
|
type PongoProjectionHandlerContext = PostgreSQLProjectionHandlerContext & {
|
|
69
134
|
pongo: PongoClient;
|
|
@@ -74,8 +139,9 @@ type PongoDocumentEvolve<Document extends PongoDocument, EventType extends Event
|
|
|
74
139
|
type PongoProjectionOptions<EventType extends Event> = {
|
|
75
140
|
handle: (events: ReadEvent<EventType, PostgresReadEventMetadata>[], context: PongoProjectionHandlerContext) => Promise<void>;
|
|
76
141
|
canHandle: CanHandle<EventType>;
|
|
142
|
+
truncate?: TruncateProjection<PongoProjectionHandlerContext>;
|
|
77
143
|
};
|
|
78
|
-
declare const pongoProjection: <EventType extends Event>({ handle, canHandle, }: PongoProjectionOptions<EventType>) => PostgreSQLProjectionDefinition<EventType>;
|
|
144
|
+
declare const pongoProjection: <EventType extends Event>({ truncate, handle, canHandle, }: PongoProjectionOptions<EventType>) => PostgreSQLProjectionDefinition<EventType>;
|
|
79
145
|
type PongoMultiStreamProjectionOptions<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends PostgresReadEventMetadata = PostgresReadEventMetadata> = {
|
|
80
146
|
canHandle: CanHandle<EventType>;
|
|
81
147
|
collectionName: string;
|
|
@@ -99,6 +165,36 @@ type PongoSingleStreamProjectionOptions<Document extends PongoDocument, EventTyp
|
|
|
99
165
|
});
|
|
100
166
|
declare const pongoSingleStreamProjection: <Document extends PongoDocument, EventType extends Event, EventMetaDataType extends PostgresReadEventMetadata = PostgresReadEventMetadata>(options: PongoSingleStreamProjectionOptions<Document, EventType, EventMetaDataType>) => PostgreSQLProjectionDefinition<EventType>;
|
|
101
167
|
|
|
168
|
+
type PongoAssertOptions = {
|
|
169
|
+
inCollection: string;
|
|
170
|
+
inDatabase?: string;
|
|
171
|
+
};
|
|
172
|
+
type FilterOrId<Doc extends PongoDocument | WithId<PongoDocument>> = {
|
|
173
|
+
withId: string;
|
|
174
|
+
} | {
|
|
175
|
+
matchingFilter: PongoFilter<Doc>;
|
|
176
|
+
};
|
|
177
|
+
declare const documentExists: <Doc extends PongoDocument | WithId<PongoDocument>>(document: Doc, options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
|
|
178
|
+
declare const documentsAreTheSame: <Doc extends PongoDocument | WithId<PongoDocument>>(documents: Doc[], options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
|
|
179
|
+
declare const documentsMatchingHaveCount: <Doc extends PongoDocument | WithId<PongoDocument>>(expectedCount: number, options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
|
|
180
|
+
declare const documentMatchingExists: <Doc extends PongoDocument | WithId<PongoDocument>>(options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
|
|
181
|
+
declare const documentDoesNotExist: <Doc extends PongoDocument | WithId<PongoDocument>>(options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
|
|
182
|
+
declare const expectPongoDocuments: {
|
|
183
|
+
fromCollection: <Doc extends PongoDocument | WithId<PongoDocument>>(collectionName: string) => {
|
|
184
|
+
withId: (id: string) => {
|
|
185
|
+
toBeEqual: (document: Doc) => PostgreSQLProjectionAssert;
|
|
186
|
+
toExist: () => PostgreSQLProjectionAssert;
|
|
187
|
+
notToExist: () => PostgreSQLProjectionAssert;
|
|
188
|
+
};
|
|
189
|
+
matching: <Doc_1 extends PongoDocument | WithId<PongoDocument>>(filter: PongoFilter<Doc_1>) => {
|
|
190
|
+
toBeTheSame: (documents: Doc_1[]) => PostgreSQLProjectionAssert;
|
|
191
|
+
toHaveCount: (expectedCount: number) => PostgreSQLProjectionAssert;
|
|
192
|
+
toExist: () => PostgreSQLProjectionAssert;
|
|
193
|
+
notToExist: () => PostgreSQLProjectionAssert;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
|
|
102
198
|
type PostgreSQLProjectionSpecEvent<EventType extends Event, EventMetaDataType extends PostgresReadEventMetadata = PostgresReadEventMetadata> = EventType & {
|
|
103
199
|
metadata?: Partial<EventMetaDataType>;
|
|
104
200
|
};
|
|
@@ -158,135 +254,9 @@ declare const postgreSQLProjection: <EventType extends Event>(definition: Postgr
|
|
|
158
254
|
declare const postgreSQLRawBatchSQLProjection: <EventType extends Event>(handle: (events: EventType[], context: PostgreSQLProjectionHandlerContext) => Promise<SQL[]> | SQL[], ...canHandle: CanHandle<EventType>) => PostgreSQLProjectionDefinition<EventType>;
|
|
159
255
|
declare const postgreSQLRawSQLProjection: <EventType extends Event>(handle: (event: EventType, context: PostgreSQLProjectionHandlerContext) => Promise<SQL> | SQL, ...canHandle: CanHandle<EventType>) => PostgreSQLProjectionDefinition<EventType>;
|
|
160
256
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
type PostgreSQLProcessorHandlerContext = {
|
|
165
|
-
execute: SQLExecutor;
|
|
166
|
-
connection: {
|
|
167
|
-
connectionString: string;
|
|
168
|
-
client: NodePostgresClient;
|
|
169
|
-
transaction: NodePostgresTransaction;
|
|
170
|
-
pool: Dumbo;
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
type PostgreSQLProcessor<EventType extends Event = Event> = {
|
|
174
|
-
id: string;
|
|
175
|
-
start: (execute: SQLExecutor) => Promise<PostgreSQLEventStoreMessageBatchPullerStartFrom | undefined>;
|
|
176
|
-
isActive: boolean;
|
|
177
|
-
handle: (messagesBatch: PostgreSQLProcessorEventsBatch<EventType>, context: {
|
|
178
|
-
pool?: Dumbo;
|
|
179
|
-
connectionString?: string;
|
|
180
|
-
}) => Promise<PostgreSQLProcessorMessageHandlerResult>;
|
|
181
|
-
};
|
|
182
|
-
declare const PostgreSQLProcessor: {
|
|
183
|
-
result: {
|
|
184
|
-
skip: (options?: {
|
|
185
|
-
reason?: string;
|
|
186
|
-
}) => PostgreSQLProcessorMessageHandlerResult;
|
|
187
|
-
stop: (options?: {
|
|
188
|
-
reason?: string;
|
|
189
|
-
error?: EmmettError;
|
|
190
|
-
}) => PostgreSQLProcessorMessageHandlerResult;
|
|
191
|
-
};
|
|
192
|
-
};
|
|
193
|
-
type PostgreSQLProcessorMessageHandlerResult = void | {
|
|
194
|
-
type: 'SKIP';
|
|
195
|
-
reason?: string;
|
|
196
|
-
} | {
|
|
197
|
-
type: 'STOP';
|
|
198
|
-
reason?: string;
|
|
199
|
-
error?: EmmettError;
|
|
200
|
-
};
|
|
201
|
-
type PostgreSQLProcessorEachMessageHandler<EventType extends Event = Event> = (event: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>, context: PostgreSQLProcessorHandlerContext) => Promise<PostgreSQLProcessorMessageHandlerResult> | PostgreSQLProcessorMessageHandlerResult;
|
|
202
|
-
type PostgreSQLProcessorEachBatchHandler<EventType extends Event = Event> = (event: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>[], context: PostgreSQLProcessorHandlerContext) => Promise<PostgreSQLProcessorMessageHandlerResult> | PostgreSQLProcessorMessageHandlerResult;
|
|
203
|
-
type PostgreSQLProcessorStartFrom = PostgreSQLEventStoreMessageBatchPullerStartFrom | 'CURRENT';
|
|
204
|
-
type PostgreSQLProcessorPooledOptions = {
|
|
205
|
-
connector?: NodePostgresConnector;
|
|
206
|
-
database?: string;
|
|
207
|
-
pooled: true;
|
|
208
|
-
pool: pg.Pool;
|
|
209
|
-
} | {
|
|
210
|
-
connector?: NodePostgresConnector;
|
|
211
|
-
database?: string;
|
|
212
|
-
pool: pg.Pool;
|
|
213
|
-
} | {
|
|
214
|
-
connector?: NodePostgresConnector;
|
|
215
|
-
database?: string;
|
|
216
|
-
pooled: true;
|
|
217
|
-
} | {
|
|
218
|
-
connector?: NodePostgresConnector;
|
|
219
|
-
database?: string;
|
|
220
|
-
};
|
|
221
|
-
type PostgreSQLProcessorNotPooledOptions = {
|
|
222
|
-
connector?: NodePostgresConnector;
|
|
223
|
-
database?: string;
|
|
224
|
-
pooled: false;
|
|
225
|
-
client: pg.Client;
|
|
226
|
-
} | {
|
|
227
|
-
connector?: NodePostgresConnector;
|
|
228
|
-
database?: string;
|
|
229
|
-
client: pg.Client;
|
|
230
|
-
} | {
|
|
231
|
-
connector?: NodePostgresConnector;
|
|
232
|
-
database?: string;
|
|
233
|
-
pooled: false;
|
|
234
|
-
} | {
|
|
235
|
-
connector?: NodePostgresConnector;
|
|
236
|
-
database?: string;
|
|
237
|
-
connection: NodePostgresPoolClientConnection | NodePostgresClientConnection;
|
|
238
|
-
pooled?: false;
|
|
239
|
-
} | {
|
|
240
|
-
connector?: NodePostgresConnector;
|
|
241
|
-
database?: string;
|
|
242
|
-
dumbo: NodePostgresPool;
|
|
243
|
-
pooled?: false;
|
|
244
|
-
};
|
|
245
|
-
type PostgreSQLProcessorConnectionOptions = {
|
|
246
|
-
connectionString: string;
|
|
247
|
-
} & (PostgreSQLProcessorPooledOptions | PostgreSQLProcessorNotPooledOptions);
|
|
248
|
-
type GenericPostgreSQLProcessorOptions<EventType extends Event = Event> = {
|
|
249
|
-
processorId: string;
|
|
250
|
-
version?: number;
|
|
251
|
-
partition?: string;
|
|
252
|
-
startFrom?: PostgreSQLProcessorStartFrom;
|
|
253
|
-
stopAfter?: (message: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>) => boolean;
|
|
254
|
-
eachMessage: PostgreSQLProcessorEachMessageHandler<EventType>;
|
|
255
|
-
connectionOptions?: PostgreSQLProcessorConnectionOptions;
|
|
256
|
-
};
|
|
257
|
-
type PostgreSQLProjectionProcessorOptions<EventType extends Event = Event> = {
|
|
258
|
-
processorId?: string;
|
|
259
|
-
version?: number;
|
|
260
|
-
projection: PostgreSQLProjectionDefinition<EventType>;
|
|
261
|
-
partition?: string;
|
|
262
|
-
startFrom?: PostgreSQLProcessorStartFrom;
|
|
263
|
-
stopAfter?: (message: ReadEvent<EventType, ReadEventMetadataWithGlobalPosition>) => boolean;
|
|
264
|
-
connectionOptions?: PostgreSQLProcessorConnectionOptions;
|
|
265
|
-
};
|
|
266
|
-
type PostgreSQLProcessorOptions<EventType extends Event = Event> = GenericPostgreSQLProcessorOptions<EventType> | PostgreSQLProjectionProcessorOptions<EventType>;
|
|
267
|
-
declare const postgreSQLProjectionProcessor: <EventType extends Event = Event>(options: PostgreSQLProjectionProcessorOptions<EventType>) => PostgreSQLProcessor;
|
|
268
|
-
declare const postgreSQLProcessor: <EventType extends Event = Event>(options: PostgreSQLProcessorOptions<EventType>) => PostgreSQLProcessor;
|
|
269
|
-
|
|
270
|
-
type PostgreSQLEventStoreConsumerConfig<ConsumerEventType extends Event = Event> = {
|
|
271
|
-
processors?: PostgreSQLProcessor<ConsumerEventType>[];
|
|
272
|
-
pulling?: {
|
|
273
|
-
batchSize?: number;
|
|
274
|
-
pullingFrequencyInMs?: number;
|
|
275
|
-
};
|
|
276
|
-
};
|
|
277
|
-
type PostgreSQLEventStoreConsumerOptions<ConsumerEventType extends Event = Event> = PostgreSQLEventStoreConsumerConfig<ConsumerEventType> & {
|
|
278
|
-
connectionString: string;
|
|
279
|
-
pool?: Dumbo;
|
|
280
|
-
};
|
|
281
|
-
type PostgreSQLEventStoreConsumer<ConsumerEventType extends Event = Event> = Readonly<{
|
|
282
|
-
isRunning: boolean;
|
|
283
|
-
processors: PostgreSQLProcessor<ConsumerEventType>[];
|
|
284
|
-
processor: <EventType extends ConsumerEventType = ConsumerEventType>(options: PostgreSQLProcessorOptions<EventType>) => PostgreSQLProcessor<EventType>;
|
|
285
|
-
start: () => Promise<void>;
|
|
286
|
-
stop: () => Promise<void>;
|
|
287
|
-
close: () => Promise<void>;
|
|
288
|
-
}>;
|
|
289
|
-
declare const postgreSQLEventStoreConsumer: <ConsumerEventType extends Event = Event>(options: PostgreSQLEventStoreConsumerOptions<ConsumerEventType>) => PostgreSQLEventStoreConsumer<ConsumerEventType>;
|
|
257
|
+
declare const rebuildPostgreSQLProjections: <EventType extends AnyEvent = AnyEvent>(options: Omit<PostgreSQLEventStoreConsumerOptions<EventType>, "stopWhen" | "processors"> & ({
|
|
258
|
+
projections: (ProjectorOptions$1<EventType, ReadEventMetadataWithGlobalPosition$1, PostgreSQLProcessorHandlerContext> | PostgreSQLProjectionDefinition<EventType>)[];
|
|
259
|
+
} | ProjectorOptions$1<EventType, ReadEventMetadataWithGlobalPosition$1, PostgreSQLProcessorHandlerContext>)) => PostgreSQLEventStoreConsumer<EventType>;
|
|
290
260
|
|
|
291
261
|
interface PostgresEventStore extends EventStore<PostgresReadEventMetadata>, EventStoreSessionFactory<PostgresEventStore> {
|
|
292
262
|
appendToStream<EventType extends Event>(streamName: string, events: EventType[], options?: AppendToStreamOptions): Promise<AppendToStreamResultWithGlobalPosition>;
|
|
@@ -399,14 +369,14 @@ type ReadMessagesBatchOptions = {
|
|
|
399
369
|
from: bigint;
|
|
400
370
|
to: bigint;
|
|
401
371
|
};
|
|
402
|
-
type ReadMessagesBatchResult<
|
|
372
|
+
type ReadMessagesBatchResult<MessageType extends Message, MessageMetadataType extends RecordedMessageMetadata = RecordedMessageMetadata> = {
|
|
403
373
|
currentGlobalPosition: bigint;
|
|
404
|
-
messages:
|
|
405
|
-
|
|
374
|
+
messages: RecordedMessage<MessageType, MessageMetadataType>[];
|
|
375
|
+
areMessagesLeft: boolean;
|
|
406
376
|
};
|
|
407
|
-
declare const readMessagesBatch: <MessageType extends
|
|
377
|
+
declare const readMessagesBatch: <MessageType extends Message, RecordedMessageMetadataType extends RecordedMessageMetadataWithGlobalPosition = RecordedMessageMetadataWithGlobalPosition>(execute: SQLExecutor, options: ReadMessagesBatchOptions & {
|
|
408
378
|
partition?: string;
|
|
409
|
-
}) => Promise<ReadMessagesBatchResult<MessageType,
|
|
379
|
+
}) => Promise<ReadMessagesBatchResult<MessageType, RecordedMessageMetadataType>>;
|
|
410
380
|
|
|
411
381
|
type ReadProcessorCheckpointResult = {
|
|
412
382
|
lastProcessedPosition: bigint | null;
|
|
@@ -428,20 +398,13 @@ type StoreLastProcessedProcessorPositionResult<Position extends bigint | null =
|
|
|
428
398
|
success: false;
|
|
429
399
|
reason: 'IGNORED' | 'MISMATCH';
|
|
430
400
|
};
|
|
431
|
-
declare
|
|
432
|
-
processorId: string;
|
|
433
|
-
version: number | undefined;
|
|
434
|
-
newPosition: bigint | null;
|
|
435
|
-
lastProcessedPosition: bigint | null;
|
|
436
|
-
partition?: string;
|
|
437
|
-
}): Promise<StoreLastProcessedProcessorPositionResult<bigint | null>>;
|
|
438
|
-
declare function storeProcessorCheckpoint(execute: SQLExecutor, options: {
|
|
401
|
+
declare const storeProcessorCheckpoint: <Position extends bigint | null>(execute: SQLExecutor, options: {
|
|
439
402
|
processorId: string;
|
|
440
403
|
version: number | undefined;
|
|
441
|
-
newPosition: bigint;
|
|
404
|
+
newPosition: null extends Position ? bigint | null : bigint;
|
|
442
405
|
lastProcessedPosition: bigint | null;
|
|
443
406
|
partition?: string;
|
|
444
|
-
})
|
|
407
|
+
}) => Promise<StoreLastProcessedProcessorPositionResult<null extends Position ? bigint | null : bigint>>;
|
|
445
408
|
|
|
446
409
|
declare const streamsTableSQL: _event_driven_io_dumbo.SQL;
|
|
447
410
|
declare const messagesTableSQL: _event_driven_io_dumbo.SQL;
|
|
@@ -492,4 +455,4 @@ declare const subscriptionsTable: {
|
|
|
492
455
|
declare const schemaSQL: SQL[];
|
|
493
456
|
declare const createEventStoreSchema: (pool: NodePostgresPool) => Promise<void>;
|
|
494
457
|
|
|
495
|
-
export { type AppendToStreamBeforeCommitHook, DefaultPostgreSQLEventStoreProcessorBatchSize, DefaultPostgreSQLEventStoreProcessorPullingFrequencyInMs, type
|
|
458
|
+
export { type AppendToStreamBeforeCommitHook, DefaultPostgreSQLEventStoreProcessorBatchSize, DefaultPostgreSQLEventStoreProcessorPullingFrequencyInMs, type ExtendableContext, type PongoAssertOptions, type PongoDocumentEvolve, type PongoMultiStreamProjectionOptions, type PongoProjectionHandlerContext, type PongoProjectionOptions, type PongoSingleStreamProjectionOptions, type PongoWithNotNullDocumentEvolve, type PongoWithNullableDocumentEvolve, type PostgreSQLCheckpointer, type PostgreSQLConsumerContext, type PostgreSQLEventStoreConsumer, type PostgreSQLEventStoreConsumerConfig, type PostgreSQLEventStoreConsumerOptions, PostgreSQLEventStoreDefaultStreamVersion, type PostgreSQLEventStoreMessageBatchPuller, type PostgreSQLEventStoreMessageBatchPullerOptions, type PostgreSQLEventStoreMessageBatchPullerStartFrom, type PostgreSQLEventStoreMessageBatchPullerStartOptions, type PostgreSQLEventStoreMessagesBatchHandlerResult, type PostgreSQLProcessor, type PostgreSQLProcessorConnectionOptions, type PostgreSQLProcessorEachBatchHandler, type PostgreSQLProcessorEachMessageHandler, type PostgreSQLProcessorHandlerContext, type PostgreSQLProcessorOptions, type PostgreSQLProcessorStartFrom, type PostgreSQLProjectionAssert, type PostgreSQLProjectionDefinition, type PostgreSQLProjectionHandler, type PostgreSQLProjectionHandlerContext, type PostgreSQLProjectionHandlerOptions, PostgreSQLProjectionSpec, type PostgreSQLProjectionSpecEvent, type PostgreSQLProjectionSpecOptions, type PostgreSQLProjectionSpecWhenOptions, type PostgreSQLProjectorOptions, type PostgresEventStore, type PostgresEventStoreConnectionOptions, type PostgresEventStoreOptions, type PostgresReadEvent, type PostgresReadEventMetadata, type ReadLastMessageGlobalPositionResult, type ReadMessagesBatchOptions, type ReadMessagesBatchResult, type ReadProcessorCheckpointResult, type StoreLastProcessedProcessorPositionResult, addDefaultPartitionSQL, addModuleForAllTenantsSQL, addModuleSQL, addPartitionSQL, addTablePartitions, addTenantForAllModulesSQL, addTenantSQL, appendToStream, appendToStreamSQL, assertSQLQueryResultMatches, createEventStoreSchema, defaultPostgreSQLOptions, defaultTag, documentDoesNotExist, documentExists, documentMatchingExists, documentsAreTheSame, documentsMatchingHaveCount, emmettPrefix, eventInStream, eventsInStream, expectPongoDocuments, expectSQL, getPostgreSQLEventStore, globalNames, globalTag, handleProjections, messagesTable, messagesTableSQL, migrationFromEventsToMessagesSQL, newEventsInStream, pongoMultiStreamProjection, pongoProjection, pongoSingleStreamProjection, postgreSQLCheckpointer, postgreSQLEventStoreConsumer, postgreSQLEventStoreMessageBatchPuller, postgreSQLMessageProcessor, postgreSQLProjection, postgreSQLProjector, postgreSQLRawBatchSQLProjection, postgreSQLRawSQLProjection, postgreSQLReactor, readLastMessageGlobalPosition, readMessagesBatch, readProcessorCheckpoint, readStream, rebuildPostgreSQLProjections, sanitizeNameSQL, schemaSQL, storeProcessorCheckpoint, storeSubscriptionCheckpointSQL, streamsTable, streamsTableSQL, subscriptionsTable, subscriptionsTableSQL, zipPostgreSQLEventStoreMessageBatchPullerStartFrom };
|