@event-driven-io/emmett-mongodb 0.30.0 → 0.32.0-alpha.1
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 +17 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +17 -11
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Event, ProjectionHandler,
|
|
1
|
+
import { Event, ProjectionHandler, ProjectionDefinition, ReadEvent, CanHandle, ThenThrows, ReadEventMetadataWithoutGlobalPosition, ProjectionRegistration, DefaultEventStoreOptions, EventStore, Closeable } from '@event-driven-io/emmett';
|
|
2
2
|
import { UpdateFilter, Collection, Document, MongoClient, MongoClientOptions, Filter } from 'mongodb';
|
|
3
3
|
|
|
4
4
|
declare const MongoDBDefaultInlineProjectionName = "_default";
|
|
@@ -9,7 +9,7 @@ type MongoDBProjectionInlineHandlerContext<EventType extends Event = Event, Even
|
|
|
9
9
|
collection: Collection<EventStream<EventType, EventMetaDataType>>;
|
|
10
10
|
};
|
|
11
11
|
type MongoDBInlineProjectionHandler<EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> = ProjectionHandler<EventType, EventMetaDataType, MongoDBProjectionInlineHandlerContext>;
|
|
12
|
-
type MongoDBInlineProjectionDefinition<EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> =
|
|
12
|
+
type MongoDBInlineProjectionDefinition<EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> = ProjectionDefinition<EventType, EventMetaDataType, MongoDBProjectionInlineHandlerContext> & {
|
|
13
13
|
name: string;
|
|
14
14
|
};
|
|
15
15
|
type InlineProjectionHandlerOptions<EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> = {
|
|
@@ -22,7 +22,7 @@ type InlineProjectionHandlerOptions<EventType extends Event = Event, EventMetaDa
|
|
|
22
22
|
client: {};
|
|
23
23
|
};
|
|
24
24
|
declare const handleInlineProjections: <EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = Readonly<{
|
|
25
|
-
|
|
25
|
+
messageId: string;
|
|
26
26
|
streamPosition: bigint;
|
|
27
27
|
streamName: string;
|
|
28
28
|
}>>(options: InlineProjectionHandlerOptions<EventType, EventMetaDataType>) => Promise<void>;
|
|
@@ -39,7 +39,7 @@ type MongoDBInlineProjectionOptions<Doc extends Document, EventType extends Even
|
|
|
39
39
|
initialState: () => Doc;
|
|
40
40
|
});
|
|
41
41
|
declare const mongoDBInlineProjection: <Doc extends Document, EventType extends Event, EventMetaDataType extends MongoDBReadEventMetadata = Readonly<{
|
|
42
|
-
|
|
42
|
+
messageId: string;
|
|
43
43
|
streamPosition: bigint;
|
|
44
44
|
streamName: string;
|
|
45
45
|
}>>(options: MongoDBInlineProjectionOptions<Doc, EventType, EventMetaDataType>) => MongoDBInlineProjectionDefinition;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Event, ProjectionHandler,
|
|
1
|
+
import { Event, ProjectionHandler, ProjectionDefinition, ReadEvent, CanHandle, ThenThrows, ReadEventMetadataWithoutGlobalPosition, ProjectionRegistration, DefaultEventStoreOptions, EventStore, Closeable } from '@event-driven-io/emmett';
|
|
2
2
|
import { UpdateFilter, Collection, Document, MongoClient, MongoClientOptions, Filter } from 'mongodb';
|
|
3
3
|
|
|
4
4
|
declare const MongoDBDefaultInlineProjectionName = "_default";
|
|
@@ -9,7 +9,7 @@ type MongoDBProjectionInlineHandlerContext<EventType extends Event = Event, Even
|
|
|
9
9
|
collection: Collection<EventStream<EventType, EventMetaDataType>>;
|
|
10
10
|
};
|
|
11
11
|
type MongoDBInlineProjectionHandler<EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> = ProjectionHandler<EventType, EventMetaDataType, MongoDBProjectionInlineHandlerContext>;
|
|
12
|
-
type MongoDBInlineProjectionDefinition<EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> =
|
|
12
|
+
type MongoDBInlineProjectionDefinition<EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> = ProjectionDefinition<EventType, EventMetaDataType, MongoDBProjectionInlineHandlerContext> & {
|
|
13
13
|
name: string;
|
|
14
14
|
};
|
|
15
15
|
type InlineProjectionHandlerOptions<EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = MongoDBReadEventMetadata> = {
|
|
@@ -22,7 +22,7 @@ type InlineProjectionHandlerOptions<EventType extends Event = Event, EventMetaDa
|
|
|
22
22
|
client: {};
|
|
23
23
|
};
|
|
24
24
|
declare const handleInlineProjections: <EventType extends Event = Event, EventMetaDataType extends MongoDBReadEventMetadata = Readonly<{
|
|
25
|
-
|
|
25
|
+
messageId: string;
|
|
26
26
|
streamPosition: bigint;
|
|
27
27
|
streamName: string;
|
|
28
28
|
}>>(options: InlineProjectionHandlerOptions<EventType, EventMetaDataType>) => Promise<void>;
|
|
@@ -39,7 +39,7 @@ type MongoDBInlineProjectionOptions<Doc extends Document, EventType extends Even
|
|
|
39
39
|
initialState: () => Doc;
|
|
40
40
|
});
|
|
41
41
|
declare const mongoDBInlineProjection: <Doc extends Document, EventType extends Event, EventMetaDataType extends MongoDBReadEventMetadata = Readonly<{
|
|
42
|
-
|
|
42
|
+
messageId: string;
|
|
43
43
|
streamPosition: bigint;
|
|
44
44
|
streamName: string;
|
|
45
45
|
}>>(options: MongoDBInlineProjectionOptions<Doc, EventType, EventMetaDataType>) => MongoDBInlineProjectionDefinition;
|
package/dist/index.js
CHANGED
|
@@ -232,8 +232,14 @@ var filterProjections = (type, projections2) => {
|
|
|
232
232
|
}
|
|
233
233
|
return inlineProjections2;
|
|
234
234
|
};
|
|
235
|
-
var inlineProjections = (definitions) => definitions.map((
|
|
236
|
-
|
|
235
|
+
var inlineProjections = (definitions) => definitions.map((definition) => ({
|
|
236
|
+
type: "inline",
|
|
237
|
+
projection: definition
|
|
238
|
+
}));
|
|
239
|
+
var asyncProjections = (definitions) => definitions.map((definition) => ({
|
|
240
|
+
type: "inline",
|
|
241
|
+
projection: definition
|
|
242
|
+
}));
|
|
237
243
|
var projections = {
|
|
238
244
|
inline: inlineProjections,
|
|
239
245
|
async: asyncProjections
|
|
@@ -380,8 +386,8 @@ var streamTransformations = {
|
|
|
380
386
|
};
|
|
381
387
|
var { retry: retry2 } = streamTransformations;
|
|
382
388
|
var AssertionError = class extends Error {
|
|
383
|
-
constructor(
|
|
384
|
-
super(
|
|
389
|
+
constructor(message2) {
|
|
390
|
+
super(message2);
|
|
385
391
|
}
|
|
386
392
|
};
|
|
387
393
|
var isSubset = (superObj, subObj) => {
|
|
@@ -396,15 +402,15 @@ var isSubset = (superObj, subObj) => {
|
|
|
396
402
|
return sub[ele] === sup[ele];
|
|
397
403
|
});
|
|
398
404
|
};
|
|
399
|
-
var assertFails = (
|
|
400
|
-
throw new AssertionError(
|
|
405
|
+
var assertFails = (message2) => {
|
|
406
|
+
throw new AssertionError(message2 ?? "That should not ever happened, right?");
|
|
401
407
|
};
|
|
402
|
-
function assertTrue(condition,
|
|
408
|
+
function assertTrue(condition, message2) {
|
|
403
409
|
if (condition !== true)
|
|
404
|
-
throw new AssertionError(
|
|
410
|
+
throw new AssertionError(message2 ?? `Condition is false`);
|
|
405
411
|
}
|
|
406
|
-
function assertOk(obj,
|
|
407
|
-
if (!obj) throw new AssertionError(
|
|
412
|
+
function assertOk(obj, message2) {
|
|
413
|
+
if (!obj) throw new AssertionError(message2 ?? `Condition is not truthy`);
|
|
408
414
|
}
|
|
409
415
|
|
|
410
416
|
// src/eventStore/mongoDBEventStore.ts
|
|
@@ -770,7 +776,7 @@ var MongoDBEventStoreImplementation = class {
|
|
|
770
776
|
let streamOffset = currentStreamVersion;
|
|
771
777
|
const eventsToAppend = events.map((event) => {
|
|
772
778
|
const metadata = {
|
|
773
|
-
|
|
779
|
+
messageId: uuid4(),
|
|
774
780
|
streamName,
|
|
775
781
|
streamPosition: ++streamOffset
|
|
776
782
|
};
|