@nestjs-transactional/cqrs 1.0.0-alpha.0 → 1.0.0-alpha.2

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 CHANGED
@@ -410,16 +410,54 @@ publications unless `options.id` is set.
410
410
 
411
411
  Full catalogue: [examples/README.md](../../examples/README.md).
412
412
 
413
+ ## Handler scopes
414
+
415
+ Works with handlers of any `@nestjs/cqrs` scope —
416
+ `Scope.DEFAULT` (singleton), `Scope.REQUEST`, and `Scope.TRANSIENT` —
417
+ since [ADR-020](../../docs/adr/020-prototype-level-cqrs-wrapping.md):
418
+ the wrap is applied to the handler class **prototype**, which
419
+ intercepts `@nestjs/cqrs`'s late-bound `instance.execute(query)` lookup
420
+ regardless of how the instance is resolved.
421
+
422
+ A common request-scoped pattern uses `@nestjs/cqrs`'s own `AsyncContext`
423
+ mechanism to carry per-request data (user, geo, A/B flags, ...) into
424
+ the handler via the standard `REQUEST` token:
425
+
426
+ ```ts
427
+ import { Inject, Scope } from '@nestjs/common';
428
+ import { REQUEST } from '@nestjs/core';
429
+ import { AsyncContext, QueryHandler, IQueryHandler } from '@nestjs/cqrs';
430
+
431
+ @QueryHandler(ListUserContributionsQuery, { scope: Scope.REQUEST })
432
+ export class ListUserContributionsQueryHandler
433
+ implements IQueryHandler<ListUserContributionsQuery> {
434
+ constructor(@Inject(REQUEST) private readonly ctx: AsyncContext) {}
435
+
436
+ async execute(query: ListUserContributionsQuery) {
437
+ // this.ctx carries the per-request data, the wrap opens a transaction
438
+ }
439
+ }
440
+ ```
441
+
442
+ Multiple dispatches that should share one handler instance per HTTP
443
+ request need to share one `AsyncContext` — either pass it as the second
444
+ argument (`queryBus.execute(query, ctx)`) or attach it to each query
445
+ via `AsyncContext.merge(source, query)`. Without sharing, each dispatch
446
+ gets a new `AsyncContext` (and a new instance) — that is `@nestjs/cqrs`
447
+ behaviour and unrelated to the transaction wrap.
448
+
413
449
  ## Limitations
414
450
 
415
- - Only works with **singleton** handlers. Request-scoped CQRS handlers
416
- are resolved per-request by `@nestjs/cqrs` via `ModuleRef.resolve(...)`,
417
- producing a fresh instance our bootstrap wrap has not mutated.
418
451
  - Direct `eventBus.publish(...)` calls (outside of an aggregate) do NOT
419
452
  go through the transactional dispatcher — only `AggregateRoot.commit()`
420
453
  -emitted events via `mergeObjectContext` / `mergeClassContext`. If you
421
454
  need phase-aware handlers on bus-published events, publish them from
422
455
  an aggregate instead.
456
+ - Arrow-function `execute = async (q) => {...}` /
457
+ `handle = async (e) => {...}` defined as instance fields are not
458
+ wrapped. The wrap point is the class prototype, and instance arrow
459
+ fields shadow the prototype. Use regular method syntax
460
+ (`async execute(q) { ... }`) so the method lives on the prototype.
423
461
  - `@nestjs/cqrs`'s handler-metadata constants are read via hardcoded
424
462
  string literals (`__commandHandler__`, etc.) because `@nestjs/cqrs`
425
463
  does not re-export them. See `handler-wrapper.ts` —
@@ -1,4 +1,5 @@
1
1
  import 'reflect-metadata';
2
+ import { type OnModuleDestroy } from '@nestjs/common';
2
3
  import { DiscoveryService } from '@nestjs/core';
3
4
  import { TransactionManager, type TransactionalMetadata } from '@nestjs-transactional/core';
