@event-driven-io/emmett-mongodb 0.43.0-beta.13 → 0.43.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +513 -1180
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +142 -137
- package/dist/index.d.ts +142 -137
- package/dist/index.js +489 -1173
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.cts
CHANGED
|
@@ -1,240 +1,244 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CanHandle, Closeable, DefaultEventStoreOptions, Event, EventStore, ProjectionDefinition, ProjectionHandler, ProjectionRegistration, ReadEvent, ReadEventMetadataWithoutGlobalPosition, ThenThrows } from "@event-driven-io/emmett";
|
|
2
|
+
import { Collection, Document, Filter, MongoClient, MongoClientOptions, UpdateFilter } from "mongodb";
|
|
3
3
|
|
|
4
|
+
//#region src/eventStore/projections/mongoDBInlineProjection.d.ts
|
|
4
5
|
declare const MongoDBDefaultInlineProjectionName = "_default";
|
|
5
6
|
type MongoDBProjectionInlineHandlerContext<EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
document: MongoDBReadModel | null;
|
|
8
|
+
streamId: string;
|
|
9
|
+
updates: UpdateFilter<EventStream<EventType, EventMetaDataType>>;
|
|
10
|
+
collection: Collection<EventStream<EventType, EventMetaDataType>>;
|
|
10
11
|
};
|
|
11
12
|
type MongoDBInlineProjectionHandler<EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> = ProjectionHandler<EventType, EventMetaDataType, MongoDBProjectionInlineHandlerContext>;
|
|
12
13
|
type MongoDBInlineProjectionDefinition<EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> = ProjectionDefinition<EventType, EventMetaDataType, MongoDBProjectionInlineHandlerContext> & {
|
|
13
|
-
|
|
14
|
+
name: string;
|
|
14
15
|
};
|
|
15
16
|
type InlineProjectionHandlerOptions<EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
readModels: Record<string, MongoDBReadModel>;
|
|
18
|
+
events: Array<ReadEvent<EventType, EventMetaDataType>>;
|
|
19
|
+
projections: MongoDBInlineProjectionDefinition<EventType, EventMetaDataType>[];
|
|
20
|
+
streamId: string;
|
|
21
|
+
collection: Collection<EventStream>;
|
|
22
|
+
updates: UpdateFilter<EventStream<Event>>;
|
|
23
|
+
client: {};
|
|
23
24
|
};
|
|
24
25
|
declare const handleInlineProjections: <EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata>(options: InlineProjectionHandlerOptions<EventType, EventMetaDataType>) => Promise<void>;
|
|
25
26
|
type MongoDBWithNotNullDocumentEvolve<Doc extends Document, EventType extends Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> = ((document: Doc, event: ReadEvent<EventType, EventMetaDataType>) => Doc | null) | ((document: Doc, event: ReadEvent<EventType>) => Promise<Doc | null>);
|
|
26
27
|
type MongoDBWithNullableDocumentEvolve<Doc extends Document, EventType extends Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> = ((document: Doc | null, event: ReadEvent<EventType, EventMetaDataType>) => Doc | null) | ((document: Doc | null, event: ReadEvent<EventType>) => Promise<Doc | null>);
|
|
27
28
|
type MongoDBInlineProjectionOptions<Doc extends Document, EventType extends Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> = {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
name?: string;
|
|
30
|
+
schemaVersion?: number;
|
|
31
|
+
canHandle: CanHandle<EventType>;
|
|
31
32
|
} & ({
|
|
32
|
-
|
|
33
|
+
evolve: MongoDBWithNullableDocumentEvolve<Doc, EventType, EventMetaDataType>;
|
|
33
34
|
} | {
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
evolve: MongoDBWithNotNullDocumentEvolve<Doc, EventType, EventMetaDataType>;
|
|
36
|
+
initialState: () => Doc;
|
|
36
37
|
});
|
|
37
38
|
declare const mongoDBInlineProjection: <Doc extends Document, EventType extends Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata>(options: MongoDBInlineProjectionOptions<Doc, EventType, EventMetaDataType>) => MongoDBInlineProjectionDefinition;
|
|
38
|
-
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/eventStore/projections/mongoDBInlineProjectionSpec.d.ts
|
|
39
41
|
type MongoDBInlineProjectionSpecGivenEvents<StreamNameType extends StreamName, EventType extends Event> = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
streamName: StreamNameType;
|
|
43
|
+
events: EventType[];
|
|
44
|
+
};
|
|
45
|
+
type MongoDBInlineProjectionSpec<StreamNameType extends StreamName, EventType extends Event> = (givenStream: MongoDBInlineProjectionSpecGivenEvents<StreamNameType, EventType>) => {
|
|
46
|
+
when: (events: EventType[]) => {
|
|
47
|
+
then: (assert: MongoDBInlineProjectionAssert, message?: string) => Promise<void>;
|
|
48
|
+
thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => Promise<void>;
|
|
49
|
+
};
|
|
42
50
|
};
|
|
43
51
|
type MongoDBInlineProjectionAssertOptions<StreamNameType extends StreamName = StreamName> = {
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
streamName: StreamNameType;
|
|
53
|
+
eventStore: MongoDBEventStore;
|
|
46
54
|
};
|
|
47
55
|
type MongoDBInlineProjectionAssert<StreamNameType extends StreamName = StreamName> = (options: MongoDBInlineProjectionAssertOptions<StreamNameType>) => Promise<void | boolean>;
|
|
48
56
|
type MongoDBInlineProjectionSpecOptions = {
|
|
49
|
-
|
|
57
|
+
projection: MongoDBInlineProjectionDefinition;
|
|
50
58
|
} & MongoDBEventStoreConnectionOptions;
|
|
51
|
-
type MongoDBInlineProjectionSpec<StreamNameType extends StreamName, EventType extends Event> = (givenStream: MongoDBInlineProjectionSpecGivenEvents<StreamNameType, EventType>) => {
|
|
52
|
-
when: (events: EventType[]) => {
|
|
53
|
-
then: (assert: MongoDBInlineProjectionAssert, message?: string) => Promise<void>;
|
|
54
|
-
thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => Promise<void>;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
59
|
declare const MongoDBInlineProjectionSpec: {
|
|
58
|
-
|
|
60
|
+
for: <StreamNameType extends StreamName, EventType extends Event>(options: MongoDBInlineProjectionSpecOptions) => MongoDBInlineProjectionSpec<StreamNameType, EventType>;
|
|
59
61
|
};
|
|
60
62
|
declare const eventInStream: <StreamNameType extends StreamName, EventType extends Event>(streamName: StreamNameType, event: EventType) => MongoDBInlineProjectionSpecGivenEvents<StreamNameType, EventType>;
|
|
61
63
|
declare const eventsInStream: <StreamNameType extends StreamName, EventType extends Event>(streamName: StreamNameType, events: EventType[]) => MongoDBInlineProjectionSpecGivenEvents<StreamNameType, EventType>;
|
|
62
64
|
declare const expectInlineReadModel: {
|
|
65
|
+
toHave: <Doc extends Document, StreamNameType extends StreamName = `${string}:${string}`>(expected: Partial<MongoDBReadModel<Doc>> | null) => MongoDBInlineProjectionAssert<StreamNameType>;
|
|
66
|
+
toDeepEquals: <Doc extends Document, StreamNameType extends StreamName = `${string}:${string}`>(expected: MongoDBReadModel<Doc> | null) => MongoDBInlineProjectionAssert<StreamNameType>;
|
|
67
|
+
toMatch: <Doc extends Document, StreamNameType extends StreamName = `${string}:${string}`>(match: (readModel: MongoDBReadModel<Doc> | null) => boolean) => MongoDBInlineProjectionAssert<StreamNameType>;
|
|
68
|
+
notToExist: <StreamNameType extends StreamName = `${string}:${string}`>() => MongoDBInlineProjectionAssert<StreamNameType>;
|
|
69
|
+
toExist: () => MongoDBInlineProjectionAssert;
|
|
70
|
+
withName: (name: string) => {
|
|
63
71
|
toHave: <Doc extends Document, StreamNameType extends StreamName = `${string}:${string}`>(expected: Partial<MongoDBReadModel<Doc>> | null) => MongoDBInlineProjectionAssert<StreamNameType>;
|
|
64
72
|
toDeepEquals: <Doc extends Document, StreamNameType extends StreamName = `${string}:${string}`>(expected: MongoDBReadModel<Doc> | null) => MongoDBInlineProjectionAssert<StreamNameType>;
|
|
65
73
|
toMatch: <Doc extends Document, StreamNameType extends StreamName = `${string}:${string}`>(match: (readModel: MongoDBReadModel<Doc> | null) => boolean) => MongoDBInlineProjectionAssert<StreamNameType>;
|
|
66
74
|
notToExist: <StreamNameType extends StreamName = `${string}:${string}`>() => MongoDBInlineProjectionAssert<StreamNameType>;
|
|
67
75
|
toExist: () => MongoDBInlineProjectionAssert;
|
|
68
|
-
|
|
69
|
-
toHave: <Doc extends Document, StreamNameType extends StreamName = `${string}:${string}`>(expected: Partial<MongoDBReadModel<Doc>> | null) => MongoDBInlineProjectionAssert<StreamNameType>;
|
|
70
|
-
toDeepEquals: <Doc extends Document, StreamNameType extends StreamName = `${string}:${string}`>(expected: MongoDBReadModel<Doc> | null) => MongoDBInlineProjectionAssert<StreamNameType>;
|
|
71
|
-
toMatch: <Doc extends Document, StreamNameType extends StreamName = `${string}:${string}`>(match: (readModel: MongoDBReadModel<Doc> | null) => boolean) => MongoDBInlineProjectionAssert<StreamNameType>;
|
|
72
|
-
notToExist: <StreamNameType extends StreamName = `${string}:${string}`>() => MongoDBInlineProjectionAssert<StreamNameType>;
|
|
73
|
-
toExist: () => MongoDBInlineProjectionAssert;
|
|
74
|
-
};
|
|
76
|
+
};
|
|
75
77
|
};
|
|
76
|
-
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/eventStore/storage/mongoDBEventStoreStorage.d.ts
|
|
77
80
|
type MongoDBEventStoreCollectionPerStreamTypeStorageOptions = {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
/**
|
|
82
|
+
* The recommended setting where each stream type will be kept
|
|
83
|
+
* in a separate collection type using the format: `emt_${streamType}`.
|
|
84
|
+
*/
|
|
85
|
+
type: 'COLLECTION_PER_STREAM_TYPE';
|
|
86
|
+
databaseName?: string;
|
|
84
87
|
};
|
|
85
88
|
type MongoDBEventStoreSingleCollectionStorageOptions = {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
/**
|
|
90
|
+
* All streams will be kept withing a single MongDB collection
|
|
91
|
+
* It'll either use default collection name ("emt_streams")
|
|
92
|
+
* or provided name through 'collection' param.
|
|
93
|
+
*/
|
|
94
|
+
type: 'SINGLE_COLLECTION';
|
|
95
|
+
collectionName?: string;
|
|
96
|
+
databaseName?: string;
|
|
94
97
|
};
|
|
95
98
|
type MongoDBEventStoreCollectionResolution = {
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
databaseName?: string;
|
|
100
|
+
collectionName: string;
|
|
98
101
|
};
|
|
99
102
|
type MongoDBEventStoreCustomStorageOptions = {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
/**
|
|
104
|
+
* This is advanced option, where you specify your own collection
|
|
105
|
+
* resolution function. You can do that by specifying the `collectionFor` function.
|
|
106
|
+
*/
|
|
107
|
+
type: 'CUSTOM';
|
|
108
|
+
databaseName?: string;
|
|
109
|
+
collectionFor: <T extends StreamType>(streamType: T) => string | MongoDBEventStoreCollectionResolution;
|
|
107
110
|
};
|
|
108
111
|
type MongoDBEventStoreStorageOptions = 'COLLECTION_PER_STREAM_TYPE' | 'SINGLE_COLLECTION' | MongoDBEventStoreSingleCollectionStorageOptions | MongoDBEventStoreCollectionPerStreamTypeStorageOptions | MongoDBEventStoreCustomStorageOptions;
|
|
109
112
|
declare const DefaultMongoDBEventStoreStorageOptions = "COLLECTION_PER_STREAM_TYPE";
|
|
110
113
|
type MongoDBEventStoreStorage = {
|
|
111
|
-
|
|
114
|
+
collectionFor: <T extends StreamType, EventType extends Event = Event>(streamType: T) => Promise<Collection<EventStream<EventType>>>;
|
|
112
115
|
};
|
|
113
116
|
declare const DefaultMongoDBEventStoreCollectionName = "emt:streams";
|
|
114
117
|
declare const mongoDBEventStoreStorage: (options: {
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
storage?: MongoDBEventStoreStorageOptions | undefined;
|
|
119
|
+
getConnectedClient: () => Promise<MongoClient>;
|
|
117
120
|
}) => MongoDBEventStoreStorage;
|
|
118
|
-
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/eventStore/mongoDBEventStore.d.ts
|
|
119
123
|
declare const MongoDBEventStoreDefaultStreamVersion = 0n;
|
|
120
124
|
type StreamType = string;
|
|
121
125
|
type StreamName<T extends StreamType = StreamType> = `${T}:${string}`;
|
|
122
126
|
type StreamNameParts<T extends StreamType = StreamType> = {
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
streamType: T;
|
|
128
|
+
streamId: string;
|
|
125
129
|
};
|
|
126
130
|
type StreamCollectionName<T extends StreamType = StreamType> = `emt:${T}`;
|
|
127
131
|
type StreamCollectionNameParts<T extends StreamType = StreamType> = {
|
|
128
|
-
|
|
132
|
+
streamType: T;
|
|
129
133
|
};
|
|
130
134
|
type MongoDBReadModelMetadata = {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
streamId: string;
|
|
136
|
+
name: string;
|
|
137
|
+
schemaVersion: number;
|
|
138
|
+
streamPosition: bigint;
|
|
135
139
|
};
|
|
136
140
|
type MongoDBReadModel<Doc extends Document = Document> = Doc & {
|
|
137
|
-
|
|
141
|
+
_metadata: MongoDBReadModelMetadata;
|
|
138
142
|
};
|
|
139
143
|
interface EventStream<EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
144
|
+
streamName: string;
|
|
145
|
+
messages: Array<ReadEvent<EventType, EventMetaDataType>>;
|
|
146
|
+
metadata: {
|
|
147
|
+
streamId: string;
|
|
148
|
+
streamType: StreamType;
|
|
149
|
+
streamPosition: bigint;
|
|
150
|
+
createdAt: Date;
|
|
151
|
+
updatedAt: Date;
|
|
152
|
+
};
|
|
153
|
+
projections: Record<string, MongoDBReadModel>;
|
|
150
154
|
}
|
|
151
155
|
type MongoDBReadEventMetadata = ReadEventMetadataWithoutGlobalPosition;
|
|
152
156
|
type MongoDBReadEvent<EventType extends Event = Event> = ReadEvent<EventType, MongoDBReadEventMetadata>;
|
|
153
157
|
type SingleProjectionQueryStreamFilter<T extends StreamType> = {
|
|
154
|
-
|
|
158
|
+
projectionName?: string;
|
|
155
159
|
} & ({
|
|
156
|
-
|
|
160
|
+
streamName: StreamName<T>;
|
|
157
161
|
} | {
|
|
158
|
-
|
|
159
|
-
|
|
162
|
+
streamType: T;
|
|
163
|
+
streamId?: string;
|
|
160
164
|
});
|
|
161
165
|
type MultiProjectionQueryStreamFilter<T extends StreamType> = {
|
|
162
|
-
|
|
166
|
+
projectionName?: string;
|
|
163
167
|
} & ({
|
|
164
|
-
|
|
168
|
+
streamNames: StreamName<T>[];
|
|
165
169
|
} | {
|
|
166
|
-
|
|
167
|
-
|
|
170
|
+
streamType: T;
|
|
171
|
+
streamIds?: string[];
|
|
168
172
|
});
|
|
169
173
|
type MultiProjectionQueryOptions = {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
174
|
+
skip?: number;
|
|
175
|
+
limit?: number;
|
|
176
|
+
sort?: [string, 1 | -1][] | Record<string, 1 | -1>;
|
|
173
177
|
};
|
|
174
178
|
/**
|
|
175
179
|
* Helpers for querying inline projections on event streams.
|
|
176
180
|
*/
|
|
177
181
|
type InlineProjectionQueries<T extends StreamType> = {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Helper for querying for a single projection. Similar to `collection.findOne`.
|
|
184
|
+
* @param streamFilter - A filter object for stream level fields. If `streamType` is required if `streamName` is not provided. If `projectionName` is not provided, the default projection will be used (`MongoDBDefaultInlineProjectionName`).
|
|
185
|
+
* @param projectionQuery - A MongoDB filter query based on the projection schema. Internally, this function will prepend each object key with the necessary projection name.
|
|
186
|
+
*/
|
|
187
|
+
findOne: <Doc extends Document>(streamFilter: SingleProjectionQueryStreamFilter<T>, projectionQuery?: Filter<MongoDBReadModel<Doc>>) => Promise<MongoDBReadModel<Doc> | null>;
|
|
188
|
+
/**
|
|
189
|
+
* Helper for querying for multiple projections. Similar to `collection.find`.
|
|
190
|
+
*
|
|
191
|
+
* ***NOTE***: If `streamFilter.streamNames` is an empty array, this function will return an empty array. If `streamFilter.streamIds` is an empty array, the `streamIds` filter will not be used.
|
|
192
|
+
*
|
|
193
|
+
* @param streamFilter - A filter object for stream level fields. If `streamType` is required if `streamNames` is not provided. If `projectionName` is not provided, the default projection will be used (`MongoDBDefaultInlineProjectionName`).
|
|
194
|
+
* @param projectionQuery - A MongoDB filter query based on the projection schema. Internally, this function will prepend each object key with the necessary projection name.
|
|
195
|
+
* @param queryOptions - Additional query options like `skip`, `limit`, and `sort`. `sort`, similar to `projectionQuery`, will prepend each object key with the necessary projection name.
|
|
196
|
+
*/
|
|
197
|
+
find: <Doc extends Document>(streamFilter: MultiProjectionQueryStreamFilter<T>, projectionQuery?: Filter<MongoDBReadModel<Doc>>, queryOptions?: MultiProjectionQueryOptions) => Promise<MongoDBReadModel<Doc>[]>;
|
|
198
|
+
/**
|
|
199
|
+
* Returns the total number of documents matching the provided filter options. Similar to `collection.countDocuments`.
|
|
200
|
+
*
|
|
201
|
+
* ***NOTE***: If `streamFilter.streamNames` is an empty array, this function will return `0`. If `streamFilter.streamIds` is an empty array, the `streamIds` filter will not be used.
|
|
202
|
+
*
|
|
203
|
+
* @param streamFilter - A filter object for stream level fields. If `streamType` is required if `streamNames` is not provided. If `projectionName` is not provided, the default projection will be used (`MongoDBDefaultInlineProjectionName`).
|
|
204
|
+
* @param projectionQuery - A MongoDB filter query based on the projection schema. Internally, this function will prepend each object key with the necessary projection name.
|
|
205
|
+
*/
|
|
206
|
+
count: <Doc extends Document>(streamFilter: MultiProjectionQueryStreamFilter<T>, projectionQuery?: Filter<MongoDBReadModel<Doc>>) => Promise<number>;
|
|
203
207
|
};
|
|
204
208
|
/**
|
|
205
209
|
* Helpers for querying projections on event streams.
|
|
206
210
|
*/
|
|
207
211
|
type ProjectionQueries<T extends StreamType> = {
|
|
208
|
-
|
|
212
|
+
inline: InlineProjectionQueries<T>;
|
|
209
213
|
};
|
|
210
214
|
type MongoDBEventStoreClientOptions = {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
215
|
+
client: MongoClient;
|
|
216
|
+
connectionString?: never;
|
|
217
|
+
clientOptions?: never;
|
|
214
218
|
};
|
|
215
219
|
type MongoDBEventStoreConnectionStringOptions = {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
220
|
+
client?: never;
|
|
221
|
+
connectionString: string;
|
|
222
|
+
clientOptions?: MongoClientOptions;
|
|
219
223
|
};
|
|
220
224
|
type MongoDBEventStoreConnectionOptions = MongoDBEventStoreClientOptions | MongoDBEventStoreConnectionStringOptions;
|
|
221
225
|
type MongoDBEventStoreOptions = {
|
|
222
|
-
|
|
223
|
-
|
|
226
|
+
projections?: ProjectionRegistration<'inline', MongoDBReadEventMetadata, MongoDBProjectionInlineHandlerContext>[];
|
|
227
|
+
storage?: MongoDBEventStoreStorageOptions;
|
|
224
228
|
} & MongoDBEventStoreConnectionOptions & DefaultEventStoreOptions<MongoDBEventStore>;
|
|
225
229
|
type MongoDBEventStore = EventStore<MongoDBReadEventMetadata> & {
|
|
226
|
-
|
|
227
|
-
|
|
230
|
+
projections: ProjectionQueries<StreamType>;
|
|
231
|
+
collectionFor: <EventType extends Event>(streamType: StreamType) => Promise<Collection<EventStream<EventType>>>;
|
|
228
232
|
};
|
|
229
233
|
/**
|
|
230
234
|
* Prepends `prefix` to all object keys that don't start with a '$'
|
|
231
235
|
*/
|
|
232
236
|
declare function prependMongoFilterWithProjectionPrefix<T, Result = T>(obj: T, prefix: string): Result;
|
|
233
237
|
declare function getMongoDBEventStore(options: MongoDBEventStoreOptions & {
|
|
234
|
-
|
|
238
|
+
client: MongoClient;
|
|
235
239
|
}): MongoDBEventStore;
|
|
236
240
|
declare function getMongoDBEventStore(options: MongoDBEventStoreOptions & {
|
|
237
|
-
|
|
241
|
+
connectionString: string;
|
|
238
242
|
}): MongoDBEventStore & Closeable;
|
|
239
243
|
/**
|
|
240
244
|
* Accepts a `streamType` (the type/category of the event stream) and an `streamId`
|
|
@@ -256,5 +260,6 @@ declare function toStreamCollectionName<T extends StreamType>(streamType: T): St
|
|
|
256
260
|
* Accepts a fully formatted `streamCollectionName` and returns the parsed `streamType`.
|
|
257
261
|
*/
|
|
258
262
|
declare function fromStreamCollectionName<T extends StreamType>(streamCollectionName: StreamCollectionName<T>): StreamCollectionNameParts<T>;
|
|
259
|
-
|
|
260
|
-
export { DefaultMongoDBEventStoreCollectionName, DefaultMongoDBEventStoreStorageOptions,
|
|
263
|
+
//#endregion
|
|
264
|
+
export { DefaultMongoDBEventStoreCollectionName, DefaultMongoDBEventStoreStorageOptions, EventStream, InlineProjectionHandlerOptions, MongoDBDefaultInlineProjectionName, MongoDBEventStore, MongoDBEventStoreClientOptions, MongoDBEventStoreCollectionPerStreamTypeStorageOptions, MongoDBEventStoreCollectionResolution, MongoDBEventStoreConnectionOptions, MongoDBEventStoreConnectionStringOptions, MongoDBEventStoreCustomStorageOptions, MongoDBEventStoreDefaultStreamVersion, MongoDBEventStoreOptions, MongoDBEventStoreSingleCollectionStorageOptions, MongoDBEventStoreStorage, MongoDBEventStoreStorageOptions, MongoDBInlineProjectionAssert, MongoDBInlineProjectionAssertOptions, MongoDBInlineProjectionDefinition, MongoDBInlineProjectionHandler, MongoDBInlineProjectionOptions, MongoDBInlineProjectionSpec, MongoDBInlineProjectionSpecGivenEvents, MongoDBInlineProjectionSpecOptions, MongoDBProjectionInlineHandlerContext, MongoDBReadEvent, MongoDBReadEventMetadata, MongoDBReadModel, MongoDBReadModelMetadata, MongoDBWithNotNullDocumentEvolve, MongoDBWithNullableDocumentEvolve, StreamCollectionName, StreamCollectionNameParts, StreamName, StreamNameParts, StreamType, eventInStream, eventsInStream, expectInlineReadModel, fromStreamCollectionName, fromStreamName, getMongoDBEventStore, handleInlineProjections, mongoDBEventStoreStorage, mongoDBInlineProjection, prependMongoFilterWithProjectionPrefix, toStreamCollectionName, toStreamName };
|
|
265
|
+
//# sourceMappingURL=index.d.cts.map
|