@event-driven-io/emmett-postgresql 0.17.0 → 0.18.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.
Files changed (117) hide show
  1. package/dist/index.d.mts +308 -10
  2. package/dist/index.d.ts +308 -10
  3. package/dist/index.js +362 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +362 -1
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +8 -8
  8. package/dist/chunk-2452BJTJ.js +0 -1
  9. package/dist/chunk-2452BJTJ.js.map +0 -1
  10. package/dist/chunk-45ODDXOQ.mjs +0 -1
  11. package/dist/chunk-45ODDXOQ.mjs.map +0 -1
  12. package/dist/chunk-5NYGSL2B.js +0 -4
  13. package/dist/chunk-5NYGSL2B.js.map +0 -1
  14. package/dist/chunk-6Z7FIKB6.mjs +0 -4
  15. package/dist/chunk-6Z7FIKB6.mjs.map +0 -1
  16. package/dist/chunk-ABNBEUC6.mjs +0 -2
  17. package/dist/chunk-ABNBEUC6.mjs.map +0 -1
  18. package/dist/chunk-EEYVFO3G.js +0 -264
  19. package/dist/chunk-EEYVFO3G.js.map +0 -1
  20. package/dist/chunk-HFIQYR5E.js +0 -2
  21. package/dist/chunk-HFIQYR5E.js.map +0 -1
  22. package/dist/chunk-JPTXK5ZT.mjs +0 -2
  23. package/dist/chunk-JPTXK5ZT.mjs.map +0 -1
  24. package/dist/chunk-NZWWNOXH.mjs +0 -2
  25. package/dist/chunk-NZWWNOXH.mjs.map +0 -1
  26. package/dist/chunk-PT4NEEE4.mjs +0 -7
  27. package/dist/chunk-PT4NEEE4.mjs.map +0 -1
  28. package/dist/chunk-QB7BC56W.js +0 -7
  29. package/dist/chunk-QB7BC56W.js.map +0 -1
  30. package/dist/chunk-R5KGCWKQ.js +0 -94
  31. package/dist/chunk-R5KGCWKQ.js.map +0 -1
  32. package/dist/chunk-SIRCKLWA.mjs +0 -94
  33. package/dist/chunk-SIRCKLWA.mjs.map +0 -1
  34. package/dist/chunk-SS2LQM3B.js +0 -2
  35. package/dist/chunk-SS2LQM3B.js.map +0 -1
  36. package/dist/chunk-UMWNWQRR.js +0 -2
  37. package/dist/chunk-UMWNWQRR.js.map +0 -1
  38. package/dist/chunk-UWD6GOZC.mjs +0 -264
  39. package/dist/chunk-UWD6GOZC.mjs.map +0 -1
  40. package/dist/chunk-WDTQXX5U.js +0 -2
  41. package/dist/chunk-WDTQXX5U.js.map +0 -1
  42. package/dist/chunk-XQJRZ4PO.mjs +0 -2
  43. package/dist/chunk-XQJRZ4PO.mjs.map +0 -1
  44. package/dist/eventStore/index.d.mts +0 -10
  45. package/dist/eventStore/index.d.ts +0 -10
  46. package/dist/eventStore/index.js +0 -2
  47. package/dist/eventStore/index.js.map +0 -1
  48. package/dist/eventStore/index.mjs +0 -2
  49. package/dist/eventStore/index.mjs.map +0 -1
  50. package/dist/eventStore/postgreSQLEventStore.d.mts +0 -5
  51. package/dist/eventStore/postgreSQLEventStore.d.ts +0 -5
  52. package/dist/eventStore/postgreSQLEventStore.js +0 -2
  53. package/dist/eventStore/postgreSQLEventStore.js.map +0 -1
  54. package/dist/eventStore/postgreSQLEventStore.mjs +0 -2
  55. package/dist/eventStore/postgreSQLEventStore.mjs.map +0 -1
  56. package/dist/eventStore/projections/index.d.mts +0 -5
  57. package/dist/eventStore/projections/index.d.ts +0 -5
  58. package/dist/eventStore/projections/index.js +0 -2
  59. package/dist/eventStore/projections/index.js.map +0 -1
  60. package/dist/eventStore/projections/index.mjs +0 -2
  61. package/dist/eventStore/projections/index.mjs.map +0 -1
  62. package/dist/eventStore/projections/pongo/index.d.mts +0 -5
  63. package/dist/eventStore/projections/pongo/index.d.ts +0 -5
  64. package/dist/eventStore/projections/pongo/index.js +0 -2
  65. package/dist/eventStore/projections/pongo/index.js.map +0 -1
  66. package/dist/eventStore/projections/pongo/index.mjs +0 -2
  67. package/dist/eventStore/projections/pongo/index.mjs.map +0 -1
  68. package/dist/eventStore/projections/pongo/pongoProjectionSpec.d.mts +0 -5
  69. package/dist/eventStore/projections/pongo/pongoProjectionSpec.d.ts +0 -5
  70. package/dist/eventStore/projections/pongo/pongoProjectionSpec.js +0 -2
  71. package/dist/eventStore/projections/pongo/pongoProjectionSpec.js.map +0 -1
  72. package/dist/eventStore/projections/pongo/pongoProjectionSpec.mjs +0 -2
  73. package/dist/eventStore/projections/pongo/pongoProjectionSpec.mjs.map +0 -1
  74. package/dist/eventStore/projections/pongo/projections.d.mts +0 -5
  75. package/dist/eventStore/projections/pongo/projections.d.ts +0 -5
  76. package/dist/eventStore/projections/pongo/projections.js +0 -2
  77. package/dist/eventStore/projections/pongo/projections.js.map +0 -1
  78. package/dist/eventStore/projections/pongo/projections.mjs +0 -2
  79. package/dist/eventStore/projections/pongo/projections.mjs.map +0 -1
  80. package/dist/eventStore/projections/postgresProjectionSpec.d.mts +0 -5
  81. package/dist/eventStore/projections/postgresProjectionSpec.d.ts +0 -5
  82. package/dist/eventStore/projections/postgresProjectionSpec.js +0 -2
  83. package/dist/eventStore/projections/postgresProjectionSpec.js.map +0 -1
  84. package/dist/eventStore/projections/postgresProjectionSpec.mjs +0 -2
  85. package/dist/eventStore/projections/postgresProjectionSpec.mjs.map +0 -1
  86. package/dist/eventStore/schema/appendToStream.d.mts +0 -21
  87. package/dist/eventStore/schema/appendToStream.d.ts +0 -21
  88. package/dist/eventStore/schema/appendToStream.js +0 -2
  89. package/dist/eventStore/schema/appendToStream.js.map +0 -1
  90. package/dist/eventStore/schema/appendToStream.mjs +0 -2
  91. package/dist/eventStore/schema/appendToStream.mjs.map +0 -1
  92. package/dist/eventStore/schema/index.d.mts +0 -12
  93. package/dist/eventStore/schema/index.d.ts +0 -12
  94. package/dist/eventStore/schema/index.js +0 -2
  95. package/dist/eventStore/schema/index.js.map +0 -1
  96. package/dist/eventStore/schema/index.mjs +0 -2
  97. package/dist/eventStore/schema/index.mjs.map +0 -1
  98. package/dist/eventStore/schema/readStream.d.mts +0 -8
  99. package/dist/eventStore/schema/readStream.d.ts +0 -8
  100. package/dist/eventStore/schema/readStream.js +0 -2
  101. package/dist/eventStore/schema/readStream.js.map +0 -1
  102. package/dist/eventStore/schema/readStream.mjs +0 -2
  103. package/dist/eventStore/schema/readStream.mjs.map +0 -1
  104. package/dist/eventStore/schema/tables.d.mts +0 -15
  105. package/dist/eventStore/schema/tables.d.ts +0 -15
  106. package/dist/eventStore/schema/tables.js +0 -2
  107. package/dist/eventStore/schema/tables.js.map +0 -1
  108. package/dist/eventStore/schema/tables.mjs +0 -2
  109. package/dist/eventStore/schema/tables.mjs.map +0 -1
  110. package/dist/eventStore/schema/typing.d.mts +0 -31
  111. package/dist/eventStore/schema/typing.d.ts +0 -31
  112. package/dist/eventStore/schema/typing.js +0 -2
  113. package/dist/eventStore/schema/typing.js.map +0 -1
  114. package/dist/eventStore/schema/typing.mjs +0 -2
  115. package/dist/eventStore/schema/typing.mjs.map +0 -1
  116. package/dist/postgreSQLEventStore-BDzOzx7q.d.mts +0 -268
  117. package/dist/postgreSQLEventStore-BDzOzx7q.d.ts +0 -268
