@fluojs/cqrs 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ko.md CHANGED
@@ -85,7 +85,7 @@ Saga를 사용하면 이벤트를 구독하고 새로운 Command를 트리거하
85
85
 
86
86
  ```typescript
87
87
  import { Inject } from '@fluojs/core';
88
- import { Saga, ISaga, IEvent, ICommand, CommandBusLifecycleService } from '@fluojs/cqrs';
88
+ import { Saga, ISaga, IEvent, ICommand, CqrsDispatchContext, CommandBusLifecycleService } from '@fluojs/cqrs';
89
89
 
90
90
  class UserCreatedEvent implements IEvent {
91
91
  constructor(public readonly userId: string) {}
@@ -100,14 +100,16 @@ class SendWelcomeEmailCommand implements ICommand {
100
100
  class UserSaga implements ISaga<UserCreatedEvent> {
101
101
  constructor(private readonly commandBus: CommandBusLifecycleService) {}
102
102
 
103
- async handle(event: UserCreatedEvent): Promise<void> {
104
- await this.commandBus.execute(new SendWelcomeEmailCommand(event.userId));
103
+ async handle(event: UserCreatedEvent, context?: CqrsDispatchContext): Promise<void> {
104
+ await this.commandBus.execute(new SendWelcomeEmailCommand(event.userId), context);
105
105
  }
106
106
  }
107
107
  ```
108
108
 
109
109
  Saga 실행은 같은 프로세스 안에서 동일 saga route로 순환 재진입하거나 중첩 hop 수가 32를 넘으면 `SagaTopologyError`로 즉시 실패합니다. 서로 다른 이벤트 단계를 순차 처리하는 multi-stage saga는 계속 허용되지만, in-process saga graph 전체는 비순환(acyclic) 구조를 유지해야 하며, 의도적인 순환/피드백 루프나 더 긴 체인은 외부 transport, scheduler, 또는 다른 bounded boundary 뒤로 이동해야 합니다.
110
110
 
111
+ Saga, command handler, query handler, event handler 안에서 다시 CQRS `execute(...)`, `publish(...)`, `publishAll(...)`를 호출할 때는 optional `CqrsDispatchContext` 인자를 그대로 전달하세요. CQRS는 이 명시적인 runtime-agnostic context로 Node.js async-local API에 의존하지 않고 nested dispatch 전반의 saga topology check를 유지합니다.
112
+
111
113
  ### Event 발행 계약
112
114
 
113
115
  `CqrsEventBusService.publish(event)`는 CQRS event pipeline을 고정된 순서로 실행합니다. 먼저 일치하는 `@EventHandler(...)` provider를 실행하고, 그다음 일치하는 `@Saga(...)` provider를 실행한 뒤, 마지막으로 `@fluojs/event-bus`로 위임 발행합니다. `publishAll(events)`는 각 event의 CQRS handler, saga, 위임 발행 호출을 기다린 뒤 다음 event를 발행하므로 입력 순서를 보존합니다. 애플리케이션 shutdown 중에는 CQRS event bus가 진행 중인 `publish(...)` pipeline, `publishAll(...)` sequence, saga execution chain이 settle될 때까지 기다린 뒤 stopped 상태로 전환합니다. Shutdown drain은 기본값이 5000ms인 `CqrsModule.forRoot({ shutdown: { drainTimeoutMs } })`로 제한됩니다. CQRS handler, saga 또는 위임 publish chain이 이 bound 이후에도 멈춰 있으면 CQRS는 degraded status diagnostic을 기록하고 경고를 남긴 뒤 애플리케이션 close를 무기한 hang시키지 않고 계속 진행합니다. `CqrsModule.forRoot({ eventBus: { publish: { waitForHandlers: false } } })`로 설정한 경우 위임 발행 호출은 일치하는 `@OnEvent(...)` subscriber가 완료되기 전에 resolve될 수 있으므로, 이 모드에서 `publish(...)`, `publishAll(...)`, shutdown drain 완료는 subscriber 완료를 의미하지 않습니다.
