@event-driven-io/emmett 0.31.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 +46 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -33
- package/dist/index.d.ts +60 -33
- package/dist/index.js +45 -37
- 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(
|
|
@@ -928,9 +935,9 @@ var StringDecoder = (_class4 = class {
|
|
|
928
935
|
return null;
|
|
929
936
|
}
|
|
930
937
|
const delimiterIndex = completeString.indexOf("\n");
|
|
931
|
-
const
|
|
938
|
+
const message2 = completeString.slice(0, delimiterIndex).trim();
|
|
932
939
|
this.buffer = [completeString.slice(delimiterIndex + 1)];
|
|
933
|
-
return this.transform(
|
|
940
|
+
return this.transform(message2);
|
|
934
941
|
}
|
|
935
942
|
}, _class4);
|
|
936
943
|
|
|
@@ -1207,8 +1214,8 @@ var decodeAndTransform = (decoder, transform, controller) => {
|
|
|
1207
1214
|
|
|
1208
1215
|
// src/testing/assertions.ts
|
|
1209
1216
|
var AssertionError = class extends Error {
|
|
1210
|
-
constructor(
|
|
1211
|
-
super(
|
|
1217
|
+
constructor(message2) {
|
|
1218
|
+
super(message2);
|
|
1212
1219
|
}
|
|
1213
1220
|
};
|
|
1214
1221
|
var isSubset = (superObj, subObj) => {
|
|
@@ -1223,8 +1230,8 @@ var isSubset = (superObj, subObj) => {
|
|
|
1223
1230
|
return sub[ele] === sup[ele];
|
|
1224
1231
|
});
|
|
1225
1232
|
};
|
|
1226
|
-
var assertFails = (
|
|
1227
|
-
throw new AssertionError(_nullishCoalesce(
|
|
1233
|
+
var assertFails = (message2) => {
|
|
1234
|
+
throw new AssertionError(_nullishCoalesce(message2, () => ( "That should not ever happened, right?")));
|
|
1228
1235
|
};
|
|
1229
1236
|
var assertThrowsAsync = async (fun, errorCheck) => {
|
|
1230
1237
|
try {
|
|
@@ -1293,28 +1300,28 @@ var assertRejects = async (promise, errorCheck) => {
|
|
|
1293
1300
|
else assertTrue(errorCheck(error2));
|
|
1294
1301
|
}
|
|
1295
1302
|
};
|
|
1296
|
-
var assertMatches = (actual, expected,
|
|
1303
|
+
var assertMatches = (actual, expected, message2) => {
|
|
1297
1304
|
if (!isSubset(actual, expected))
|
|
1298
1305
|
throw new AssertionError(
|
|
1299
|
-
_nullishCoalesce(
|
|
1306
|
+
_nullishCoalesce(message2, () => ( `subObj:
|
|
1300
1307
|
${JSONParser.stringify(expected)}
|
|
1301
1308
|
is not subset of
|
|
1302
1309
|
${JSONParser.stringify(actual)}`))
|
|
1303
1310
|
);
|
|
1304
1311
|
};
|
|
1305
|
-
var assertDeepEqual = (actual, expected,
|
|
1312
|
+
var assertDeepEqual = (actual, expected, message2) => {
|
|
1306
1313
|
if (!deepEquals(actual, expected))
|
|
1307
1314
|
throw new AssertionError(
|
|
1308
|
-
_nullishCoalesce(
|
|
1315
|
+
_nullishCoalesce(message2, () => ( `subObj:
|
|
1309
1316
|
${JSONParser.stringify(expected)}
|
|
1310
1317
|
is not equal to
|
|
1311
1318
|
${JSONParser.stringify(actual)}`))
|
|
1312
1319
|
);
|
|
1313
1320
|
};
|
|
1314
|
-
var assertNotDeepEqual = (actual, expected,
|
|
1321
|
+
var assertNotDeepEqual = (actual, expected, message2) => {
|
|
1315
1322
|
if (deepEquals(actual, expected))
|
|
1316
1323
|
throw new AssertionError(
|
|
1317
|
-
_nullishCoalesce(
|
|
1324
|
+
_nullishCoalesce(message2, () => ( `subObj:
|
|
1318
1325
|
${JSONParser.stringify(expected)}
|
|
1319
1326
|
is equals to
|
|
1320
1327
|
${JSONParser.stringify(actual)}`))
|
|
@@ -1325,29 +1332,29 @@ var assertThat = (item) => {
|
|
|
1325
1332
|
isEqualTo: (other) => assertTrue(deepEquals(item, other))
|
|
1326
1333
|
};
|
|
1327
1334
|
};
|
|
1328
|
-
function assertFalse(condition,
|
|
1335
|
+
function assertFalse(condition, message2) {
|
|
1329
1336
|
if (condition !== false)
|
|
1330
|
-
throw new AssertionError(_nullishCoalesce(
|
|
1337
|
+
throw new AssertionError(_nullishCoalesce(message2, () => ( `Condition is true`)));
|
|
1331
1338
|
}
|
|
1332
|
-
function assertTrue(condition,
|
|
1339
|
+
function assertTrue(condition, message2) {
|
|
1333
1340
|
if (condition !== true)
|
|
1334
|
-
throw new AssertionError(_nullishCoalesce(
|
|
1341
|
+
throw new AssertionError(_nullishCoalesce(message2, () => ( `Condition is false`)));
|
|
1335
1342
|
}
|
|
1336
|
-
function assertOk(obj,
|
|
1337
|
-
if (!obj) throw new AssertionError(_nullishCoalesce(
|
|
1343
|
+
function assertOk(obj, message2) {
|
|
1344
|
+
if (!obj) throw new AssertionError(_nullishCoalesce(message2, () => ( `Condition is not truthy`)));
|
|
1338
1345
|
}
|
|
1339
|
-
function assertEqual(expected, actual,
|
|
1346
|
+
function assertEqual(expected, actual, message2) {
|
|
1340
1347
|
if (expected !== actual)
|
|
1341
1348
|
throw new AssertionError(
|
|
1342
|
-
`${_nullishCoalesce(
|
|
1349
|
+
`${_nullishCoalesce(message2, () => ( "Objects are not equal"))}:
|
|
1343
1350
|
Expected: ${JSONParser.stringify(expected)}
|
|
1344
1351
|
Actual: ${JSONParser.stringify(actual)}`
|
|
1345
1352
|
);
|
|
1346
1353
|
}
|
|
1347
|
-
function assertNotEqual(obj, other,
|
|
1354
|
+
function assertNotEqual(obj, other, message2) {
|
|
1348
1355
|
if (obj === other)
|
|
1349
1356
|
throw new AssertionError(
|
|
1350
|
-
_nullishCoalesce(
|
|
1357
|
+
_nullishCoalesce(message2, () => ( `Objects are equal: ${JSONParser.stringify(obj)}`))
|
|
1351
1358
|
);
|
|
1352
1359
|
}
|
|
1353
1360
|
function assertIsNotNull(result) {
|
|
@@ -1700,5 +1707,6 @@ var WrapEventStore = (eventStore) => {
|
|
|
1700
1707
|
|
|
1701
1708
|
|
|
1702
1709
|
|
|
1703
|
-
|
|
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;
|
|
1704
1712
|
//# sourceMappingURL=index.cjs.map
|