@nestjs-transactional/cqrs 1.0.0-alpha.5 → 2.0.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 +155 -410
- package/dist/decorators/integration-events-handler.decorator.d.ts +2 -2
- package/dist/decorators/integration-events-handler.decorator.js +9 -14
- package/dist/decorators/integration-events-handler.decorator.js.map +1 -1
- package/dist/decorators/transactional-events-handler.decorator.d.ts +4 -4
- package/dist/decorators/transactional-events-handler.decorator.js +12 -17
- package/dist/decorators/transactional-events-handler.decorator.js.map +1 -1
- package/dist/event-dispatcher/event-dispatcher.d.ts +4 -4
- package/dist/event-dispatcher/event-dispatcher.js +18 -22
- package/dist/event-dispatcher/event-dispatcher.js.map +1 -1
- package/dist/event-publisher/hybrid-event-publisher.d.ts +2 -2
- package/dist/event-publisher/hybrid-event-publisher.js +10 -13
- package/dist/event-publisher/hybrid-event-publisher.js.map +1 -1
- package/dist/event-publisher/transactional-event-publisher-adapter.d.ts +15 -5
- package/dist/event-publisher/transactional-event-publisher-adapter.js +20 -12
- package/dist/event-publisher/transactional-event-publisher-adapter.js.map +1 -1
- package/dist/event-publisher/transactional-event-publisher.d.ts +1 -1
- package/dist/event-publisher/transactional-event-publisher.js +6 -9
- package/dist/event-publisher/transactional-event-publisher.js.map +1 -1
- package/dist/handlers/bootstrap.d.ts +1 -1
- package/dist/handlers/bootstrap.js +6 -9
- package/dist/handlers/bootstrap.js.map +1 -1
- package/dist/handlers/handler-wrapper.js +16 -19
- package/dist/handlers/handler-wrapper.js.map +1 -1
- package/dist/handlers/integration-events-handler-scanner.d.ts +2 -2
- package/dist/handlers/integration-events-handler-scanner.js +19 -22
- package/dist/handlers/integration-events-handler-scanner.js.map +1 -1
- package/dist/handlers/listener-scanner.d.ts +1 -1
- package/dist/handlers/listener-scanner.js +11 -14
- package/dist/handlers/listener-scanner.js.map +1 -1
- package/dist/handlers/outbox-listener-registrar.d.ts +3 -3
- package/dist/handlers/outbox-listener-registrar.js +2 -5
- package/dist/handlers/outbox-listener-registrar.js.map +1 -1
- package/dist/index.d.ts +15 -15
- package/dist/index.js +13 -36
- package/dist/index.js.map +1 -1
- package/dist/interfaces/integration-event-handler.interface.js +1 -2
- package/dist/interfaces/transactional-event-handler.interface.js +1 -2
- package/dist/module/cqrs-transactional.module.d.ts +66 -8
- package/dist/module/cqrs-transactional.module.js +120 -68
- package/dist/module/cqrs-transactional.module.js.map +1 -1
- package/dist/types/transactional-listener.types.js +2 -5
- package/dist/types/transactional-listener.types.js.map +1 -1
- package/package.json +27 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/handlers/bootstrap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/handlers/bootstrap.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAA+B,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;;;;;GASG;AAEI,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACR;IAA7B,YAA6B,OAA2B;QAA3B,YAAO,GAAP,OAAO,CAAoB;IAAG,CAAC;IAE5D,sBAAsB;QACpB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF,CAAA;AANY,0BAA0B;IADtC,UAAU,EAAE;qCAE2B,kBAAkB;GAD7C,0BAA0B,CAMtC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -12,12 +11,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
12
|
};
|
|
14
13
|
var CqrsHandlerWrapper_1;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const core_1 = require("@nestjs/core");
|
|
20
|
-
const core_2 = require("@nestjs-transactional/core");
|
|
14
|
+
import 'reflect-metadata';
|
|
15
|
+
import { Inject, Injectable, Logger } from '@nestjs/common';
|
|
16
|
+
import { DiscoveryService } from '@nestjs/core';
|
|
17
|
+
import { PropagationMode, TRANSACTIONAL_METADATA, TransactionManager, getTransactionalMetadata, } from '@nestjs-transactional/core';
|
|
21
18
|
/**
|
|
22
19
|
* Metadata keys written by `@nestjs/cqrs`'s `@CommandHandler` /
|
|
23
20
|
* `@QueryHandler` / `@EventsHandler` decorators onto the handler class
|
|
@@ -48,7 +45,7 @@ const WRAPPED_MARKER = Symbol.for('@nestjs-transactional/wrapped');
|
|
|
48
45
|
* options via this token so `CqrsTransactionalModule` can provide them
|
|
49
46
|
* synchronously or asynchronously.
|
|
50
47
|
*/
|
|
51
|
-
|
|
48
|
+
export const CQRS_HANDLER_WRAPPER_OPTIONS = Symbol('CQRS_HANDLER_WRAPPER_OPTIONS');
|
|
52
49
|
/**
|
|
53
50
|
* Wraps the `execute` (or `handle`) method of every `@CommandHandler` /
|
|
54
51
|
* `@QueryHandler` / `@EventsHandler` class prototype with a transaction,
|
|
@@ -81,7 +78,7 @@ let CqrsHandlerWrapper = class CqrsHandlerWrapper {
|
|
|
81
78
|
discovery;
|
|
82
79
|
manager;
|
|
83
80
|
options;
|
|
84
|
-
logger = new
|
|
81
|
+
logger = new Logger(CqrsHandlerWrapper_1.name);
|
|
85
82
|
/**
|
|
86
83
|
* Tracks every prototype the wrapper has mutated so
|
|
87
84
|
* {@link CqrsHandlerWrapper.resetForTesting} can restore the
|
|
@@ -202,11 +199,11 @@ let CqrsHandlerWrapper = class CqrsHandlerWrapper {
|
|
|
202
199
|
return manager.run(resolved, () => Promise.resolve(original.apply(this, args)));
|
|
203
200
|
};
|
|
204
201
|
Reflect.defineMetadata(WRAPPED_MARKER, true, wrapped);
|
|
205
|
-
Reflect.defineMetadata(
|
|
202
|
+
Reflect.defineMetadata(TRANSACTIONAL_METADATA, resolved, wrapped);
|
|
206
203
|
proto[methodName] = wrapped;
|
|
207
204
|
CqrsHandlerWrapper_1.wrappedPrototypes.set(metatype, { methodName, originalMethod: original });
|
|
208
205
|
this.logger.debug(`Wrapped ${kind} handler ${metatype.name}.prototype.${methodName} ` +
|
|
209
|
-
`(propagation=${resolved.propagation ??
|
|
206
|
+
`(propagation=${resolved.propagation ?? PropagationMode.REQUIRED})`);
|
|
210
207
|
return true;
|
|
211
208
|
}
|
|
212
209
|
/**
|
|
@@ -215,7 +212,7 @@ let CqrsHandlerWrapper = class CqrsHandlerWrapper {
|
|
|
215
212
|
* nothing applies — the handler is then left unwrapped.
|
|
216
213
|
*/
|
|
217
214
|
resolveMetadata(method, metatype, kind) {
|
|
218
|
-
const explicit =
|
|
215
|
+
const explicit = getTransactionalMetadata(method) ?? getTransactionalMetadata(metatype);
|
|
219
216
|
if (explicit !== undefined) {
|
|
220
217
|
return explicit;
|
|
221
218
|
}
|
|
@@ -223,7 +220,7 @@ let CqrsHandlerWrapper = class CqrsHandlerWrapper {
|
|
|
223
220
|
if (defaults === undefined) {
|
|
224
221
|
return undefined;
|
|
225
222
|
}
|
|
226
|
-
return { propagation:
|
|
223
|
+
return { propagation: PropagationMode.REQUIRED, ...defaults };
|
|
227
224
|
}
|
|
228
225
|
pickDefaults(kind) {
|
|
229
226
|
switch (kind) {
|
|
@@ -236,11 +233,11 @@ let CqrsHandlerWrapper = class CqrsHandlerWrapper {
|
|
|
236
233
|
}
|
|
237
234
|
}
|
|
238
235
|
};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
core_2.TransactionManager, Object])
|
|
236
|
+
CqrsHandlerWrapper = CqrsHandlerWrapper_1 = __decorate([
|
|
237
|
+
Injectable(),
|
|
238
|
+
__param(2, Inject(CQRS_HANDLER_WRAPPER_OPTIONS)),
|
|
239
|
+
__metadata("design:paramtypes", [DiscoveryService,
|
|
240
|
+
TransactionManager, Object])
|
|
245
241
|
], CqrsHandlerWrapper);
|
|
242
|
+
export { CqrsHandlerWrapper };
|
|
246
243
|
//# sourceMappingURL=handler-wrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler-wrapper.js","sourceRoot":"","sources":["../../src/handlers/handler-wrapper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handler-wrapper.js","sourceRoot":"","sources":["../../src/handlers/handler-wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAwB,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAElB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;;;;;GAYG;AACH,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AACtD,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAClD,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,cAAc,GAAW,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,8BAA8B,CAAC,CAAC;AAqCnF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;;IA0CV;IACA;IAEA;IA5CF,MAAM,GAAG,IAAI,MAAM,CAAC,oBA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,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,EAAE,WAAW,EAAE,eAAe,CAAC,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAAC;IAChE,CAAC;IAEO,YAAY,CAAC,IAAiB;QACpC,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC;YAC1C,KAAK,SAAS;gBACZ,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC;YAC5C,KAAK,OAAO;gBACV,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC;;AAlMU,kBAAkB;IAD9B,UAAU,EAAE;IA6CR,WAAA,MAAM,CAAC,4BAA4B,CAAC,CAAA;qCAFT,gBAAgB;QAClB,kBAAkB;GA3CnC,kBAAkB,CAmM9B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type OnModuleInit } from '@nestjs/common';
|
|
2
2
|
import { DiscoveryService } from '@nestjs/core';
|
|
3
3
|
import { TransactionManager } from '@nestjs-transactional/core';
|
|
4
|
-
import { TransactionalEventDispatcher } from '../event-dispatcher/event-dispatcher';
|
|
5
|
-
import { type OutboxListenerRegistrar } from './outbox-listener-registrar';
|
|
4
|
+
import { TransactionalEventDispatcher } from '../event-dispatcher/event-dispatcher.js';
|
|
5
|
+
import { type OutboxListenerRegistrar } from './outbox-listener-registrar.js';
|
|
6
6
|
/**
|
|
7
7
|
* Bootstrap-time scanner for `@IntegrationEventsHandler`-annotated
|
|
8
8
|
* classes. Decides at startup which delivery path to wire based on
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -12,15 +11,13 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
12
|
};
|
|
14
13
|
var IntegrationEventsHandlerScanner_1;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const transactional_listener_types_1 = require("../types/transactional-listener.types");
|
|
23
|
-
const outbox_listener_registrar_1 = require("./outbox-listener-registrar");
|
|
14
|
+
import { Inject, Injectable, Logger, Optional } from '@nestjs/common';
|
|
15
|
+
import { DiscoveryService } from '@nestjs/core';
|
|
16
|
+
import { PropagationMode, TransactionManager } from '@nestjs-transactional/core';
|
|
17
|
+
import { getIntegrationEventsHandlerMetadata, } from '../decorators/integration-events-handler.decorator.js';
|
|
18
|
+
import { TransactionalEventDispatcher } from '../event-dispatcher/event-dispatcher.js';
|
|
19
|
+
import { TransactionPhase } from '../types/transactional-listener.types.js';
|
|
20
|
+
import { OUTBOX_LISTENER_REGISTRAR, } from './outbox-listener-registrar.js';
|
|
24
21
|
/**
|
|
25
22
|
* Bootstrap-time scanner for `@IntegrationEventsHandler`-annotated
|
|
26
23
|
* classes. Decides at startup which delivery path to wire based on
|
|
@@ -46,7 +43,7 @@ let IntegrationEventsHandlerScanner = IntegrationEventsHandlerScanner_1 = class
|
|
|
46
43
|
dispatcher;
|
|
47
44
|
manager;
|
|
48
45
|
registrar;
|
|
49
|
-
logger = new
|
|
46
|
+
logger = new Logger(IntegrationEventsHandlerScanner_1.name);
|
|
50
47
|
constructor(discovery, dispatcher, manager, registrar) {
|
|
51
48
|
this.discovery = discovery;
|
|
52
49
|
this.dispatcher = dispatcher;
|
|
@@ -62,7 +59,7 @@ let IntegrationEventsHandlerScanner = IntegrationEventsHandlerScanner_1 = class
|
|
|
62
59
|
wrapper.instance === undefined) {
|
|
63
60
|
continue;
|
|
64
61
|
}
|
|
65
|
-
const metadata =
|
|
62
|
+
const metadata = getIntegrationEventsHandlerMetadata(wrapper.metatype);
|
|
66
63
|
if (metadata === undefined) {
|
|
67
64
|
continue;
|
|
68
65
|
}
|
|
@@ -85,7 +82,7 @@ let IntegrationEventsHandlerScanner = IntegrationEventsHandlerScanner_1 = class
|
|
|
85
82
|
registerToOutbox(instance, metadata, boundHandle, registrar) {
|
|
86
83
|
const manager = this.manager;
|
|
87
84
|
const invoke = async (event) => {
|
|
88
|
-
await manager.run({ propagation:
|
|
85
|
+
await manager.run({ propagation: PropagationMode.REQUIRES_NEW }, async () => {
|
|
89
86
|
await boundHandle(event);
|
|
90
87
|
});
|
|
91
88
|
};
|
|
@@ -116,7 +113,7 @@ let IntegrationEventsHandlerScanner = IntegrationEventsHandlerScanner_1 = class
|
|
|
116
113
|
for (const eventType of metadata.eventTypes) {
|
|
117
114
|
this.dispatcher.registerListener(proxy, 'handle', {
|
|
118
115
|
eventType,
|
|
119
|
-
phase:
|
|
116
|
+
phase: TransactionPhase.AFTER_COMMIT,
|
|
120
117
|
async: true,
|
|
121
118
|
fallbackExecution: false,
|
|
122
119
|
dataSource: metadata.dataSource,
|
|
@@ -124,15 +121,15 @@ let IntegrationEventsHandlerScanner = IntegrationEventsHandlerScanner_1 = class
|
|
|
124
121
|
}
|
|
125
122
|
}
|
|
126
123
|
};
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
(
|
|
130
|
-
__param(3, (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
core_2.TransactionManager, Object])
|
|
124
|
+
IntegrationEventsHandlerScanner = IntegrationEventsHandlerScanner_1 = __decorate([
|
|
125
|
+
Injectable(),
|
|
126
|
+
__param(3, Optional()),
|
|
127
|
+
__param(3, Inject(OUTBOX_LISTENER_REGISTRAR)),
|
|
128
|
+
__metadata("design:paramtypes", [DiscoveryService,
|
|
129
|
+
TransactionalEventDispatcher,
|
|
130
|
+
TransactionManager, Object])
|
|
135
131
|
], IntegrationEventsHandlerScanner);
|
|
132
|
+
export { IntegrationEventsHandlerScanner };
|
|
136
133
|
/**
|
|
137
134
|
* Compose the stable listener id. Always ends with `#${EventName}`
|
|
138
135
|
* so a single class handling multiple event types gets distinct ids
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-events-handler-scanner.js","sourceRoot":"","sources":["../../src/handlers/integration-events-handler-scanner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"integration-events-handler-scanner.js","sourceRoot":"","sources":["../../src/handlers/integration-events-handler-scanner.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAgC,MAAM,gBAAgB,CAAC;AACpG,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEjF,OAAO,EAEL,mCAAmC,GACpC,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAE5E,OAAO,EACL,yBAAyB,GAE1B,MAAM,gCAAgC,CAAC;AAIxC;;;;;;;;;;;;;;;;;;;GAmBG;AAEI,IAAM,+BAA+B,uCAArC,MAAM,+BAA+B;IAIvB;IACA;IACA;IAGA;IARF,MAAM,GAAG,IAAI,MAAM,CAAC,iCAA+B,CAAC,IAAI,CAAC,CAAC;IAE3E,YACmB,SAA2B,EAC3B,UAAwC,EACxC,OAA2B,EAG3B,SAAmC;QALnC,cAAS,GAAT,SAAS,CAAkB;QA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,EAAiB,EAAE;YACrD,MAAM,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,IAAI,EAAE;gBAC/B,MAAM,WAAW,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;YAC5C,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE;gBAChD,SAAS;gBACT,KAAK,EAAE,gBAAgB,CAAC,YAAY;gBACpC,KAAK,EAAE,IAAI;gBACX,iBAAiB,EAAE,KAAK;gBACxB,UAAU,EAAE,QAAQ,CAAC,UAAU;aAChC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAA;AA1GY,+BAA+B;IAD3C,UAAU,EAAE;IAQR,WAAA,QAAQ,EAAE,CAAA;IACV,WAAA,MAAM,CAAC,yBAAyB,CAAC,CAAA;qCAJN,gBAAgB;QACf,4BAA4B;QAC/B,kBAAkB;GANnC,+BAA+B,CA0G3C;;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,MAAc,EAAE,SAAe;IACxD,OAAO,GAAG,MAAM,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type OnModuleInit } from '@nestjs/common';
|
|
2
2
|
import { DiscoveryService } from '@nestjs/core';
|
|
3
|
-
import { TransactionalEventDispatcher } from '../event-dispatcher/event-dispatcher';
|
|
3
|
+
import { TransactionalEventDispatcher } from '../event-dispatcher/event-dispatcher.js';
|
|
4
4
|
/**
|
|
5
5
|
* Bootstrap-time scanner that walks every provider in the running
|
|
6
6
|
* Nest application, finds every class decorated with
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -9,12 +8,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
10
|
var TransactionalListenerScanner_1;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const transactional_events_handler_decorator_1 = require("../decorators/transactional-events-handler.decorator");
|
|
17
|
-
const event_dispatcher_1 = require("../event-dispatcher/event-dispatcher");
|
|
11
|
+
import { Injectable, Logger } from '@nestjs/common';
|
|
12
|
+
import { DiscoveryService } from '@nestjs/core';
|
|
13
|
+
import { getTransactionalEventsHandlerMetadata } from '../decorators/transactional-events-handler.decorator.js';
|
|
14
|
+
import { TransactionalEventDispatcher } from '../event-dispatcher/event-dispatcher.js';
|
|
18
15
|
/**
|
|
19
16
|
* Bootstrap-time scanner that walks every provider in the running
|
|
20
17
|
* Nest application, finds every class decorated with
|
|
@@ -40,7 +37,7 @@ const event_dispatcher_1 = require("../event-dispatcher/event-dispatcher");
|
|
|
40
37
|
let TransactionalListenerScanner = TransactionalListenerScanner_1 = class TransactionalListenerScanner {
|
|
41
38
|
discovery;
|
|
42
39
|
dispatcher;
|
|
43
|
-
logger = new
|
|
40
|
+
logger = new Logger(TransactionalListenerScanner_1.name);
|
|
44
41
|
constructor(discovery, dispatcher) {
|
|
45
42
|
this.discovery = discovery;
|
|
46
43
|
this.dispatcher = dispatcher;
|
|
@@ -54,7 +51,7 @@ let TransactionalListenerScanner = TransactionalListenerScanner_1 = class Transa
|
|
|
54
51
|
wrapper.instance === undefined) {
|
|
55
52
|
continue;
|
|
56
53
|
}
|
|
57
|
-
const metadata =
|
|
54
|
+
const metadata = getTransactionalEventsHandlerMetadata(wrapper.metatype);
|
|
58
55
|
if (metadata === undefined) {
|
|
59
56
|
continue;
|
|
60
57
|
}
|
|
@@ -77,10 +74,10 @@ let TransactionalListenerScanner = TransactionalListenerScanner_1 = class Transa
|
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
76
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
(
|
|
83
|
-
|
|
84
|
-
event_dispatcher_1.TransactionalEventDispatcher])
|
|
77
|
+
TransactionalListenerScanner = TransactionalListenerScanner_1 = __decorate([
|
|
78
|
+
Injectable(),
|
|
79
|
+
__metadata("design:paramtypes", [DiscoveryService,
|
|
80
|
+
TransactionalEventDispatcher])
|
|
85
81
|
], TransactionalListenerScanner);
|
|
82
|
+
export { TransactionalListenerScanner };
|
|
86
83
|
//# sourceMappingURL=listener-scanner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listener-scanner.js","sourceRoot":"","sources":["../../src/handlers/listener-scanner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"listener-scanner.js","sourceRoot":"","sources":["../../src/handlers/listener-scanner.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAqB,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,qCAAqC,EAAE,MAAM,yDAAyD,CAAC;AAChH,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEI,IAAM,4BAA4B,oCAAlC,MAAM,4BAA4B;IAIpB;IACA;IAJF,MAAM,GAAG,IAAI,MAAM,CAAC,8BAA4B,CAAC,IAAI,CAAC,CAAC;IAExE,YACmB,SAA2B,EAC3B,UAAwC;QADxC,cAAS,GAAT,SAAS,CAAkB;QAC3B,eAAU,GAAV,UAAU,CAA8B;IACxD,CAAC;IAEJ,YAAY;QACV,MAAM,SAAS,GAA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 @@
|
|
|
7
7
|
* `@nestjs-transactional/outbox`'s `OutboxListenerRegistry`
|
|
8
8
|
* satisfies this interface structurally (its `register` method
|
|
9
9
|
* accepts exactly this shape). The outbox package's
|
|
10
|
-
* `MultiDsOutboxListenerRegistrar`
|
|
10
|
+
* `MultiDsOutboxListenerRegistrar` is a smarter
|
|
11
11
|
* implementation that walks every per-dataSource event-type registry
|
|
12
12
|
* to resolve which dataSource owns each listener's event class and
|
|
13
13
|
* routes the registration to the matching per-DS registry — so a
|
|
14
14
|
* single binding handles arbitrary multi-dataSource deployments.
|
|
15
15
|
*
|
|
16
|
-
* **Auto-binding
|
|
16
|
+
* **Auto-binding.** `OutboxModule.forRoot` binds this
|
|
17
17
|
* token to `MultiDsOutboxListenerRegistrar` automatically on the
|
|
18
18
|
* first `forRoot` call. Consumers do NOT need to declare the binding
|
|
19
19
|
* themselves; the registrar is in place by the time the cqrs
|
|
@@ -39,7 +39,7 @@ export interface OutboxListenerRegistrar {
|
|
|
39
39
|
* falls back to in-memory registration via
|
|
40
40
|
* {@link TransactionalEventDispatcher}.
|
|
41
41
|
*
|
|
42
|
-
* `Symbol.for(...)` (not `Symbol(...)`) —
|
|
42
|
+
* `Symbol.for(...)` (not `Symbol(...)`) — the outbox
|
|
43
43
|
* package auto-binds this token to its `MultiDsOutboxListenerRegistrar`
|
|
44
44
|
* via `Symbol.for` lookup on the same key. Both packages thereby
|
|
45
45
|
* refer to the same Symbol identity without a direct import in
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OUTBOX_LISTENER_REGISTRAR = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* DI token for the optional {@link OutboxListenerRegistrar} injected
|
|
6
3
|
* into `IntegrationEventsHandlerScanner`. When unbound, the scanner
|
|
7
4
|
* falls back to in-memory registration via
|
|
8
5
|
* {@link TransactionalEventDispatcher}.
|
|
9
6
|
*
|
|
10
|
-
* `Symbol.for(...)` (not `Symbol(...)`) —
|
|
7
|
+
* `Symbol.for(...)` (not `Symbol(...)`) — the outbox
|
|
11
8
|
* package auto-binds this token to its `MultiDsOutboxListenerRegistrar`
|
|
12
9
|
* via `Symbol.for` lookup on the same key. Both packages thereby
|
|
13
10
|
* refer to the same Symbol identity without a direct import in
|
|
14
11
|
* either direction.
|
|
15
12
|
*/
|
|
16
|
-
|
|
13
|
+
export const OUTBOX_LISTENER_REGISTRAR = Symbol.for('@nestjs-transactional/cqrs/outbox-listener-registrar');
|
|
17
14
|
//# sourceMappingURL=outbox-listener-registrar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outbox-listener-registrar.js","sourceRoot":"","sources":["../../src/handlers/outbox-listener-registrar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"outbox-listener-registrar.js","sourceRoot":"","sources":["../../src/handlers/outbox-listener-registrar.ts"],"names":[],"mappings":"AAoCA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,GAAG,CACjD,sDAAsD,CACvD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export { TransactionPhase } from './types/transactional-listener.types';
|
|
2
|
-
export { TRANSACTIONAL_EVENTS_HANDLER_METADATA, TransactionalEventsHandler, getTransactionalEventsHandlerMetadata, type TransactionalEventsHandlerMetadata, type TransactionalEventsHandlerOptions, } from './decorators/transactional-events-handler.decorator';
|
|
3
|
-
export { INTEGRATION_EVENTS_HANDLER_METADATA, IntegrationEventsHandler, getIntegrationEventsHandlerMetadata, type IntegrationEventsHandlerMetadata, type IntegrationEventsHandlerOptions, } from './decorators/integration-events-handler.decorator';
|
|
4
|
-
export type { ITransactionalEventHandler } from './interfaces/transactional-event-handler.interface';
|
|
5
|
-
export type { IIntegrationEventHandler } from './interfaces/integration-event-handler.interface';
|
|
6
|
-
export { TransactionalEventDispatcher, type DispatcherListenerMetadata, } from './event-dispatcher/event-dispatcher';
|
|
7
|
-
export { TransactionalListenerScanner } from './handlers/listener-scanner';
|
|
8
|
-
export { IntegrationEventsHandlerScanner } from './handlers/integration-events-handler-scanner';
|
|
9
|
-
export { OUTBOX_LISTENER_REGISTRAR, type OutboxListenerRegistrar, } from './handlers/outbox-listener-registrar';
|
|
10
|
-
export { CQRS_HANDLER_WRAPPER_OPTIONS, CqrsHandlerWrapper, type HandlerWrapperOptions, } from './handlers/handler-wrapper';
|
|
11
|
-
export { CqrsTransactionalBootstrap } from './handlers/bootstrap';
|
|
12
|
-
export { TransactionalEventPublisher } from './event-publisher/transactional-event-publisher';
|
|
13
|
-
export { TransactionalEventPublisherAdapter } from './event-publisher/transactional-event-publisher-adapter';
|
|
14
|
-
export { HybridEventPublisher, OUTBOX_PUBLICATION_SCHEDULER, type OutboxPublicationScheduler, } from './event-publisher/hybrid-event-publisher';
|
|
15
|
-
export { CQRS_TRANSACTIONAL_OPTIONS, CqrsTransactionalModule, type CqrsTransactionalOptions, } from './module/cqrs-transactional.module';
|
|
1
|
+
export { TransactionPhase } from './types/transactional-listener.types.js';
|
|
2
|
+
export { TRANSACTIONAL_EVENTS_HANDLER_METADATA, TransactionalEventsHandler, getTransactionalEventsHandlerMetadata, type TransactionalEventsHandlerMetadata, type TransactionalEventsHandlerOptions, } from './decorators/transactional-events-handler.decorator.js';
|
|
3
|
+
export { INTEGRATION_EVENTS_HANDLER_METADATA, IntegrationEventsHandler, getIntegrationEventsHandlerMetadata, type IntegrationEventsHandlerMetadata, type IntegrationEventsHandlerOptions, } from './decorators/integration-events-handler.decorator.js';
|
|
4
|
+
export type { ITransactionalEventHandler } from './interfaces/transactional-event-handler.interface.js';
|
|
5
|
+
export type { IIntegrationEventHandler } from './interfaces/integration-event-handler.interface.js';
|
|
6
|
+
export { TransactionalEventDispatcher, type DispatcherListenerMetadata, } from './event-dispatcher/event-dispatcher.js';
|
|
7
|
+
export { TransactionalListenerScanner } from './handlers/listener-scanner.js';
|
|
8
|
+
export { IntegrationEventsHandlerScanner } from './handlers/integration-events-handler-scanner.js';
|
|
9
|
+
export { OUTBOX_LISTENER_REGISTRAR, type OutboxListenerRegistrar, } from './handlers/outbox-listener-registrar.js';
|
|
10
|
+
export { CQRS_HANDLER_WRAPPER_OPTIONS, CqrsHandlerWrapper, type HandlerWrapperOptions, } from './handlers/handler-wrapper.js';
|
|
11
|
+
export { CqrsTransactionalBootstrap } from './handlers/bootstrap.js';
|
|
12
|
+
export { TransactionalEventPublisher } from './event-publisher/transactional-event-publisher.js';
|
|
13
|
+
export { type AggregateConstructor, TransactionalEventPublisherAdapter, } from './event-publisher/transactional-event-publisher-adapter.js';
|
|
14
|
+
export { HybridEventPublisher, OUTBOX_PUBLICATION_SCHEDULER, type OutboxPublicationScheduler, } from './event-publisher/hybrid-event-publisher.js';
|
|
15
|
+
export { CQRS_TRANSACTIONAL_OPTIONS, CqrsTransactionalModule, type CqrsTransactionalAsyncFactoryResult, type CqrsTransactionalAsyncOptions, type CqrsTransactionalOptions, } from './module/cqrs-transactional.module.js';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,37 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var event_dispatcher_1 = require("./event-dispatcher/event-dispatcher");
|
|
15
|
-
Object.defineProperty(exports, "TransactionalEventDispatcher", { enumerable: true, get: function () { return event_dispatcher_1.TransactionalEventDispatcher; } });
|
|
16
|
-
var listener_scanner_1 = require("./handlers/listener-scanner");
|
|
17
|
-
Object.defineProperty(exports, "TransactionalListenerScanner", { enumerable: true, get: function () { return listener_scanner_1.TransactionalListenerScanner; } });
|
|
18
|
-
var integration_events_handler_scanner_1 = require("./handlers/integration-events-handler-scanner");
|
|
19
|
-
Object.defineProperty(exports, "IntegrationEventsHandlerScanner", { enumerable: true, get: function () { return integration_events_handler_scanner_1.IntegrationEventsHandlerScanner; } });
|
|
20
|
-
var outbox_listener_registrar_1 = require("./handlers/outbox-listener-registrar");
|
|
21
|
-
Object.defineProperty(exports, "OUTBOX_LISTENER_REGISTRAR", { enumerable: true, get: function () { return outbox_listener_registrar_1.OUTBOX_LISTENER_REGISTRAR; } });
|
|
22
|
-
var handler_wrapper_1 = require("./handlers/handler-wrapper");
|
|
23
|
-
Object.defineProperty(exports, "CQRS_HANDLER_WRAPPER_OPTIONS", { enumerable: true, get: function () { return handler_wrapper_1.CQRS_HANDLER_WRAPPER_OPTIONS; } });
|
|
24
|
-
Object.defineProperty(exports, "CqrsHandlerWrapper", { enumerable: true, get: function () { return handler_wrapper_1.CqrsHandlerWrapper; } });
|
|
25
|
-
var bootstrap_1 = require("./handlers/bootstrap");
|
|
26
|
-
Object.defineProperty(exports, "CqrsTransactionalBootstrap", { enumerable: true, get: function () { return bootstrap_1.CqrsTransactionalBootstrap; } });
|
|
27
|
-
var transactional_event_publisher_1 = require("./event-publisher/transactional-event-publisher");
|
|
28
|
-
Object.defineProperty(exports, "TransactionalEventPublisher", { enumerable: true, get: function () { return transactional_event_publisher_1.TransactionalEventPublisher; } });
|
|
29
|
-
var transactional_event_publisher_adapter_1 = require("./event-publisher/transactional-event-publisher-adapter");
|
|
30
|
-
Object.defineProperty(exports, "TransactionalEventPublisherAdapter", { enumerable: true, get: function () { return transactional_event_publisher_adapter_1.TransactionalEventPublisherAdapter; } });
|
|
31
|
-
var hybrid_event_publisher_1 = require("./event-publisher/hybrid-event-publisher");
|
|
32
|
-
Object.defineProperty(exports, "HybridEventPublisher", { enumerable: true, get: function () { return hybrid_event_publisher_1.HybridEventPublisher; } });
|
|
33
|
-
Object.defineProperty(exports, "OUTBOX_PUBLICATION_SCHEDULER", { enumerable: true, get: function () { return hybrid_event_publisher_1.OUTBOX_PUBLICATION_SCHEDULER; } });
|
|
34
|
-
var cqrs_transactional_module_1 = require("./module/cqrs-transactional.module");
|
|
35
|
-
Object.defineProperty(exports, "CQRS_TRANSACTIONAL_OPTIONS", { enumerable: true, get: function () { return cqrs_transactional_module_1.CQRS_TRANSACTIONAL_OPTIONS; } });
|
|
36
|
-
Object.defineProperty(exports, "CqrsTransactionalModule", { enumerable: true, get: function () { return cqrs_transactional_module_1.CqrsTransactionalModule; } });
|
|
1
|
+
export { TransactionPhase } from './types/transactional-listener.types.js';
|
|
2
|
+
export { TRANSACTIONAL_EVENTS_HANDLER_METADATA, TransactionalEventsHandler, getTransactionalEventsHandlerMetadata, } from './decorators/transactional-events-handler.decorator.js';
|
|
3
|
+
export { INTEGRATION_EVENTS_HANDLER_METADATA, IntegrationEventsHandler, getIntegrationEventsHandlerMetadata, } from './decorators/integration-events-handler.decorator.js';
|
|
4
|
+
export { TransactionalEventDispatcher, } from './event-dispatcher/event-dispatcher.js';
|
|
5
|
+
export { TransactionalListenerScanner } from './handlers/listener-scanner.js';
|
|
6
|
+
export { IntegrationEventsHandlerScanner } from './handlers/integration-events-handler-scanner.js';
|
|
7
|
+
export { OUTBOX_LISTENER_REGISTRAR, } from './handlers/outbox-listener-registrar.js';
|
|
8
|
+
export { CQRS_HANDLER_WRAPPER_OPTIONS, CqrsHandlerWrapper, } from './handlers/handler-wrapper.js';
|
|
9
|
+
export { CqrsTransactionalBootstrap } from './handlers/bootstrap.js';
|
|
10
|
+
export { TransactionalEventPublisher } from './event-publisher/transactional-event-publisher.js';
|
|
11
|
+
export { TransactionalEventPublisherAdapter, } from './event-publisher/transactional-event-publisher-adapter.js';
|
|
12
|
+
export { HybridEventPublisher, OUTBOX_PUBLICATION_SCHEDULER, } from './event-publisher/hybrid-event-publisher.js';
|
|
13
|
+
export { CQRS_TRANSACTIONAL_OPTIONS, CqrsTransactionalModule, } from './module/cqrs-transactional.module.js';
|
|
37
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,OAAO,EACL,qCAAqC,EACrC,0BAA0B,EAC1B,qCAAqC,GAGtC,MAAM,wDAAwD,CAAC;AAEhE,OAAO,EACL,mCAAmC,EACnC,wBAAwB,EACxB,mCAAmC,GAGpC,MAAM,sDAAsD,CAAC;AAK9D,OAAO,EACL,4BAA4B,GAE7B,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AACnG,OAAO,EACL,yBAAyB,GAE1B,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,GAEnB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAErE,OAAO,EAAE,2BAA2B,EAAE,MAAM,oDAAoD,CAAC;AACjG,OAAO,EAEL,kCAAkC,GACnC,MAAM,4DAA4D,CAAC;AACpE,OAAO,EACL,oBAAoB,EACpB,4BAA4B,GAE7B,MAAM,6CAA6C,CAAC;AAErD,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,GAIxB,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { type HandlerWrapperOptions } from '../handlers/handler-wrapper';
|
|
1
|
+
import { type DynamicModule, type InjectionToken, type ModuleMetadata } from '@nestjs/common';
|
|
2
|
+
import { type HandlerWrapperOptions } from '../handlers/handler-wrapper.js';
|
|
3
3
|
/**
|
|
4
4
|
* DI token for the resolved {@link CqrsTransactionalOptions} object.
|
|
5
5
|
* Consumers normally do not inject this directly — it is used by the
|
|
@@ -16,7 +16,9 @@ export declare const CQRS_TRANSACTIONAL_OPTIONS = "CQRS_TRANSACTIONAL_OPTIONS";
|
|
|
16
16
|
* - `wrapCommandHandlers`: `true`
|
|
17
17
|
* - `wrapQueryHandlers`: `true`
|
|
18
18
|
* - `wrapEventHandlers`: `true`
|
|
19
|
-
* - `defaultQueryOptions`: `{ readOnly: true }`
|
|
19
|
+
* - `defaultQueryOptions`: `{ readOnly: true }` — enforced by the
|
|
20
|
+
* database on Postgres-family dialects, a documenting hint elsewhere
|
|
21
|
+
* (DD-027)
|
|
20
22
|
* - `useTransactionalEventPublisher`: `true`
|
|
21
23
|
*/
|
|
22
24
|
export interface CqrsTransactionalOptions extends HandlerWrapperOptions {
|
|
@@ -30,6 +32,37 @@ export interface CqrsTransactionalOptions extends HandlerWrapperOptions {
|
|
|
30
32
|
*/
|
|
31
33
|
readonly useTransactionalEventPublisher?: boolean;
|
|
32
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Result shape resolved by {@link CqrsTransactionalAsyncOptions.useFactory}.
|
|
37
|
+
*
|
|
38
|
+
* Carries only the value-shaped options — the ones
|
|
39
|
+
* {@link CqrsHandlerWrapper} reads at runtime.
|
|
40
|
+
* `useTransactionalEventPublisher` is deliberately NOT here: it decides
|
|
41
|
+
* whether the `EventPublisher` override provider exists at all, and
|
|
42
|
+
* NestJS needs provider tokens at module-definition time, before any
|
|
43
|
+
* async factory has run. It lives on
|
|
44
|
+
* {@link CqrsTransactionalAsyncOptions} instead — the same split
|
|
45
|
+
* `OutboxModule.forRootAsync` uses for `repository` (convention #21).
|
|
46
|
+
*/
|
|
47
|
+
export type CqrsTransactionalAsyncFactoryResult = HandlerWrapperOptions;
|
|
48
|
+
/**
|
|
49
|
+
* Asynchronous options for {@link CqrsTransactionalModule.forRootAsync}.
|
|
50
|
+
*
|
|
51
|
+
* There is still exactly one `CqrsTransactionalModule` registration per
|
|
52
|
+
* application regardless of how many dataSources are configured — the
|
|
53
|
+
* cqrs runtime is dataSource-agnostic by design, so unlike
|
|
54
|
+
* `OutboxModule` there is no per-dataSource variant of this call.
|
|
55
|
+
*/
|
|
56
|
+
export interface CqrsTransactionalAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
57
|
+
/**
|
|
58
|
+
* Structural — see {@link CqrsTransactionalAsyncFactoryResult}. Same
|
|
59
|
+
* meaning and default (`true`) as on
|
|
60
|
+
* {@link CqrsTransactionalOptions}.
|
|
61
|
+
*/
|
|
62
|
+
readonly useTransactionalEventPublisher?: boolean;
|
|
63
|
+
readonly useFactory: (...args: never[]) => Promise<CqrsTransactionalAsyncFactoryResult> | CqrsTransactionalAsyncFactoryResult;
|
|
64
|
+
readonly inject?: readonly InjectionToken[];
|
|
65
|
+
}
|
|
33
66
|
/**
|
|
34
67
|
* NestJS module that wires the `@nestjs-transactional/cqrs` runtime:
|
|
35
68
|
*
|
|
@@ -49,23 +82,30 @@ export interface CqrsTransactionalOptions extends HandlerWrapperOptions {
|
|
|
49
82
|
* dispatcher.
|
|
50
83
|
*
|
|
51
84
|
* Pair with `TransactionalModule.forRoot({ isGlobal: true })` at the
|
|
52
|
-
* application root. For TypeORM-backed applications,
|
|
53
|
-
*
|
|
85
|
+
* application root. For TypeORM-backed applications, register one
|
|
86
|
+
* adapter per DataSource with `TypeOrmTransactionalModule.forRoot(...)`
|
|
87
|
+
* (ADR-019 — one call per dataSource, not one per feature module).
|
|
88
|
+
*
|
|
89
|
+
* Do NOT import `@nestjs/cqrs`'s `CqrsModule` alongside this module
|
|
90
|
+
* (convention #6): this module imports `CqrsModule` internally and
|
|
91
|
+
* overrides the `EventPublisher` DI token, so a second import in the
|
|
92
|
+
* consumer shadows the override and aggregate events silently bypass
|
|
93
|
+
* the dispatcher.
|
|
54
94
|
*
|
|
55
95
|
* @example
|
|
56
96
|
* ```ts
|
|
57
97
|
* @Module({
|
|
58
98
|
* imports: [
|
|
59
99
|
* TransactionalModule.forRoot({ isGlobal: true }),
|
|
60
|
-
* TypeOrmTransactionalModule.
|
|
61
|
-
* CqrsModule
|
|
100
|
+
* TypeOrmTransactionalModule.forRoot({ isDefault: true }),
|
|
101
|
+
* // No `CqrsModule` here — see the note above.
|
|
62
102
|
* CqrsTransactionalModule.forRoot(),
|
|
63
103
|
* ],
|
|
64
104
|
* })
|
|
65
105
|
* export class AppModule {}
|
|
66
106
|
* ```
|
|
67
107
|
*
|
|
68
|
-
* **Multi-dataSource setups
|
|
108
|
+
* **Multi-dataSource setups**: the cqrs runtime is
|
|
69
109
|
* dataSource-agnostic by design. There is exactly one
|
|
70
110
|
* `CqrsTransactionalModule.forRoot()` per application regardless of
|
|
71
111
|
* how many dataSources are configured — multi-DS routing emerges
|
|
@@ -88,5 +128,23 @@ export interface CqrsTransactionalOptions extends HandlerWrapperOptions {
|
|
|
88
128
|
*/
|
|
89
129
|
export declare class CqrsTransactionalModule {
|
|
90
130
|
static forRoot(options?: CqrsTransactionalOptions): DynamicModule;
|
|
131
|
+
/**
|
|
132
|
+
* Asynchronous registration. Resolves the wrapper options through a
|
|
133
|
+
* NestJS-style async factory before binding
|
|
134
|
+
* {@link CqrsHandlerWrapper}.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* CqrsTransactionalModule.forRootAsync({
|
|
139
|
+
* imports: [ConfigModule],
|
|
140
|
+
* inject: [ConfigService],
|
|
141
|
+
* useFactory: (cfg: ConfigService) => ({
|
|
142
|
+
* wrapQueryHandlers: cfg.get('WRAP_QUERIES') !== 'false',
|
|
143
|
+
* defaultCommandOptions: { isolation: cfg.get('TX_ISOLATION') },
|
|
144
|
+
* }),
|
|
145
|
+
* });
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
static forRootAsync(options: CqrsTransactionalAsyncOptions): DynamicModule;
|
|
91
149
|
}
|
|
92
150
|
//# sourceMappingURL=cqrs-transactional.module.d.ts.map
|