package/dist/index.d.mts CHANGED
@@ -1,10 +1,308 @@
1
- export { l as PongoAssertOptions, w as PongoDocumentEvolve, z as PongoMultiStreamProjectionOptions, t as PongoProjectionHandlerContext, x as PongoProjectionOptions, B as PongoSingleStreamProjectionOptions, u as PongoWithNotNullDocumentEvolve, v as PongoWithNullableDocumentEvolve, G as PostgreSQLProjectionAssert, e as PostgreSQLProjectionDefinition, d as PostgreSQLProjectionHandler, c as PostgreSQLProjectionHandlerContext, F as PostgreSQLProjectionSpec, D as PostgreSQLProjectionSpecEvent, H as PostgreSQLProjectionSpecOptions, E as PostgreSQLProjectionSpecWhenOptions, P as PostgresEventStore, a as PostgresEventStoreConnectionOptions, b as PostgresEventStoreOptions, h as ProjectionHandlerOptions, L as assertSQLQueryResultMatches, f as defaultPostgreSQLProjectionOptions, r as documentDoesNotExist, m as documentExists, q as documentMatchingExists, n as documentsAreTheSame, o as documentsMatchingHaveCount, I as eventInStream, J as eventsInStream, s as expectPongoDocuments, M as expectSQL, g as getPostgreSQLEventStore, i as handleProjections, K as newEventsInStream, A as pongoMultiStreamProjection, y as pongoProjection, C as pongoSingleStreamProjection, p as postgreSQLProjection, j as postgreSQLRawBatchSQLProjection, k as postgreSQLRawSQLProjection } from './postgreSQLEventStore-BDzOzx7q.mjs';
2
- export { createEventStoreSchema, schemaSQL } from './eventStore/schema/index.mjs';
3
- export { appendEventsSQL, appendToStream } from './eventStore/schema/appendToStream.mjs';
4
- export { readStream } from './eventStore/schema/readStream.mjs';
5
- export { addDefaultPartition, addEventsPartitions, addModuleForAllTenantsSQL, addModuleSQL, addTablePartitions, addTenantForAllModulesSQL, addTenantSQL, eventsTableSQL, sanitizeNameSQL, streamsTableSQL, subscriptionsTableSQL } from './eventStore/schema/tables.mjs';
6
- export { defaultTag, emmettPrefix, eventsTable, globalNames, globalTag, streamsTable } from './eventStore/schema/typing.mjs';
7
- import '@event-driven-io/dumbo';
8
- import '@event-driven-io/emmett';
9
- import 'pg';
10
- import '@event-driven-io/pongo';
1
+ import * as _event_driven_io_dumbo from '@event-driven-io/dumbo';
2
+ import { Dumbo, DumboOptions, QueryResultRow, SQL, NodePostgresClient, SQLExecutor, NodePostgresTransaction, NodePostgresConnector, NodePostgresPoolClientConnection, NodePostgresClientConnection, NodePostgresPool } from '@event-driven-io/dumbo';
3
+ import { Event, EventMetaDataOf, ReadEventMetadataWithGlobalPosition, ReadEvent, CanHandle, ThenThrows, ReadEventMetadata, ProjectionHandler, TypedProjectionDefinition, EventStore, DefaultStreamVersionType, EventStoreSessionFactory, ProjectionRegistration, AppendToStreamOptions, ReadStreamOptions, ReadStreamResult } from '@event-driven-io/emmett';
4
+ import pg from 'pg';
5
+ import { PongoDocument, WithId, PongoFilter, PongoClient } from '@event-driven-io/pongo';
6
+
7
+ type PongoAssertOptions = {
8
+ inCollection: string;
9
+ inDatabase?: string;
10
+ };
11
+ type FilterOrId<Doc extends PongoDocument | WithId<PongoDocument>> = {
12
+ withId: string;
13
+ } | {
14
+ matchingFilter: PongoFilter<Doc>;
15
+ };
16
+ declare const documentExists: <Doc extends PongoDocument | WithId<PongoDocument>>(document: Doc, options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
17
+ declare const documentsAreTheSame: <Doc extends PongoDocument | WithId<PongoDocument>>(documents: Doc[], options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
18
+ declare const documentsMatchingHaveCount: <Doc extends PongoDocument | WithId<PongoDocument>>(expectedCount: number, options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
19
+ declare const documentMatchingExists: <Doc extends PongoDocument | WithId<PongoDocument>>(options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
20
+ declare const documentDoesNotExist: <Doc extends PongoDocument | WithId<PongoDocument>>(options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
21
+ declare const expectPongoDocuments: {
22
+ fromCollection: <Doc extends PongoDocument | WithId<PongoDocument>>(collectionName: string) => {
23
+ withId: (id: string) => {
24
+ toBeEqual: (document: Doc) => PostgreSQLProjectionAssert;
25
+ toExist: () => PostgreSQLProjectionAssert;
26
+ notToExist: () => PostgreSQLProjectionAssert;
27
+ };
28
+ matching: <Doc_1 extends PongoDocument | WithId<PongoDocument>>(filter: PongoFilter<Doc_1>) => {
29
+ toBeTheSame: (documents: Doc_1[]) => PostgreSQLProjectionAssert;
30
+ toHaveCount: (expectedCount: number) => PostgreSQLProjectionAssert;
31
+ toExist: () => PostgreSQLProjectionAssert;
32
+ notToExist: () => PostgreSQLProjectionAssert;
33
+ };
34
+ };
35
+ };
36
+
37
+ type PongoProjectionHandlerContext = PostgreSQLProjectionHandlerContext & {
38
+ pongo: PongoClient;
39
+ };
40
+ type PongoWithNotNullDocumentEvolve<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition> = ((document: Document, event: ReadEvent<EventType, EventMetaDataType>) => Document | null) | ((document: Document, event: ReadEvent<EventType>) => Promise<Document | null>);
41
+ type PongoWithNullableDocumentEvolve<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition> = ((document: Document | null, event: ReadEvent<EventType, EventMetaDataType>) => Document | null) | ((document: Document | null, event: ReadEvent<EventType>) => Promise<Document | null>);
42
+ type PongoDocumentEvolve<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition> = PongoWithNotNullDocumentEvolve<Document, EventType, EventMetaDataType> | PongoWithNullableDocumentEvolve<Document, EventType, EventMetaDataType>;
43
+ type PongoProjectionOptions<EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition> = {
44
+ handle: (events: ReadEvent<EventType, EventMetaDataType>[], context: PongoProjectionHandlerContext) => Promise<void>;
45
+ canHandle: CanHandle<EventType>;
46
+ };
47
+ declare const pongoProjection: <EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & Readonly<{
48
+ eventId: string;
49
+ streamPosition: bigint;
50
+ streamName: string;
51
+ }> & {
52
+ globalPosition: bigint;
53
+ }>({ handle, canHandle, }: PongoProjectionOptions<EventType, EventMetaDataType>) => PostgreSQLProjectionDefinition;
54
+ type PongoMultiStreamProjectionOptions<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition> = {
55
+ canHandle: CanHandle<EventType>;
56
+ collectionName: string;
57
+ getDocumentId: (event: ReadEvent<EventType>) => string;
58
+ } & ({
59
+ evolve: PongoWithNullableDocumentEvolve<Document, EventType, EventMetaDataType>;
60
+ } | {
61
+ evolve: PongoWithNotNullDocumentEvolve<Document, EventType, EventMetaDataType>;
62
+ initialState: () => Document;
63
+ });
64
+ declare const pongoMultiStreamProjection: <Document extends PongoDocument, EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & Readonly<{
65
+ eventId: string;
66
+ streamPosition: bigint;
67
+ streamName: string;
68
+ }> & {
69
+ globalPosition: bigint;
70
+ }>(options: PongoMultiStreamProjectionOptions<Document, EventType, EventMetaDataType>) => PostgreSQLProjectionDefinition;
71
+ type PongoSingleStreamProjectionOptions<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition> = {
72
+ canHandle: CanHandle<EventType>;
73
+ collectionName: string;
74
+ } & ({
75
+ evolve: PongoWithNullableDocumentEvolve<Document, EventType, EventMetaDataType>;
76
+ } | {
77
+ evolve: PongoWithNotNullDocumentEvolve<Document, EventType, EventMetaDataType>;
78
+ initialState: () => Document;
79
+ });
80
+ declare const pongoSingleStreamProjection: <Document extends PongoDocument, EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & Readonly<{
81
+ eventId: string;
82
+ streamPosition: bigint;
83
+ streamName: string;
84
+ }> & {
85
+ globalPosition: bigint;
86
+ }>(options: PongoSingleStreamProjectionOptions<Document, EventType, EventMetaDataType>) => PostgreSQLProjectionDefinition;
87
+
88
+ type PostgreSQLProjectionSpecEvent<EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition> = EventType & {
89
+ metadata?: Partial<EventMetaDataType>;
90
+ };
91
+ type PostgreSQLProjectionSpecWhenOptions = {
92
+ numberOfTimes: number;
93
+ };
94
+ type PostgreSQLProjectionAssert = (options: {
95
+ pool: Dumbo;
96
+ connectionString: string;
97
+ }) => Promise<void | boolean>;
98
+ type PostgreSQLProjectionSpecOptions = {
99
+ projection: PostgreSQLProjectionDefinition;
100
+ } & DumboOptions;
101
+ type PostgreSQLProjectionSpec<EventType extends Event> = (givenEvents: PostgreSQLProjectionSpecEvent<EventType>[]) => {
102
+ when: (events: PostgreSQLProjectionSpecEvent<EventType>[], options?: PostgreSQLProjectionSpecWhenOptions) => {
103
+ then: (assert: PostgreSQLProjectionAssert, message?: string) => Promise<void>;
104
+ thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => Promise<void>;
105
+ };
106
+ };
107
+ declare const PostgreSQLProjectionSpec: {
108
+ for: <EventType extends Event>(options: PostgreSQLProjectionSpecOptions) => PostgreSQLProjectionSpec<EventType>;
109
+ };
110
+ declare const eventInStream: <EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & Readonly<{
111
+ eventId: string;
112
+ streamPosition: bigint;
113
+ streamName: string;
114
+ }> & {
115
+ globalPosition: bigint;
116
+ }>(streamName: string, event: PostgreSQLProjectionSpecEvent<EventType, EventMetaDataType>) => PostgreSQLProjectionSpecEvent<EventType, EventMetaDataType>;
117
+ declare const eventsInStream: <EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & Readonly<{
118
+ eventId: string;
119
+ streamPosition: bigint;
120
+ streamName: string;
121
+ }> & {
122
+ globalPosition: bigint;
123
+ }>(streamName: string, events: PostgreSQLProjectionSpecEvent<EventType, EventMetaDataType>[]) => PostgreSQLProjectionSpecEvent<EventType, EventMetaDataType>[];
124
+ declare const newEventsInStream: <EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & Readonly<{
125
+ eventId: string;
126
+ streamPosition: bigint;
127
+ streamName: string;
128
+ }> & {
129
+ globalPosition: bigint;
130
+ }>(streamName: string, events: PostgreSQLProjectionSpecEvent<EventType, EventMetaDataType>[]) => PostgreSQLProjectionSpecEvent<EventType, EventMetaDataType>[];
131
+ declare const assertSQLQueryResultMatches: <T extends QueryResultRow>(sql: SQL, rows: T[]) => PostgreSQLProjectionAssert;
132
+ declare const expectSQL: {
133
+ query: (sql: SQL) => {
134
+ resultRows: {
135
+ toBeTheSame: <T extends QueryResultRow>(rows: T[]) => PostgreSQLProjectionAssert;
136
+ };
137
+ };
138
+ };
139
+
140
+ type PostgreSQLProjectionHandlerContext = {
141
+ connectionString: string;
142
+ client: NodePostgresClient;
143
+ execute: SQLExecutor;
144
+ transaction: NodePostgresTransaction;
145
+ };
146
+ type PostgreSQLProjectionHandler<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & ReadEventMetadata> = ProjectionHandler<EventType, EventMetaDataType, PostgreSQLProjectionHandlerContext>;
147
+ type PostgreSQLProjectionDefinition<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & ReadEventMetadata> = TypedProjectionDefinition<EventType, EventMetaDataType, PostgreSQLProjectionHandlerContext>;
148
+ type ProjectionHandlerOptions<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & ReadEventMetadata> = {
149
+ events: ReadEvent<EventType, EventMetaDataType>[];
150
+ projections: PostgreSQLProjectionDefinition<EventType>[];
151
+ connection: {
152
+ connectionString: string;
153
+ transaction: NodePostgresTransaction;
154
+ };
155
+ };
156
+ declare const handleProjections: <EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & Readonly<{
157
+ eventId: string;
158
+ streamPosition: bigint;
159
+ streamName: string;
160
+ }>>(options: ProjectionHandlerOptions<EventType, EventMetaDataType>) => Promise<void>;
161
+ declare const postgreSQLProjection: <EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & Readonly<{
162
+ eventId: string;
163
+ streamPosition: bigint;
164
+ streamName: string;
165
+ }>>(definition: PostgreSQLProjectionDefinition<EventType>) => PostgreSQLProjectionDefinition;
166
+ declare const postgreSQLRawBatchSQLProjection: <EventType extends Event>(handle: (events: EventType[], context: PostgreSQLProjectionHandlerContext) => Promise<SQL[]> | SQL[], ...canHandle: CanHandle<EventType>) => PostgreSQLProjectionDefinition;
167
+ declare const postgreSQLRawSQLProjection: <EventType extends Event>(handle: (event: EventType, context: PostgreSQLProjectionHandlerContext) => Promise<SQL> | SQL, ...canHandle: CanHandle<EventType>) => PostgreSQLProjectionDefinition;
168
+
169
+ interface PostgresEventStore extends EventStore<DefaultStreamVersionType, ReadEventMetadataWithGlobalPosition>, EventStoreSessionFactory<PostgresEventStore, DefaultStreamVersionType> {
170
+ close(): Promise<void>;
171
+ schema: {
172
+ sql(): string;
173
+ print(): void;
174
+ migrate(): Promise<void>;
175
+ };
176
+ }
177
+ type PostgresEventStorePooledOptions = {
178
+ connector?: NodePostgresConnector;
179
+ connectionString?: string;
180
+ database?: string;
181
+ pooled: true;
182
+ pool: pg.Pool;
183
+ } | {
184
+ connector?: NodePostgresConnector;
185
+ connectionString?: string;
186
+ database?: string;
187
+ pool: pg.Pool;
188
+ } | {
189
+ connector?: NodePostgresConnector;
190
+ connectionString?: string;
191
+ database?: string;
192
+ pooled: true;
193
+ } | {
194
+ connector?: NodePostgresConnector;
195
+ connectionString?: string;
196
+ database?: string;
197
+ };
198
+ type PostgresEventStoreNotPooledOptions = {
199
+ connector?: NodePostgresConnector;
200
+ connectionString?: string;
201
+ database?: string;
202
+ pooled: false;
203
+ client: pg.Client;
204
+ } | {
205
+ connector?: NodePostgresConnector;
206
+ connectionString?: string;
207
+ database?: string;
208
+ client: pg.Client;
209
+ } | {
210
+ connector?: NodePostgresConnector;
211
+ connectionString?: string;
212
+ database?: string;
213
+ pooled: false;
214
+ } | {
215
+ connector?: NodePostgresConnector;
216
+ connectionString?: string;
217
+ database?: string;
218
+ connection: NodePostgresPoolClientConnection | NodePostgresClientConnection;
219
+ pooled?: false;
220
+ } | {
221
+ connector?: NodePostgresConnector;
222
+ connectionString?: string;
223
+ database?: string;
224
+ dumbo: NodePostgresPool;
225
+ pooled?: false;
226
+ };
227
+ declare enum SchemaMigration {
228
+ None = "None",
229
+ CreateOrUpdate = "CreateOrUpdate"
230
+ }
231
+ type PostgresEventStoreConnectionOptions = PostgresEventStorePooledOptions | PostgresEventStoreNotPooledOptions;
232
+ type PostgresEventStoreOptions = {
233
+ projections?: ProjectionRegistration<'inline', PostgreSQLProjectionHandlerContext>[];
234
+ schema?: {
235
+ autoMigration?: SchemaMigration;
236
+ };
237
+ connectionOptions?: PostgresEventStoreConnectionOptions;
238
+ };
239
+ declare const defaultPostgreSQLOptions: PostgresEventStoreOptions;
240
+ declare const getPostgreSQLEventStore: (connectionString: string, options?: PostgresEventStoreOptions) => PostgresEventStore;
241
+
242
+ declare const appendEventsSQL: _event_driven_io_dumbo.SQL;
243
+ type AppendEventResult = {
244
+ success: true;
245
+ nextStreamPosition: bigint;
246
+ lastGlobalPosition: bigint;
247
+ transactionId: string;
248
+ } | {
249
+ success: false;
250
+ };
251
+ type AppendToStreamPreCommitHook = (events: ReadEvent[], context: {
252
+ transaction: NodePostgresTransaction;
253
+ }) => Promise<void>;
254
+ declare const appendToStream: (pool: NodePostgresPool, streamName: string, streamType: string, events: Event[], options?: AppendToStreamOptions & {
255
+ partition?: string;
256
+ preCommitHook?: AppendToStreamPreCommitHook;
257
+ }) => Promise<AppendEventResult>;
258
+
259
+ declare const readStream: <EventType extends Event>(execute: SQLExecutor, streamId: string, options?: ReadStreamOptions & {
260
+ partition?: string;
261
+ }) => Promise<ReadStreamResult<EventType, DefaultStreamVersionType, ReadEventMetadataWithGlobalPosition>>;
262
+
263
+ declare const streamsTableSQL: _event_driven_io_dumbo.SQL;
264
+ declare const eventsTableSQL: _event_driven_io_dumbo.SQL;
265
+ declare const subscriptionsTableSQL: _event_driven_io_dumbo.SQL;
266
+ declare const sanitizeNameSQL: _event_driven_io_dumbo.SQL;
267
+ declare const addTablePartitions: _event_driven_io_dumbo.SQL;
268
+ declare const addEventsPartitions: _event_driven_io_dumbo.SQL;
269
+ declare const addModuleSQL: _event_driven_io_dumbo.SQL;
270
+ declare const addTenantSQL: _event_driven_io_dumbo.SQL;
271
+ declare const addModuleForAllTenantsSQL: _event_driven_io_dumbo.SQL;
272
+ declare const addTenantForAllModulesSQL: _event_driven_io_dumbo.SQL;
273
+ declare const addDefaultPartition: _event_driven_io_dumbo.SQL;
274
+
275
+ declare const emmettPrefix = "emt";
276
+ declare const globalTag = "global";
277
+ declare const defaultTag = "emt:default";
278
+ declare const globalNames: {
279
+ module: string;
280
+ tenant: string;
281
+ };
282
+ declare const streamsTable: {
283
+ name: string;
284
+ columns: {
285
+ partition: {
286
+ name: string;
287
+ };
288
+ isArchived: {
289
+ name: string;
290
+ };
291
+ };
292
+ };
293
+ declare const eventsTable: {
294
+ name: string;
295
+ columns: {
296
+ partition: {
297
+ name: string;
298
+ };
299
+ isArchived: {
300
+ name: string;
301
+ };
302
+ };
303
+ };
304
+
305
+ declare const schemaSQL: SQL[];
306
+ declare const createEventStoreSchema: (pool: NodePostgresPool) => Promise<void>;
307
+
308
+ export { type AppendToStreamPreCommitHook, type PongoAssertOptions, type PongoDocumentEvolve, type PongoMultiStreamProjectionOptions, type PongoProjectionHandlerContext, type PongoProjectionOptions, type PongoSingleStreamProjectionOptions, type PongoWithNotNullDocumentEvolve, type PongoWithNullableDocumentEvolve, type PostgreSQLProjectionAssert, type PostgreSQLProjectionDefinition, type PostgreSQLProjectionHandler, type PostgreSQLProjectionHandlerContext, PostgreSQLProjectionSpec, type PostgreSQLProjectionSpecEvent, type PostgreSQLProjectionSpecOptions, type PostgreSQLProjectionSpecWhenOptions, type PostgresEventStore, type PostgresEventStoreConnectionOptions, type PostgresEventStoreOptions, type ProjectionHandlerOptions, SchemaMigration, addDefaultPartition, addEventsPartitions, addModuleForAllTenantsSQL, addModuleSQL, addTablePartitions, addTenantForAllModulesSQL, addTenantSQL, appendEventsSQL, appendToStream, assertSQLQueryResultMatches, createEventStoreSchema, defaultPostgreSQLOptions, defaultTag, documentDoesNotExist, documentExists, documentMatchingExists, documentsAreTheSame, documentsMatchingHaveCount, emmettPrefix, eventInStream, eventsInStream, eventsTable, eventsTableSQL, expectPongoDocuments, expectSQL, getPostgreSQLEventStore, globalNames, globalTag, handleProjections, newEventsInStream, pongoMultiStreamProjection, pongoProjection, pongoSingleStreamProjection, postgreSQLProjection, postgreSQLRawBatchSQLProjection, postgreSQLRawSQLProjection, readStream, sanitizeNameSQL, schemaSQL, streamsTable, streamsTableSQL, subscriptionsTableSQL };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,308 @@
1
- export { l as PongoAssertOptions, w as PongoDocumentEvolve, z as PongoMultiStreamProjectionOptions, t as PongoProjectionHandlerContext, x as PongoProjectionOptions, B as PongoSingleStreamProjectionOptions, u as PongoWithNotNullDocumentEvolve, v as PongoWithNullableDocumentEvolve, G as PostgreSQLProjectionAssert, e as PostgreSQLProjectionDefinition, d as PostgreSQLProjectionHandler, c as PostgreSQLProjectionHandlerContext, F as PostgreSQLProjectionSpec, D as PostgreSQLProjectionSpecEvent, H as PostgreSQLProjectionSpecOptions, E as PostgreSQLProjectionSpecWhenOptions, P as PostgresEventStore, a as PostgresEventStoreConnectionOptions, b as PostgresEventStoreOptions, h as ProjectionHandlerOptions, L as assertSQLQueryResultMatches, f as defaultPostgreSQLProjectionOptions, r as documentDoesNotExist, m as documentExists, q as documentMatchingExists, n as documentsAreTheSame, o as documentsMatchingHaveCount, I as eventInStream, J as eventsInStream, s as expectPongoDocuments, M as expectSQL, g as getPostgreSQLEventStore, i as handleProjections, K as newEventsInStream, A as pongoMultiStreamProjection, y as pongoProjection, C as pongoSingleStreamProjection, p as postgreSQLProjection, j as postgreSQLRawBatchSQLProjection, k as postgreSQLRawSQLProjection } from './postgreSQLEventStore-BDzOzx7q.js';
2
- export { createEventStoreSchema, schemaSQL } from './eventStore/schema/index.js';
3
- export { appendEventsSQL, appendToStream } from './eventStore/schema/appendToStream.js';
4
- export { readStream } from './eventStore/schema/readStream.js';
5
- export { addDefaultPartition, addEventsPartitions, addModuleForAllTenantsSQL, addModuleSQL, addTablePartitions, addTenantForAllModulesSQL, addTenantSQL, eventsTableSQL, sanitizeNameSQL, streamsTableSQL, subscriptionsTableSQL } from './eventStore/schema/tables.js';
6
- export { defaultTag, emmettPrefix, eventsTable, globalNames, globalTag, streamsTable } from './eventStore/schema/typing.js';
7
- import '@event-driven-io/dumbo';
8
- import '@event-driven-io/emmett';
9
- import 'pg';
10
- import '@event-driven-io/pongo';
1
+ import * as _event_driven_io_dumbo from '@event-driven-io/dumbo';
2
+ import { Dumbo, DumboOptions, QueryResultRow, SQL, NodePostgresClient, SQLExecutor, NodePostgresTransaction, NodePostgresConnector, NodePostgresPoolClientConnection, NodePostgresClientConnection, NodePostgresPool } from '@event-driven-io/dumbo';
3
+ import { Event, EventMetaDataOf, ReadEventMetadataWithGlobalPosition, ReadEvent, CanHandle, ThenThrows, ReadEventMetadata, ProjectionHandler, TypedProjectionDefinition, EventStore, DefaultStreamVersionType, EventStoreSessionFactory, ProjectionRegistration, AppendToStreamOptions, ReadStreamOptions, ReadStreamResult } from '@event-driven-io/emmett';
4
+ import pg from 'pg';
5
+ import { PongoDocument, WithId, PongoFilter, PongoClient } from '@event-driven-io/pongo';
6
+
7
+ type PongoAssertOptions = {
8
+ inCollection: string;
9
+ inDatabase?: string;
10
+ };
11
+ type FilterOrId<Doc extends PongoDocument | WithId<PongoDocument>> = {
12
+ withId: string;
13
+ } | {
14
+ matchingFilter: PongoFilter<Doc>;
15
+ };
16
+ declare const documentExists: <Doc extends PongoDocument | WithId<PongoDocument>>(document: Doc, options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
17
+ declare const documentsAreTheSame: <Doc extends PongoDocument | WithId<PongoDocument>>(documents: Doc[], options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
18
+ declare const documentsMatchingHaveCount: <Doc extends PongoDocument | WithId<PongoDocument>>(expectedCount: number, options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
19
+ declare const documentMatchingExists: <Doc extends PongoDocument | WithId<PongoDocument>>(options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
20
+ declare const documentDoesNotExist: <Doc extends PongoDocument | WithId<PongoDocument>>(options: PongoAssertOptions & FilterOrId<Doc>) => PostgreSQLProjectionAssert;
21
+ declare const expectPongoDocuments: {
22
+ fromCollection: <Doc extends PongoDocument | WithId<PongoDocument>>(collectionName: string) => {
23
+ withId: (id: string) => {
24
+ toBeEqual: (document: Doc) => PostgreSQLProjectionAssert;
25
+ toExist: () => PostgreSQLProjectionAssert;
26
+ notToExist: () => PostgreSQLProjectionAssert;
27
+ };
28
+ matching: <Doc_1 extends PongoDocument | WithId<PongoDocument>>(filter: PongoFilter<Doc_1>) => {
29
+ toBeTheSame: (documents: Doc_1[]) => PostgreSQLProjectionAssert;
30
+ toHaveCount: (expectedCount: number) => PostgreSQLProjectionAssert;
31
+ toExist: () => PostgreSQLProjectionAssert;
32
+ notToExist: () => PostgreSQLProjectionAssert;
33
+ };
34
+ };
35
+ };
36
+
37
+ type PongoProjectionHandlerContext = PostgreSQLProjectionHandlerContext & {
38
+ pongo: PongoClient;
39
+ };
40
+ type PongoWithNotNullDocumentEvolve<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition> = ((document: Document, event: ReadEvent<EventType, EventMetaDataType>) => Document | null) | ((document: Document, event: ReadEvent<EventType>) => Promise<Document | null>);
41
+ type PongoWithNullableDocumentEvolve<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition> = ((document: Document | null, event: ReadEvent<EventType, EventMetaDataType>) => Document | null) | ((document: Document | null, event: ReadEvent<EventType>) => Promise<Document | null>);
42
+ type PongoDocumentEvolve<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition> = PongoWithNotNullDocumentEvolve<Document, EventType, EventMetaDataType> | PongoWithNullableDocumentEvolve<Document, EventType, EventMetaDataType>;
43
+ type PongoProjectionOptions<EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition> = {
44
+ handle: (events: ReadEvent<EventType, EventMetaDataType>[], context: PongoProjectionHandlerContext) => Promise<void>;
45
+ canHandle: CanHandle<EventType>;
46
+ };
47
+ declare const pongoProjection: <EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & Readonly<{
48
+ eventId: string;
49
+ streamPosition: bigint;
50
+ streamName: string;
51
+ }> & {
52
+ globalPosition: bigint;
53
+ }>({ handle, canHandle, }: PongoProjectionOptions<EventType, EventMetaDataType>) => PostgreSQLProjectionDefinition;
54
+ type PongoMultiStreamProjectionOptions<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition> = {
55
+ canHandle: CanHandle<EventType>;
56
+ collectionName: string;
57
+ getDocumentId: (event: ReadEvent<EventType>) => string;
58
+ } & ({
59
+ evolve: PongoWithNullableDocumentEvolve<Document, EventType, EventMetaDataType>;
60
+ } | {
61
+ evolve: PongoWithNotNullDocumentEvolve<Document, EventType, EventMetaDataType>;
62
+ initialState: () => Document;
63
+ });
64
+ declare const pongoMultiStreamProjection: <Document extends PongoDocument, EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & Readonly<{
65
+ eventId: string;
66
+ streamPosition: bigint;
67
+ streamName: string;
68
+ }> & {
69
+ globalPosition: bigint;
70
+ }>(options: PongoMultiStreamProjectionOptions<Document, EventType, EventMetaDataType>) => PostgreSQLProjectionDefinition;
71
+ type PongoSingleStreamProjectionOptions<Document extends PongoDocument, EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition> = {
72
+ canHandle: CanHandle<EventType>;
73
+ collectionName: string;
74
+ } & ({
75
+ evolve: PongoWithNullableDocumentEvolve<Document, EventType, EventMetaDataType>;
76
+ } | {
77
+ evolve: PongoWithNotNullDocumentEvolve<Document, EventType, EventMetaDataType>;
78
+ initialState: () => Document;
79
+ });
80
+ declare const pongoSingleStreamProjection: <Document extends PongoDocument, EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & Readonly<{
81
+ eventId: string;
82
+ streamPosition: bigint;
83
+ streamName: string;
84
+ }> & {
85
+ globalPosition: bigint;
86
+ }>(options: PongoSingleStreamProjectionOptions<Document, EventType, EventMetaDataType>) => PostgreSQLProjectionDefinition;
87
+
88
+ type PostgreSQLProjectionSpecEvent<EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition> = EventType & {
89
+ metadata?: Partial<EventMetaDataType>;
90
+ };
91
+ type PostgreSQLProjectionSpecWhenOptions = {
92
+ numberOfTimes: number;
93
+ };
94
+ type PostgreSQLProjectionAssert = (options: {
95
+ pool: Dumbo;
96
+ connectionString: string;
97
+ }) => Promise<void | boolean>;
98
+ type PostgreSQLProjectionSpecOptions = {
99
+ projection: PostgreSQLProjectionDefinition;
100
+ } & DumboOptions;
101
+ type PostgreSQLProjectionSpec<EventType extends Event> = (givenEvents: PostgreSQLProjectionSpecEvent<EventType>[]) => {
102
+ when: (events: PostgreSQLProjectionSpecEvent<EventType>[], options?: PostgreSQLProjectionSpecWhenOptions) => {
103
+ then: (assert: PostgreSQLProjectionAssert, message?: string) => Promise<void>;
104
+ thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => Promise<void>;
105
+ };
106
+ };
107
+ declare const PostgreSQLProjectionSpec: {
108
+ for: <EventType extends Event>(options: PostgreSQLProjectionSpecOptions) => PostgreSQLProjectionSpec<EventType>;
109
+ };
110
+ declare const eventInStream: <EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & Readonly<{
111
+ eventId: string;
112
+ streamPosition: bigint;
113
+ streamName: string;
114
+ }> & {
115
+ globalPosition: bigint;
116
+ }>(streamName: string, event: PostgreSQLProjectionSpecEvent<EventType, EventMetaDataType>) => PostgreSQLProjectionSpecEvent<EventType, EventMetaDataType>;
117
+ declare const eventsInStream: <EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & Readonly<{
118
+ eventId: string;
119
+ streamPosition: bigint;
120
+ streamName: string;
121
+ }> & {
122
+ globalPosition: bigint;
123
+ }>(streamName: string, events: PostgreSQLProjectionSpecEvent<EventType, EventMetaDataType>[]) => PostgreSQLProjectionSpecEvent<EventType, EventMetaDataType>[];
124
+ declare const newEventsInStream: <EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadataWithGlobalPosition = EventMetaDataOf<EventType> & Readonly<{
125
+ eventId: string;
126
+ streamPosition: bigint;
127
+ streamName: string;
128
+ }> & {
129
+ globalPosition: bigint;
130
+ }>(streamName: string, events: PostgreSQLProjectionSpecEvent<EventType, EventMetaDataType>[]) => PostgreSQLProjectionSpecEvent<EventType, EventMetaDataType>[];
131
+ declare const assertSQLQueryResultMatches: <T extends QueryResultRow>(sql: SQL, rows: T[]) => PostgreSQLProjectionAssert;
132
+ declare const expectSQL: {
133
+ query: (sql: SQL) => {
134
+ resultRows: {
135
+ toBeTheSame: <T extends QueryResultRow>(rows: T[]) => PostgreSQLProjectionAssert;
136
+ };
137
+ };
138
+ };
139
+
140
+ type PostgreSQLProjectionHandlerContext = {
141
+ connectionString: string;
142
+ client: NodePostgresClient;
143
+ execute: SQLExecutor;
144
+ transaction: NodePostgresTransaction;
145
+ };
146
+ type PostgreSQLProjectionHandler<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & ReadEventMetadata> = ProjectionHandler<EventType, EventMetaDataType, PostgreSQLProjectionHandlerContext>;
147
+ type PostgreSQLProjectionDefinition<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & ReadEventMetadata> = TypedProjectionDefinition<EventType, EventMetaDataType, PostgreSQLProjectionHandlerContext>;
148
+ type ProjectionHandlerOptions<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & ReadEventMetadata> = {
149
+ events: ReadEvent<EventType, EventMetaDataType>[];
150
+ projections: PostgreSQLProjectionDefinition<EventType>[];
151
+ connection: {
152
+ connectionString: string;
153
+ transaction: NodePostgresTransaction;
154
+ };
155
+ };
156
+ declare const handleProjections: <EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & Readonly<{
157
+ eventId: string;
158
+ streamPosition: bigint;
159
+ streamName: string;
160
+ }>>(options: ProjectionHandlerOptions<EventType, EventMetaDataType>) => Promise<void>;
161
+ declare const postgreSQLProjection: <EventType extends Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & Readonly<{
162
+ eventId: string;
163
+ streamPosition: bigint;
164
+ streamName: string;
165
+ }>>(definition: PostgreSQLProjectionDefinition<EventType>) => PostgreSQLProjectionDefinition;
166
+ declare const postgreSQLRawBatchSQLProjection: <EventType extends Event>(handle: (events: EventType[], context: PostgreSQLProjectionHandlerContext) => Promise<SQL[]> | SQL[], ...canHandle: CanHandle<EventType>) => PostgreSQLProjectionDefinition;
167
+ declare const postgreSQLRawSQLProjection: <EventType extends Event>(handle: (event: EventType, context: PostgreSQLProjectionHandlerContext) => Promise<SQL> | SQL, ...canHandle: CanHandle<EventType>) => PostgreSQLProjectionDefinition;
168
+
169
+ interface PostgresEventStore extends EventStore<DefaultStreamVersionType, ReadEventMetadataWithGlobalPosition>, EventStoreSessionFactory<PostgresEventStore, DefaultStreamVersionType> {
170
+ close(): Promise<void>;
171
+ schema: {
172
+ sql(): string;
173
+ print(): void;
174
+ migrate(): Promise<void>;
175
+ };
176
+ }
177
+ type PostgresEventStorePooledOptions = {
178
+ connector?: NodePostgresConnector;
179
+ connectionString?: string;
180
+ database?: string;
181
+ pooled: true;
182
+ pool: pg.Pool;
183
+ } | {
184
+ connector?: NodePostgresConnector;
185
+ connectionString?: string;
186
+ database?: string;
187
+ pool: pg.Pool;
188
+ } | {
189
+ connector?: NodePostgresConnector;
190
+ connectionString?: string;
191
+ database?: string;
192
+ pooled: true;
193
+ } | {
194
+ connector?: NodePostgresConnector;
195
+ connectionString?: string;
196
+ database?: string;
197
+ };
198
+ type PostgresEventStoreNotPooledOptions = {
199
+ connector?: NodePostgresConnector;
200
+ connectionString?: string;
201
+ database?: string;
202
+ pooled: false;
203
+ client: pg.Client;
204
+ } | {
205
+ connector?: NodePostgresConnector;
206
+ connectionString?: string;
207
+ database?: string;
208
+ client: pg.Client;
209
+ } | {
210
+ connector?: NodePostgresConnector;
211
+ connectionString?: string;
212
+ database?: string;
213
+ pooled: false;
214
+ } | {
215
+ connector?: NodePostgresConnector;
216
+ connectionString?: string;
217
+ database?: string;
218
+ connection: NodePostgresPoolClientConnection | NodePostgresClientConnection;
219
+ pooled?: false;
220
+ } | {
221
+ connector?: NodePostgresConnector;
222
+ connectionString?: string;
223
+ database?: string;
224
+ dumbo: NodePostgresPool;
225
+ pooled?: false;
226
+ };
227
+ declare enum SchemaMigration {
228
+ None = "None",
229
+ CreateOrUpdate = "CreateOrUpdate"
230
+ }
231
+ type PostgresEventStoreConnectionOptions = PostgresEventStorePooledOptions | PostgresEventStoreNotPooledOptions;
232
+ type PostgresEventStoreOptions = {
233
+ projections?: ProjectionRegistration<'inline', PostgreSQLProjectionHandlerContext>[];
234
+ schema?: {
235
+ autoMigration?: SchemaMigration;
236
+ };
237
+ connectionOptions?: PostgresEventStoreConnectionOptions;
238
+ };
239
+ declare const defaultPostgreSQLOptions: PostgresEventStoreOptions;
240
+ declare const getPostgreSQLEventStore: (connectionString: string, options?: PostgresEventStoreOptions) => PostgresEventStore;
241
+
242
+ declare const appendEventsSQL: _event_driven_io_dumbo.SQL;
243
+ type AppendEventResult = {
244
+ success: true;
245
+ nextStreamPosition: bigint;
246
+ lastGlobalPosition: bigint;
247
+ transactionId: string;
248
+ } | {
249
+ success: false;
250
+ };
251
+ type AppendToStreamPreCommitHook = (events: ReadEvent[], context: {
252
+ transaction: NodePostgresTransaction;
253
+ }) => Promise<void>;
254
+ declare const appendToStream: (pool: NodePostgresPool, streamName: string, streamType: string, events: Event[], options?: AppendToStreamOptions & {
255
+ partition?: string;
256
+ preCommitHook?: AppendToStreamPreCommitHook;
257
+ }) => Promise<AppendEventResult>;
258
+
259
+ declare const readStream: <EventType extends Event>(execute: SQLExecutor, streamId: string, options?: ReadStreamOptions & {
260
+ partition?: string;
261
+ }) => Promise<ReadStreamResult<EventType, DefaultStreamVersionType, ReadEventMetadataWithGlobalPosition>>;
262
+
263
+ declare const streamsTableSQL: _event_driven_io_dumbo.SQL;
264
+ declare const eventsTableSQL: _event_driven_io_dumbo.SQL;
265
+ declare const subscriptionsTableSQL: _event_driven_io_dumbo.SQL;
266
+ declare const sanitizeNameSQL: _event_driven_io_dumbo.SQL;
267
+ declare const addTablePartitions: _event_driven_io_dumbo.SQL;
268
+ declare const addEventsPartitions: _event_driven_io_dumbo.SQL;
269
+ declare const addModuleSQL: _event_driven_io_dumbo.SQL;
270
+ declare const addTenantSQL: _event_driven_io_dumbo.SQL;
271
+ declare const addModuleForAllTenantsSQL: _event_driven_io_dumbo.SQL;
272
+ declare const addTenantForAllModulesSQL: _event_driven_io_dumbo.SQL;
273
+ declare const addDefaultPartition: _event_driven_io_dumbo.SQL;
274
+
275
+ declare const emmettPrefix = "emt";
276
+ declare const globalTag = "global";
277
+ declare const defaultTag = "emt:default";
278
+ declare const globalNames: {
279
+ module: string;
280
+ tenant: string;
281
+ };
282
+ declare const streamsTable: {
283
+ name: string;
284
+ columns: {
285
+ partition: {
286
+ name: string;
287
+ };
288
+ isArchived: {
289
+ name: string;
290
+ };
291
+ };
292
+ };
293
+ declare const eventsTable: {
294
+ name: string;
295
+ columns: {
296
+ partition: {
297
+ name: string;
298
+ };
299
+ isArchived: {
300
+ name: string;
301
+ };
302
+ };
303
+ };
304
+
305
+ declare const schemaSQL: SQL[];
306
+ declare const createEventStoreSchema: (pool: NodePostgresPool) => Promise<void>;
307
+
308
+ export { type AppendToStreamPreCommitHook, type PongoAssertOptions, type PongoDocumentEvolve, type PongoMultiStreamProjectionOptions, type PongoProjectionHandlerContext, type PongoProjectionOptions, type PongoSingleStreamProjectionOptions, type PongoWithNotNullDocumentEvolve, type PongoWithNullableDocumentEvolve, type PostgreSQLProjectionAssert, type PostgreSQLProjectionDefinition, type PostgreSQLProjectionHandler, type PostgreSQLProjectionHandlerContext, PostgreSQLProjectionSpec, type PostgreSQLProjectionSpecEvent, type PostgreSQLProjectionSpecOptions, type PostgreSQLProjectionSpecWhenOptions, type PostgresEventStore, type PostgresEventStoreConnectionOptions, type PostgresEventStoreOptions, type ProjectionHandlerOptions, SchemaMigration, addDefaultPartition, addEventsPartitions, addModuleForAllTenantsSQL, addModuleSQL, addTablePartitions, addTenantForAllModulesSQL, addTenantSQL, appendEventsSQL, appendToStream, assertSQLQueryResultMatches, createEventStoreSchema, defaultPostgreSQLOptions, defaultTag, documentDoesNotExist, documentExists, documentMatchingExists, documentsAreTheSame, documentsMatchingHaveCount, emmettPrefix, eventInStream, eventsInStream, eventsTable, eventsTableSQL, expectPongoDocuments, expectSQL, getPostgreSQLEventStore, globalNames, globalTag, handleProjections, newEventsInStream, pongoMultiStreamProjection, pongoProjection, pongoSingleStreamProjection, postgreSQLProjection, postgreSQLRawBatchSQLProjection, postgreSQLRawSQLProjection, readStream, sanitizeNameSQL, schemaSQL, streamsTable, streamsTableSQL, subscriptionsTableSQL };