@cqrs-ddd/cqrs 0.5.1 → 0.6.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/dist/create-cqrs.d.ts +1 -1
- package/dist/create-cqrs.d.ts.map +1 -1
- package/dist/create-cqrs.js +8 -2
- package/dist/create-cqrs.js.map +1 -1
- package/dist/dispatch.d.ts +2 -2
- package/dist/dispatch.d.ts.map +1 -1
- package/dist/dispatch.js +11 -34
- package/dist/dispatch.js.map +1 -1
- package/dist/registry.d.ts +2 -10
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +2 -45
- package/dist/registry.js.map +1 -1
- package/package.json +4 -4
package/dist/create-cqrs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type IPipelineBehavior, type PipelineLogger } from '@cqrs-ddd/pipeline';
|
|
2
2
|
import { CommandBus } from './command.bus.js';
|
|
3
3
|
import { EventBus } from './event.bus.js';
|
|
4
4
|
import { QueryBus } from './query.bus.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-cqrs.d.ts","sourceRoot":"","sources":["../src/create-cqrs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"create-cqrs.d.ts","sourceRoot":"","sources":["../src/create-cqrs.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAEL,KAAK,mBAAmB,EAGzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,qCAAqC;AACrC,MAAM,WAAW,WAAY,SAAQ,mBAAmB;IACtD;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAClD,0FAA0F;IAC1F,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC;IACjC;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED,8EAA8E;AAC9E,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IACtD;;;;;;;OAOG;IACH,QAAQ,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACtC,wFAAwF;IACxF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,WAAgB,GAAG,IAAI,CAoC1D"}
|
package/dist/create-cqrs.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
2
|
+
import { createBehaviorResolver, } from '@cqrs-ddd/pipeline';
|
|
2
3
|
import { CommandBus } from './command.bus.js';
|
|
3
4
|
import { commandOf, eventsOf, queryOf } from './decorators.js';
|
|
4
5
|
import { EventBus } from './event.bus.js';
|
|
5
6
|
import { QueryBus } from './query.bus.js';
|
|
6
|
-
import {
|
|
7
|
+
import { Handlers, registerHandlers, } from './registry.js';
|
|
7
8
|
import { UnhandledExceptionBus } from './unhandled-exception.bus.js';
|
|
8
9
|
/**
|
|
9
10
|
* Creates the command, query and event buses with no container: the application builds
|
|
@@ -26,7 +27,12 @@ import { UnhandledExceptionBus } from './unhandled-exception.bus.js';
|
|
|
26
27
|
*/
|
|
27
28
|
export function createCqrs(options = {}) {
|
|
28
29
|
const logger = options.logger ?? console;
|
|
29
|
-
const behavior =
|
|
30
|
+
const behavior = createBehaviorResolver({
|
|
31
|
+
owner: 'createCqrs',
|
|
32
|
+
given: options.behaviors ?? [],
|
|
33
|
+
globalBehaviors: options.globalBehaviors,
|
|
34
|
+
logger,
|
|
35
|
+
});
|
|
30
36
|
const handlers = new Handlers();
|
|
31
37
|
const registry = { handlers, behavior, options, logger };
|
|
32
38
|
const unhandledExceptionBus = new UnhandledExceptionBus();
|
package/dist/create-cqrs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-cqrs.js","sourceRoot":"","sources":["../src/create-cqrs.ts"],"names":[],"mappings":"AAAA,sEAAsE;
|
|
1
|
+
{"version":3,"file":"create-cqrs.js","sourceRoot":"","sources":["../src/create-cqrs.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAEL,sBAAsB,GAGvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,QAAQ,EAGR,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAuCrE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,UAAU,CAAC,OAAO,GAAgB,EAAE;IAClD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC;IACzC,MAAM,QAAQ,GAAG,sBAAsB,CAAC;QACtC,KAAK,EAAE,YAAY;QACnB,KAAK,EAAE,OAA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"}
|
package/dist/dispatch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Constructor, type ContextSources, type DeclaredKind, type GlobalBehaviorsOptions, type
|
|
1
|
+
import { type BehaviorResolver, type Constructor, type ContextSources, type DeclaredKind, type GlobalBehaviorsOptions, type PipelineBehaviorDiagnostic } from '@cqrs-ddd/pipeline';
|
|
2
2
|
import type { RequestType } from './decorators.js';
|
|
3
3
|
/** Runs one request through its handler and the handler's pipeline. */
|
|
4
4
|
export type Dispatch = (request: unknown) => Promise<unknown>;
|
|
@@ -7,7 +7,7 @@ export interface PipelineSettings {
|
|
|
7
7
|
readonly globalBehaviors?: GlobalBehaviorsOptions | GlobalBehaviorsOptions[];
|
|
8
8
|
readonly sources?: ContextSources;
|
|
9
9
|
/** Returns the one instance of a behavior class. */
|
|
10
|
-
readonly behavior:
|
|
10
|
+
readonly behavior: BehaviorResolver;
|
|
11
11
|
/** Receives contract violations; absent, contracts are not validated. */
|
|
12
12
|
readonly diagnostics?: PipelineBehaviorDiagnostic[];
|
|
13
13
|
/** Receives a line per handler that runs behaviors, naming them in order. */
|
package/dist/dispatch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,cAAc,EAGnB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,cAAc,EAGnB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAChC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAOnD,uEAAuE;AACvE,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE9D,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,eAAe,CAAC,EAAE,sBAAsB,GAAG,sBAAsB,EAAE,CAAC;IAC7E,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IAClC,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,yEAAyE;IACzE,QAAQ,CAAC,WAAW,CAAC,EAAE,0BAA0B,EAAE,CAAC;IACpD,6EAA6E;IAC7E,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;AAED,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;CAC7B;AAQD;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,gBAAgB,GACzB,QAAQ,CAkBV;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACvB,OAAO,EAAE,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC,EACpC,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,SAAS,CAUf"}
|
package/dist/dispatch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
2
|
-
import {
|
|
2
|
+
import { compileHandlerPlan, createHandlerRunner, } from '@cqrs-ddd/pipeline';
|
|
3
3
|
import { InvalidCommandHandlerException, InvalidEventsHandlerException, InvalidQueryHandlerException, } from './errors.js';
|
|
4
4
|
const INVALID = {
|
|
5
5
|
command: InvalidCommandHandlerException,
|
|
@@ -22,41 +22,18 @@ export function toDispatch(handler, settings) {
|
|
|
22
22
|
const method = Reflect.get(handlerType.prototype, name);
|
|
23
23
|
if (typeof method !== 'function')
|
|
24
24
|
throw new INVALID[kind]();
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const behaviors = plan.behaviorTypes.map(settings.behavior);
|
|
28
|
-
if (plan.hasPipeline) {
|
|
29
|
-
settings.log?.(`Wrapping ${handlerName}.${name}() [${kind}] with pipeline: [${plan.behaviorTypes.map((type) => type.name).join(' → ')}]`);
|
|
30
|
-
}
|
|
31
|
-
if (settings.diagnostics) {
|
|
32
|
-
validateBehaviorContracts({
|
|
33
|
-
...plan,
|
|
34
|
-
handlerType,
|
|
35
|
-
handlerName,
|
|
36
|
-
requestKind: kind,
|
|
37
|
-
resolvedBehaviors: new Map(behaviors.map((b, i) => [i, b])),
|
|
38
|
-
diagnostics: settings.diagnostics,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
const run = createPipelineRunner(method, {
|
|
25
|
+
const plan = compileHandlerPlan(handlerType, kind, settings.globalBehaviors);
|
|
26
|
+
const run = createHandlerRunner({
|
|
42
27
|
handlerType,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
function planOf(handlerType, kind, settings) {
|
|
51
|
-
const declared = pipelineOf(handlerType);
|
|
52
|
-
return compilePipelinePlan({
|
|
53
|
-
handlerName: handlerType.name,
|
|
54
|
-
requestKind: kind,
|
|
55
|
-
handlerBehaviorTypes: declared.types,
|
|
56
|
-
handlerOptions: declared.options,
|
|
57
|
-
skippedBehaviorTypes: declared.skipped,
|
|
58
|
-
globalBehaviors: settings.globalBehaviors,
|
|
28
|
+
kind,
|
|
29
|
+
plan,
|
|
30
|
+
method,
|
|
31
|
+
behaviors: plan.behaviorTypes.map(settings.behavior),
|
|
32
|
+
sources: settings.sources,
|
|
33
|
+
diagnostics: settings.diagnostics,
|
|
34
|
+
log: settings.log,
|
|
59
35
|
});
|
|
36
|
+
return (request) => run(resolve(), request);
|
|
60
37
|
}
|
|
61
38
|
/**
|
|
62
39
|
* The entry of a request class or, failing that, of its nearest parent class.
|
package/dist/dispatch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAIL,kBAAkB,EAClB,mBAAmB,GAIpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AAwBrB,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,8BAA8B;IACvC,KAAK,EAAE,4BAA4B;IACnC,KAAK,EAAE,6BAA6B;CACrC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CACxB,OAAwB,EACxB,QAA0B;IAE1B,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACrD,MAAM,IAAI,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IACrD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACxD,IAAI,OAAO,MAAM,KAAK,UAAU;QAAE,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;IAC5D,MAAM,IAAI,GAAG,kBAAkB,CAAC,WAAW,EAAE,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;IAC7E,MAAM,GAAG,GAAG,mBAAmB,CAAC;QAC9B,WAAW;QACX,IAAI;QACJ,IAAI;QACJ,MAAM;QACN,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACpD,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,GAAG,EAAE,QAAQ,CAAC,GAAG;KAClB,CAAC,CAAC;IAEH,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CACrB,OAAoC,EACpC,IAAY;IAEZ,KACE,IAAI,OAAO,GAAG,IAAI,EAClB,OAAO,KAAK,QAAQ,CAAC,SAAS,EAC9B,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,EACxC,CAAC;QACD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,OAAsB,CAAC,CAAC;QAClD,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;IAC1B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/registry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Constructor, type ContextSources, type
|
|
1
|
+
import { type Constructor, type ContextSources, type DiagnosticsMode, type GlobalBehaviorsOptions, type LogLevel, type PipelineLogger } from '@cqrs-ddd/pipeline';
|
|
2
2
|
import { type Dispatch, type PipelineSettings } from './dispatch.js';
|
|
3
3
|
import type { EventSubscriber } from './event.bus.js';
|
|
4
4
|
/** The dispatch tables the buses read, filled as handlers register. */
|
|
@@ -11,7 +11,7 @@ export declare class Handlers {
|
|
|
11
11
|
export interface RegistrationOptions {
|
|
12
12
|
readonly globalBehaviors?: GlobalBehaviorsOptions | GlobalBehaviorsOptions[];
|
|
13
13
|
readonly sources?: ContextSources;
|
|
14
|
-
readonly diagnostics?:
|
|
14
|
+
readonly diagnostics?: DiagnosticsMode;
|
|
15
15
|
readonly bootstrapLogLevel?: LogLevel | 'none';
|
|
16
16
|
}
|
|
17
17
|
/** A handler to register: its class, and what gives the instance per request. */
|
|
@@ -26,14 +26,6 @@ export interface Registry {
|
|
|
26
26
|
readonly options: RegistrationOptions;
|
|
27
27
|
readonly logger: PipelineLogger;
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
30
|
-
* The one instance of each behavior class: the instance given for that class, else
|
|
31
|
-
* `LoggingBehavior` on the logger, else one built with no arguments. The global behaviors
|
|
32
|
-
* are built here, so one that cannot be built fails at once.
|
|
33
|
-
*
|
|
34
|
-
* @throws TypeError on two given instances of one behavior class.
|
|
35
|
-
*/
|
|
36
|
-
export declare function behaviorResolver(given: readonly IPipelineBehavior[], globalBehaviors: RegistrationOptions['globalBehaviors'], logger: PipelineLogger): PipelineSettings['behavior'];
|
|
37
29
|
/**
|
|
38
30
|
* Compiles each handler's pipeline once and adds it to the dispatch tables. Contract
|
|
39
31
|
* violations throw a `PipelineConfigurationError` in `'strict'` mode, are logged in
|
package/dist/registry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,QAAQ,EAEb,KAAK,cAAc,EAEpB,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EAEtB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,uEAAuE;AACvE,qBAAa,QAAQ;IACnB,QAAQ,CAAC,QAAQ,uDAAoC;IACrD,QAAQ,CAAC,OAAO,uDAAoC;IACpD,QAAQ,CAAC,MAAM,gEAA6C;CAC7D;AAED,6CAA6C;AAC7C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,eAAe,CAAC,EAAE,sBAAsB,GAAG,sBAAsB,EAAE,CAAC;IAC7E,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC;IACvC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CAChD;AAED,iFAAiF;AACjF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,MAAM,CAAC;CAChC;AAED,kFAAkF;AAClF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAChD,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;CACjC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,SAAS,YAAY,EAAE,GAC/B,IAAI,CAuCN"}
|
package/dist/registry.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* Copyright (C) 2026-present Aristotelis — see repository license. */
|
|
2
|
-
import {
|
|
2
|
+
import { reportDiagnostics, } from '@cqrs-ddd/pipeline';
|
|
3
3
|
import { commandOf, eventsOf, queryOf, } from './decorators.js';
|
|
4
4
|
import { toDispatch, } from './dispatch.js';
|
|
5
5
|
/** The dispatch tables the buses read, filled as handlers register. */
|
|
@@ -8,40 +8,6 @@ export class Handlers {
|
|
|
8
8
|
queries = new Map();
|
|
9
9
|
events = new Map();
|
|
10
10
|
}
|
|
11
|
-
const LOGGING_ID = getBehaviorId(LoggingBehavior);
|
|
12
|
-
/**
|
|
13
|
-
* The one instance of each behavior class: the instance given for that class, else
|
|
14
|
-
* `LoggingBehavior` on the logger, else one built with no arguments. The global behaviors
|
|
15
|
-
* are built here, so one that cannot be built fails at once.
|
|
16
|
-
*
|
|
17
|
-
* @throws TypeError on two given instances of one behavior class.
|
|
18
|
-
*/
|
|
19
|
-
export function behaviorResolver(given, globalBehaviors, logger) {
|
|
20
|
-
const instances = new Map();
|
|
21
|
-
for (const instance of given) {
|
|
22
|
-
const type = instance.constructor;
|
|
23
|
-
const id = getBehaviorId(type);
|
|
24
|
-
if (instances.has(id)) {
|
|
25
|
-
throw new TypeError(`createCqrs: two instances of ${type.name}; pass one per behavior class.`);
|
|
26
|
-
}
|
|
27
|
-
instances.set(id, instance);
|
|
28
|
-
}
|
|
29
|
-
const behavior = (type) => {
|
|
30
|
-
const id = getBehaviorId(type);
|
|
31
|
-
let instance = instances.get(id);
|
|
32
|
-
if (!instance) {
|
|
33
|
-
instance = id === LOGGING_ID ? new LoggingBehavior(logger) : new type();
|
|
34
|
-
instances.set(id, instance);
|
|
35
|
-
}
|
|
36
|
-
return instance;
|
|
37
|
-
};
|
|
38
|
-
for (const config of toGlobalConfigs(globalBehaviors)) {
|
|
39
|
-
for (const entry of [...(config.before ?? []), ...(config.after ?? [])]) {
|
|
40
|
-
behavior(behaviorEntryType(entry, 'globalBehaviors'));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return behavior;
|
|
44
|
-
}
|
|
45
11
|
/**
|
|
46
12
|
* Compiles each handler's pipeline once and adds it to the dispatch tables. Contract
|
|
47
13
|
* violations throw a `PipelineConfigurationError` in `'strict'` mode, are logged in
|
|
@@ -76,7 +42,7 @@ export function registerHandlers(registry, entries) {
|
|
|
76
42
|
subscribe(handlers.events, events, { name: type.name, run });
|
|
77
43
|
}
|
|
78
44
|
}
|
|
79
|
-
|
|
45
|
+
reportDiagnostics(found, mode, logger);
|
|
80
46
|
}
|
|
81
47
|
function subscribe(table, events, subscriber) {
|
|
82
48
|
for (const event of events) {
|
|
@@ -84,15 +50,6 @@ function subscribe(table, events, subscriber) {
|
|
|
84
50
|
table.set(event, [...subscribers, subscriber]);
|
|
85
51
|
}
|
|
86
52
|
}
|
|
87
|
-
/** Throws the contract violations in `'strict'` mode, else logs each one. */
|
|
88
|
-
function report(found, mode, logger) {
|
|
89
|
-
if (found.length > 0 && mode === 'strict') {
|
|
90
|
-
throw new PipelineConfigurationError(found);
|
|
91
|
-
}
|
|
92
|
-
for (const d of found) {
|
|
93
|
-
logger.warn(`[Pipeline Diagnostic] Handler '${d.handlerName}' with behavior '${d.behaviorName}': ${d.message}. Fix: ${d.fix}`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
53
|
function bind(table, binding, settings) {
|
|
97
54
|
const { kind, request, type } = binding;
|
|
98
55
|
if (table.has(request)) {
|
package/dist/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAQL,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,SAAS,EACT,QAAQ,EACR,OAAO,GAER,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAGL,UAAU,GACX,MAAM,eAAe,CAAC;AAGvB,uEAAuE;AACvE,MAAM,OAAO,QAAQ;IACV,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC5C,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC3C,MAAM,GAAG,IAAI,GAAG,EAAkC,CAAC;CAC7D;AAwBD;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAAkB,EAClB,OAAgC;IAEhC,MAAM,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": "Command, query and event buses with handler decorators and a pipeline per handler, built by createCqrs() with no framework and no container",
|
|
5
5
|
"author": "Aristotelis",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@cqrs-ddd/pipeline": "^0.
|
|
46
|
+
"@cqrs-ddd/pipeline": "^0.6.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
+
"@cqrs-ddd/pipeline": "0.6.0",
|
|
49
50
|
"@vitest/coverage-v8": "^5.0.5",
|
|
50
|
-
"vitest": "^5.0.5"
|
|
51
|
-
"@cqrs-ddd/pipeline": "0.5.1"
|
|
51
|
+
"vitest": "^5.0.5"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "tsc -p tsconfig.build.json",
|