4
5
  /**
@@ -35,30 +36,80 @@ export interface HandlerWrapperOptions {
35
36
  }
36
37
  /**
37
38
  * Wraps the `execute` (or `handle`) method of every `@CommandHandler` /
38
- * `@QueryHandler` / `@EventsHandler` instance with a transaction, using
39
- * the handler's own `@Transactional` metadata where present or the
39
+ * `@QueryHandler` / `@EventsHandler` class prototype with a transaction,
40
+ * using the handler's own `@Transactional` metadata where present or the
40
41
  * kind-specific defaults from {@link HandlerWrapperOptions} otherwise.
41
42
  *
42
- * The replacement is an own-property assignment on each handler instance,
43
- * shadowing the prototype method. `@nestjs/cqrs`'s buses resolve
44
- * `instance.execute` / `instance.handle` at call time (late binding), so
45
- * the wrap takes effect for every subsequent bus dispatch.
43
+ * The replacement is an own-property assignment on each handler class
44
+ * prototype, intercepting `@nestjs/cqrs`'s late-bound
45
+ * `instance.execute(query)` / `instance.handle(event)` lookup. This works
46
+ * for handlers of any scope — `Scope.DEFAULT` (singleton),
47
+ * `Scope.REQUEST`, and `Scope.TRANSIENT` — because the wrap point is the
48
+ * prototype, not any particular instance. See ADR-020.
46
49
  *
47
50
  * Double-wrap prevention: each wrapped method is tagged with the shared
48
51
  * `WRAPPED_MARKER` symbol. Other mechanisms in the coordinated wrapping
49
52
  * triad (see ADR-005) honour the same marker.
50
53
  *
51
- * Limitation: only works with static-dependency-tree (singleton) handlers.
52
- * Request-scoped handlers are resolved per-request by `@nestjs/cqrs`'s
53
- * `ModuleRef.resolve`, which produces a fresh instance our wrap has not
54
- * mutated.
54
+ * Test isolation: prototype mutation persists across `TestingModule`
55
+ * rebuilds. Call {@link CqrsHandlerWrapper.resetForTesting} in
56
+ * `beforeEach` to restore prototypes between cases. See ADR-020.
57
+ *
58
+ * Limitation: arrow-function `execute = async (q) => {...}` /
59
+ * `handle = async (e) => {...}` defined as instance fields are not
60
+ * wrapped — they live on the instance and shadow the prototype. Use
61
+ * regular method syntax (`async execute(q) { ... }`) so the method
62
+ * lives on the prototype.
55
63
  */
