@fluojs/cqrs
Advanced tools
@@ -1,5 +0,5 @@ | ||
| import { metadataSymbol } from '@fluojs/core/internal'; | ||
| import { ensureMetadataSymbol } from '@fluojs/core/internal'; | ||
| import { commandHandlerMetadataSymbol, eventHandlerMetadataSymbol, queryHandlerMetadataSymbol, sagaMetadataSymbol } from './metadata.js'; | ||
| ensureMetadataSymbol(); | ||
| function getStandardMetadataBag(metadata) { | ||
| void metadataSymbol; | ||
| if (typeof metadata !== 'object' || metadata === null) { | ||
@@ -6,0 +6,0 @@ throw new Error('Decorator metadata is unavailable. Ensure standard decorators are enabled.'); |
+15
-0
| import { type Token } from '@fluojs/core'; | ||
| import type { Container } from '@fluojs/di'; | ||
| import type { ApplicationLogger, CompiledModule } from '@fluojs/runtime'; | ||
| /** | ||
| * Describes the discovery candidate contract. | ||
| */ | ||
| export interface DiscoveryCandidate { | ||
@@ -10,2 +13,11 @@ moduleName: string; | ||
| } | ||
| /** | ||
| * Create duplicate handler message. | ||
| * | ||
| * @param kind The kind. | ||
| * @param messageType The message type. | ||
| * @param first The first. | ||
| * @param second The second. | ||
| * @returns The create duplicate handler message result. | ||
| */ | ||
| export declare function createDuplicateHandlerMessage(kind: 'command' | 'query' | 'event', messageType: Function, first: { | ||
@@ -18,2 +30,5 @@ moduleName: string; | ||
| }): string; | ||
| /** | ||
| * Represents the cqrs bus base. | ||
| */ | ||
| export declare abstract class CqrsBusBase { | ||
@@ -20,0 +35,0 @@ protected readonly runtimeContainer: Container; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAY,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEzE,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,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,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;IAC7C,UAAU,EAAE,QAAQ,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC;CACd;AAkBD;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,EACnC,WAAW,EAAE,QAAQ,EACrB,KAAK,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,QAAQ,CAAA;CAAE,EACnD,MAAM,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,QAAQ,CAAA;CAAE,GACnD,MAAM,CAER;AAED;;GAEG;AACH,8BAAsB,WAAW;IAI7B,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,SAAS;IAC9C,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,SAAS,cAAc,EAAE;IAC7D,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB;IAL9C,SAAS,CAAC,QAAQ,CAAC,gBAAgB,+BAAsC;gBAGpD,gBAAgB,EAAE,SAAS,EAC3B,eAAe,EAAE,SAAS,cAAc,EAAE,EAC1C,MAAM,EAAE,iBAAiB;IAG9C,SAAS,CAAC,mBAAmB,IAAI,kBAAkB,EAAE;cAsCrC,sBAAsB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;cAgBnD,sBAAsB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC;CAiBvE"} |
+19
-0
| import { getClassDiMetadata } from '@fluojs/core/internal'; | ||
| /** | ||
| * Describes the discovery candidate contract. | ||
| */ | ||
| function scopeFromProvider(provider) { | ||
@@ -14,5 +19,19 @@ if (typeof provider === 'function') { | ||
| } | ||
| /** | ||
| * Create duplicate handler message. | ||
| * | ||
| * @param kind The kind. | ||
| * @param messageType The message type. | ||
| * @param first The first. | ||
| * @param second The second. | ||
| * @returns The create duplicate handler message result. | ||
| */ | ||
| export function createDuplicateHandlerMessage(kind, messageType, first, second) { | ||
| return `Duplicate ${kind} handler for ${messageType.name} was discovered in ${first.moduleName}.${first.targetType.name} and ${second.moduleName}.${second.targetType.name}.`; | ||
| } | ||
| /** | ||
| * Represents the cqrs bus base. | ||
| */ | ||
| export class CqrsBusBase { | ||
@@ -19,0 +38,0 @@ handlerInstances = new Map(); |
+15
-0
| import type { PlatformHealthReport, PlatformReadinessReport, PlatformSnapshot } from '@fluojs/runtime'; | ||
| /** | ||
| * Defines the cqrs lifecycle state type. | ||
| */ | ||
| export type CqrsLifecycleState = 'created' | 'discovering' | 'ready' | 'stopping' | 'stopped' | 'failed'; | ||
| /** | ||
| * Describes the cqrs status adapter input contract. | ||
| */ | ||
| export interface CqrsStatusAdapterInput { | ||
@@ -10,2 +16,5 @@ eventHandlersDiscovered: number; | ||
| } | ||
| /** | ||
| * Describes the cqrs platform status snapshot contract. | ||
| */ | ||
| export interface CqrsPlatformStatusSnapshot { | ||
@@ -17,3 +26,9 @@ readiness: PlatformReadinessReport; | ||
| } | ||
| /** | ||
| * Create cqrs platform status snapshot. | ||
| * | ||
| * @param input The input. | ||
| * @returns The create cqrs platform status snapshot result. | ||
| */ | ||
| export declare function createCqrsPlatformStatusSnapshot(input: CqrsStatusAdapterInput): CqrsPlatformStatusSnapshot; | ||
| //# sourceMappingURL=status.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEvG,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,aAAa,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEzG,MAAM,WAAW,sBAAsB;IACrC,uBAAuB,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
+19
-0
@@ -0,1 +1,13 @@ | ||
| /** | ||
| * Defines the cqrs lifecycle state type. | ||
| */ | ||
| /** | ||
| * Describes the cqrs status adapter input contract. | ||
| */ | ||
| /** | ||
| * Describes the cqrs platform status snapshot contract. | ||
| */ | ||
| function createReadiness(input) { | ||
@@ -52,2 +64,9 @@ if (input.lifecycleState === 'ready' && input.sagaLifecycleState === 'ready') { | ||
| } | ||
| /** | ||
| * Create cqrs platform status snapshot. | ||
| * | ||
| * @param input The input. | ||
| * @returns The create cqrs platform status snapshot result. | ||
| */ | ||
| export function createCqrsPlatformStatusSnapshot(input) { | ||
@@ -54,0 +73,0 @@ return { |
+5
-5
@@ -12,3 +12,3 @@ { | ||
| ], | ||
| "version": "1.0.0-beta.3", | ||
| "version": "1.0.0-beta.4", | ||
| "private": false, | ||
@@ -40,6 +40,6 @@ "license": "MIT", | ||
| "dependencies": { | ||
| "@fluojs/core": "^1.0.0-beta.2", | ||
| "@fluojs/di": "^1.0.0-beta.3", | ||
| "@fluojs/event-bus": "^1.0.0-beta.3", | ||
| "@fluojs/runtime": "^1.0.0-beta.3" | ||
| "@fluojs/core": "^1.0.0-beta.4", | ||
| "@fluojs/di": "^1.0.0-beta.6", | ||
| "@fluojs/event-bus": "^1.0.0-beta.4", | ||
| "@fluojs/runtime": "^1.0.0-beta.11" | ||
| }, | ||
@@ -46,0 +46,0 @@ "devDependencies": { |
+13
-1
@@ -109,3 +109,3 @@ # @fluojs/cqrs | ||
| 이제 saga 실행은 같은 프로세스 안에서 동일 saga route로 순환 재진입하거나 중첩 hop 수가 32를 넘으면 `SagaTopologyError`로 즉시 실패합니다. 서로 다른 이벤트 단계를 순차 처리하는 multi-stage saga는 계속 허용되지만, in-process saga graph 전체는 비순환(acyclic) 구조를 유지해야 하며, 의도적인 순환/피드백 루프나 더 긴 체인은 외부 transport, scheduler, 또는 다른 bounded boundary 뒤로 이동해야 합니다. | ||
| Saga 실행은 같은 프로세스 안에서 동일 saga route로 순환 재진입하거나 중첩 hop 수가 32를 넘으면 `SagaTopologyError`로 즉시 실패합니다. 서로 다른 이벤트 단계를 순차 처리하는 multi-stage saga는 계속 허용되지만, in-process saga graph 전체는 비순환(acyclic) 구조를 유지해야 하며, 의도적인 순환/피드백 루프나 더 긴 체인은 외부 transport, scheduler, 또는 다른 bounded boundary 뒤로 이동해야 합니다. | ||
@@ -120,2 +120,4 @@ ### Event 발행 계약 | ||
| CQRS handler, event handler, saga는 singleton provider에서만 discovery됩니다. Non-singleton registration은 경고와 함께 건너뜁니다. | ||
| ### 심볼 토큰 | ||
@@ -139,2 +141,3 @@ | ||
| - `CqrsModule.forRoot(options)`: 메인 진입점입니다. 버스를 등록하고 탐색을 시작합니다. | ||
| - Module option은 명시적인 `commandHandlers`, `queryHandlers`, `eventHandlers`, `sagas`, 위임 `eventBus` option을 받을 수 있습니다. | ||
| - `CommandBusLifecycleService`: Command 실행을 위한 기본 서비스입니다. | ||
@@ -155,4 +158,11 @@ - `QueryBusLifecycleService`: Query 실행을 위한 기본 서비스입니다. | ||
| ### 오류 | ||
| - `CommandHandlerNotFoundException`, `QueryHandlerNotFoundException`: bus에 일치하는 handler가 없을 때 발생합니다. | ||
| - `DuplicateCommandHandlerError`, `DuplicateQueryHandlerError`, `DuplicateEventHandlerError`: 중복 handler registration에서 발생합니다. | ||
| - `SagaExecutionError`: 예상하지 못한 non-Fluo saga 실패를 감쌉니다. | ||
| - `SagaTopologyError`: 자기 트리거, 순환, 또는 과도하게 깊은 in-process saga graph를 감지했을 때 발생합니다. | ||
| ### status와 metadata | ||
| - `createCqrsPlatformStatusSnapshot(...)`: diagnostics와 health surface를 위한 CQRS status snapshot을 생성합니다. | ||
| - command, query, event, saga registration을 검사해야 하는 framework package를 위해 metadata helper와 symbol이 export됩니다. | ||
| ## 관련 패키지 | ||
@@ -167,1 +177,3 @@ | ||
| - `packages/cqrs/src/public-api.test.ts`: 루트 배럴 공개 API 계약 검증 예제. | ||
| - `packages/cqrs/src/status.test.ts`: CQRS status snapshot 동작 테스트 예제. | ||
| - `packages/cqrs/src/event-clone.test.ts`: event clone fallback 동작 테스트 예제. |
+13
-1
@@ -109,3 +109,3 @@ # @fluojs/cqrs | ||
| Saga execution now 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. | ||
| 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. | ||
@@ -120,2 +120,4 @@ ### Event Publishing Contracts | ||
| CQRS handlers, event handlers, and sagas are discovered only on singleton providers. Non-singleton registrations are skipped with warnings. | ||
| ### Symbol Tokens | ||
@@ -139,2 +141,3 @@ | ||
| - `CqrsModule.forRoot(options)`: Main entry point. Registers buses and starts discovery. | ||
| - Module options can provide explicit `commandHandlers`, `queryHandlers`, `eventHandlers`, `sagas`, and delegated `eventBus` options. | ||
| - `CommandBusLifecycleService`: Primary service for executing commands. | ||
@@ -155,4 +158,11 @@ - `QueryBusLifecycleService`: Primary service for executing queries. | ||
| ### Errors | ||
| - `CommandHandlerNotFoundException`, `QueryHandlerNotFoundException`: Raised when a bus has no matching handler. | ||
| - `DuplicateCommandHandlerError`, `DuplicateQueryHandlerError`, `DuplicateEventHandlerError`: Raised for duplicate handler registrations. | ||
| - `SagaExecutionError`: Wraps unexpected non-Fluo saga failures. | ||
| - `SagaTopologyError`: Raised when saga orchestration detects a self-triggering, cyclic, or over-deep in-process saga graph. | ||
| ### Status and metadata | ||
| - `createCqrsPlatformStatusSnapshot(...)`: Creates CQRS status snapshots for diagnostics and health surfaces. | ||
| - Metadata helpers and symbols are exported for framework packages that need to inspect command, query, event, or saga registrations. | ||
| ## Related Packages | ||
@@ -167,1 +177,3 @@ | ||
| - `packages/cqrs/src/public-api.test.ts`: Root-barrel public API contract coverage. | ||
| - `packages/cqrs/src/status.test.ts`: CQRS status snapshot behavior. | ||
| - `packages/cqrs/src/event-clone.test.ts`: Event clone fallback behavior. |
126785
2.83%2012
3.07%175
7.36%Updated
Updated