@schorts/shared-kernel 8.1.0 → 8.2.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.
- package/README.md +1 -1
- package/dist/cjs/cqrs/async/async-command-handler.js +3 -0
- package/dist/cjs/cqrs/async/async-command-handler.js.map +1 -0
- package/dist/cjs/cqrs/async/index.js +3 -0
- package/dist/cjs/cqrs/async/index.js.map +1 -0
- package/dist/cjs/cqrs/in-memory/async/async-in-memory-command-bus.js +19 -0
- package/dist/cjs/cqrs/in-memory/async/async-in-memory-command-bus.js.map +1 -0
- package/dist/cjs/cqrs/in-memory/async/async-in-memory-query-bus.js +19 -0
- package/dist/cjs/cqrs/in-memory/async/async-in-memory-query-bus.js.map +1 -0
- package/dist/cjs/cqrs/in-memory/async/index.js +8 -0
- package/dist/cjs/cqrs/in-memory/async/index.js.map +1 -0
- package/dist/cjs/cqrs/in-memory/index.js +16 -5
- package/dist/cjs/cqrs/in-memory/index.js.map +1 -1
- package/dist/cjs/cqrs/in-memory/sync/index.js +8 -0
- package/dist/cjs/cqrs/in-memory/sync/index.js.map +1 -0
- package/dist/cjs/cqrs/in-memory/sync/sync-in-memory-command-bus.js +19 -0
- package/dist/cjs/cqrs/in-memory/sync/sync-in-memory-command-bus.js.map +1 -0
- package/dist/cjs/cqrs/in-memory/sync/sync-in-memory-query-bus.js +19 -0
- package/dist/cjs/cqrs/in-memory/sync/sync-in-memory-query-bus.js.map +1 -0
- package/dist/cjs/domain-events/domain-event.js.map +1 -1
- package/dist/cjs/event-bus/in-memory/async/async-in-memory-dead-letter-store.js +17 -0
- package/dist/cjs/event-bus/in-memory/async/async-in-memory-dead-letter-store.js.map +1 -0
- package/dist/cjs/event-bus/in-memory/async/async-in-memory-event-bus.js +65 -0
- package/dist/cjs/event-bus/in-memory/async/async-in-memory-event-bus.js.map +1 -0
- package/dist/cjs/event-bus/in-memory/async/async-in-memory-event-store.js +25 -0
- package/dist/cjs/event-bus/in-memory/async/async-in-memory-event-store.js.map +1 -0
- package/dist/cjs/event-bus/in-memory/async/index.js +10 -0
- package/dist/cjs/event-bus/in-memory/async/index.js.map +1 -0
- package/dist/cjs/event-bus/in-memory/index.js +16 -7
- package/dist/cjs/event-bus/in-memory/index.js.map +1 -1
- package/dist/cjs/event-bus/in-memory/sync/index.js +10 -0
- package/dist/cjs/event-bus/in-memory/sync/index.js.map +1 -0
- package/dist/cjs/event-bus/in-memory/sync/sync-in-memory-dead-letter-store.js +17 -0
- package/dist/cjs/event-bus/in-memory/sync/sync-in-memory-dead-letter-store.js.map +1 -0
- package/dist/cjs/event-bus/in-memory/sync/sync-in-memory-event-bus.js +65 -0
- package/dist/cjs/event-bus/in-memory/sync/sync-in-memory-event-bus.js.map +1 -0
- package/dist/cjs/event-bus/in-memory/sync/sync-in-memory-event-store.js +25 -0
- package/dist/cjs/event-bus/in-memory/sync/sync-in-memory-event-store.js.map +1 -0
- package/dist/esm/cqrs/async/async-command-handler.js +3 -0
- package/dist/esm/cqrs/async/async-command-handler.js.map +1 -0
- package/dist/esm/cqrs/async/index.js +3 -0
- package/dist/esm/cqrs/async/index.js.map +1 -0
- package/dist/esm/cqrs/in-memory/async/async-in-memory-command-bus.js +19 -0
- package/dist/esm/cqrs/in-memory/async/async-in-memory-command-bus.js.map +1 -0
- package/dist/esm/cqrs/in-memory/async/async-in-memory-query-bus.js +19 -0
- package/dist/esm/cqrs/in-memory/async/async-in-memory-query-bus.js.map +1 -0
- package/dist/esm/cqrs/in-memory/async/index.js +8 -0
- package/dist/esm/cqrs/in-memory/async/index.js.map +1 -0
- package/dist/esm/cqrs/in-memory/index.js +16 -5
- package/dist/esm/cqrs/in-memory/index.js.map +1 -1
- package/dist/esm/cqrs/in-memory/sync/index.js +8 -0
- package/dist/esm/cqrs/in-memory/sync/index.js.map +1 -0
- package/dist/esm/cqrs/in-memory/sync/sync-in-memory-command-bus.js +19 -0
- package/dist/esm/cqrs/in-memory/sync/sync-in-memory-command-bus.js.map +1 -0
- package/dist/esm/cqrs/in-memory/sync/sync-in-memory-query-bus.js +19 -0
- package/dist/esm/cqrs/in-memory/sync/sync-in-memory-query-bus.js.map +1 -0
- package/dist/esm/domain-events/domain-event.js.map +1 -1
- package/dist/esm/event-bus/in-memory/async/async-in-memory-dead-letter-store.js +17 -0
- package/dist/esm/event-bus/in-memory/async/async-in-memory-dead-letter-store.js.map +1 -0
- package/dist/esm/event-bus/in-memory/async/async-in-memory-event-bus.js +65 -0
- package/dist/esm/event-bus/in-memory/async/async-in-memory-event-bus.js.map +1 -0
- package/dist/esm/event-bus/in-memory/async/async-in-memory-event-store.js +25 -0
- package/dist/esm/event-bus/in-memory/async/async-in-memory-event-store.js.map +1 -0
- package/dist/esm/event-bus/in-memory/async/index.js +10 -0
- package/dist/esm/event-bus/in-memory/async/index.js.map +1 -0
- package/dist/esm/event-bus/in-memory/index.js +16 -7
- package/dist/esm/event-bus/in-memory/index.js.map +1 -1
- package/dist/esm/event-bus/in-memory/sync/index.js +10 -0
- package/dist/esm/event-bus/in-memory/sync/index.js.map +1 -0
- package/dist/esm/event-bus/in-memory/sync/sync-in-memory-dead-letter-store.js +17 -0
- package/dist/esm/event-bus/in-memory/sync/sync-in-memory-dead-letter-store.js.map +1 -0
- package/dist/esm/event-bus/in-memory/sync/sync-in-memory-event-bus.js +65 -0
- package/dist/esm/event-bus/in-memory/sync/sync-in-memory-event-bus.js.map +1 -0
- package/dist/esm/event-bus/in-memory/sync/sync-in-memory-event-store.js +25 -0
- package/dist/esm/event-bus/in-memory/sync/sync-in-memory-event-store.js.map +1 -0
- package/dist/types/cqrs/async/async-command-handler.d.ts +5 -0
- package/dist/types/cqrs/async/async-command-handler.d.ts.map +1 -0
- package/dist/types/cqrs/async/index.d.ts +2 -0
- package/dist/types/cqrs/async/index.d.ts.map +1 -0
- package/dist/types/cqrs/in-memory/async/async-in-memory-command-bus.d.ts +7 -0
- package/dist/types/cqrs/in-memory/async/async-in-memory-command-bus.d.ts.map +1 -0
- package/dist/types/cqrs/in-memory/async/async-in-memory-query-bus.d.ts +7 -0
- package/dist/types/cqrs/in-memory/async/async-in-memory-query-bus.d.ts.map +1 -0
- package/dist/types/cqrs/in-memory/async/index.d.ts +3 -0
- package/dist/types/cqrs/in-memory/async/index.d.ts.map +1 -0
- package/dist/types/cqrs/in-memory/index.d.ts +2 -2
- package/dist/types/cqrs/in-memory/index.d.ts.map +1 -1
- package/dist/types/cqrs/in-memory/sync/index.d.ts +3 -0
- package/dist/types/cqrs/in-memory/sync/index.d.ts.map +1 -0
- package/dist/types/cqrs/in-memory/sync/sync-in-memory-command-bus.d.ts +7 -0
- package/dist/types/cqrs/in-memory/sync/sync-in-memory-command-bus.d.ts.map +1 -0
- package/dist/types/cqrs/in-memory/sync/sync-in-memory-query-bus.d.ts +7 -0
- package/dist/types/cqrs/in-memory/sync/sync-in-memory-query-bus.d.ts.map +1 -0
- package/dist/types/domain-events/domain-event.d.ts +1 -1
- package/dist/types/domain-events/domain-event.d.ts.map +1 -1
- package/dist/types/event-bus/in-memory/async/async-in-memory-dead-letter-store.d.ts +12 -0
- package/dist/types/event-bus/in-memory/async/async-in-memory-dead-letter-store.d.ts.map +1 -0
- package/dist/types/event-bus/in-memory/async/async-in-memory-event-bus.d.ts +17 -0
- package/dist/types/event-bus/in-memory/async/async-in-memory-event-bus.d.ts.map +1 -0
- package/dist/types/event-bus/in-memory/async/async-in-memory-event-store.d.ts +11 -0
- package/dist/types/event-bus/in-memory/async/async-in-memory-event-store.d.ts.map +1 -0
- package/dist/types/event-bus/in-memory/async/index.d.ts +4 -0
- package/dist/types/event-bus/in-memory/async/index.d.ts.map +1 -0
- package/dist/types/event-bus/in-memory/index.d.ts +2 -3
- package/dist/types/event-bus/in-memory/index.d.ts.map +1 -1
- package/dist/types/event-bus/in-memory/sync/index.d.ts +4 -0
- package/dist/types/event-bus/in-memory/sync/index.d.ts.map +1 -0
- package/dist/types/event-bus/in-memory/sync/sync-in-memory-dead-letter-store.d.ts +12 -0
- package/dist/types/event-bus/in-memory/sync/sync-in-memory-dead-letter-store.d.ts.map +1 -0
- package/dist/types/event-bus/in-memory/sync/sync-in-memory-event-bus.d.ts +17 -0
- package/dist/types/event-bus/in-memory/sync/sync-in-memory-event-bus.d.ts.map +1 -0
- package/dist/types/event-bus/in-memory/sync/sync-in-memory-event-store.d.ts +11 -0
- package/dist/types/event-bus/in-memory/sync/sync-in-memory-event-store.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ npm install @schorts/shared-kernel --save
|
|
|
35
35
|
|
|
36
36
|
### 🔁 Event Bus
|
|
37
37
|
|
|
38
|
-
- **
|
|
38
|
+
- **InMemoryEventBus:** Lightweight, in-memory event dispatcher with support for retries, acknowledgments, and requeueing. Designed for testing, local development, or as a foundation for more robust event-driven architectures.
|
|
39
39
|
- **DomainEventRegistry:** Centralized registry for hydrating polymorphic domain events from serialized primitives.
|
|
40
40
|
- **EventSubscriber:** Interface for subscribing to specific event types with clean, type-safe handlers.
|
|
41
41
|
- **InMemoryEventStore:** Simple event store for tracking and replaying events, with retry metadata and bounded requeue support.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-command-handler.js","sourceRoot":"","sources":["../../../../src/cqrs/async/async-command-handler.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cqrs/async/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncInMemoryCommandBus = void 0;
|
|
4
|
+
const index_1 = require("../../index");
|
|
5
|
+
class AsyncInMemoryCommandBus {
|
|
6
|
+
handlers = new Map();
|
|
7
|
+
register(type, handler) {
|
|
8
|
+
this.handlers.set(type, handler);
|
|
9
|
+
}
|
|
10
|
+
async dispatch(command) {
|
|
11
|
+
const handler = this.handlers.get(command.getType());
|
|
12
|
+
if (!handler) {
|
|
13
|
+
throw new index_1.CommandNotRegistered(command.getType());
|
|
14
|
+
}
|
|
15
|
+
return handler.handle(command);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.AsyncInMemoryCommandBus = AsyncInMemoryCommandBus;
|
|
19
|
+
//# sourceMappingURL=async-in-memory-command-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-in-memory-command-bus.js","sourceRoot":"","sources":["../../../../../src/cqrs/in-memory/async/async-in-memory-command-bus.ts"],"names":[],"mappings":";;;AAAA,uCAAwF;AAExF,MAAa,uBAAuB;IACjB,QAAQ,GAAG,IAAI,GAAG,EAA4C,CAAC;IAEhF,QAAQ,CAA8B,IAAY,EAAE,OAA6B;QAC/E,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,QAAQ,CAA8B,OAAU;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,CAAqC,CAAC;QAEzF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,4BAAoB,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACpD,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;CACF;AAhBD,0DAgBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncInMemoryQueryBus = void 0;
|
|
4
|
+
const index_1 = require("../../index");
|
|
5
|
+
class AsyncInMemoryQueryBus {
|
|
6
|
+
handlers = new Map();
|
|
7
|
+
register(type, handler) {
|
|
8
|
+
this.handlers.set(type, handler);
|
|
9
|
+
}
|
|
10
|
+
async dispatch(query) {
|
|
11
|
+
const handler = this.handlers.get(query.getType());
|
|
12
|
+
if (!handler) {
|
|
13
|
+
throw new index_1.QueryNotRegistered(query.getType());
|
|
14
|
+
}
|
|
15
|
+
return await handler.handle(query);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.AsyncInMemoryQueryBus = AsyncInMemoryQueryBus;
|
|
19
|
+
//# sourceMappingURL=async-in-memory-query-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-in-memory-query-bus.js","sourceRoot":"","sources":["../../../../../src/cqrs/in-memory/async/async-in-memory-query-bus.ts"],"names":[],"mappings":";;;AAAA,uCAAgF;AAEhF,MAAa,qBAAqB;IACf,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAAC;IAE5D,QAAQ,CAAqB,IAAY,EAAE,OAA2B;QACpE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAqB,KAAQ;QACzC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,CAAmC,CAAC;QAErF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,0BAAkB,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;CACF;AAhBD,sDAgBC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncInMemoryQueryBus = exports.AsyncInMemoryCommandBus = void 0;
|
|
4
|
+
var async_in_memory_command_bus_1 = require("./async-in-memory-command-bus");
|
|
5
|
+
Object.defineProperty(exports, "AsyncInMemoryCommandBus", { enumerable: true, get: function () { return async_in_memory_command_bus_1.AsyncInMemoryCommandBus; } });
|
|
6
|
+
var async_in_memory_query_bus_1 = require("./async-in-memory-query-bus");
|
|
7
|
+
Object.defineProperty(exports, "AsyncInMemoryQueryBus", { enumerable: true, get: function () { return async_in_memory_query_bus_1.AsyncInMemoryQueryBus; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/cqrs/in-memory/async/index.ts"],"names":[],"mappings":";;;AAAA,6EAAwE;AAA/D,sIAAA,uBAAuB,OAAA;AAChC,yEAAoE;AAA3D,kIAAA,qBAAqB,OAAA"}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "AsyncInMemoryCommandBus", { enumerable: true, get: function () { return async_in_memory_command_bus_1.AsyncInMemoryCommandBus; } });
|
|
6
|
-
var async_in_memory_query_bus_1 = require("./async-in-memory-query-bus");
|
|
7
|
-
Object.defineProperty(exports, "AsyncInMemoryQueryBus", { enumerable: true, get: function () { return async_in_memory_query_bus_1.AsyncInMemoryQueryBus; } });
|
|
17
|
+
__exportStar(require("./async"), exports);
|
|
18
|
+
__exportStar(require("./sync"), exports);
|
|
8
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cqrs/in-memory/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cqrs/in-memory/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,yCAAuB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SyncInMemoryQueryBus = exports.SyncInMemoryCommandBus = void 0;
|
|
4
|
+
var sync_in_memory_command_bus_1 = require("./sync-in-memory-command-bus");
|
|
5
|
+
Object.defineProperty(exports, "SyncInMemoryCommandBus", { enumerable: true, get: function () { return sync_in_memory_command_bus_1.SyncInMemoryCommandBus; } });
|
|
6
|
+
var sync_in_memory_query_bus_1 = require("./sync-in-memory-query-bus");
|
|
7
|
+
Object.defineProperty(exports, "SyncInMemoryQueryBus", { enumerable: true, get: function () { return sync_in_memory_query_bus_1.SyncInMemoryQueryBus; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/cqrs/in-memory/sync/index.ts"],"names":[],"mappings":";;;AAAA,2EAAsE;AAA7D,oIAAA,sBAAsB,OAAA;AAC/B,uEAAkE;AAAzD,gIAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SyncInMemoryCommandBus = void 0;
|
|
4
|
+
const index_1 = require("../../index");
|
|
5
|
+
class SyncInMemoryCommandBus {
|
|
6
|
+
handlers = new Map();
|
|
7
|
+
register(type, handler) {
|
|
8
|
+
this.handlers.set(type, handler);
|
|
9
|
+
}
|
|
10
|
+
async dispatch(command) {
|
|
11
|
+
const handler = this.handlers.get(command.getType());
|
|
12
|
+
if (!handler) {
|
|
13
|
+
throw new index_1.CommandNotRegistered(command.getType());
|
|
14
|
+
}
|
|
15
|
+
return handler.handle(command);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.SyncInMemoryCommandBus = SyncInMemoryCommandBus;
|
|
19
|
+
//# sourceMappingURL=sync-in-memory-command-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-in-memory-command-bus.js","sourceRoot":"","sources":["../../../../../src/cqrs/in-memory/sync/sync-in-memory-command-bus.ts"],"names":[],"mappings":";;;AAAA,uCAAwF;AAExF,MAAa,sBAAsB;IAChB,QAAQ,GAAG,IAAI,GAAG,EAA4C,CAAC;IAEhF,QAAQ,CAA8B,IAAY,EAAE,OAA6B;QAC/E,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,QAAQ,CAA8B,OAAU;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,CAAqC,CAAC;QAEzF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,4BAAoB,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACpD,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;CACF;AAhBD,wDAgBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SyncInMemoryQueryBus = void 0;
|
|
4
|
+
const index_1 = require("../../index");
|
|
5
|
+
class SyncInMemoryQueryBus {
|
|
6
|
+
handlers = new Map();
|
|
7
|
+
register(type, handler) {
|
|
8
|
+
this.handlers.set(type, handler);
|
|
9
|
+
}
|
|
10
|
+
async dispatch(query) {
|
|
11
|
+
const handler = this.handlers.get(query.getType());
|
|
12
|
+
if (!handler) {
|
|
13
|
+
throw new index_1.QueryNotRegistered(query.getType());
|
|
14
|
+
}
|
|
15
|
+
return await handler.handle(query);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.SyncInMemoryQueryBus = SyncInMemoryQueryBus;
|
|
19
|
+
//# sourceMappingURL=sync-in-memory-query-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-in-memory-query-bus.js","sourceRoot":"","sources":["../../../../../src/cqrs/in-memory/sync/sync-in-memory-query-bus.ts"],"names":[],"mappings":";;;AAAA,uCAAgF;AAEhF,MAAa,oBAAoB;IACd,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAAC;IAE5D,QAAQ,CAAqB,IAAY,EAAE,OAA2B;QACpE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAqB,KAAQ;QACzC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,CAAmC,CAAC;QAErF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,0BAAkB,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;CACF;AAhBD,oDAgBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-event.js","sourceRoot":"","sources":["../../../src/domain-events/domain-event.ts"],"names":[],"mappings":";;;AAEA,MAAsB,WAAW;IAEpB;IACA;IACA;IACA;IACA;IACF;IANT,YACW,EAAU,EACV,UAAgB,EAChB,IAAY,EACZ,OAAe,EACf,OAAsB,EACxB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE;QALnB,OAAE,GAAF,EAAE,CAAQ;QACV,eAAU,GAAV,UAAU,CAAM;QAChB,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAe;QACxB,SAAI,GAAJ,IAAI,CAAiB;IAC3B,CAAC;IAIJ,YAAY;QACV,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE;YACvC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;IACJ,CAAC;IAED,GAAG,CAAc;IACjB,OAAO,
|
|
1
|
+
{"version":3,"file":"domain-event.js","sourceRoot":"","sources":["../../../src/domain-events/domain-event.ts"],"names":[],"mappings":";;;AAEA,MAAsB,WAAW;IAEpB;IACA;IACA;IACA;IACA;IACF;IANT,YACW,EAAU,EACV,UAAgB,EAChB,IAAY,EACZ,OAAe,EACf,OAAsB,EACxB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE;QALnB,OAAE,GAAF,EAAE,CAAQ;QACV,eAAU,GAAV,UAAU,CAAM;QAChB,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAe;QACxB,SAAI,GAAJ,IAAI,CAAiB;IAC3B,CAAC;IAIJ,YAAY;QACV,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE;YACvC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;IACJ,CAAC;IAED,GAAG,CAAc;IACjB,OAAO,CAA2B;CACnC;AAzBD,kCAyBC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncInMemoryDeadLetterStore = void 0;
|
|
4
|
+
class AsyncInMemoryDeadLetterStore {
|
|
5
|
+
failed = [];
|
|
6
|
+
async add(primitives, reason) {
|
|
7
|
+
this.failed.push({ primitives, reason });
|
|
8
|
+
}
|
|
9
|
+
async all() {
|
|
10
|
+
return [...this.failed];
|
|
11
|
+
}
|
|
12
|
+
async clear() {
|
|
13
|
+
this.failed.length = 0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.AsyncInMemoryDeadLetterStore = AsyncInMemoryDeadLetterStore;
|
|
17
|
+
//# sourceMappingURL=async-in-memory-dead-letter-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-in-memory-dead-letter-store.js","sourceRoot":"","sources":["../../../../../src/event-bus/in-memory/async/async-in-memory-dead-letter-store.ts"],"names":[],"mappings":";;;AAGA,MAAa,4BAA4B;IACtB,MAAM,GAAiE,EAAE,CAAC;IAE3F,KAAK,CAAC,GAAG,CAAC,UAAiC,EAAE,MAAc;QACzD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,GAAG;QACP,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACzB,CAAC;CACF;AAdD,oEAcC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncInMemoryEventBus = void 0;
|
|
4
|
+
const domain_events_1 = require("../../../domain-events");
|
|
5
|
+
const async_in_memory_event_store_1 = require("./async-in-memory-event-store");
|
|
6
|
+
class AsyncInMemoryEventBus {
|
|
7
|
+
subscribers = new Map();
|
|
8
|
+
store;
|
|
9
|
+
maxRetries;
|
|
10
|
+
deadLetterStore;
|
|
11
|
+
constructor(store = new async_in_memory_event_store_1.AsyncInMemoryEventStore(), maxRetries = 3, deadLetterStore) {
|
|
12
|
+
this.store = store;
|
|
13
|
+
this.maxRetries = maxRetries;
|
|
14
|
+
this.deadLetterStore = deadLetterStore;
|
|
15
|
+
}
|
|
16
|
+
subscribe(eventName, subscriber) {
|
|
17
|
+
if (!this.subscribers.has(eventName)) {
|
|
18
|
+
this.subscribers.set(eventName, []);
|
|
19
|
+
}
|
|
20
|
+
this.subscribers.get(eventName).push(subscriber);
|
|
21
|
+
}
|
|
22
|
+
async publish(event) {
|
|
23
|
+
const primitives = event.toPrimitives();
|
|
24
|
+
this.store.save(primitives);
|
|
25
|
+
await this.dispatch(event);
|
|
26
|
+
}
|
|
27
|
+
async dispatch(event) {
|
|
28
|
+
const eventName = event.getEventName();
|
|
29
|
+
const subs = this.subscribers.get(eventName) ?? [];
|
|
30
|
+
const primitives = event.toPrimitives();
|
|
31
|
+
event.ack = () => this.store.delete(event.id);
|
|
32
|
+
event.requeue = (error) => {
|
|
33
|
+
event.ack?.();
|
|
34
|
+
if (event.meta.retries < this.maxRetries) {
|
|
35
|
+
const updatedPrimitives = {
|
|
36
|
+
...primitives,
|
|
37
|
+
meta: { ...primitives.meta, retries: event.meta.retries + 1 },
|
|
38
|
+
};
|
|
39
|
+
this.store.requeue(updatedPrimitives);
|
|
40
|
+
this.publish(domain_events_1.DomainEventRegistry.create(updatedPrimitives));
|
|
41
|
+
}
|
|
42
|
+
else if (this.deadLetterStore) {
|
|
43
|
+
const reason = error ? error.message : `Exceeded max retries (${this.maxRetries})`;
|
|
44
|
+
this.deadLetterStore.add(primitives, reason);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
for (const sub of subs) {
|
|
48
|
+
try {
|
|
49
|
+
await sub.handle(event);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
event.requeue?.(err);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async replay() {
|
|
57
|
+
const events = await this.store.all();
|
|
58
|
+
for (const primitives of events) {
|
|
59
|
+
const event = domain_events_1.DomainEventRegistry.create(primitives);
|
|
60
|
+
await this.dispatch(event);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.AsyncInMemoryEventBus = AsyncInMemoryEventBus;
|
|
65
|
+
//# sourceMappingURL=async-in-memory-event-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-in-memory-event-bus.js","sourceRoot":"","sources":["../../../../../src/event-bus/in-memory/async/async-in-memory-event-bus.ts"],"names":[],"mappings":";;;AAAA,0DAA0E;AAC1E,+EAAwE;AAMxE,MAAa,qBAAqB;IACf,WAAW,GAAG,IAAI,GAAG,EAA6B,CAAC;IACnD,KAAK,CAAmB;IACxB,UAAU,CAAS;IACnB,eAAe,CAA8B;IAE9D,YACE,QAA0B,IAAI,qDAAuB,EAAE,EACvD,UAAU,GAAG,CAAC,EACd,eAAiC;QAEjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAED,SAAS,CAA4B,SAAiB,EAAE,UAAkC;QACxF,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE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AAC,iBAAiB,CAAC,CAAC,CAAC;YAC9D,CAAC;iBAAM,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;gBAChC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,yBAAyB,IAAI,CAAC,UAAU,GAAG,CAAC;gBAEnF,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,CAAC;gBACH,MAAM,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC1B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,KAAK,CAAC,OAAO,EAAE,CAAC,GAAY,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAEtC,KAAK,MAAM,UAAU,IAAI,MAAM,EAAE,CAAC;YAChC,MAAM,KAAK,GAAG,mCAAmB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAErD,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;CACF;AA1ED,sDA0EC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncInMemoryEventStore = void 0;
|
|
4
|
+
class AsyncInMemoryEventStore {
|
|
5
|
+
events = [];
|
|
6
|
+
async save(primitives) {
|
|
7
|
+
this.events.push(primitives);
|
|
8
|
+
}
|
|
9
|
+
async all() {
|
|
10
|
+
return [...this.events];
|
|
11
|
+
}
|
|
12
|
+
async delete(id) {
|
|
13
|
+
const index = this.events.findIndex(e => e.id === id);
|
|
14
|
+
if (index !== -1)
|
|
15
|
+
this.events.splice(index, 1);
|
|
16
|
+
}
|
|
17
|
+
async requeue(primitives) {
|
|
18
|
+
this.events.push(primitives);
|
|
19
|
+
}
|
|
20
|
+
async clear() {
|
|
21
|
+
this.events.length = 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.AsyncInMemoryEventStore = AsyncInMemoryEventStore;
|
|
25
|
+
//# sourceMappingURL=async-in-memory-event-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-in-memory-event-store.js","sourceRoot":"","sources":["../../../../../src/event-bus/in-memory/async/async-in-memory-event-store.ts"],"names":[],"mappings":";;;AAGA,MAAa,uBAAuB;IACjB,MAAM,GAA4B,EAAE,CAAC;IAEtD,KAAK,CAAC,IAAI,CAAC,UAAiC;QAC1C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,GAAG;QACP,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAEtD,IAAI,KAAK,KAAK,CAAC,CAAC;YAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAAiC;QAC7C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACzB,CAAC;CACF;AAxBD,0DAwBC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncInMemoryDeadLetterStore = exports.AsyncInMemoryEventBus = exports.AsyncInMemoryEventStore = void 0;
|
|
4
|
+
var async_in_memory_event_store_1 = require("./async-in-memory-event-store");
|
|
5
|
+
Object.defineProperty(exports, "AsyncInMemoryEventStore", { enumerable: true, get: function () { return async_in_memory_event_store_1.AsyncInMemoryEventStore; } });
|
|
6
|
+
var async_in_memory_event_bus_1 = require("./async-in-memory-event-bus");
|
|
7
|
+
Object.defineProperty(exports, "AsyncInMemoryEventBus", { enumerable: true, get: function () { return async_in_memory_event_bus_1.AsyncInMemoryEventBus; } });
|
|
8
|
+
var async_in_memory_dead_letter_store_1 = require("./async-in-memory-dead-letter-store");
|
|
9
|
+
Object.defineProperty(exports, "AsyncInMemoryDeadLetterStore", { enumerable: true, get: function () { return async_in_memory_dead_letter_store_1.AsyncInMemoryDeadLetterStore; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/event-bus/in-memory/async/index.ts"],"names":[],"mappings":";;;AAAA,6EAAwE;AAA/D,sIAAA,uBAAuB,OAAA;AAChC,yEAAmE;AAA1D,kIAAA,qBAAqB,OAAA;AAC9B,yFAAmF;AAA1E,iJAAA,4BAA4B,OAAA"}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "AsyncInMemoryEventStore", { enumerable: true, get: function () { return async_in_memory_event_store_1.AsyncInMemoryEventStore; } });
|
|
6
|
-
var async_in_memory_event_bus_1 = require("./async-in-memory-event-bus");
|
|
7
|
-
Object.defineProperty(exports, "AsyncInMemoryEventBus", { enumerable: true, get: function () { return async_in_memory_event_bus_1.AsyncInMemoryEventBus; } });
|
|
8
|
-
var async_in_memory_dead_letter_store_1 = require("./async-in-memory-dead-letter-store");
|
|
9
|
-
Object.defineProperty(exports, "AsyncInMemoryDeadLetterStore", { enumerable: true, get: function () { return async_in_memory_dead_letter_store_1.AsyncInMemoryDeadLetterStore; } });
|
|
17
|
+
__exportStar(require("./async"), exports);
|
|
18
|
+
__exportStar(require("./sync"), exports);
|
|
10
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/event-bus/in-memory/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/event-bus/in-memory/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,yCAAuB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SyncInMemoryEventBus = exports.SyncInMemoryEventStore = exports.SyncInMemoryDeadLetterStore = void 0;
|
|
4
|
+
var sync_in_memory_dead_letter_store_1 = require("./sync-in-memory-dead-letter-store");
|
|
5
|
+
Object.defineProperty(exports, "SyncInMemoryDeadLetterStore", { enumerable: true, get: function () { return sync_in_memory_dead_letter_store_1.SyncInMemoryDeadLetterStore; } });
|
|
6
|
+
var sync_in_memory_event_store_1 = require("./sync-in-memory-event-store");
|
|
7
|
+
Object.defineProperty(exports, "SyncInMemoryEventStore", { enumerable: true, get: function () { return sync_in_memory_event_store_1.SyncInMemoryEventStore; } });
|
|
8
|
+
var sync_in_memory_event_bus_1 = require("./sync-in-memory-event-bus");
|
|
9
|
+
Object.defineProperty(exports, "SyncInMemoryEventBus", { enumerable: true, get: function () { return sync_in_memory_event_bus_1.SyncInMemoryEventBus; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/event-bus/in-memory/sync/index.ts"],"names":[],"mappings":";;;AAAA,uFAAiF;AAAxE,+IAAA,2BAA2B,OAAA;AACpC,2EAAsE;AAA7D,oIAAA,sBAAsB,OAAA;AAC/B,uEAAkE;AAAzD,gIAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SyncInMemoryDeadLetterStore = void 0;
|
|
4
|
+
class SyncInMemoryDeadLetterStore {
|
|
5
|
+
failed = [];
|
|
6
|
+
add(primitives, reason) {
|
|
7
|
+
this.failed.push({ primitives, reason });
|
|
8
|
+
}
|
|
9
|
+
all() {
|
|
10
|
+
return [...this.failed];
|
|
11
|
+
}
|
|
12
|
+
clear() {
|
|
13
|
+
this.failed.length = 0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.SyncInMemoryDeadLetterStore = SyncInMemoryDeadLetterStore;
|
|
17
|
+
//# sourceMappingURL=sync-in-memory-dead-letter-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-in-memory-dead-letter-store.js","sourceRoot":"","sources":["../../../../../src/event-bus/in-memory/sync/sync-in-memory-dead-letter-store.ts"],"names":[],"mappings":";;;AAGA,MAAa,2BAA2B;IACrB,MAAM,GAAiE,EAAE,CAAC;IAE3F,GAAG,CAAC,UAAiC,EAAE,MAAc;QACnD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,GAAG;QACD,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACzB,CAAC;CACF;AAdD,kEAcC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SyncInMemoryEventBus = void 0;
|
|
4
|
+
const domain_events_1 = require("../../../domain-events");
|
|
5
|
+
const sync_in_memory_event_store_1 = require("./sync-in-memory-event-store");
|
|
6
|
+
class SyncInMemoryEventBus {
|
|
7
|
+
subscribers = new Map();
|
|
8
|
+
store;
|
|
9
|
+
maxRetries;
|
|
10
|
+
deadLetterStore;
|
|
11
|
+
constructor(store = new sync_in_memory_event_store_1.SyncInMemoryEventStore(), maxRetries = 3, deadLetterStore) {
|
|
12
|
+
this.store = store;
|
|
13
|
+
this.maxRetries = maxRetries;
|
|
14
|
+
this.deadLetterStore = deadLetterStore;
|
|
15
|
+
}
|
|
16
|
+
subscribe(eventName, subscriber) {
|
|
17
|
+
if (!this.subscribers.has(eventName)) {
|
|
18
|
+
this.subscribers.set(eventName, []);
|
|
19
|
+
}
|
|
20
|
+
this.subscribers.get(eventName).push(subscriber);
|
|
21
|
+
}
|
|
22
|
+
publish(event) {
|
|
23
|
+
const primitives = event.toPrimitives();
|
|
24
|
+
this.store.save(primitives);
|
|
25
|
+
this.dispatch(event);
|
|
26
|
+
}
|
|
27
|
+
dispatch(event) {
|
|
28
|
+
const eventName = event.getEventName();
|
|
29
|
+
const subs = this.subscribers.get(eventName) ?? [];
|
|
30
|
+
const primitives = event.toPrimitives();
|
|
31
|
+
event.ack = () => this.store.delete(event.id);
|
|
32
|
+
event.requeue = (error) => {
|
|
33
|
+
event.ack?.();
|
|
34
|
+
if (event.meta.retries < this.maxRetries) {
|
|
35
|
+
const updatedPrimitives = {
|
|
36
|
+
...primitives,
|
|
37
|
+
meta: { ...primitives.meta, retries: event.meta.retries + 1 },
|
|
38
|
+
};
|
|
39
|
+
this.store.requeue(updatedPrimitives);
|
|
40
|
+
this.publish(domain_events_1.DomainEventRegistry.create(updatedPrimitives));
|
|
41
|
+
}
|
|
42
|
+
else if (this.deadLetterStore) {
|
|
43
|
+
const reason = error ? error.message : `Exceeded max retries (${this.maxRetries})`;
|
|
44
|
+
this.deadLetterStore.add(primitives, reason);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
for (const sub of subs) {
|
|
48
|
+
try {
|
|
49
|
+
sub.handle(event);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
event.requeue?.(err);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
replay() {
|
|
57
|
+
const events = this.store.all();
|
|
58
|
+
for (const primitives of events) {
|
|
59
|
+
const event = domain_events_1.DomainEventRegistry.create(primitives);
|
|
60
|
+
this.dispatch(event);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.SyncInMemoryEventBus = SyncInMemoryEventBus;
|
|
65
|
+
//# sourceMappingURL=sync-in-memory-event-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-in-memory-event-bus.js","sourceRoot":"","sources":["../../../../../src/event-bus/in-memory/sync/sync-in-memory-event-bus.ts"],"names":[],"mappings":";;;AAAA,0DAA0E;AAC1E,6E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CAAC;IACH,CAAC;CACF;AA1ED,oDA0EC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SyncInMemoryEventStore = void 0;
|
|
4
|
+
class SyncInMemoryEventStore {
|
|
5
|
+
events = [];
|
|
6
|
+
save(primitives) {
|
|
7
|
+
this.events.push(primitives);
|
|
8
|
+
}
|
|
9
|
+
all() {
|
|
10
|
+
return [...this.events];
|
|
11
|
+
}
|
|
12
|
+
delete(id) {
|
|
13
|
+
const index = this.events.findIndex(e => e.id === id);
|
|
14
|
+
if (index !== -1)
|
|
15
|
+
this.events.splice(index, 1);
|
|
16
|
+
}
|
|
17
|
+
requeue(primitives) {
|
|
18
|
+
this.events.push(primitives);
|
|
19
|
+
}
|
|
20
|
+
clear() {
|
|
21
|
+
this.events.length = 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.SyncInMemoryEventStore = SyncInMemoryEventStore;
|
|
25
|
+
//# sourceMappingURL=sync-in-memory-event-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-in-memory-event-store.js","sourceRoot":"","sources":["../../../../../src/event-bus/in-memory/sync/sync-in-memory-event-store.ts"],"names":[],"mappings":";;;AAGA,MAAa,sBAAsB;IAChB,MAAM,GAA4B,EAAE,CAAC;IAEtD,IAAI,CAAC,UAAiC;QACpC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC;IAED,GAAG;QACD,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,EAAU;QACf,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAEtD,IAAI,KAAK,KAAK,CAAC,CAAC;YAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,CAAC,UAAiC;QACvC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACzB,CAAC;CACF;AAxBD,wDAwBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-command-handler.js","sourceRoot":"","sources":["../../../../src/cqrs/async/async-command-handler.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cqrs/async/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncInMemoryCommandBus = void 0;
|
|
4
|
+
const index_1 = require("../../index");
|
|
5
|
+
class AsyncInMemoryCommandBus {
|
|
6
|
+
handlers = new Map();
|
|
7
|
+
register(type, handler) {
|
|
8
|
+
this.handlers.set(type, handler);
|
|
9
|
+
}
|
|
10
|
+
async dispatch(command) {
|
|
11
|
+
const handler = this.handlers.get(command.getType());
|
|
12
|
+
if (!handler) {
|
|
13
|
+
throw new index_1.CommandNotRegistered(command.getType());
|
|
14
|
+
}
|
|
15
|
+
return handler.handle(command);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.AsyncInMemoryCommandBus = AsyncInMemoryCommandBus;
|
|
19
|
+
//# sourceMappingURL=async-in-memory-command-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-in-memory-command-bus.js","sourceRoot":"","sources":["../../../../../src/cqrs/in-memory/async/async-in-memory-command-bus.ts"],"names":[],"mappings":";;;AAAA,uCAAwF;AAExF,MAAa,uBAAuB;IACjB,QAAQ,GAAG,IAAI,GAAG,EAA4C,CAAC;IAEhF,QAAQ,CAA8B,IAAY,EAAE,OAA6B;QAC/E,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,QAAQ,CAA8B,OAAU;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,CAAqC,CAAC;QAEzF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,4BAAoB,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACpD,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;CACF;AAhBD,0DAgBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncInMemoryQueryBus = void 0;
|
|
4
|
+
const index_1 = require("../../index");
|
|
5
|
+
class AsyncInMemoryQueryBus {
|
|
6
|
+
handlers = new Map();
|
|
7
|
+
register(type, handler) {
|
|
8
|
+
this.handlers.set(type, handler);
|
|
9
|
+
}
|
|
10
|
+
async dispatch(query) {
|
|
11
|
+
const handler = this.handlers.get(query.getType());
|
|
12
|
+
if (!handler) {
|
|
13
|
+
throw new index_1.QueryNotRegistered(query.getType());
|
|
14
|
+
}
|
|
15
|
+
return await handler.handle(query);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.AsyncInMemoryQueryBus = AsyncInMemoryQueryBus;
|
|
19
|
+
//# sourceMappingURL=async-in-memory-query-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-in-memory-query-bus.js","sourceRoot":"","sources":["../../../../../src/cqrs/in-memory/async/async-in-memory-query-bus.ts"],"names":[],"mappings":";;;AAAA,uCAAgF;AAEhF,MAAa,qBAAqB;IACf,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAAC;IAE5D,QAAQ,CAAqB,IAAY,EAAE,OAA2B;QACpE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAqB,KAAQ;QACzC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,CAAmC,CAAC;QAErF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,0BAAkB,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;CACF;AAhBD,sDAgBC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncInMemoryQueryBus = exports.AsyncInMemoryCommandBus = void 0;
|
|
4
|
+
var async_in_memory_command_bus_1 = require("./async-in-memory-command-bus");
|
|
5
|
+
Object.defineProperty(exports, "AsyncInMemoryCommandBus", { enumerable: true, get: function () { return async_in_memory_command_bus_1.AsyncInMemoryCommandBus; } });
|
|
6
|
+
var async_in_memory_query_bus_1 = require("./async-in-memory-query-bus");
|
|
7
|
+
Object.defineProperty(exports, "AsyncInMemoryQueryBus", { enumerable: true, get: function () { return async_in_memory_query_bus_1.AsyncInMemoryQueryBus; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/cqrs/in-memory/async/index.ts"],"names":[],"mappings":";;;AAAA,6EAAwE;AAA/D,sIAAA,uBAAuB,OAAA;AAChC,yEAAoE;AAA3D,kIAAA,qBAAqB,OAAA"}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "AsyncInMemoryCommandBus", { enumerable: true, get: function () { return async_in_memory_command_bus_1.AsyncInMemoryCommandBus; } });
|
|
6
|
-
var async_in_memory_query_bus_1 = require("./async-in-memory-query-bus");
|
|
7
|
-
Object.defineProperty(exports, "AsyncInMemoryQueryBus", { enumerable: true, get: function () { return async_in_memory_query_bus_1.AsyncInMemoryQueryBus; } });
|
|
17
|
+
__exportStar(require("./async"), exports);
|
|
18
|
+
__exportStar(require("./sync"), exports);
|
|
8
19
|
//# sourceMappingURL=index.js.map
|