56
- export declare class CqrsHandlerWrapper {
64
+ export declare class CqrsHandlerWrapper implements OnModuleDestroy {
57
65
  private readonly discovery;
58
66
  private readonly manager;
59
67
  private readonly options;
60
68
  private readonly logger;
69
+ /**
70
+ * Tracks every prototype the wrapper has mutated so
71
+ * {@link CqrsHandlerWrapper.resetForTesting} can restore the
72
+ * originals. Static — shared across wrapper instances (typically one
73
+ * per app; multiple `TestingModule` rebuilds across tests share this
74
+ * tracker and the marker on each prototype method, hence the need
75
+ * for an explicit reset).
76
+ */
77
+ private static readonly wrappedPrototypes;
78
+ /**
79
+ * @internal Test-isolation hook (ADR-020). Restores prototype
80
+ * methods mutated by previous `wrapAll` runs and clears the
81
+ * tracker. Call in `beforeEach` when a test suite rebuilds the
82
+ * `TestingModule` between cases — without this, the prototype
83
+ * stays wrapped from the previous test and `WRAPPED_MARKER` makes
84
+ * the next `wrapAll` a no-op, leaving the wrong wrapper (or any
85
+ * wrapper at all, in "leaves unwrapped" assertions) in place.
86
+ *
87
+ * Production code calling this after the wrap loop has finished
88
+ * does not affect already-resolved handler instances — late-bound
89
+ * `instance.execute(query)` resolves to whatever lives on the
90
+ * prototype at call time, which after this call is the original
91
+ * method.
92
+ *
93
+ * Mirrors `OutboxModule.resetForTesting` (ADR-019 § 5).
94
+ */
95
+ static resetForTesting(): void;
61
96
  constructor(discovery: DiscoveryService, manager: TransactionManager, options: HandlerWrapperOptions);
97
+ /**
98
+ * NestJS lifecycle hook. When the module closes (`module.close()`,
99
+ * `app.close()`, test teardown via `afterEach: module.close`), restore
100
+ * every wrapped prototype method. This makes subsequent
101
+ * `TestingModule` rebuilds in the same process start from a clean
102
+ * prototype — without it, the `WRAPPED_MARKER` on the previous
103
+ * wrapper short-circuits the next `wrapAll`, leaving a stale closure
104
+ * (over the previous `TransactionManager`) on the prototype.
105
+ *
106
+ * Production effect: none — by the time `onModuleDestroy` fires the
107
+ * app is shutting down and no further bus dispatches occur. The
108
+ * explicit {@link CqrsHandlerWrapper.resetForTesting} static remains
109
+ * available for tests that do not rely on `module.close()` for
110
+ * cleanup.
111
+ */
112
+ onModuleDestroy(): void;
62
113
  /**
63
114
  * Scan every provider and wrap handler methods. Safe to call multiple
64
115
  * times — the `WRAPPED_MARKER` check guarantees idempotency.
@@ -51,34 +51,93 @@ const WRAPPED_MARKER = Symbol.for('@nestjs-transactional/wrapped');
51
51
  exports.CQRS_HANDLER_WRAPPER_OPTIONS = Symbol('CQRS_HANDLER_WRAPPER_OPTIONS');
52
52
  /**
53
53
  * Wraps the `execute` (or `handle`) method of every `@CommandHandler` /
54
- * `@QueryHandler` / `@EventsHandler` instance with a transaction, using
55
- * the handler's own `@Transactional` metadata where present or the
54
+ * `@QueryHandler` / `@EventsHandler` class prototype with a transaction,
55
+ * using the handler's own `@Transactional` metadata where present or the
56
56
  * kind-specific defaults from {@link HandlerWrapperOptions} otherwise.
57
57
  *
58
- * The replacement is an own-property assignment on each handler instance,
59
- * shadowing the prototype method. `@nestjs/cqrs`'s buses resolve
60
- * `instance.execute` / `instance.handle` at call time (late binding), so
61
- * the wrap takes effect for every subsequent bus dispatch.
58
+ * The replacement is an own-property assignment on each handler class
59
+ * prototype, intercepting `@nestjs/cqrs`'s late-bound
60
+ * `instance.execute(query)` / `instance.handle(event)` lookup. This works
61
+ * for handlers of any scope — `Scope.DEFAULT` (singleton),
62
+ * `Scope.REQUEST`, and `Scope.TRANSIENT` — because the wrap point is the
63
+ * prototype, not any particular instance. See ADR-020.
62
64
  *
63
65
  * Double-wrap prevention: each wrapped method is tagged with the shared
64
66
  * `WRAPPED_MARKER` symbol. Other mechanisms in the coordinated wrapping
65
67
  * triad (see ADR-005) honour the same marker.
66
68
  *
67
- * Limitation: only works with static-dependency-tree (singleton) handlers.
68
- * Request-scoped handlers are resolved per-request by `@nestjs/cqrs`'s
69
- * `ModuleRef.resolve`, which produces a fresh instance our wrap has not
70
- * mutated.
69
+ * Test isolation: prototype mutation persists across `TestingModule`
70
+ * rebuilds. Call {@link CqrsHandlerWrapper.resetForTesting} in
71
+ * `beforeEach` to restore prototypes between cases. See ADR-020.
72
+ *
73
+ * Limitation: arrow-function `execute = async (q) => {...}` /
74
+ * `handle = async (e) => {...}` defined as instance fields are not
75
+ * wrapped — they live on the instance and shadow the prototype. Use
76
+ * regular method syntax (`async execute(q) { ... }`) so the method
77
+ * lives on the prototype.
71
78
  */
72
- let CqrsHandlerWrapper = CqrsHandlerWrapper_1 = class CqrsHandlerWrapper {
79
+ let CqrsHandlerWrapper = class CqrsHandlerWrapper {
80
+ static { CqrsHandlerWrapper_1 = this; }
73
81
  discovery;
74
82
  manager;
75
83
  options;
76
84
  logger = new common_1.Logger(CqrsHandlerWrapper_1.name);
85
+ /**
86
+ * Tracks every prototype the wrapper has mutated so
87
+ * {@link CqrsHandlerWrapper.resetForTesting} can restore the
88
+ * originals. Static — shared across wrapper instances (typically one
89
+ * per app; multiple `TestingModule` rebuilds across tests share this
90
+ * tracker and the marker on each prototype method, hence the need
91
+ * for an explicit reset).
92
+ */
93
+ static wrappedPrototypes = new Map();
94
+ /**
95
+ * @internal Test-isolation hook (ADR-020). Restores prototype
96
+ * methods mutated by previous `wrapAll` runs and clears the
97
+ * tracker. Call in `beforeEach` when a test suite rebuilds the
98
+ * `TestingModule` between cases — without this, the prototype
99
+ * stays wrapped from the previous test and `WRAPPED_MARKER` makes
100
+ * the next `wrapAll` a no-op, leaving the wrong wrapper (or any
101
+ * wrapper at all, in "leaves unwrapped" assertions) in place.
102
+ *
103
+ * Production code calling this after the wrap loop has finished
104
+ * does not affect already-resolved handler instances — late-bound
105
+ * `instance.execute(query)` resolves to whatever lives on the
106
+ * prototype at call time, which after this call is the original
107
+ * method.
108
+ *
109
+ * Mirrors `OutboxModule.resetForTesting` (ADR-019 § 5).
110
+ */
111
+ static resetForTesting() {
112
+ for (const [metatype, { methodName, originalMethod }] of this.wrappedPrototypes) {
113
+ const proto = metatype.prototype;
114
+ proto[methodName] = originalMethod;
115
+ }
116
+ this.wrappedPrototypes.clear();
117
+ }
77
118
  constructor(discovery, manager, options) {
78
119
  this.discovery = discovery;
79
120
  this.manager = manager;
80
121
  this.options = options;
81
122
  }
123
+ /**
124
+ * NestJS lifecycle hook. When the module closes (`module.close()`,
125
+ * `app.close()`, test teardown via `afterEach: module.close`), restore
126
+ * every wrapped prototype method. This makes subsequent
127
+ * `TestingModule` rebuilds in the same process start from a clean
128
+ * prototype — without it, the `WRAPPED_MARKER` on the previous
129
+ * wrapper short-circuits the next `wrapAll`, leaving a stale closure
130
+ * (over the previous `TransactionManager`) on the prototype.
131
+ *
132
+ * Production effect: none — by the time `onModuleDestroy` fires the
133
+ * app is shutting down and no further bus dispatches occur. The
134
+ * explicit {@link CqrsHandlerWrapper.resetForTesting} static remains
135
+ * available for tests that do not rely on `module.close()` for
136
+ * cleanup.
137
+ */
138
+ onModuleDestroy() {
139
+ CqrsHandlerWrapper_1.resetForTesting();
140
+ }
82
141
  /**
83
142
  * Scan every provider and wrap handler methods. Safe to call multiple
84
143
  * times — the `WRAPPED_MARKER` check guarantees idempotency.
@@ -87,22 +146,18 @@ let CqrsHandlerWrapper = CqrsHandlerWrapper_1 = class CqrsHandlerWrapper {
87
146
  const providers = this.discovery.getProviders();
88
147
  let wrappedCount = 0;
89
148
  for (const wrapper of providers) {
90
- if (wrapper.instance === null || wrapper.instance === undefined) {
91
- continue;
92
- }
93
149
  if (typeof wrapper.metatype !== 'function') {
94
150
  // Value / factory providers have no class constructor — nothing to
95
151
  // classify as a CQRS handler.
96
152
  continue;
97
153
  }
98
- const instance = wrapper.instance;
99
154
  const metatype = wrapper.metatype;
100
155
  const kind = this.classifyHandler(metatype);
101
156
  if (kind === null) {
102
157
  continue;
103
158
  }
104
159
  const methodName = kind === 'event' ? 'handle' : 'execute';
105
- if (this.wrapHandler(instance, metatype, methodName, kind)) {
160
+ if (this.wrapHandler(metatype, methodName, kind)) {
106
161
  wrappedCount++;
107
162
  }
108
163
  }
@@ -123,26 +178,34 @@ let CqrsHandlerWrapper = CqrsHandlerWrapper_1 = class CqrsHandlerWrapper {
123
178
  }
124
179
  return null;
125
180
  }
126
- wrapHandler(instance, metatype, methodName, kind) {
127
- const host = instance;
128
- const currentMethod = host[methodName];
129
- if (typeof currentMethod !== 'function') {
181
+ wrapHandler(metatype, methodName, kind) {
182
+ const proto = metatype.prototype;
183
+ const protoMethod = proto[methodName];
184
+ if (typeof protoMethod !== 'function') {
185
+ // Method is not on the prototype (e.g. arrow-function instance field).
186
+ // See ADR-020 "Limitations".
130
187
  return false;
131
188
  }
132
- if (Reflect.getMetadata(WRAPPED_MARKER, currentMethod) === true) {
189
+ if (Reflect.getMetadata(WRAPPED_MARKER, protoMethod) === true) {
133
190
  return false;
134
191
  }
135
- const resolved = this.resolveMetadata(currentMethod, metatype, kind);
192
+ const resolved = this.resolveMetadata(protoMethod, metatype, kind);
136
193
  if (resolved === undefined) {
137
194
  return false;
138
195
  }
139
- const boundOriginal = currentMethod.bind(instance);
196
+ const original = protoMethod;
140
197
  const manager = this.manager;
141
- const wrapped = (...args) => manager.run(resolved, () => Promise.resolve(boundOriginal(...args)));
198
+ // Regular function (not arrow) — `this` is bound by the call site
199
+ // (`instance.execute(query)`) so the wrap composes with any scope of
200
+ // handler instance.
201
+ const wrapped = function (...args) {
202
+ return manager.run(resolved, () => Promise.resolve(original.apply(this, args)));
203
+ };
142
204
  Reflect.defineMetadata(WRAPPED_MARKER, true, wrapped);
143
205
  Reflect.defineMetadata(core_2.TRANSACTIONAL_METADATA, resolved, wrapped);
144
- host[methodName] = wrapped;
145
- this.logger.debug(`Wrapped ${kind} handler ${instance.constructor.name}.${methodName} ` +
206
+ proto[methodName] = wrapped;
207
+ CqrsHandlerWrapper_1.wrappedPrototypes.set(metatype, { methodName, originalMethod: original });
208
+ this.logger.debug(`Wrapped ${kind} handler ${metatype.name}.prototype.${methodName} ` +
146
209
  `(propagation=${resolved.propagation ?? core_2.PropagationMode.REQUIRED})`);
147
210
  return true;
148
211
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handler-wrapper.js","sourceRoot":"","sources":["../../src/handlers/handler-wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4BAA0B;AAE1B,2CAA4D;AAC5D,uCAAgD;AAChD,qDAMoC;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;AACU,QAAA,4BAA4B,GAAG,MAAM,CAAC,8BAA8B,CAAC,CAAC;AAqCnF;;;;;;;;;;;;;;;;;;;GAmBG;AAEI,IAAM,kBAAkB,0BAAxB,MAAM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AAG,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,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IA6CR,WAAA,IAAA,eAAM,EAAC,oCAA4B,CAAC,CAAA;qCAFT,uBAAgB;QAClB,yBAAkB;GA3CnC,kBAAkB,CAmM9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs-transactional/cqrs",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-alpha.2",
4
4
  "description": "@nestjs/cqrs integration for @nestjs-transactional/core — transactional event listeners with phases, handler wrapping, AggregateRoot integration",
5
5
  "license": "MIT",
6
6
  "author": "Igor Golovanov",