@@ -150,6 +152,7 @@ class TokenInjectedService {
150
152
  ### 인터페이스
151
153
  - `ICommand`, `IQuery<T>`, `IEvent`: 메시지 마커 인터페이스입니다.
152
154
  - `ICommandHandler<C, R>`, `IQueryHandler<Q, R>`, `IEventHandler<E>`, `ISaga<E>`: 핸들러 계약입니다.
155
+ - `CqrsDispatchContext`: handler와 saga에서 nested CQRS dispatch로 그대로 전달하는 opaque optional context 값입니다.
153
156
 
154
157
  ### 오류
155
158
  - `CommandHandlerNotFoundException`, `QueryHandlerNotFoundException`: bus에 일치하는 handler가 없을 때 발생합니다.
package/README.md CHANGED
@@ -85,7 +85,7 @@ Sagas allow you to listen for events and trigger new commands, enabling complex
85
85
 
86
86
  ```typescript
87
87
  import { Inject } from '@fluojs/core';
88
- import { Saga, ISaga, IEvent, ICommand, CommandBusLifecycleService } from '@fluojs/cqrs';
88
+ import { Saga, ISaga, IEvent, ICommand, CqrsDispatchContext, CommandBusLifecycleService } from '@fluojs/cqrs';
89
89
 
90
90
  class UserCreatedEvent implements IEvent {
91
91
  constructor(public readonly userId: string) {}
@@ -100,14 +100,16 @@ class SendWelcomeEmailCommand implements ICommand {
100
100
  class UserSaga implements ISaga<UserCreatedEvent> {
101
101
  constructor(private readonly commandBus: CommandBusLifecycleService) {}
102
102
 
103
- async handle(event: UserCreatedEvent): Promise<void> {
104
- await this.commandBus.execute(new SendWelcomeEmailCommand(event.userId));
103
+ async handle(event: UserCreatedEvent, context?: CqrsDispatchContext): Promise<void> {
104
+ await this.commandBus.execute(new SendWelcomeEmailCommand(event.userId), context);
105
105
  }
106
106
  }
107
107
  ```
108
108
 
109
109
  Saga execution fails fast with `SagaTopologyError` when an in-process publish chain re-enters the same saga route cyclically or exceeds 32 nested saga hops. Multi-stage sagas may still react to different event types in sequence, but in-process saga graphs must stay acyclic overall; move intentionally cyclic or long-running feedback loops behind an external transport, scheduler, or other bounded boundary.
110
110
 
111
+ When a saga, command handler, query handler, or event handler performs another CQRS `execute(...)`, `publish(...)`, or `publishAll(...)` call, pass the optional `CqrsDispatchContext` argument through unchanged. CQRS uses this explicit runtime-agnostic context to keep saga topology checks intact across nested dispatch without relying on Node.js async-local APIs.
112
+
111
113
  ### Event Publishing Contracts
112
114
 
113
115
  `CqrsEventBusService.publish(event)` runs the CQRS event pipeline in a fixed order: matching `@EventHandler(...)` providers first, matching `@Saga(...)` providers second, and delegated `@fluojs/event-bus` publication last. `publishAll(events)` preserves the input order by awaiting each event's CQRS handlers, sagas, and delegated publication call before publishing the next event. During application shutdown, the CQRS event bus waits for active `publish(...)` pipelines, `publishAll(...)` sequences, and saga execution chains to settle before marking itself stopped. Shutdown drain is bounded by `CqrsModule.forRoot({ shutdown: { drainTimeoutMs } })`, which defaults to 5000ms; if a CQRS handler, saga, or delegated publish chain is still stuck after the bound, CQRS records degraded status diagnostics, logs a warning, and lets application close continue instead of hanging indefinitely. When `CqrsModule.forRoot({ eventBus: { publish: { waitForHandlers: false } } })` is configured, the delegated publication call can resolve before matching `@OnEvent(...)` subscribers finish, so `publish(...)`, `publishAll(...)`, and shutdown drain completion do not imply subscriber completion in that mode.
@@ -150,6 +152,7 @@ class TokenInjectedService {
150
152
  ### Interfaces
151
153
  - `ICommand`, `IQuery<T>`, `IEvent`: Marker interfaces for messages.
152
154
  - `ICommandHandler<C, R>`, `IQueryHandler<Q, R>`, `IEventHandler<E>`, `ISaga<E>`: Handler contracts.
155
+ - `CqrsDispatchContext`: Opaque optional context value to pass through nested CQRS dispatch from handlers and sagas.
153
156
 
154
157
  ### Errors
155
158
  - `CommandHandlerNotFoundException`, `QueryHandlerNotFoundException`: Raised when a bus has no matching handler.
@@ -1,6 +1,6 @@
1
1
  import type { OnApplicationBootstrap } from '@fluojs/runtime';
2
2
  import { CqrsBusBase } from '../discovery.js';
3
- import type { CommandBus, ICommand } from '../types.js';
3
+ import type { CommandBus, CqrsDispatchContext, ICommand } from '../types.js';
4
4
  /**
5
5
  * Discovers and executes command handlers during application bootstrap and runtime dispatch.
6
6
  *
@@ -16,12 +16,13 @@ export declare class CommandBusLifecycleService extends CqrsBusBase implements C
16
16
  * Executes one command by dispatching it to the discovered handler for its constructor.
17
17
  *
18
18
  * @param command Command instance to execute.
19
+ * @param context Optional saga dispatch context to pass through nested CQRS calls.
19
20
  * @returns The resolved handler result.
20
21
  *
21
22
  * @throws {CommandHandlerNotFoundException} When no handler is registered for the command type.
22
23
  * @throws {InvariantError} When the resolved provider does not implement `execute(command)`.
23
24
  */
24
- execute<TCommand extends ICommand, TResult = void>(command: TCommand): Promise<TResult>;
25
+ execute<TCommand extends ICommand, TResult = void>(command: TCommand, context?: CqrsDispatchContext): Promise<TResult>;
25
26
  private ensureDiscovered;
26
27
  private discoverHandlers;
27
28
  private discoverCommandDescriptors;
@@ -1 +1 @@
1
- {"version":3,"file":"command-bus.d.ts","sourceRoot":"","sources":["../../src/buses/command-bus.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAK9D,OAAO,EAAE,WAAW,EAAiC,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EACV,UAAU,EAGV,QAAQ,EAET,MAAM,aAAa,CAAC;AAUrB;;;;;GAKG;AACH,qBACa,0BAA2B,SAAQ,WAAY,YAAW,UAAU,EAAE,sBAAsB;IACvG,OAAO,CAAC,WAAW,CAAoD;IACvE,OAAO,CAAC,gBAAgB,CAA4B;IACpD,OAAO,CAAC,UAAU,CAAS;IAErB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7C;;;;;;;;OAQG;IACG,OAAO,CAAC,QAAQ,SAAS,QAAQ,EAAE,OAAO,GAAG,IAAI,EAAE,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;YAmB/E,gBAAgB;YAchB,gBAAgB;IAe9B,OAAO,CAAC,0BAA0B;CAmDnC"}
1
+ {"version":3,"file":"command-bus.d.ts","sourceRoot":"","sources":["../../src/buses/command-bus.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAiC,MAAM,iBAAiB,CAAC;AAG7E,OAAO,KAAK,EACV,UAAU,EAGV,mBAAmB,EACnB,QAAQ,EAET,MAAM,aAAa,CAAC;AAUrB;;;;;GAKG;AACH,qBACa,0BAA2B,SAAQ,WAAY,YAAW,UAAU,EAAE,sBAAsB;IACvG,OAAO,CAAC,WAAW,CAAoD;IACvE,OAAO,CAAC,gBAAgB,CAA4B;IACpD,OAAO,CAAC,UAAU,CAAS;IAErB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7C;;;;;;;;;OASG;IACG,OAAO,CAAC,QAAQ,SAAS,QAAQ,EAAE,OAAO,GAAG,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;YAmB9G,gBAAgB;YAchB,gBAAgB;IAe9B,OAAO,CAAC,0BAA0B;CAmDnC"}
@@ -6,9 +6,9 @@ function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.descrip
6
6
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
7
7
  import { Inject, InvariantError } from '@fluojs/core';
8
8
  import { APPLICATION_LOGGER, COMPILED_MODULES, RUNTIME_CONTAINER } from '@fluojs/runtime/internal';
9
+ import { CqrsBusBase, createDuplicateHandlerMessage } from '../discovery.js';
9
10
  import { CommandHandlerNotFoundException, DuplicateCommandHandlerError } from '../errors.js';
10
11
  import { getCommandHandlerMetadata } from '../metadata.js';
11
- import { CqrsBusBase, createDuplicateHandlerMessage } from '../discovery.js';
12
12
  function isCommandHandler(value) {
13
13
  if (typeof value !== 'object' || value === null) {
14
14
  return false;
@@ -38,12 +38,13 @@ class CommandBusLifecycleService extends CqrsBusBase {
38
38
  * Executes one command by dispatching it to the discovered handler for its constructor.
39
39
  *
40
40
  * @param command Command instance to execute.
41
+ * @param context Optional saga dispatch context to pass through nested CQRS calls.
41
42
  * @returns The resolved handler result.
42
43
  *
43
44
  * @throws {CommandHandlerNotFoundException} When no handler is registered for the command type.
44
45
  * @throws {InvariantError} When the resolved provider does not implement `execute(command)`.
45
46
  */
46
- async execute(command) {
47
+ async execute(command, context) {
47
48
  await this.ensureDiscovered();
48
49
  const commandType = command.constructor;
49
50
  const descriptor = this.descriptors.get(commandType);
@@ -54,7 +55,7 @@ class CommandBusLifecycleService extends CqrsBusBase {
54
55
  if (!isCommandHandler(instance)) {
55
56
  throw new InvariantError(`Command handler ${descriptor.targetType.name} must implement execute(command).`);
56
57
  }
57
- return await instance.execute(command);
58
+ return await instance.execute(command, context);
58
59
  }
59
60
  async ensureDiscovered() {
60
61
  if (this.discovered) {
@@ -1,8 +1,8 @@
1
1
  import { type EventBus } from '@fluojs/event-bus';
2
- import type { OnApplicationShutdown, OnApplicationBootstrap } from '@fluojs/runtime';
2
+ import type { OnApplicationBootstrap, OnApplicationShutdown } from '@fluojs/runtime';
3
3
  import { CqrsBusBase } from '../discovery.js';
4
4
  import type { CqrsModuleOptions } from '../module.js';
5
- import type { CqrsEventBus, IEvent } from '../types.js';
5
+ import type { CqrsDispatchContext, CqrsEventBus, IEvent } from '../types.js';
6
6
  import { CqrsSagaLifecycleService } from './saga-bus.js';
7
7
  /**
8
8
  * CQRS-facing event bus that dispatches local event handlers, sagas, and the shared event transport.
@@ -33,18 +33,20 @@ export declare class CqrsEventBusService extends CqrsBusBase implements CqrsEven
33
33
  * Publishes one event to matching CQRS handlers, sagas, and the shared event bus.
34
34
  *
35
35
  * @param event Event instance to publish.
36
+ * @param context Optional saga dispatch context to pass through nested CQRS calls.
36
37
  * @returns A promise that resolves once all local CQRS side effects and delegated publication complete.
37
38
  *
38
39
  * @throws {InvariantError} When a discovered provider does not implement `handle(event)`.
39
40
  */
40
- publish<TEvent extends IEvent>(event: TEvent): Promise<void>;
41
+ publish<TEvent extends IEvent>(event: TEvent, context?: CqrsDispatchContext): Promise<void>;
41
42
  /**
42
43
  * Publishes a batch of events sequentially through the CQRS event pipeline.
43
44
  *
44
45
  * @param events Event instances to publish in order.
46
+ * @param context Optional saga dispatch context to pass through nested CQRS calls.
45
47
  * @returns A promise that resolves once all events are published.
46
48
  */
47
- publishAll<TEvent extends IEvent>(events: readonly TEvent[]): Promise<void>;
49
+ publishAll<TEvent extends IEvent>(events: readonly TEvent[], context?: CqrsDispatchContext): Promise<void>;
48
50
  private runPublishPipeline;
49
51
  private runPublishAllPipeline;
50
52
  private trackPublishPipeline;
@@ -1 +1 @@
1
- {"version":3,"file":"event-bus.d.ts","sourceRoot":"","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nE,OAAO,CAAC,qBAAqB,CAAK;IAClC,OAAO,CAAC,cAAc,CAAsF;gBAGzF,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,wBAAwB,EACtD,gBAAgB,EAAE,qBAAqB,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,EAC9D,eAAe,EAAE,qBAAqB,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,EAC7D,MAAM,EAAE,qBAAqB,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,EACnC,aAAa,GAAE,iBAAsB;IAKlD,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAYvC,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAU5C;;;;OAIG;IACH,4BAA4B;IAe5B;;;;;;;;OAQG;IACG,OAAO,CAAC,MAAM,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjG;;;;;;OAMG;IACG,UAAU,CAAC,MAAM,SAAS,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;YAIlG,kBAAkB;YAiBlB,qBAAqB;YAMrB,oBAAoB;YAUpB,2BAA2B;YAc3B,kBAAkB;IAiBhC,OAAO,CAAC,6BAA6B;IAUrC,OAAO,CAAC,qBAAqB;YAIf,gBAAgB;YAchB,gBAAgB;IAe9B,OAAO,CAAC,wBAAwB;CA4CjC"}
@@ -10,8 +10,8 @@ import { APPLICATION_LOGGER, COMPILED_MODULES, RUNTIME_CONTAINER } from '@fluojs
10
10
  import { CqrsBusBase } from '../discovery.js';
11
11
  import { createIsolatedEvent } from '../event-clone.js';
12
12
  import { getEventHandlerMetadata } from '../metadata.js';
13
- import { CQRS_MODULE_OPTIONS } from '../tokens.js';
14
13
  import { createCqrsPlatformStatusSnapshot } from '../status.js';
14
+ import { CQRS_MODULE_OPTIONS } from '../tokens.js';
15
15
  import { CqrsSagaLifecycleService } from './saga-bus.js';
16
16
  const DEFAULT_SHUTDOWN_DRAIN_TIMEOUT_MS = 5000;
17
17
  function isEventHandler(value) {
@@ -85,38 +85,40 @@ class CqrsEventBusService extends CqrsBusBase {
85
85
  * Publishes one event to matching CQRS handlers, sagas, and the shared event bus.
86
86
  *
87
87
  * @param event Event instance to publish.
88
+ * @param context Optional saga dispatch context to pass through nested CQRS calls.
88
89
  * @returns A promise that resolves once all local CQRS side effects and delegated publication complete.
89
90
  *
90
91
  * @throws {InvariantError} When a discovered provider does not implement `handle(event)`.
91
92
  */
92
- async publish(event) {
93
- await this.trackPublishPipeline(this.runPublishPipeline(event));
93
+ async publish(event, context) {
94
+ await this.trackPublishPipeline(this.runPublishPipeline(event, context));
94
95
  }
95
96
 
96
97
  /**
97
98
  * Publishes a batch of events sequentially through the CQRS event pipeline.
98
99
  *
99
100
  * @param events Event instances to publish in order.
101
+ * @param context Optional saga dispatch context to pass through nested CQRS calls.
100
102
  * @returns A promise that resolves once all events are published.
101
103
  */
102
- async publishAll(events) {
103
- await this.trackPublishPipeline(this.runPublishAllPipeline(events));
104
+ async publishAll(events, context) {
105
+ await this.trackPublishPipeline(this.runPublishAllPipeline(events, context));
104
106
  }
105
- async runPublishPipeline(event) {
107
+ async runPublishPipeline(event, context) {
106
108
  await this.ensureDiscovered();
107
109
  for (const descriptor of this.matchEventDescriptors(event)) {
108
110
  const instance = await this.resolveHandlerInstance(descriptor.token);
109
111
  if (!isEventHandler(instance)) {
110
112
  throw new InvariantError(`Event handler ${descriptor.targetType.name} must implement handle(event).`);
111
113
  }
112
- await instance.handle(createIsolatedEvent(descriptor.eventType, event));
114
+ await instance.handle(createIsolatedEvent(descriptor.eventType, event), context);
113
115
  }
114
- await this.sagaService.dispatch(event);
116
+ await this.sagaService.dispatch(event, context);
115
117
  await this.eventBus.publish(event);
116
118
  }
117
- async runPublishAllPipeline(events) {
119
+ async runPublishAllPipeline(events, context) {
118
120
  for (const event of events) {
119
- await this.publish(event);
121
+ await this.publish(event, context);
120
122
  }
121
123
  }
122
124
  async trackPublishPipeline(pipeline) {
@@ -1,6 +1,6 @@
1
- import { type OnApplicationBootstrap } from '@fluojs/runtime';
1
+ import type { OnApplicationBootstrap } from '@fluojs/runtime';
2
2
  import { CqrsBusBase } from '../discovery.js';
3
- import type { IQuery, QueryBus } from '../types.js';
3
+ import type { CqrsDispatchContext, IQuery, QueryBus } from '../types.js';
4
4
  /**
5
5
  * Discovers and executes query handlers during bootstrap and runtime dispatch.
6
6
  *
@@ -16,12 +16,13 @@ export declare class QueryBusLifecycleService extends CqrsBusBase implements Que
16
16
  * Executes one query by dispatching it to the discovered handler for its constructor.
17
17
  *
18
18
  * @param query Query instance to execute.
19
+ * @param context Optional saga dispatch context to pass through nested CQRS calls.
19
20
  * @returns The resolved handler result.
20
21
  *
21
22
  * @throws {QueryHandlerNotFoundException} When no handler is registered for the query type.
22
23
  * @throws {InvariantError} When the resolved provider does not implement `execute(query)`.
23
24
  */
24
- execute<TQuery extends IQuery<TResult>, TResult = unknown>(query: TQuery): Promise<TResult>;
25
+ execute<TQuery extends IQuery<TResult>, TResult = unknown>(query: TQuery, context?: CqrsDispatchContext): Promise<TResult>;
25
26
  private ensureDiscovered;
26
27
  private discoverHandlers;
27
28
  private discoverQueryDescriptors;
@@ -1 +1 @@
1
- {"version":3,"file":"query-bus.d.ts","sourceRoot":"","sources":["../../src/buses/query-bus.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,sBAAsB,EAC5B,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EAAE,WAAW,EAAiC,MAAM,iBAAiB,CAAC;AAC7E,OAAO,KAAK,EACV,MAAM,EAEN,QAAQ,EAGT,MAAM,aAAa,CAAC;AAUrB;;;;;GAKG;AACH,qBACa,wBAAyB,SAAQ,WAAY,YAAW,QAAQ,EAAE,sBAAsB;IACnG,OAAO,CAAC,WAAW,CAAgD;IACnE,OAAO,CAAC,gBAAgB,CAA4B;IACpD,OAAO,CAAC,UAAU,CAAS;IAErB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7C;;;;;;;;OAQG;IACG,OAAO,CAAC,MAAM,SAAS,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;YAmBnF,gBAAgB;YAchB,gBAAgB;IAe9B,OAAO,CAAC,wBAAwB;CAmDjC"}
1
+ {"version":3,"file":"query-bus.d.ts","sourceRoot":"","sources":["../../src/buses/query-bus.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,WAAW,EAAiC,MAAM,iBAAiB,CAAC;AAG7E,OAAO,KAAK,EACV,mBAAmB,EACnB,MAAM,EAEN,QAAQ,EAGT,MAAM,aAAa,CAAC;AAUrB;;;;;GAKG;AACH,qBACa,wBAAyB,SAAQ,WAAY,YAAW,QAAQ,EAAE,sBAAsB;IACnG,OAAO,CAAC,WAAW,CAAgD;IACnE,OAAO,CAAC,gBAAgB,CAA4B;IACpD,OAAO,CAAC,UAAU,CAAS;IAErB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7C;;;;;;;;;OASG;IACG,OAAO,CAAC,MAAM,SAAS,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;YAmBlH,gBAAgB;YAchB,gBAAgB;IAe9B,OAAO,CAAC,wBAAwB;CAmDjC"}
@@ -6,9 +6,9 @@ function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.descrip
6
6
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
7
7
  import { Inject, InvariantError } from '@fluojs/core';
8
8
  import { APPLICATION_LOGGER, COMPILED_MODULES, RUNTIME_CONTAINER } from '@fluojs/runtime/internal';
9
+ import { CqrsBusBase, createDuplicateHandlerMessage } from '../discovery.js';
9
10
  import { DuplicateQueryHandlerError, QueryHandlerNotFoundException } from '../errors.js';
10
11
  import { getQueryHandlerMetadata } from '../metadata.js';
11
- import { CqrsBusBase, createDuplicateHandlerMessage } from '../discovery.js';
12
12
  function isQueryHandler(value) {
13
13
  if (typeof value !== 'object' || value === null) {
14
14
  return false;
@@ -38,12 +38,13 @@ class QueryBusLifecycleService extends CqrsBusBase {
38
38
  * Executes one query by dispatching it to the discovered handler for its constructor.
39
39
  *
40
40
  * @param query Query instance to execute.
41
+ * @param context Optional saga dispatch context to pass through nested CQRS calls.
41
42
  * @returns The resolved handler result.
42
43
  *
43
44
  * @throws {QueryHandlerNotFoundException} When no handler is registered for the query type.
44
45
  * @throws {InvariantError} When the resolved provider does not implement `execute(query)`.
45
46
  */
46
- async execute(query) {
47
+ async execute(query, context) {
47
48
  await this.ensureDiscovered();
48
49
  const queryType = query.constructor;
49
50
  const descriptor = this.descriptors.get(queryType);
@@ -54,7 +55,7 @@ class QueryBusLifecycleService extends CqrsBusBase {
54
55
  if (!isQueryHandler(instance)) {
55
56
  throw new InvariantError(`Query handler ${descriptor.targetType.name} must implement execute(query).`);
56
57
  }
57
- return await instance.execute(query);
58
+ return await instance.execute(query, context);
58
59
  }
59
60
  async ensureDiscovered() {
60
61
  if (this.discovered) {
@@ -1,7 +1,7 @@
1
1
  import type { OnApplicationBootstrap, OnApplicationShutdown } from '@fluojs/runtime';
2
2
  import { CqrsBusBase } from '../discovery.js';
3
3
  import type { CqrsModuleOptions } from '../module.js';
4
- import type { IEvent } from '../types.js';
4
+ import type { CqrsDispatchContext, IEvent } from '../types.js';
5
5
  /**
6
6
  * Runtime saga coordinator that discovers `@Saga()` providers and serializes execution per saga token.
7
7
  *
@@ -16,7 +16,6 @@ export declare class CqrsSagaLifecycleService extends CqrsBusBase implements OnA
16
16
  private readonly executionChains;
17
17
  private lifecycleState;
18
18
  private readonly pendingDispatches;
19
- private readonly dispatchContext;
20
19
  private shutdownDrainTimeouts;
21
20
  constructor(runtimeContainer: ConstructorParameters<typeof CqrsBusBase>[0], compiledModules: ConstructorParameters<typeof CqrsBusBase>[1], logger: ConstructorParameters<typeof CqrsBusBase>[2], moduleOptions?: CqrsModuleOptions);
22
21
  onApplicationBootstrap(): Promise<void>;
@@ -39,13 +38,13 @@ export declare class CqrsSagaLifecycleService extends CqrsBusBase implements OnA
39
38
  * @param event Event instance that may trigger one or more sagas.
40
39
  * @returns A promise that resolves once all matching saga chains for the event complete.
41
40
  */
42
- dispatch<TEvent extends IEvent>(event: TEvent): Promise<void>;
41
+ dispatch<TEvent extends IEvent>(event: TEvent, context?: CqrsDispatchContext): Promise<void>;
43
42
  private matchSagaDescriptors;
44
43
  private dispatchWithOrdering;
45
44
  private drainActiveSagaWork;
46
45
  private awaitShutdownDrain;
47
46
  private resolveShutdownDrainTimeoutMs;
48
- private runInDispatchContext;
47
+ private createDispatchContext;
49
48
  private invokeSaga;
50
49
  private ensureDiscovered;
51
50
  private discoverHandlers;
@@ -1 +1 @@
1
- {"version":3,"file":"saga-bus.d.ts","sourceRoot":"","sources":["../../src/buses/saga-bus.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAGrF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAK9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAiB,MAAM,EAAyB,MAAM,aAAa,CAAC;AA2BhF;;;;;GAKG;AACH,qBACa,wBAAyB,SAAQ,WAAY,YAAW,sBAAsB,EAAE,qBAAqB;IAc9G,OAAO,CAAC,QAAQ,CAAC,aAAa;IAbhC,OAAO,CAAC,kBAAkB,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CAAC;KAC/B;IAUD;;;;;OAKG;IACG,QAAQ,CAAC,MAAM,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAYlG,OAAO,CAAC,oBAAoB;YAYd,oBAAoB;YAyCpB,mBAAmB;YAmBnB,kBAAkB;IAiBhC,OAAO,CAAC,6BAA6B;IAUrC,OAAO,CAAC,qBAAqB;YAYf,UAAU;YAoBV,gBAAgB;YAchB,gBAAgB;IAiB9B,OAAO,CAAC,uBAAuB;CA+ChC"}
@@ -4,8 +4,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
4
4
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
5
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
6
6
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
7
- import { AsyncLocalStorage } from 'node:async_hooks';
8
- import { Inject, InvariantError, FluoError } from '@fluojs/core';
7
+ import { FluoError, Inject, InvariantError } from '@fluojs/core';
9
8
  import { APPLICATION_LOGGER, COMPILED_MODULES, RUNTIME_CONTAINER } from '@fluojs/runtime/internal';
10
9
  import { CqrsBusBase } from '../discovery.js';
11
10
  import { SagaExecutionError, SagaTopologyError } from '../errors.js';
@@ -44,7 +43,6 @@ class CqrsSagaLifecycleService extends CqrsBusBase {
44
43
  executionChains = new Map();
45
44
  lifecycleState = 'created';
46
45
  pendingDispatches = new Set();
47
- dispatchContext = new AsyncLocalStorage();
48
46
  shutdownDrainTimeouts = 0;
49
47
  constructor(runtimeContainer, compiledModules, logger, moduleOptions = {}) {
50
48
  super(runtimeContainer, compiledModules, logger);
@@ -92,13 +90,13 @@ class CqrsSagaLifecycleService extends CqrsBusBase {
92
90
  * @param event Event instance that may trigger one or more sagas.
93
91
  * @returns A promise that resolves once all matching saga chains for the event complete.
94
92
  */
95
- async dispatch(event) {
93
+ async dispatch(event, context) {
96
94
  await this.ensureDiscovered();
97
95
  const descriptors = this.matchSagaDescriptors(event);
98
96
  if (descriptors.length === 0) {
99
97
  return;
100
98
  }
101
- await Promise.all(descriptors.map(descriptor => this.dispatchWithOrdering(descriptor, event)));
99
+ await Promise.all(descriptors.map(descriptor => this.dispatchWithOrdering(descriptor, event, context)));
102
100
  }
103
101
  matchSagaDescriptors(event) {
104
102
  const descriptors = [];
@@ -109,8 +107,7 @@ class CqrsSagaLifecycleService extends CqrsBusBase {
109
107
  }
110
108
  return descriptors;
111
109
  }
112
- async dispatchWithOrdering(descriptor, event) {
113
- const activeContext = this.dispatchContext.getStore();
110
+ async dispatchWithOrdering(descriptor, event, activeContext) {
114
111
  const routeLabel = `${descriptor.targetType.name}(${descriptor.eventType.name})`;
115
112
  const isActiveRoute = activeContext?.activeRoutes.some(route => route.token === descriptor.token && route.eventType === descriptor.eventType);
116
113
  const isActiveToken = activeContext?.activeRoutes.some(route => route.token === descriptor.token) ?? false;
@@ -121,16 +118,12 @@ class CqrsSagaLifecycleService extends CqrsBusBase {
121
118
  throw new SagaTopologyError(`Saga ${descriptor.targetType.name} exceeded the maximum nested saga depth of ${MAX_NESTED_SAGA_DEPTH} while handling ${descriptor.eventType.name}. ` + 'Keep in-process saga graphs acyclic and externally bounded.');
122
119
  }
123
120
  if (isActiveToken) {
124
- await this.runInDispatchContext(activeContext, descriptor, routeLabel, async () => {
125
- await this.invokeSaga(descriptor, event);
126
- });
121
+ await this.invokeSaga(descriptor, event, this.createDispatchContext(activeContext, descriptor, routeLabel));
127
122
  return;
128
123
  }
129
124
  const previous = this.executionChains.get(descriptor.token) ?? Promise.resolve();
130
125
  const current = previous.then(async () => {
131
- await this.runInDispatchContext(activeContext, descriptor, routeLabel, async () => {
132
- await this.invokeSaga(descriptor, event);
133
- });
126
+ await this.invokeSaga(descriptor, event, this.createDispatchContext(activeContext, descriptor, routeLabel));
134
127
  });
135
128
  this.executionChains.set(descriptor.token, current.catch(() => undefined));
136
129
  this.pendingDispatches.add(current);
@@ -173,8 +166,8 @@ class CqrsSagaLifecycleService extends CqrsBusBase {
173
166
  }
174
167
  return Math.floor(timeoutMs);
175
168
  }
176
- async runInDispatchContext(activeContext, descriptor, routeLabel, callback) {
177
- const nextContext = {
169
+ createDispatchContext(activeContext, descriptor, routeLabel) {
170
+ return {
178
171
  activeRoutes: [...(activeContext?.activeRoutes ?? []), {
179
172
  eventType: descriptor.eventType,
180
173
  token: descriptor.token
@@ -182,15 +175,14 @@ class CqrsSagaLifecycleService extends CqrsBusBase {
182
175
  depth: (activeContext?.depth ?? 0) + 1,
183
176
  path: [...(activeContext?.path ?? []), routeLabel]
184
177
  };
185
- await this.dispatchContext.run(nextContext, callback);
186
178
  }
187
- async invokeSaga(descriptor, event) {
179
+ async invokeSaga(descriptor, event, context) {
188
180
  const instance = await this.resolveHandlerInstance(descriptor.token);
189
181
  if (!isSaga(instance)) {
190
182
  throw new InvariantError(`Saga ${descriptor.targetType.name} must implement handle(event).`);
191
183
  }
192
184
  try {
193
- await instance.handle(createIsolatedEvent(descriptor.eventType, event));
185
+ await instance.handle(createIsolatedEvent(descriptor.eventType, event), context);
194
186
  } catch (error) {
195
187
  if (error instanceof FluoError) {
196
188
  throw error;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export { CommandHandler, EventHandler, QueryHandler, Saga } from './decorators.js';
2
- export { DuplicateCommandHandlerError, DuplicateEventHandlerError, DuplicateQueryHandlerError, CommandHandlerNotFoundException, QueryHandlerNotFoundException, SagaExecutionError, SagaTopologyError, } from './errors.js';
3
- export { commandHandlerMetadataSymbol, defineCommandHandlerMetadata, defineEventHandlerMetadata, defineQueryHandlerMetadata, eventHandlerMetadataSymbol, getCommandHandlerMetadata, getCommandHandlerMetadataEntry, getEventHandlerMetadata, getQueryHandlerMetadata, getQueryHandlerMetadataEntry, queryHandlerMetadataSymbol, defineSagaMetadata, getSagaMetadata, sagaMetadataSymbol, } from './metadata.js';
4
- export { CqrsModule, type CqrsModuleOptions } from './module.js';
5
- export * from './status.js';
6
1
  export { CommandBusLifecycleService } from './buses/command-bus.js';
7
2
  export { CqrsEventBusService } from './buses/event-bus.js';
8
3
  export { QueryBusLifecycleService } from './buses/query-bus.js';
4
+ export { CommandHandler, EventHandler, QueryHandler, Saga } from './decorators.js';
5
+ export { CommandHandlerNotFoundException, DuplicateCommandHandlerError, DuplicateEventHandlerError, DuplicateQueryHandlerError, QueryHandlerNotFoundException, SagaExecutionError, SagaTopologyError, } from './errors.js';
6
+ export { commandHandlerMetadataSymbol, defineCommandHandlerMetadata, defineEventHandlerMetadata, defineQueryHandlerMetadata, defineSagaMetadata, eventHandlerMetadataSymbol, getCommandHandlerMetadata, getCommandHandlerMetadataEntry, getEventHandlerMetadata, getQueryHandlerMetadata, getQueryHandlerMetadataEntry, getSagaMetadata, queryHandlerMetadataSymbol, sagaMetadataSymbol, } from './metadata.js';
7
+ export { CqrsModule, type CqrsModuleOptions } from './module.js';
8
+ export * from './status.js';
9
9
  export { COMMAND_BUS, EVENT_BUS, QUERY_BUS } from './tokens.js';
10
- export type { CommandBus, CommandHandlerClass, CommandHandlerDescriptor, CommandHandlerMetadata, CommandType, CqrsEventBus, CqrsEventType, EventHandlerDescriptor, EventHandlerClass, EventHandlerMetadata, ICommand, ICommandHandler, IEvent, IEventHandler, IQuery, IQueryHandler, ISaga, QueryBus, QueryHandlerClass, QueryHandlerDescriptor, QueryHandlerMetadata, QueryType, SagaClass, SagaDescriptor, SagaMetadata, } from './types.js';
10
+ export type { CommandBus, CommandHandlerClass, CommandHandlerDescriptor, CommandHandlerMetadata, CommandType, CqrsDispatchContext, CqrsEventBus, CqrsEventType, EventHandlerClass, EventHandlerDescriptor, EventHandlerMetadata, ICommand, ICommandHandler, IEvent, IEventHandler, IQuery, IQueryHandler, ISaga, QueryBus, QueryHandlerClass, QueryHandlerDescriptor, QueryHandlerMetadata, QueryType, SagaClass, SagaDescriptor, SagaMetadata, } from './types.js';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,0BAA0B,EAC1B,+BAA+B,EAC/B,6BAA6B,EAC7B,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,8BAA8B,EAC9B,uBAAuB,EACvB,uBAAuB,EACvB,4BAA4B,EAC5B,0BAA0B,EAC1B,kBAAkB,EAClB,eAAe,EACf,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACjE,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAChE,YAAY,EACV,UAAU,EACV,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,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jB,sBAAsB,EACtB,oBAAoB,EACpB,QAAQ,EACR,eAAe,EACf,MAAM,EACN,aAAa,EACb,MAAM,EACN,aAAa,EACb,KAAK,EACL,QAAQ,EACR,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,SAAS,EACT,SAAS,EACT,cAAc,EACd,YAAY,GACb,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- export { CommandHandler, EventHandler, QueryHandler, Saga } from './decorators.js';
2
- export { DuplicateCommandHandlerError, DuplicateEventHandlerError, DuplicateQueryHandlerError, CommandHandlerNotFoundException, QueryHandlerNotFoundException, SagaExecutionError, SagaTopologyError } from './errors.js';
3
- export { commandHandlerMetadataSymbol, defineCommandHandlerMetadata, defineEventHandlerMetadata, defineQueryHandlerMetadata, eventHandlerMetadataSymbol, getCommandHandlerMetadata, getCommandHandlerMetadataEntry, getEventHandlerMetadata, getQueryHandlerMetadata, getQueryHandlerMetadataEntry, queryHandlerMetadataSymbol, defineSagaMetadata, getSagaMetadata, sagaMetadataSymbol } from './metadata.js';
4
- export { CqrsModule } from './module.js';
5
- export * from './status.js';
6
1
  export { CommandBusLifecycleService } from './buses/command-bus.js';
7
2
  export { CqrsEventBusService } from './buses/event-bus.js';
8
3
  export { QueryBusLifecycleService } from './buses/query-bus.js';
4
+ export { CommandHandler, EventHandler, QueryHandler, Saga } from './decorators.js';
5
+ export { CommandHandlerNotFoundException, DuplicateCommandHandlerError, DuplicateEventHandlerError, DuplicateQueryHandlerError, QueryHandlerNotFoundException, SagaExecutionError, SagaTopologyError } from './errors.js';
6
+ export { commandHandlerMetadataSymbol, defineCommandHandlerMetadata, defineEventHandlerMetadata, defineQueryHandlerMetadata, defineSagaMetadata, eventHandlerMetadataSymbol, getCommandHandlerMetadata, getCommandHandlerMetadataEntry, getEventHandlerMetadata, getQueryHandlerMetadata, getQueryHandlerMetadataEntry, getSagaMetadata, queryHandlerMetadataSymbol, sagaMetadataSymbol } from './metadata.js';
7
+ export { CqrsModule } from './module.js';
8
+ export * from './status.js';
9
9
  export { COMMAND_BUS, EVENT_BUS, QUERY_BUS } from './tokens.js';
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAkB,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAOhE,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EAIjB,iBAAiB,EACjB,SAAS,EACV,MAAM,YAAY,CAAC;AAEpB,4FAA4F;AAC5F,MAAM,WAAW,iBAAiB;IAChC,eAAe,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACjD,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,aAAa,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC7C,iFAAiF;IACjF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC7C,KAAK,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B,8GAA8G;IAC9G,QAAQ,CAAC,EAAE;QACT,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAwBD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,iBAAsB,GAAG,QAAQ,EAAE,CAkC/E;AAED,iFAAiF;AACjF,qBAAa,UAAU;IACrB;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,iBAAsB,GAAG,UAAU;CAiB5D"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAkB,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAOhE,OAAO,KAAK,EACV,mBAAmB,EAEnB,iBAAiB,EAIjB,iBAAiB,EACjB,SAAS,EACV,MAAM,YAAY,CAAC;AAEpB,4FAA4F;AAC5F,MAAM,WAAW,iBAAiB;IAChC,eAAe,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACjD,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,aAAa,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC7C,iFAAiF;IACjF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC7C,KAAK,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B,8GAA8G;IAC9G,QAAQ,CAAC,EAAE;QACT,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AA0CD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,iBAAsB,GAAG,QAAQ,EAAE,CA8C/E;AAED,iFAAiF;AACjF,qBAAa,UAAU;IACrB;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,iBAAsB,GAAG,UAAU;CAiB5D"}
package/dist/module.js CHANGED
@@ -24,6 +24,21 @@ function collectOptionHandlerProviders(options) {
24
24
  }
25
25
  return providers;
26
26
  }
27
+ function assertCommandBusService(service) {
28
+ if (!(service instanceof CommandBusLifecycleService)) {
29
+ throw new TypeError('CQRS command bus alias expected CommandBusLifecycleService.');
30
+ }
31
+ }
32
+ function assertQueryBusService(service) {
33
+ if (!(service instanceof QueryBusLifecycleService)) {
34
+ throw new TypeError('CQRS query bus alias expected QueryBusLifecycleService.');
35
+ }
36
+ }
37
+ function assertCqrsEventBusService(service) {
38
+ if (!(service instanceof CqrsEventBusService)) {
39
+ throw new TypeError('CQRS event bus alias expected CqrsEventBusService.');
40
+ }
41
+ }
27
42
 
28
43
  /**
29
44
  * Creates the providers required for CQRS buses, compatibility aliases, and optional handler registration.
@@ -38,22 +53,31 @@ export function createCqrsProviders(options = {}) {
38
53
  }, CommandBusLifecycleService, {
39
54
  inject: [CommandBusLifecycleService],
40
55
  provide: COMMAND_BUS,
41
- useFactory: service => ({
42
- execute: command => service.execute(command)
43
- })
56
+ useFactory: service => {
57
+ assertCommandBusService(service);
58
+ return {
59
+ execute: (command, context) => service.execute(command, context)
60
+ };
61
+ }
44
62
  }, QueryBusLifecycleService, {
45
63
  inject: [QueryBusLifecycleService],
46
64
  provide: QUERY_BUS,
47
- useFactory: service => ({
48
- execute: query => service.execute(query)
49
- })
65
+ useFactory: service => {
66
+ assertQueryBusService(service);
67
+ return {
68
+ execute: (query, context) => service.execute(query, context)
69
+ };
70
+ }
50
71
  }, CqrsSagaLifecycleService, CqrsEventBusService, {
51
72
  inject: [CqrsEventBusService],
52
73
  provide: EVENT_BUS,
53
- useFactory: service => ({
54
- publish: event => service.publish(event),
55
- publishAll: events => service.publishAll(events)
56
- })
74
+ useFactory: service => {
75
+ assertCqrsEventBusService(service);
76
+ return {
77
+ publish: (event, context) => service.publish(event, context),
78
+ publishAll: (events, context) => service.publishAll(events, context)
79
+ };
80
+ }
57
81
  }, ...collectOptionHandlerProviders(options)];
58
82
  }
59
83
 
package/dist/types.d.ts CHANGED
@@ -15,9 +15,10 @@ export interface ICommandHandler<TCommand extends ICommand, TResult = void> {
15
15
  * Executes one command instance.
16
16
  *
17
17
  * @param command Command payload to handle.
18
+ * @param context Optional saga dispatch context to pass through nested CQRS calls.
18
19
  * @returns The handler result returned to the command bus caller.
19
20
  */
20
- execute(command: TCommand): TResult | Promise<TResult>;
21
+ execute(command: TCommand, context?: CqrsDispatchContext): TResult | Promise<TResult>;
21
22
  }
22
23
  /** Contract implemented by classes decorated with {@link QueryHandler}. */
23
24
  export interface IQueryHandler<TQuery extends IQuery<TResult>, TResult = unknown> {
@@ -25,9 +26,10 @@ export interface IQueryHandler<TQuery extends IQuery<TResult>, TResult = unknown
25
26
  * Executes one query instance.
26
27
  *
27
28
  * @param query Query payload to handle.
29
+ * @param context Optional saga dispatch context to pass through nested CQRS calls.
28
30
  * @returns The query result returned to the caller.
29
31
  */
30
- execute(query: TQuery): TResult | Promise<TResult>;
32
+ execute(query: TQuery, context?: CqrsDispatchContext): TResult | Promise<TResult>;
31
33
  }
32
34
  /** Contract implemented by classes decorated with {@link EventHandler}. */
33
35
  export interface IEventHandler<TEvent extends IEvent> {
@@ -35,9 +37,10 @@ export interface IEventHandler<TEvent extends IEvent> {
35
37
  * Reacts to one isolated copy of a published event instance.
36
38
  *
37
39
  * @param event Event payload cloned for this handler before delegated event-bus publication.
40
+ * @param context Optional saga dispatch context to pass through nested CQRS calls.
38
41
  * @returns A promise or void once side effects complete.
39
42
  */
40
- handle(event: TEvent): void | Promise<void>;
43
+ handle(event: TEvent, context?: CqrsDispatchContext): void | Promise<void>;
41
44
  }
42
45
  /** Contract implemented by classes decorated with {@link Saga}. */
43
46
  export interface ISaga<TEvent extends IEvent = IEvent> {
@@ -45,9 +48,27 @@ export interface ISaga<TEvent extends IEvent = IEvent> {
45
48
  * Reacts to one isolated copy of an event and typically emits follow-up commands.
46
49
  *
47
50
  * @param event Event payload cloned for this saga route before delegated event-bus publication.
51
+ * @param context Optional saga dispatch context to pass through nested CQRS calls.
48
52
  * @returns A promise or void once orchestration side effects complete.
49
53
  */
50
- handle(event: TEvent): void | Promise<void>;
54
+ handle(event: TEvent, context?: CqrsDispatchContext): void | Promise<void>;
55
+ }
56
+ /**
57
+ * Opaque dispatch context used to preserve saga topology guards across nested CQRS calls.
58
+ *
59
+ * Pass this value unchanged from handlers and sagas into nested `execute(...)`, `publish(...)`,
60
+ * or `publishAll(...)` calls. Application code should not inspect or construct it directly.
61
+ */
62
+ export interface CqrsDispatchContext {
63
+ /** Saga routes currently active in the in-process CQRS dispatch chain. */
64
+ readonly activeRoutes: readonly Readonly<{
65
+ eventType: CqrsEventType;
66
+ token: Token;
67
+ }>[];
68
+ /** Current nested saga depth for in-process topology guarding. */
69
+ readonly depth: number;
70
+ /** Human-readable saga route labels used when reporting topology failures. */
71
+ readonly path: readonly string[];
51
72
  }
52
73
  /** Constructor type used to identify a command message class. */
53
74
  export interface CommandType<TCommand extends ICommand = ICommand> {
@@ -129,7 +150,7 @@ export interface CommandBus {
129
150
  * @param command Command instance to dispatch.
130
151
  * @returns The handler result.
131
152
  */
132
- execute<TCommand extends ICommand, TResult = void>(command: TCommand): Promise<TResult>;
153
+ execute<TCommand extends ICommand, TResult = void>(command: TCommand, context?: CqrsDispatchContext): Promise<TResult>;
133
154
  }
134
155
  /** Query dispatch facade exposed by the CQRS module. */
135
156
  export interface QueryBus {
@@ -139,7 +160,7 @@ export interface QueryBus {
139
160
  * @param query Query instance to dispatch.
140
161
  * @returns The handler result.
141
162
  */
142
- execute<TQuery extends IQuery<TResult>, TResult = unknown>(query: TQuery): Promise<TResult>;
163
+ execute<TQuery extends IQuery<TResult>, TResult = unknown>(query: TQuery, context?: CqrsDispatchContext): Promise<TResult>;
143
164
  }
144
165
  /** Event publishing facade exposed by the CQRS module. */
145
166
  export interface CqrsEventBus {
@@ -150,15 +171,17 @@ export interface CqrsEventBus {
150
171
  * subscribers receive the original event after local CQRS side effects complete.
151
172
  *
152
173
  * @param event Event instance to publish.
174
+ * @param context Optional saga dispatch context to pass through nested CQRS calls.
153
175
  * @returns A promise that resolves once publication completes.
154
176
  */
155
- publish<TEvent extends IEvent>(event: TEvent): Promise<void>;
177
+ publish<TEvent extends IEvent>(event: TEvent, context?: CqrsDispatchContext): Promise<void>;
156
178
  /**
157
179
  * Publishes a batch of events in order.
158
180
  *
159
181
  * @param events Event instances to publish.
182
+ * @param context Optional saga dispatch context to pass through nested CQRS calls.
160
183
  * @returns A promise that resolves once all events are published.
161
184
  */
162
- publishAll<TEvent extends IEvent>(events: readonly TEvent[]): Promise<void>;
185
+ publishAll<TEvent extends IEvent>(events: readonly TEvent[], context?: CqrsDispatchContext): Promise<void>;
163
186
  }
164
187
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE1C,2EAA2E;AAC3E,MAAM,WAAW,QAAQ;CAAG;AAE5B,mGAAmG;AACnG,MAAM,WAAW,MAAM,CAAC,OAAO,GAAG,OAAO;IACvC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACxC;AAED,yFAAyF;AACzF,MAAM,WAAW,MAAM;CAAG;AAE1B,6EAA6E;AAC7E,MAAM,WAAW,eAAe,CAAC,QAAQ,SAAS,QAAQ,EAAE,OAAO,GAAG,IAAI;IACxE;;;;;OAKG;IACH,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACxD;AAED,2EAA2E;AAC3E,MAAM,WAAW,aAAa,CAAC,MAAM,SAAS,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO;IAC9E;;;;;OAKG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACpD;AAED,2EAA2E;AAC3E,MAAM,WAAW,aAAa,CAAC,MAAM,SAAS,MAAM;IAClD;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C;AAED,mEAAmE;AACnE,MAAM,WAAW,KAAK,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM;IACnD;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C;AAED,iEAAiE;AACjE,MAAM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C,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACxH;AAED,wDAAwD;AACxD,MAAM,WAAW,QAAQ;IACvB;;;;;OAKG;IACH,OAAO,CAAC,MAAM,SAAS,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5H;AAED,0DAA0D;AAC1D,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;OASG;IACH,OAAO,CAAC,MAAM,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5F;;;;;;OAMG;IACH,UAAU,CAAC,MAAM,SAAS,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5G"}
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "saga",
10
10
  "event-sourcing"
11
11
  ],
12
- "version": "1.0.0",
12
+ "version": "1.1.1",
13
13
  "private": false,
14
14
  "license": "MIT",
15
15
  "repository": {
@@ -36,10 +36,10 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@fluojs/core": "^1.0.0",
40
- "@fluojs/di": "^1.0.0",
39
+ "@fluojs/core": "^1.0.3",
40
+ "@fluojs/di": "^1.1.0",
41
41
  "@fluojs/event-bus": "^1.0.0",
42
- "@fluojs/runtime": "^1.0.0"
42
+ "@fluojs/runtime": "^1.1.7"
43
43
  },
44
44
  "devDependencies": {
45
45
  "vitest": "^3.2.4"