@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,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.INTEGRATION_EVENTS_HANDLER_METADATA = void 0;
|
|
4
|
-
exports.IntegrationEventsHandler = IntegrationEventsHandler;
|
|
5
|
-
exports.getIntegrationEventsHandlerMetadata = getIntegrationEventsHandlerMetadata;
|
|
6
|
-
require("reflect-metadata");
|
|
7
|
-
const core_1 = require("@nestjs-transactional/core");
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { DEFAULT_DATA_SOURCE_NAME } from '@nestjs-transactional/core';
|
|
8
3
|
/**
|
|
9
4
|
* Metadata key under which {@link IntegrationEventsHandlerMetadata} is
|
|
10
5
|
* stored on classes decorated with {@link IntegrationEventsHandler}.
|
|
@@ -13,15 +8,15 @@ const core_1 = require("@nestjs-transactional/core");
|
|
|
13
8
|
* smart scanner routes the handler based on whether a registrar is
|
|
14
9
|
* bound, not by inspecting shared metadata).
|
|
15
10
|
*/
|
|
16
|
-
|
|
17
|
-
function IntegrationEventsHandler(...args) {
|
|
11
|
+
export const INTEGRATION_EVENTS_HANDLER_METADATA = Symbol('INTEGRATION_EVENTS_HANDLER_METADATA');
|
|
12
|
+
export function IntegrationEventsHandler(...args) {
|
|
18
13
|
const metadata = resolveMetadata(args);
|
|
19
14
|
if (metadata.eventTypes.length === 0) {
|
|
20
15
|
throw new Error('@IntegrationEventsHandler requires at least one event type. ' +
|
|
21
16
|
'Pass class constructors as rest arguments or via the `events` option.');
|
|
22
17
|
}
|
|
23
18
|
return (target) => {
|
|
24
|
-
Reflect.defineMetadata(
|
|
19
|
+
Reflect.defineMetadata(INTEGRATION_EVENTS_HANDLER_METADATA, metadata, target);
|
|
25
20
|
};
|
|
26
21
|
}
|
|
27
22
|
function resolveMetadata(args) {
|
|
@@ -30,12 +25,12 @@ function resolveMetadata(args) {
|
|
|
30
25
|
return {
|
|
31
26
|
eventTypes: [...options.events],
|
|
32
27
|
id: options.id,
|
|
33
|
-
dataSource: options.dataSource ??
|
|
28
|
+
dataSource: options.dataSource ?? DEFAULT_DATA_SOURCE_NAME,
|
|
34
29
|
};
|
|
35
30
|
}
|
|
36
31
|
return {
|
|
37
32
|
eventTypes: args,
|
|
38
|
-
dataSource:
|
|
33
|
+
dataSource: DEFAULT_DATA_SOURCE_NAME,
|
|
39
34
|
};
|
|
40
35
|
}
|
|
41
36
|
function isOptionsObject(candidate) {
|
|
@@ -50,8 +45,8 @@ function isOptionsObject(candidate) {
|
|
|
50
45
|
* `target` by {@link IntegrationEventsHandler}. Returns `undefined`
|
|
51
46
|
* when the class was not decorated.
|
|
52
47
|
*/
|
|
53
|
-
function getIntegrationEventsHandlerMetadata(target) {
|
|
54
|
-
const value = Reflect.getMetadata(
|
|
48
|
+
export function getIntegrationEventsHandlerMetadata(target) {
|
|
49
|
+
const value = Reflect.getMetadata(INTEGRATION_EVENTS_HANDLER_METADATA, target);
|
|
55
50
|
return value;
|
|
56
51
|
}
|
|
57
52
|
//# sourceMappingURL=integration-events-handler.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-events-handler.decorator.js","sourceRoot":"","sources":["../../src/decorators/integration-events-handler.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"integration-events-handler.decorator.js","sourceRoot":"","sources":["../../src/decorators/integration-events-handler.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,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AIG;AACH,MAAM,UAAU,mCAAmC,CACjD,MAAc;IAEd,MAAM,KAAK,GAAY,OAAO,CAAC,WAAW,CAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;IACxF,OAAO,KAAqD,CAAC;AAC/D,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { type Type } from '@nestjs/common';
|
|
3
|
-
import { TransactionPhase } from '../types/transactional-listener.types';
|
|
3
|
+
import { TransactionPhase } from '../types/transactional-listener.types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Metadata key under which {@link TransactionalEventsHandlerMetadata} is
|
|
6
6
|
* stored on classes decorated with {@link TransactionalEventsHandler}.
|
|
@@ -40,7 +40,7 @@ export interface TransactionalEventsHandlerOptions {
|
|
|
40
40
|
*/
|
|
41
41
|
readonly fallbackExecution?: boolean;
|
|
42
42
|
/**
|
|
43
|
-
* dataSource the handler's phase hooks attach to
|
|
43
|
+
* dataSource the handler's phase hooks attach to.
|
|
44
44
|
* Defaults to {@link DEFAULT_DATA_SOURCE_NAME} (`'default'`) —
|
|
45
45
|
* single-dataSource apps can omit it.
|
|
46
46
|
*
|
|
@@ -57,7 +57,7 @@ export interface TransactionalEventsHandlerOptions {
|
|
|
57
57
|
* outbox path — both of which auto-resolve the dataSource by
|
|
58
58
|
* walking per-DS event-type registries — the in-memory dispatcher
|
|
59
59
|
* has no event-type registry to consult. The cqrs package is
|
|
60
|
-
* decoupled from outbox by design
|
|
60
|
+
* decoupled from outbox by design, so the dataSource
|
|
61
61
|
* is declared explicitly on the decorator.
|
|
62
62
|
*/
|
|
63
63
|
readonly dataSource?: string;
|
|
@@ -101,7 +101,7 @@ export interface TransactionalEventsHandlerMetadata {
|
|
|
101
101
|
* dispatcher registration happens at application bootstrap via
|
|
102
102
|
* `TransactionalListenerScanner`.
|
|
103
103
|
*
|
|
104
|
-
* **Multi-dataSource semantics
|
|
104
|
+
* **Multi-dataSource semantics.** The dispatcher pushes
|
|
105
105
|
* phase hooks directly onto the per-dataSource active transaction
|
|
106
106
|
* resolved via
|
|
107
107
|
* `TransactionContext.getActiveTransactionByDataSource(dataSource)`,
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.TransactionalEventsHandler = TransactionalEventsHandler;
|
|
5
|
-
exports.getTransactionalEventsHandlerMetadata = getTransactionalEventsHandlerMetadata;
|
|
6
|
-
require("reflect-metadata");
|
|
7
|
-
const core_1 = require("@nestjs-transactional/core");
|
|
8
|
-
const transactional_listener_types_1 = require("../types/transactional-listener.types");
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { DEFAULT_DATA_SOURCE_NAME } from '@nestjs-transactional/core';
|
|
3
|
+
import { TransactionPhase } from '../types/transactional-listener.types.js';
|
|
9
4
|
/**
|
|
10
5
|
* Metadata key under which {@link TransactionalEventsHandlerMetadata} is
|
|
11
6
|
* stored on classes decorated with {@link TransactionalEventsHandler}.
|
|
@@ -14,15 +9,15 @@ const transactional_listener_types_1 = require("../types/transactional-listener.
|
|
|
14
9
|
* private to the cqrs package and does not need to be shared across
|
|
15
10
|
* package boundaries.
|
|
16
11
|
*/
|
|
17
|
-
|
|
18
|
-
function TransactionalEventsHandler(...args) {
|
|
12
|
+
export const TRANSACTIONAL_EVENTS_HANDLER_METADATA = Symbol('TRANSACTIONAL_EVENTS_HANDLER_METADATA');
|
|
13
|
+
export function TransactionalEventsHandler(...args) {
|
|
19
14
|
const metadata = resolveMetadata(args);
|
|
20
15
|
if (metadata.eventTypes.length === 0) {
|
|
21
16
|
throw new Error('@TransactionalEventsHandler requires at least one event type. ' +
|
|
22
17
|
'Pass class constructors as rest arguments or via the `events` option.');
|
|
23
18
|
}
|
|
24
19
|
return (target) => {
|
|
25
|
-
Reflect.defineMetadata(
|
|
20
|
+
Reflect.defineMetadata(TRANSACTIONAL_EVENTS_HANDLER_METADATA, metadata, target);
|
|
26
21
|
};
|
|
27
22
|
}
|
|
28
23
|
function resolveMetadata(args) {
|
|
@@ -30,18 +25,18 @@ function resolveMetadata(args) {
|
|
|
30
25
|
const options = args[0];
|
|
31
26
|
return {
|
|
32
27
|
eventTypes: [...options.events],
|
|
33
|
-
phase: options.phase ??
|
|
28
|
+
phase: options.phase ?? TransactionPhase.AFTER_COMMIT,
|
|
34
29
|
async: options.async ?? false,
|
|
35
30
|
fallbackExecution: options.fallbackExecution ?? false,
|
|
36
|
-
dataSource: options.dataSource ??
|
|
31
|
+
dataSource: options.dataSource ?? DEFAULT_DATA_SOURCE_NAME,
|
|
37
32
|
};
|
|
38
33
|
}
|
|
39
34
|
return {
|
|
40
35
|
eventTypes: args,
|
|
41
|
-
phase:
|
|
36
|
+
phase: TransactionPhase.AFTER_COMMIT,
|
|
42
37
|
async: false,
|
|
43
38
|
fallbackExecution: false,
|
|
44
|
-
dataSource:
|
|
39
|
+
dataSource: DEFAULT_DATA_SOURCE_NAME,
|
|
45
40
|
};
|
|
46
41
|
}
|
|
47
42
|
function isOptionsObject(candidate) {
|
|
@@ -58,8 +53,8 @@ function isOptionsObject(candidate) {
|
|
|
58
53
|
*
|
|
59
54
|
* @param target - The class constructor.
|
|
60
55
|
*/
|
|
61
|
-
function getTransactionalEventsHandlerMetadata(target) {
|
|
62
|
-
const value = Reflect.getMetadata(
|
|
56
|
+
export function getTransactionalEventsHandlerMetadata(target) {
|
|
57
|
+
const value = Reflect.getMetadata(TRANSACTIONAL_EVENTS_HANDLER_METADATA, target);
|
|
63
58
|
return value;
|
|
64
59
|
}
|
|
65
60
|
//# sourceMappingURL=transactional-events-handler.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactional-events-handler.decorator.js","sourceRoot":"","sources":["../../src/decorators/transactional-events-handler.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transactional-events-handler.decorator.js","sourceRoot":"","sources":["../../src/decorators/transactional-events-handler.decorator.ts"],"names":[],"mappings":"A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K;QACxB,UAAU,EAAE,wBAAwB;KACrC,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,SAAkB;IACzC,OAAO,CACL,SAAS,KAAK,IAAI;QAClB,OAAO,SAAS,KAAK,QAAQ;QAC7B,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QACzB,OAAO,SAAS,KAAK,UAAU;QAC/B,QAAQ,IAAI,SAAS,CACtB,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qCAAqC,CACnD,MAAc;IAEd,MAAM,KAAK,GAAY,OAAO,CAAC,WAAW,CAAC,qCAAqC,EAAE,MAAM,CAAC,CAAC;IAC1F,OAAO,KAAuD,CAAC;AACjE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Type } from '@nestjs/common';
|
|
2
2
|
import { TransactionManager } from '@nestjs-transactional/core';
|
|
3
|
-
import { TransactionPhase } from '../types/transactional-listener.types';
|
|
3
|
+
import { TransactionPhase } from '../types/transactional-listener.types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Resolved per-event-type listener configuration used by
|
|
6
6
|
* {@link TransactionalEventDispatcher.registerListener}. Scanners flatten
|
|
@@ -13,7 +13,7 @@ export interface DispatcherListenerMetadata {
|
|
|
13
13
|
readonly fallbackExecution: boolean;
|
|
14
14
|
readonly async: boolean;
|
|
15
15
|
/**
|
|
16
|
-
* dataSource the listener's phase hooks attach to
|
|
16
|
+
* dataSource the listener's phase hooks attach to.
|
|
17
17
|
* Optional for backward compatibility — when omitted, defaults to
|
|
18
18
|
* `'default'`. Scanners normalise from decorator metadata before
|
|
19
19
|
* calling {@link TransactionalEventDispatcher.registerListener}.
|
|
@@ -44,7 +44,7 @@ export interface DispatcherListenerMetadata {
|
|
|
44
44
|
* their failures are logged but never reach the enclosing
|
|
45
45
|
* transaction, even in BEFORE_COMMIT phase.
|
|
46
46
|
*
|
|
47
|
-
* **Multi-dataSource
|
|
47
|
+
* **Multi-dataSource.** Hook attachment is per-dataSource:
|
|
48
48
|
* the dispatcher resolves the listener's bound dataSource via
|
|
49
49
|
* `TransactionContext.getActiveTransactionByDataSource(dataSource)`
|
|
50
50
|
* and pushes hooks directly onto that transaction's hook list,
|
|
@@ -63,7 +63,7 @@ export declare class TransactionalEventDispatcher {
|
|
|
63
63
|
private readonly logger;
|
|
64
64
|
private readonly listenersByType;
|
|
65
65
|
/**
|
|
66
|
-
* `manager` is no longer consulted
|
|
66
|
+
* `manager` is no longer consulted — the
|
|
67
67
|
* dispatcher pushes hooks directly onto the per-dataSource
|
|
68
68
|
* `ActiveTransaction` resolved via `TransactionContext`. The
|
|
69
69
|
* parameter is preserved as a constructor argument so existing
|
|
@@ -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,11 +8,9 @@ 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 TransactionalEventDispatcher_1;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const core_1 = require("@nestjs-transactional/core");
|
|
16
|
-
const transactional_listener_types_1 = require("../types/transactional-listener.types");
|
|
11
|
+
import { Injectable, Logger } from '@nestjs/common';
|
|
12
|
+
import { DEFAULT_DATA_SOURCE_NAME, TransactionContext, TransactionManager, } from '@nestjs-transactional/core';
|
|
13
|
+
import { TransactionPhase } from '../types/transactional-listener.types.js';
|
|
17
14
|
/**
|
|
18
15
|
* Routes domain events to methods registered by scanners for
|
|
19
16
|
* `@TransactionalEventsHandler`-annotated classes, honouring the
|
|
@@ -38,7 +35,7 @@ const transactional_listener_types_1 = require("../types/transactional-listener.
|
|
|
38
35
|
* their failures are logged but never reach the enclosing
|
|
39
36
|
* transaction, even in BEFORE_COMMIT phase.
|
|
40
37
|
*
|
|
41
|
-
* **Multi-dataSource
|
|
38
|
+
* **Multi-dataSource.** Hook attachment is per-dataSource:
|
|
42
39
|
* the dispatcher resolves the listener's bound dataSource via
|
|
43
40
|
* `TransactionContext.getActiveTransactionByDataSource(dataSource)`
|
|
44
41
|
* and pushes hooks directly onto that transaction's hook list,
|
|
@@ -54,10 +51,10 @@ const transactional_listener_types_1 = require("../types/transactional-listener.
|
|
|
54
51
|
*/
|
|
55
52
|
let TransactionalEventDispatcher = TransactionalEventDispatcher_1 = class TransactionalEventDispatcher {
|
|
56
53
|
manager;
|
|
57
|
-
logger = new
|
|
54
|
+
logger = new Logger(TransactionalEventDispatcher_1.name);
|
|
58
55
|
listenersByType = new Map();
|
|
59
56
|
/**
|
|
60
|
-
* `manager` is no longer consulted
|
|
57
|
+
* `manager` is no longer consulted — the
|
|
61
58
|
* dispatcher pushes hooks directly onto the per-dataSource
|
|
62
59
|
* `ActiveTransaction` resolved via `TransactionContext`. The
|
|
63
60
|
* parameter is preserved as a constructor argument so existing
|
|
@@ -65,7 +62,6 @@ let TransactionalEventDispatcher = TransactionalEventDispatcher_1 = class Transa
|
|
|
65
62
|
* keep compiling. NestJS DI continues to inject the manager
|
|
66
63
|
* automatically. A future cleanup phase may drop it.
|
|
67
64
|
*/
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
69
65
|
constructor(manager) {
|
|
70
66
|
this.manager = manager;
|
|
71
67
|
}
|
|
@@ -115,11 +111,11 @@ let TransactionalEventDispatcher = TransactionalEventDispatcher_1 = class Transa
|
|
|
115
111
|
if (listeners === undefined || listeners.length === 0) {
|
|
116
112
|
return;
|
|
117
113
|
}
|
|
118
|
-
const store =
|
|
114
|
+
const store = TransactionContext.getStore();
|
|
119
115
|
const anyTxActive = store !== undefined && store.activeTransactions.size > 0;
|
|
120
116
|
for (const listener of listeners) {
|
|
121
|
-
const dataSource = listener.metadata.dataSource ??
|
|
122
|
-
const tx =
|
|
117
|
+
const dataSource = listener.metadata.dataSource ?? DEFAULT_DATA_SOURCE_NAME;
|
|
118
|
+
const tx = TransactionContext.getActiveTransactionByDataSource(dataSource);
|
|
123
119
|
if (tx === undefined) {
|
|
124
120
|
// No active transaction for this listener's dataSource. Two
|
|
125
121
|
// sub-cases:
|
|
@@ -155,18 +151,18 @@ let TransactionalEventDispatcher = TransactionalEventDispatcher_1 = class Transa
|
|
|
155
151
|
// Push hooks directly onto THIS specific transaction's hook lists,
|
|
156
152
|
// bypassing TransactionManager.registerBeforeCommit's
|
|
157
153
|
// first-active-tx resolution. Same pattern as
|
|
158
|
-
// DataSourceOutboxPublisher.scheduleForPublication
|
|
154
|
+
// DataSourceOutboxPublisher.scheduleForPublication.
|
|
159
155
|
switch (listener.metadata.phase) {
|
|
160
|
-
case
|
|
156
|
+
case TransactionPhase.BEFORE_COMMIT:
|
|
161
157
|
tx.beforeCommitHooks.push(invoke);
|
|
162
158
|
return;
|
|
163
|
-
case
|
|
159
|
+
case TransactionPhase.AFTER_COMMIT:
|
|
164
160
|
tx.afterCommitHooks.push(invoke);
|
|
165
161
|
return;
|
|
166
|
-
case
|
|
162
|
+
case TransactionPhase.AFTER_ROLLBACK:
|
|
167
163
|
tx.afterRollbackHooks.push(invokeWithError);
|
|
168
164
|
return;
|
|
169
|
-
case
|
|
165
|
+
case TransactionPhase.AFTER_COMPLETION:
|
|
170
166
|
tx.afterCommitHooks.push(invoke);
|
|
171
167
|
tx.afterRollbackHooks.push(invokeWithError);
|
|
172
168
|
return;
|
|
@@ -221,9 +217,9 @@ let TransactionalEventDispatcher = TransactionalEventDispatcher_1 = class Transa
|
|
|
221
217
|
this.logger.error(`Transactional event handler ${listener.instanceLabel}.${listener.methodName} failed`, err instanceof Error ? err.stack : String(err));
|
|
222
218
|
}
|
|
223
219
|
};
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
(
|
|
227
|
-
__metadata("design:paramtypes", [core_1.TransactionManager])
|
|
220
|
+
TransactionalEventDispatcher = TransactionalEventDispatcher_1 = __decorate([
|
|
221
|
+
Injectable(),
|
|
222
|
+
__metadata("design:paramtypes", [TransactionManager])
|
|
228
223
|
], TransactionalEventDispatcher);
|
|
224
|
+
export { TransactionalEventDispatcher };
|
|
229
225
|
//# sourceMappingURL=event-dispatcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-dispatcher.js","sourceRoot":"","sources":["../../src/event-dispatcher/event-dispatcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event-dispatcher.js","sourceRoot":"","sources":["../../src/event-dispatcher/event-dispatcher.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAa,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAEL,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AA4C5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEI,IAAM,4BAA4B,oCAAlC,MAAM,4BAA4B;IAaV;IAZZ,MAAM,GAAG,IAAI,MAAM,CAAC,8BAA4B,CAAC,IAAI,CAAC,CAAC;IACvD,eAAe,GAAG,IAAI,GAAG,EAAgC,CAAC;IAE3E;;;;;;;;OAQG;IACH,YAA6B,OAA2B;QAA3B,YAAO,GAAP,OAAO,CAAoB;IAAG,CAAC;IAE5D;;;;;;;;;OASG;IACH,gBAAgB,CACd,QAAgB,EAChB,UAAkB,EAClB,QAAoC;QAEpC,MAAM,SAAS,GAAI,QAAoC,CAAC,UAAU,CAAC,CAAC;QACpE,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;YACpC,MAAM,IAAI,SAAS,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A+B,QAAQ,CAAC,aAAa,IAAI,QAAQ,CAAC,UAAU,SAAS,EACrF,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAC/C,CAAC;IACJ,CAAC;CACF,CAAA;AAvMY,4BAA4B;IADxC,UAAU,EAAE;qCAc2B,kBAAkB;GAb7C,4BAA4B,CAuMxC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IEvent, IEventPublisher } from '@nestjs/cqrs';
|
|
2
|
-
import { TransactionalEventDispatcher } from '../event-dispatcher/event-dispatcher';
|
|
2
|
+
import { TransactionalEventDispatcher } from '../event-dispatcher/event-dispatcher.js';
|
|
3
3
|
/**
|
|
4
4
|
* Minimal structural contract for the outbox-side publisher. Declared
|
|
5
5
|
* here (and injected via the {@link OUTBOX_PUBLICATION_SCHEDULER}
|
|
@@ -56,7 +56,7 @@ export declare const OUTBOX_PUBLICATION_SCHEDULER: unique symbol;
|
|
|
56
56
|
* hook flushes the buffer DO bubble up — they cause the transaction
|
|
57
57
|
* to roll back, which is the intended behavior.
|
|
58
58
|
*
|
|
59
|
-
* **Multi-dataSource
|
|
59
|
+
* **Multi-dataSource.** The outbox scheduler is the
|
|
60
60
|
* smart-facade `OutboxEventPublisher` (DD-024). When wired,
|
|
61
61
|
* AggregateRoot events are routed to the per-dataSource publisher
|
|
62
62
|
* that owns the event class — the same routing semantics as
|
|
@@ -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);
|
|
@@ -11,16 +10,14 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
|
-
const event_dispatcher_1 = require("../event-dispatcher/event-dispatcher");
|
|
13
|
+
import { Inject, Injectable, Optional } from '@nestjs/common';
|
|
14
|
+
import { TransactionalEventDispatcher } from '../event-dispatcher/event-dispatcher.js';
|
|
18
15
|
/**
|
|
19
16
|
* DI token for the optional outbox scheduler injected into
|
|
20
17
|
* {@link HybridEventPublisher}. When unbound, the hybrid publisher
|
|
21
18
|
* delegates only to the in-memory dispatcher.
|
|
22
19
|
*/
|
|
23
|
-
|
|
20
|
+
export const OUTBOX_PUBLICATION_SCHEDULER = Symbol('OUTBOX_PUBLICATION_SCHEDULER');
|
|
24
21
|
/**
|
|
25
22
|
* `IEventPublisher` implementation that routes aggregate-emitted
|
|
26
23
|
* events through BOTH the in-memory transactional dispatcher
|
|
@@ -47,7 +44,7 @@ exports.OUTBOX_PUBLICATION_SCHEDULER = Symbol('OUTBOX_PUBLICATION_SCHEDULER');
|
|
|
47
44
|
* hook flushes the buffer DO bubble up — they cause the transaction
|
|
48
45
|
* to roll back, which is the intended behavior.
|
|
49
46
|
*
|
|
50
|
-
* **Multi-dataSource
|
|
47
|
+
* **Multi-dataSource.** The outbox scheduler is the
|
|
51
48
|
* smart-facade `OutboxEventPublisher` (DD-024). When wired,
|
|
52
49
|
* AggregateRoot events are routed to the per-dataSource publisher
|
|
53
50
|
* that owns the event class — the same routing semantics as
|
|
@@ -76,11 +73,11 @@ let HybridEventPublisher = class HybridEventPublisher {
|
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
75
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
(
|
|
82
|
-
__param(1, (
|
|
83
|
-
|
|
84
|
-
__metadata("design:paramtypes", [event_dispatcher_1.TransactionalEventDispatcher, Object])
|
|
76
|
+
HybridEventPublisher = __decorate([
|
|
77
|
+
Injectable(),
|
|
78
|
+
__param(1, Optional()),
|
|
79
|
+
__param(1, Inject(OUTBOX_PUBLICATION_SCHEDULER)),
|
|
80
|
+
__metadata("design:paramtypes", [TransactionalEventDispatcher, Object])
|
|
85
81
|
], HybridEventPublisher);
|
|
82
|
+
export { HybridEventPublisher };
|
|
86
83
|
//# sourceMappingURL=hybrid-event-publisher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hybrid-event-publisher.js","sourceRoot":"","sources":["../../src/event-publisher/hybrid-event-publisher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hybrid-event-publisher.js","sourceRoot":"","sources":["../../src/event-publisher/hybrid-event-publisher.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AA2BvF;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,8BAA8B,CAAC,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAEZ;IAGA;IAJnB,YACmB,UAAwC,EAGxC,MAAmC;QAHnC,eAAU,GAAV,UAAU,CAA8B;QAGxC,WAAM,GAAN,MAAM,CAA6B;IACnD,CAAC;IAEJ,OAAO,CAAmB,KAAQ;QAChC,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,UAAU,CAAmB,MAAW;QACtC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;CACF,CAAA;AApBY,oBAAoB;IADhC,UAAU,EAAE;IAIR,WAAA,QAAQ,EAAE,CAAA;IACV,WAAA,MAAM,CAAC,4BAA4B,CAAC,CAAA;qCAFR,4BAA4B;GAFhD,oBAAoB,CAoBhC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AggregateConstructor<T extends
|
|
1
|
+
import { type AsyncContext, EventBus, EventPublisher, type IEventPublisher } from '@nestjs/cqrs';
|
|
2
|
+
export type AggregateConstructor<T extends object = object> = new (...args: never[]) => T;
|
|
3
3
|
/**
|
|
4
4
|
* Drop-in replacement for `@nestjs/cqrs`'s `EventPublisher`. Wired
|
|
5
5
|
* automatically by `CqrsTransactionalModule` via
|
|
@@ -21,12 +21,22 @@ type AggregateConstructor<T extends AggregateRoot> = new (...args: never[]) => T
|
|
|
21
21
|
* bypass phase-aware dispatching. Only aggregate-emitted events routed
|
|
22
22
|
* via `mergeObjectContext` / `mergeClassContext` get transactional
|
|
23
23
|
* semantics.
|
|
24
|
+
*
|
|
25
|
+
* **`asyncContext` is accepted and not used**, on both `@nestjs/cqrs` 11
|
|
26
|
+
* and 12. The base class forwards it to `eventBus.publish(event, this,
|
|
27
|
+
* asyncContext)`, where it selects a request-scoped handler instance.
|
|
28
|
+
* This adapter never reaches that path: `TransactionalEventDispatcher`
|
|
29
|
+
* keeps its own listener registry and binds each handler method to its
|
|
30
|
+
* instance at registration time, so there is no scoped resolution left
|
|
31
|
+
* for an `AsyncContext` to influence. The parameter is declared so the
|
|
32
|
+
* override matches the base signature, and swallowing it silently would
|
|
33
|
+
* be worse than saying so here. Scoped CQRS handlers are not supported
|
|
34
|
+
* through this publisher.
|
|
24
35
|
*/
|
|
25
36
|
export declare class TransactionalEventPublisherAdapter extends EventPublisher {
|
|
26
37
|
private readonly strategy;
|
|
27
38
|
constructor(strategy: IEventPublisher, eventBus: EventBus);
|
|
28
|
-
mergeClassContext<T extends AggregateConstructor
|
|
29
|
-
mergeObjectContext<T extends
|
|
39
|
+
mergeClassContext<T extends AggregateConstructor>(metatype: T, _asyncContext?: AsyncContext): T;
|
|
40
|
+
mergeObjectContext<T extends object>(object: T, _asyncContext?: AsyncContext): T;
|
|
30
41
|
}
|
|
31
|
-
export {};
|
|
32
42
|
//# sourceMappingURL=transactional-event-publisher-adapter.d.ts.map
|
|
@@ -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);
|
|
@@ -8,10 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
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
|
-
|
|
12
|
-
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const cqrs_1 = require("@nestjs/cqrs");
|
|
10
|
+
import { Injectable } from '@nestjs/common';
|
|
11
|
+
import { EventBus, EventPublisher, } from '@nestjs/cqrs';
|
|
15
12
|
/**
|
|
16
13
|
* Drop-in replacement for `@nestjs/cqrs`'s `EventPublisher`. Wired
|
|
17
14
|
* automatically by `CqrsTransactionalModule` via
|
|
@@ -33,14 +30,25 @@ const cqrs_1 = require("@nestjs/cqrs");
|
|
|
33
30
|
* bypass phase-aware dispatching. Only aggregate-emitted events routed
|
|
34
31
|
* via `mergeObjectContext` / `mergeClassContext` get transactional
|
|
35
32
|
* semantics.
|
|
33
|
+
*
|
|
34
|
+
* **`asyncContext` is accepted and not used**, on both `@nestjs/cqrs` 11
|
|
35
|
+
* and 12. The base class forwards it to `eventBus.publish(event, this,
|
|
36
|
+
* asyncContext)`, where it selects a request-scoped handler instance.
|
|
37
|
+
* This adapter never reaches that path: `TransactionalEventDispatcher`
|
|
38
|
+
* keeps its own listener registry and binds each handler method to its
|
|
39
|
+
* instance at registration time, so there is no scoped resolution left
|
|
40
|
+
* for an `AsyncContext` to influence. The parameter is declared so the
|
|
41
|
+
* override matches the base signature, and swallowing it silently would
|
|
42
|
+
* be worse than saying so here. Scoped CQRS handlers are not supported
|
|
43
|
+
* through this publisher.
|
|
36
44
|
*/
|
|
37
|
-
let TransactionalEventPublisherAdapter = class TransactionalEventPublisherAdapter extends
|
|
45
|
+
let TransactionalEventPublisherAdapter = class TransactionalEventPublisherAdapter extends EventPublisher {
|
|
38
46
|
strategy;
|
|
39
47
|
constructor(strategy, eventBus) {
|
|
40
48
|
super(eventBus);
|
|
41
49
|
this.strategy = strategy;
|
|
42
50
|
}
|
|
43
|
-
mergeClassContext(metatype) {
|
|
51
|
+
mergeClassContext(metatype, _asyncContext) {
|
|
44
52
|
const strategy = this.strategy;
|
|
45
53
|
class TransactionalMerged extends metatype {
|
|
46
54
|
publish(event) {
|
|
@@ -52,7 +60,7 @@ let TransactionalEventPublisherAdapter = class TransactionalEventPublisherAdapte
|
|
|
52
60
|
}
|
|
53
61
|
return TransactionalMerged;
|
|
54
62
|
}
|
|
55
|
-
mergeObjectContext(object) {
|
|
63
|
+
mergeObjectContext(object, _asyncContext) {
|
|
56
64
|
const strategy = this.strategy;
|
|
57
65
|
const host = object;
|
|
58
66
|
host.publish = (event) => {
|
|
@@ -64,9 +72,9 @@ let TransactionalEventPublisherAdapter = class TransactionalEventPublisherAdapte
|
|
|
64
72
|
return object;
|
|
65
73
|
}
|
|
66
74
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(
|
|
70
|
-
__metadata("design:paramtypes", [Object, cqrs_1.EventBus])
|
|
75
|
+
TransactionalEventPublisherAdapter = __decorate([
|
|
76
|
+
Injectable(),
|
|
77
|
+
__metadata("design:paramtypes", [Object, EventBus])
|
|
71
78
|
], TransactionalEventPublisherAdapter);
|
|
79
|
+
export { TransactionalEventPublisherAdapter };
|
|
72
80
|
//# sourceMappingURL=transactional-event-publisher-adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactional-event-publisher-adapter.js","sourceRoot":"","sources":["../../src/event-publisher/transactional-event-publisher-adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transactional-event-publisher-adapter.js","sourceRoot":"","sources":["../../src/event-publisher/transactional-event-publisher-adapter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAEL,QAAQ,EACR,cAAc,GAGf,MAAM,cAAc,CAAC;AAkBtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEI,IAAM,kCAAkC,GAAxC,MAAM,kCAAmC,SAAQ,cAAc;IAEjD;IADnB,YACmB,QAAyB,EAC1C,QAAkB;QAElB,KAAK,CAAC,QAAQ,CAAC,CAAC;QAHC,aAAQ,GAAR,QAAQ,CAAiB;IAI5C,CAAC;IAED,iBAAiB,CAAiC,QAAW,EAAE,aAA4B;QACzF,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE/B,MAAM,mBAAoB,SAAS,QAAiC;YAClE,OAAO,CAAwB,KAAa;gBAC1C,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC1B,CAAC;YACD,UAAU,CAAwB,MAAgB;gBAChD,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC;YAChC,CAAC;SACF;QAED,OAAO,mBAAmC,CAAC;IAC7C,CAAC;IAED,kBAAkB,CAAmB,MAAS,EAAE,aAA4B;QAC1E,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,MAAM,IAAI,GAAG,MAGZ,CAAC;QACF,IAAI,CAAC,OAAO,GAAG,CAAC,KAAa,EAAQ,EAAE;YACrC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC,CAAC;QACF,IAAI,CAAC,UAAU,GAAG,CAAC,MAAgB,EAAQ,EAAE;YAC3C,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC;QAChC,CAAC,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AArCY,kCAAkC;IAD9C,UAAU,EAAE;6CAIC,QAAQ;GAHT,kCAAkC,CAqC9C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IEvent, IEventPublisher } from '@nestjs/cqrs';
|
|
2
|
-
import { TransactionalEventDispatcher } from '../event-dispatcher/event-dispatcher';
|
|
2
|
+
import { TransactionalEventDispatcher } from '../event-dispatcher/event-dispatcher.js';
|
|
3
3
|
/**
|
|
4
4
|
* `IEventPublisher` implementation that routes aggregate-emitted events
|
|
5
5
|
* to {@link TransactionalEventDispatcher} instead of pushing them straight
|
|
@@ -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);
|
|
@@ -8,10 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
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
|
-
|
|
12
|
-
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const event_dispatcher_1 = require("../event-dispatcher/event-dispatcher");
|
|
10
|
+
import { Injectable } from '@nestjs/common';
|
|
11
|
+
import { TransactionalEventDispatcher } from '../event-dispatcher/event-dispatcher.js';
|
|
15
12
|
/**
|
|
16
13
|
* `IEventPublisher` implementation that routes aggregate-emitted events
|
|
17
14
|
* to {@link TransactionalEventDispatcher} instead of pushing them straight
|
|
@@ -50,9 +47,9 @@ let TransactionalEventPublisher = class TransactionalEventPublisher {
|
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
49
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
(
|
|
56
|
-
__metadata("design:paramtypes", [event_dispatcher_1.TransactionalEventDispatcher])
|
|
50
|
+
TransactionalEventPublisher = __decorate([
|
|
51
|
+
Injectable(),
|
|
52
|
+
__metadata("design:paramtypes", [TransactionalEventDispatcher])
|
|
57
53
|
], TransactionalEventPublisher);
|
|
54
|
+
export { TransactionalEventPublisher };
|
|
58
55
|
//# sourceMappingURL=transactional-event-publisher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactional-event-publisher.js","sourceRoot":"","sources":["../../src/event-publisher/transactional-event-publisher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transactional-event-publisher.js","sourceRoot":"","sources":["../../src/event-publisher/transactional-event-publisher.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAEvF;;;;;;;;;;;;;GAaG;AAEI,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IACT;IAA7B,YAA6B,UAAwC;QAAxC,eAAU,GAAV,UAAU,CAA8B;IAAG,CAAC;IAEzE;;;;;OAKG;IACH,OAAO,CAAmB,KAAQ;QAChC,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACH,UAAU,CAAmB,MAAW;QACtC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;CACF,CAAA;AAtBY,2BAA2B;IADvC,UAAU,EAAE;qCAE8B,4BAA4B;GAD1D,2BAA2B,CAsBvC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type OnApplicationBootstrap } from '@nestjs/common';
|
|
2
|
-
import { CqrsHandlerWrapper } from './handler-wrapper';
|
|
2
|
+
import { CqrsHandlerWrapper } from './handler-wrapper.js';
|
|
3
3
|
/**
|
|
4
4
|
* Fires `CqrsHandlerWrapper.wrapAll` at application bootstrap, after all
|
|
5
5
|
* `onModuleInit` hooks (including `@nestjs/cqrs`'s explorer) have
|
|
@@ -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);
|
|
@@ -8,10 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
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
|
-
|
|
12
|
-
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const handler_wrapper_1 = require("./handler-wrapper");
|
|
10
|
+
import { Injectable } from '@nestjs/common';
|
|
11
|
+
import { CqrsHandlerWrapper } from './handler-wrapper.js';
|
|
15
12
|
/**
|
|
16
13
|
* Fires `CqrsHandlerWrapper.wrapAll` at application bootstrap, after all
|
|
17
14
|
* `onModuleInit` hooks (including `@nestjs/cqrs`'s explorer) have
|
|
@@ -31,9 +28,9 @@ let CqrsTransactionalBootstrap = class CqrsTransactionalBootstrap {
|
|
|
31
28
|
this.wrapper.wrapAll();
|
|
32
29
|
}
|
|
33
30
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
(
|
|
37
|
-
__metadata("design:paramtypes", [handler_wrapper_1.CqrsHandlerWrapper])
|
|
31
|
+
CqrsTransactionalBootstrap = __decorate([
|
|
32
|
+
Injectable(),
|
|
33
|
+
__metadata("design:paramtypes", [CqrsHandlerWrapper])
|
|
38
34
|
], CqrsTransactionalBootstrap);
|
|
35
|
+
export { CqrsTransactionalBootstrap };
|
|
39
36
|
//# sourceMappingURL=bootstrap.js.map
|