@event-driven-io/emmett 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 +54 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -40
- package/dist/index.d.ts +64 -40
- package/dist/index.js +53 -39
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,38 +20,44 @@ var _chunkWM5VB4U5cjs = require('./chunk-WM5VB4U5.cjs');
|
|
|
20
20
|
// src/typing/command.ts
|
|
21
21
|
var command = (...args) => {
|
|
22
22
|
const [type, data, metadata] = args;
|
|
23
|
-
return metadata !== void 0 ? { type, data, metadata } : { type, data };
|
|
23
|
+
return metadata !== void 0 ? { type, data, metadata, kind: "Command" } : { type, data, kind: "Command" };
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
// src/typing/event.ts
|
|
27
27
|
var event = (...args) => {
|
|
28
28
|
const [type, data, metadata] = args;
|
|
29
|
-
return metadata !== void 0 ? { type, data, metadata } : { type, data };
|
|
29
|
+
return metadata !== void 0 ? { type, data, metadata, kind: "Event" } : { type, data, kind: "Event" };
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// src/typing/message.ts
|
|
33
|
+
var message = (...args) => {
|
|
34
|
+
const [kind, type, data, metadata] = args;
|
|
35
|
+
return metadata !== void 0 ? { type, data, metadata, kind } : { type, data, kind };
|
|
30
36
|
};
|
|
31
37
|
|
|
32
38
|
// src/typing/workflow.ts
|
|
33
|
-
var reply = (
|
|
39
|
+
var reply = (message2) => {
|
|
34
40
|
return {
|
|
35
41
|
kind: "Reply",
|
|
36
|
-
message
|
|
42
|
+
message: message2
|
|
37
43
|
};
|
|
38
44
|
};
|
|
39
|
-
var send = (
|
|
45
|
+
var send = (message2) => {
|
|
40
46
|
return {
|
|
41
47
|
kind: "Send",
|
|
42
|
-
message
|
|
48
|
+
message: message2
|
|
43
49
|
};
|
|
44
50
|
};
|
|
45
|
-
var publish = (
|
|
51
|
+
var publish = (message2) => {
|
|
46
52
|
return {
|
|
47
53
|
kind: "Publish",
|
|
48
|
-
message
|
|
54
|
+
message: message2
|
|
49
55
|
};
|
|
50
56
|
};
|
|
51
|
-
var schedule = (
|
|
57
|
+
var schedule = (message2, when) => {
|
|
52
58
|
return {
|
|
53
59
|
kind: "Schedule",
|
|
54
|
-
message,
|
|
60
|
+
message: message2,
|
|
55
61
|
when
|
|
56
62
|
};
|
|
57
63
|
};
|
|
@@ -90,8 +96,8 @@ async function tryPublishMessagesAfterCommit(messages, options, context) {
|
|
|
90
96
|
|
|
91
97
|
// src/eventStore/afterCommit/forwardToMessageBus.ts
|
|
92
98
|
var forwardToMessageBus = (eventPublisher) => async (messages) => {
|
|
93
|
-
for (const
|
|
94
|
-
await eventPublisher.publish(
|
|
99
|
+
for (const message2 of messages) {
|
|
100
|
+
await eventPublisher.publish(message2);
|
|
95
101
|
}
|
|
96
102
|
};
|
|
97
103
|
|
|
@@ -321,12 +327,13 @@ var getInMemoryEventStore = (eventStoreOptions) => {
|
|
|
321
327
|
const newEvents = events.map((event2, index) => {
|
|
322
328
|
const metadata = {
|
|
323
329
|
streamName,
|
|
324
|
-
|
|
330
|
+
messageId: _uuid.v4.call(void 0, ),
|
|
325
331
|
streamPosition: BigInt(currentEvents.length + index + 1),
|
|
326
332
|
globalPosition: BigInt(getAllEventsCount() + index + 1)
|
|
327
333
|
};
|
|
328
334
|
return {
|
|
329
335
|
...event2,
|
|
336
|
+
kind: _nullishCoalesce(event2.kind, () => ( "Event")),
|
|
330
337
|
metadata: {
|
|
331
338
|
..."metadata" in event2 ? _nullishCoalesce(event2.metadata, () => ( {})) : {},
|
|
332
339
|
...metadata
|
|
@@ -790,8 +797,8 @@ var getInMemoryMessageBus = () => {
|
|
|
790
797
|
await eventHandler(event2);
|
|
791
798
|
}
|
|
792
799
|
},
|
|
793
|
-
schedule: (
|
|
794
|
-
pendingMessages = [...pendingMessages, { message, options: when }];
|
|
800
|
+
schedule: (message2, when) => {
|
|
801
|
+
pendingMessages = [...pendingMessages, { message: message2, options: when }];
|
|
795
802
|
},
|
|
796
803
|
handle: (commandHandler, ...commandTypes) => {
|
|
797
804
|
const alreadyRegistered = [...allHandlers.keys()].filter(
|
|
@@ -838,8 +845,14 @@ var filterProjections = (type, projections2) => {
|
|
|
838
845
|
return inlineProjections2;
|
|
839
846
|
};
|
|
840
847
|
var projection = (definition) => definition;
|
|
841
|
-
var inlineProjections = (definitions) => definitions.map((
|
|
842
|
-
|
|
848
|
+
var inlineProjections = (definitions) => definitions.map((definition) => ({
|
|
849
|
+
type: "inline",
|
|
850
|
+
projection: definition
|
|
851
|
+
}));
|
|
852
|
+
var asyncProjections = (definitions) => definitions.map((definition) => ({
|
|
853
|
+
type: "inline",
|
|
854
|
+
projection: definition
|
|
855
|
+
}));
|
|
843
856
|
var projections = {
|
|
844
857
|
inline: inlineProjections,
|
|
845
858
|
async: asyncProjections
|
|
@@ -922,9 +935,9 @@ var StringDecoder = (_class4 = class {
|
|
|
922
935
|
return null;
|
|
923
936
|
}
|
|
924
937
|
const delimiterIndex = completeString.indexOf("\n");
|
|
925
|
-
const
|
|
938
|
+
const message2 = completeString.slice(0, delimiterIndex).trim();
|
|
926
939
|
this.buffer = [completeString.slice(delimiterIndex + 1)];
|
|
927
|
-
return this.transform(
|
|
940
|
+
return this.transform(message2);
|
|
928
941
|
}
|
|
929
942
|
}, _class4);
|
|
930
943
|
|
|
@@ -1201,8 +1214,8 @@ var decodeAndTransform = (decoder, transform, controller) => {
|
|
|
1201
1214
|
|
|
1202
1215
|
// src/testing/assertions.ts
|
|
1203
1216
|
var AssertionError = class extends Error {
|
|
1204
|
-
constructor(
|
|
1205
|
-
super(
|
|
1217
|
+
constructor(message2) {
|
|
1218
|
+
super(message2);
|
|
1206
1219
|
}
|
|
1207
1220
|
};
|
|
1208
1221
|
var isSubset = (superObj, subObj) => {
|
|
@@ -1217,8 +1230,8 @@ var isSubset = (superObj, subObj) => {
|
|
|
1217
1230
|
return sub[ele] === sup[ele];
|
|
1218
1231
|
});
|
|
1219
1232
|
};
|
|
1220
|
-
var assertFails = (
|
|
1221
|
-
throw new AssertionError(_nullishCoalesce(
|
|
1233
|
+
var assertFails = (message2) => {
|
|
1234
|
+
throw new AssertionError(_nullishCoalesce(message2, () => ( "That should not ever happened, right?")));
|
|
1222
1235
|
};
|
|
1223
1236
|
var assertThrowsAsync = async (fun, errorCheck) => {
|
|
1224
1237
|
try {
|
|
@@ -1287,28 +1300,28 @@ var assertRejects = async (promise, errorCheck) => {
|
|
|
1287
1300
|
else assertTrue(errorCheck(error2));
|
|
1288
1301
|
}
|
|
1289
1302
|
};
|
|
1290
|
-
var assertMatches = (actual, expected,
|
|
1303
|
+
var assertMatches = (actual, expected, message2) => {
|
|
1291
1304
|
if (!isSubset(actual, expected))
|
|
1292
1305
|
throw new AssertionError(
|
|
1293
|
-
_nullishCoalesce(
|
|
1306
|
+
_nullishCoalesce(message2, () => ( `subObj:
|
|
1294
1307
|
${JSONParser.stringify(expected)}
|
|
1295
1308
|
is not subset of
|
|
1296
1309
|
${JSONParser.stringify(actual)}`))
|
|
1297
1310
|
);
|
|
1298
1311
|
};
|
|
1299
|
-
var assertDeepEqual = (actual, expected,
|
|
1312
|
+
var assertDeepEqual = (actual, expected, message2) => {
|
|
1300
1313
|
if (!deepEquals(actual, expected))
|
|
1301
1314
|
throw new AssertionError(
|
|
1302
|
-
_nullishCoalesce(
|
|
1315
|
+
_nullishCoalesce(message2, () => ( `subObj:
|
|
1303
1316
|
${JSONParser.stringify(expected)}
|
|
1304
1317
|
is not equal to
|
|
1305
1318
|
${JSONParser.stringify(actual)}`))
|
|
1306
1319
|
);
|
|
1307
1320
|
};
|
|
1308
|
-
var assertNotDeepEqual = (actual, expected,
|
|
1321
|
+
var assertNotDeepEqual = (actual, expected, message2) => {
|
|
1309
1322
|
if (deepEquals(actual, expected))
|
|
1310
1323
|
throw new AssertionError(
|
|
1311
|
-
_nullishCoalesce(
|
|
1324
|
+
_nullishCoalesce(message2, () => ( `subObj:
|
|
1312
1325
|
${JSONParser.stringify(expected)}
|
|
1313
1326
|
is equals to
|
|
1314
1327
|
${JSONParser.stringify(actual)}`))
|
|
@@ -1319,29 +1332,29 @@ var assertThat = (item) => {
|
|
|
1319
1332
|
isEqualTo: (other) => assertTrue(deepEquals(item, other))
|
|
1320
1333
|
};
|
|
1321
1334
|
};
|
|
1322
|
-
function assertFalse(condition,
|
|
1335
|
+
function assertFalse(condition, message2) {
|
|
1323
1336
|
if (condition !== false)
|
|
1324
|
-
throw new AssertionError(_nullishCoalesce(
|
|
1337
|
+
throw new AssertionError(_nullishCoalesce(message2, () => ( `Condition is true`)));
|
|
1325
1338
|
}
|
|
1326
|
-
function assertTrue(condition,
|
|
1339
|
+
function assertTrue(condition, message2) {
|
|
1327
1340
|
if (condition !== true)
|
|
1328
|
-
throw new AssertionError(_nullishCoalesce(
|
|
1341
|
+
throw new AssertionError(_nullishCoalesce(message2, () => ( `Condition is false`)));
|
|
1329
1342
|
}
|
|
1330
|
-
function assertOk(obj,
|
|
1331
|
-
if (!obj) throw new AssertionError(_nullishCoalesce(
|
|
1343
|
+
function assertOk(obj, message2) {
|
|
1344
|
+
if (!obj) throw new AssertionError(_nullishCoalesce(message2, () => ( `Condition is not truthy`)));
|
|
1332
1345
|
}
|
|
1333
|
-
function assertEqual(expected, actual,
|
|
1346
|
+
function assertEqual(expected, actual, message2) {
|
|
1334
1347
|
if (expected !== actual)
|
|
1335
1348
|
throw new AssertionError(
|
|
1336
|
-
`${_nullishCoalesce(
|
|
1349
|
+
`${_nullishCoalesce(message2, () => ( "Objects are not equal"))}:
|
|
1337
1350
|
Expected: ${JSONParser.stringify(expected)}
|
|
1338
1351
|
Actual: ${JSONParser.stringify(actual)}`
|
|
1339
1352
|
);
|
|
1340
1353
|
}
|
|
1341
|
-
function assertNotEqual(obj, other,
|
|
1354
|
+
function assertNotEqual(obj, other, message2) {
|
|
1342
1355
|
if (obj === other)
|
|
1343
1356
|
throw new AssertionError(
|
|
1344
|
-
_nullishCoalesce(
|
|
1357
|
+
_nullishCoalesce(message2, () => ( `Objects are equal: ${JSONParser.stringify(obj)}`))
|
|
1345
1358
|
);
|
|
1346
1359
|
}
|
|
1347
1360
|
function assertIsNotNull(result) {
|
|
@@ -1694,5 +1707,6 @@ var WrapEventStore = (eventStore) => {
|
|
|
1694
1707
|
|
|
1695
1708
|
|
|
1696
1709
|
|
|
1697
|
-
|
|
1710
|
+
|
|
1711
|
+
exports.AssertionError = AssertionError; exports.BinaryJsonDecoder = BinaryJsonDecoder; exports.CaughtUpTransformStream = CaughtUpTransformStream; exports.CommandHandler = CommandHandler; exports.CommandHandlerStreamVersionConflictRetryOptions = CommandHandlerStreamVersionConflictRetryOptions; exports.CompositeDecoder = CompositeDecoder; exports.ConcurrencyError = _chunkWM5VB4U5cjs.ConcurrencyError; exports.DeciderCommandHandler = DeciderCommandHandler; exports.DeciderSpecification = DeciderSpecification; exports.DefaultDecoder = DefaultDecoder; exports.EmmettError = _chunkWM5VB4U5cjs.EmmettError; exports.ExpectedVersionConflictError = ExpectedVersionConflictError; exports.GlobalStreamCaughtUpType = GlobalStreamCaughtUpType; exports.IllegalStateError = _chunkWM5VB4U5cjs.IllegalStateError; exports.InMemoryEventStoreDefaultStreamVersion = InMemoryEventStoreDefaultStreamVersion; exports.InProcessLock = InProcessLock; exports.JSONParser = JSONParser; exports.JsonDecoder = JsonDecoder; exports.NO_CONCURRENCY_CHECK = NO_CONCURRENCY_CHECK; exports.NoRetries = NoRetries; exports.NotFoundError = _chunkWM5VB4U5cjs.NotFoundError; exports.ObjectDecoder = ObjectDecoder; exports.ParseError = ParseError; exports.STREAM_DOES_NOT_EXIST = STREAM_DOES_NOT_EXIST; exports.STREAM_EXISTS = STREAM_EXISTS; exports.StreamingCoordinator = StreamingCoordinator; exports.StringDecoder = StringDecoder; exports.TaskProcessor = TaskProcessor; exports.ValidationError = _chunkWM5VB4U5cjs.ValidationError; exports.ValidationErrors = _chunkWM5VB4U5cjs.ValidationErrors; exports.WrapEventStore = WrapEventStore; exports.accept = accept; exports.argMatches = argMatches; exports.argValue = argValue; exports.arrayUtils = arrayUtils; exports.assertDeepEqual = assertDeepEqual; exports.assertDoesNotThrow = assertDoesNotThrow; exports.assertEqual = assertEqual; exports.assertExpectedVersionMatchesCurrent = assertExpectedVersionMatchesCurrent; exports.assertFails = assertFails; exports.assertFalse = assertFalse; exports.assertIsNotNull = assertIsNotNull; exports.assertIsNull = assertIsNull; exports.assertMatches = assertMatches; exports.assertNotDeepEqual = assertNotDeepEqual; exports.assertNotEmptyString = _chunkWM5VB4U5cjs.assertNotEmptyString; exports.assertNotEqual = assertNotEqual; exports.assertOk = assertOk; exports.assertPositiveNumber = _chunkWM5VB4U5cjs.assertPositiveNumber; exports.assertRejects = assertRejects; exports.assertThat = assertThat; exports.assertThatArray = assertThatArray; exports.assertThrows = assertThrows; exports.assertThrowsAsync = assertThrowsAsync; exports.assertTrue = assertTrue; exports.assertUnsignedBigInt = _chunkWM5VB4U5cjs.assertUnsignedBigInt; exports.asyncProjections = asyncProjections; exports.asyncRetry = asyncRetry; exports.canCreateEventStoreSession = canCreateEventStoreSession; exports.caughtUpEventFrom = caughtUpEventFrom; exports.collect = collect; exports.command = command; exports.complete = complete; exports.concatUint8Arrays = concatUint8Arrays; exports.deepEquals = deepEquals; exports.error = error; exports.event = event; exports.filterProjections = filterProjections; exports.formatDateToUtcYYYYMMDD = _chunkWM5VB4U5cjs.formatDateToUtcYYYYMMDD; exports.forwardToMessageBus = forwardToMessageBus; exports.getInMemoryDatabase = getInMemoryDatabase; exports.getInMemoryEventStore = getInMemoryEventStore; exports.getInMemoryMessageBus = getInMemoryMessageBus; exports.globalStreamCaughtUp = globalStreamCaughtUp; exports.ignore = ignore; exports.inlineProjections = inlineProjections; exports.isEquatable = isEquatable; exports.isErrorConstructor = _chunkWM5VB4U5cjs.isErrorConstructor; exports.isExpectedVersionConflictError = isExpectedVersionConflictError; exports.isGlobalStreamCaughtUp = isGlobalStreamCaughtUp; exports.isNotInternalEvent = isNotInternalEvent; exports.isNumber = _chunkWM5VB4U5cjs.isNumber; exports.isPluginConfig = _chunkWM5VB4U5cjs.isPluginConfig; exports.isString = _chunkWM5VB4U5cjs.isString; exports.isSubscriptionEvent = isSubscriptionEvent; exports.isSubset = isSubset; exports.isValidYYYYMMDD = _chunkWM5VB4U5cjs.isValidYYYYMMDD; exports.matchesExpectedVersion = matchesExpectedVersion; exports.merge = merge; exports.message = message; exports.nulloSessionFactory = nulloSessionFactory; exports.parseDateFromUtcYYYYMMDD = _chunkWM5VB4U5cjs.parseDateFromUtcYYYYMMDD; exports.projection = projection; exports.projections = projections; exports.publish = publish; exports.reply = reply; exports.restream = restream; exports.schedule = schedule; exports.send = send; exports.streamGenerators = streamGenerators; exports.streamTrackingGlobalPosition = streamTrackingGlobalPosition; exports.streamTransformations = streamTransformations; exports.sum = sum; exports.tryPublishMessagesAfterCommit = tryPublishMessagesAfterCommit; exports.verifyThat = verifyThat;
|
|
1698
1712
|
//# sourceMappingURL=index.cjs.map
|