effectable 0.1.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/LICENSE +21 -0
- package/README.md +157 -0
- package/build/LICENSE +21 -0
- package/build/bootstrap/bootstrap.d.ts +32 -0
- package/build/bootstrap/bootstrap.d.ts.map +1 -0
- package/build/bootstrap/bootstrap.js +179 -0
- package/build/bootstrap/bootstrap.js.map +1 -0
- package/build/bootstrap/index.d.ts +9 -0
- package/build/bootstrap/index.d.ts.map +1 -0
- package/build/bootstrap/index.js +14 -0
- package/build/bootstrap/index.js.map +1 -0
- package/build/bootstrap/types.d.ts +105 -0
- package/build/bootstrap/types.d.ts.map +1 -0
- package/build/bootstrap/types.js +26 -0
- package/build/bootstrap/types.js.map +1 -0
- package/build/component/Component.d.ts +126 -0
- package/build/component/Component.d.ts.map +1 -0
- package/build/component/Component.js +123 -0
- package/build/component/Component.js.map +1 -0
- package/build/component/GraphRuntime.d.ts +457 -0
- package/build/component/GraphRuntime.d.ts.map +1 -0
- package/build/component/GraphRuntime.js +1168 -0
- package/build/component/GraphRuntime.js.map +1 -0
- package/build/component/constants.d.ts +1 -0
- package/build/component/constants.d.ts.map +1 -0
- package/build/component/constants.js +2 -0
- package/build/component/constants.js.map +1 -0
- package/build/component/context.d.ts +199 -0
- package/build/component/context.d.ts.map +1 -0
- package/build/component/context.js +262 -0
- package/build/component/context.js.map +1 -0
- package/build/component/graphRuntime.constants.d.ts +13 -0
- package/build/component/graphRuntime.constants.d.ts.map +1 -0
- package/build/component/graphRuntime.constants.js +15 -0
- package/build/component/graphRuntime.constants.js.map +1 -0
- package/build/component/h.d.ts +48 -0
- package/build/component/h.d.ts.map +1 -0
- package/build/component/h.js +72 -0
- package/build/component/h.js.map +1 -0
- package/build/component/index.d.ts +19 -0
- package/build/component/index.d.ts.map +1 -0
- package/build/component/index.js +39 -0
- package/build/component/index.js.map +1 -0
- package/build/component/lifecycle.d.ts +179 -0
- package/build/component/lifecycle.d.ts.map +1 -0
- package/build/component/lifecycle.js +367 -0
- package/build/component/lifecycle.js.map +1 -0
- package/build/component/refs.d.ts +105 -0
- package/build/component/refs.d.ts.map +1 -0
- package/build/component/refs.js +128 -0
- package/build/component/refs.js.map +1 -0
- package/build/component/types.d.ts +169 -0
- package/build/component/types.d.ts.map +1 -0
- package/build/component/types.js +40 -0
- package/build/component/types.js.map +1 -0
- package/build/connect/connect.d.ts +31 -0
- package/build/connect/connect.d.ts.map +1 -0
- package/build/connect/connect.js +500 -0
- package/build/connect/connect.js.map +1 -0
- package/build/connect/index.d.ts +8 -0
- package/build/connect/index.d.ts.map +1 -0
- package/build/connect/index.js +11 -0
- package/build/connect/index.js.map +1 -0
- package/build/connect/types.d.ts +90 -0
- package/build/connect/types.d.ts.map +1 -0
- package/build/connect/types.js +8 -0
- package/build/connect/types.js.map +1 -0
- package/build/index.d.ts +26 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +60 -0
- package/build/index.js.map +1 -0
- package/build/runtime/BusDecorators.d.ts +113 -0
- package/build/runtime/BusDecorators.d.ts.map +1 -0
- package/build/runtime/BusDecorators.js +302 -0
- package/build/runtime/BusDecorators.js.map +1 -0
- package/build/runtime/CommandBus.d.ts +43 -0
- package/build/runtime/CommandBus.d.ts.map +1 -0
- package/build/runtime/CommandBus.js +65 -0
- package/build/runtime/CommandBus.js.map +1 -0
- package/build/runtime/EventBus.d.ts +50 -0
- package/build/runtime/EventBus.d.ts.map +1 -0
- package/build/runtime/EventBus.js +90 -0
- package/build/runtime/EventBus.js.map +1 -0
- package/build/runtime/HandleRegistry.d.ts +143 -0
- package/build/runtime/HandleRegistry.d.ts.map +1 -0
- package/build/runtime/HandleRegistry.js +244 -0
- package/build/runtime/HandleRegistry.js.map +1 -0
- package/build/runtime/QueryBus.d.ts +43 -0
- package/build/runtime/QueryBus.d.ts.map +1 -0
- package/build/runtime/QueryBus.js +65 -0
- package/build/runtime/QueryBus.js.map +1 -0
- package/build/runtime/index.d.ts +13 -0
- package/build/runtime/index.d.ts.map +1 -0
- package/build/runtime/index.js +32 -0
- package/build/runtime/index.js.map +1 -0
- package/build/runtime/types.d.ts +79 -0
- package/build/runtime/types.d.ts.map +1 -0
- package/build/runtime/types.js +8 -0
- package/build/runtime/types.js.map +1 -0
- package/build/store/createStore.d.ts +36 -0
- package/build/store/createStore.d.ts.map +1 -0
- package/build/store/createStore.js +131 -0
- package/build/store/createStore.js.map +1 -0
- package/build/store/index.d.ts +14 -0
- package/build/store/index.d.ts.map +1 -0
- package/build/store/index.js +39 -0
- package/build/store/index.js.map +1 -0
- package/build/store/middleware.d.ts +38 -0
- package/build/store/middleware.d.ts.map +1 -0
- package/build/store/middleware.js +99 -0
- package/build/store/middleware.js.map +1 -0
- package/build/store/selector.d.ts +62 -0
- package/build/store/selector.d.ts.map +1 -0
- package/build/store/selector.js +226 -0
- package/build/store/selector.js.map +1 -0
- package/build/store/semanticStateTree.d.ts +91 -0
- package/build/store/semanticStateTree.d.ts.map +1 -0
- package/build/store/semanticStateTree.js +263 -0
- package/build/store/semanticStateTree.js.map +1 -0
- package/build/store/types.d.ts +259 -0
- package/build/store/types.d.ts.map +1 -0
- package/build/store/types.js +28 -0
- package/build/store/types.js.map +1 -0
- package/package.json +109 -0
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effectable entry point: bootstrap, store, component, connect, runtime.
|
|
3
|
+
* Re-exports bootstrap, store, component, connect, and runtime for a single entry
|
|
4
|
+
* (Effectable or selective imports).
|
|
5
|
+
*
|
|
6
|
+
* Note on name conflicts:
|
|
7
|
+
* - UseRef and UseImperativeHandle from runtime/HandleRegistry are for registering
|
|
8
|
+
* imperative handles in HandleRegistry (legacy mechanism).
|
|
9
|
+
* - UseRef and UseImperativeHandle from component/refs are for GraphRuntime
|
|
10
|
+
* (fiber-based declarative tree, mounted lifecycle).
|
|
11
|
+
* To resolve the conflict, the runtime versions are exported with the Handle* alias.
|
|
12
|
+
*
|
|
13
|
+
* @module Effectable
|
|
14
|
+
*/
|
|
15
|
+
export * from './bootstrap';
|
|
16
|
+
export * from './store';
|
|
17
|
+
export * from './component';
|
|
18
|
+
export * from './connect';
|
|
19
|
+
export { HandleRegistry, forwardRef, UseRef as HandleRegistryUseRef, UseImperativeHandle as HandleRegistryUseImperativeHandle, } from './runtime/HandleRegistry';
|
|
20
|
+
export { CommandBus } from './runtime/CommandBus';
|
|
21
|
+
export { QueryBus } from './runtime/QueryBus';
|
|
22
|
+
export { EventBus } from './runtime/EventBus';
|
|
23
|
+
export type { RuntimeCommand, RuntimeQuery, RuntimeEvent, RuntimeDispose, CommandHandler, QueryHandler, EventHandler, RuntimeCommandHandlerContract, RuntimeQueryHandlerContract, } from './runtime/types';
|
|
24
|
+
export { UseCommandBus, UseQueryBus, UseEventBus, OnCommand, OnQuery, OnEvent, createRuntimeBuses, wireRuntimeBuses, wireRuntimeBusesIfDecorated, instanceUsesRuntimeBusDecorators, wireRuntimeBusesAll, } from './runtime/BusDecorators';
|
|
25
|
+
export type { RuntimeBusesBundle } from './runtime/BusDecorators';
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAG1B,OAAO,EACL,cAAc,EACd,UAAU,EACV,MAAM,IAAI,oBAAoB,EAC9B,mBAAmB,IAAI,iCAAiC,GACzD,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,YAAY,EACV,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,WAAW,EACX,WAAW,EACX,SAAS,EACT,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,gBAAgB,EAChB,2BAA2B,EAC3B,gCAAgC,EAChC,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Effectable entry point: bootstrap, store, component, connect, runtime.
|
|
4
|
+
* Re-exports bootstrap, store, component, connect, and runtime for a single entry
|
|
5
|
+
* (Effectable or selective imports).
|
|
6
|
+
*
|
|
7
|
+
* Note on name conflicts:
|
|
8
|
+
* - UseRef and UseImperativeHandle from runtime/HandleRegistry are for registering
|
|
9
|
+
* imperative handles in HandleRegistry (legacy mechanism).
|
|
10
|
+
* - UseRef and UseImperativeHandle from component/refs are for GraphRuntime
|
|
11
|
+
* (fiber-based declarative tree, mounted lifecycle).
|
|
12
|
+
* To resolve the conflict, the runtime versions are exported with the Handle* alias.
|
|
13
|
+
*
|
|
14
|
+
* @module Effectable
|
|
15
|
+
*/
|
|
16
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
19
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
20
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
|
+
}
|
|
22
|
+
Object.defineProperty(o, k2, desc);
|
|
23
|
+
}) : (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
o[k2] = m[k];
|
|
26
|
+
}));
|
|
27
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
28
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.wireRuntimeBusesAll = exports.instanceUsesRuntimeBusDecorators = exports.wireRuntimeBusesIfDecorated = exports.wireRuntimeBuses = exports.createRuntimeBuses = exports.OnEvent = exports.OnQuery = exports.OnCommand = exports.UseEventBus = exports.UseQueryBus = exports.UseCommandBus = exports.EventBus = exports.QueryBus = exports.CommandBus = exports.HandleRegistryUseImperativeHandle = exports.HandleRegistryUseRef = exports.forwardRef = exports.HandleRegistry = void 0;
|
|
32
|
+
__exportStar(require("./bootstrap"), exports);
|
|
33
|
+
__exportStar(require("./store"), exports);
|
|
34
|
+
__exportStar(require("./component"), exports);
|
|
35
|
+
__exportStar(require("./connect"), exports);
|
|
36
|
+
// runtime: export with aliases for UseRef/UseImperativeHandle to avoid conflict with component/refs
|
|
37
|
+
var HandleRegistry_1 = require("./runtime/HandleRegistry");
|
|
38
|
+
Object.defineProperty(exports, "HandleRegistry", { enumerable: true, get: function () { return HandleRegistry_1.HandleRegistry; } });
|
|
39
|
+
Object.defineProperty(exports, "forwardRef", { enumerable: true, get: function () { return HandleRegistry_1.forwardRef; } });
|
|
40
|
+
Object.defineProperty(exports, "HandleRegistryUseRef", { enumerable: true, get: function () { return HandleRegistry_1.UseRef; } });
|
|
41
|
+
Object.defineProperty(exports, "HandleRegistryUseImperativeHandle", { enumerable: true, get: function () { return HandleRegistry_1.UseImperativeHandle; } });
|
|
42
|
+
var CommandBus_1 = require("./runtime/CommandBus");
|
|
43
|
+
Object.defineProperty(exports, "CommandBus", { enumerable: true, get: function () { return CommandBus_1.CommandBus; } });
|
|
44
|
+
var QueryBus_1 = require("./runtime/QueryBus");
|
|
45
|
+
Object.defineProperty(exports, "QueryBus", { enumerable: true, get: function () { return QueryBus_1.QueryBus; } });
|
|
46
|
+
var EventBus_1 = require("./runtime/EventBus");
|
|
47
|
+
Object.defineProperty(exports, "EventBus", { enumerable: true, get: function () { return EventBus_1.EventBus; } });
|
|
48
|
+
var BusDecorators_1 = require("./runtime/BusDecorators");
|
|
49
|
+
Object.defineProperty(exports, "UseCommandBus", { enumerable: true, get: function () { return BusDecorators_1.UseCommandBus; } });
|
|
50
|
+
Object.defineProperty(exports, "UseQueryBus", { enumerable: true, get: function () { return BusDecorators_1.UseQueryBus; } });
|
|
51
|
+
Object.defineProperty(exports, "UseEventBus", { enumerable: true, get: function () { return BusDecorators_1.UseEventBus; } });
|
|
52
|
+
Object.defineProperty(exports, "OnCommand", { enumerable: true, get: function () { return BusDecorators_1.OnCommand; } });
|
|
53
|
+
Object.defineProperty(exports, "OnQuery", { enumerable: true, get: function () { return BusDecorators_1.OnQuery; } });
|
|
54
|
+
Object.defineProperty(exports, "OnEvent", { enumerable: true, get: function () { return BusDecorators_1.OnEvent; } });
|
|
55
|
+
Object.defineProperty(exports, "createRuntimeBuses", { enumerable: true, get: function () { return BusDecorators_1.createRuntimeBuses; } });
|
|
56
|
+
Object.defineProperty(exports, "wireRuntimeBuses", { enumerable: true, get: function () { return BusDecorators_1.wireRuntimeBuses; } });
|
|
57
|
+
Object.defineProperty(exports, "wireRuntimeBusesIfDecorated", { enumerable: true, get: function () { return BusDecorators_1.wireRuntimeBusesIfDecorated; } });
|
|
58
|
+
Object.defineProperty(exports, "instanceUsesRuntimeBusDecorators", { enumerable: true, get: function () { return BusDecorators_1.instanceUsesRuntimeBusDecorators; } });
|
|
59
|
+
Object.defineProperty(exports, "wireRuntimeBusesAll", { enumerable: true, get: function () { return BusDecorators_1.wireRuntimeBusesAll; } });
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;;;;;;AAEH,8CAA4B;AAC5B,0CAAwB;AACxB,8CAA4B;AAC5B,4CAA0B;AAE1B,oGAAoG;AACpG,2DAKkC;AAJhC,gHAAA,cAAc,OAAA;AACd,4GAAA,UAAU,OAAA;AACV,sHAAA,MAAM,OAAwB;AAC9B,mIAAA,mBAAmB,OAAqC;AAE1D,mDAAkD;AAAzC,wGAAA,UAAU,OAAA;AACnB,+CAA8C;AAArC,oGAAA,QAAQ,OAAA;AACjB,+CAA8C;AAArC,oGAAA,QAAQ,OAAA;AAYjB,yDAYiC;AAX/B,8GAAA,aAAa,OAAA;AACb,4GAAA,WAAW,OAAA;AACX,4GAAA,WAAW,OAAA;AACX,0GAAA,SAAS,OAAA;AACT,wGAAA,OAAO,OAAA;AACP,wGAAA,OAAO,OAAA;AACP,mHAAA,kBAAkB,OAAA;AAClB,iHAAA,gBAAgB,OAAA;AAChB,4HAAA,2BAA2B,OAAA;AAC3B,iIAAA,gCAAgC,OAAA;AAChC,oHAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decorators and wiring for CommandBus / QueryBus / EventBus.
|
|
3
|
+
*
|
|
4
|
+
* Property: `@UseCommandBus()`, `@UseQueryBus()`, `@UseEventBus()` — inject a bus instance into a field.
|
|
5
|
+
* Method: `@OnCommand(type)`, `@OnQuery(type)`, `@OnEvent(type)` — register a method as a handler.
|
|
6
|
+
*
|
|
7
|
+
* After creating an instance, call `wireRuntimeBuses(instance, buses)`; it returns a disposer.
|
|
8
|
+
*
|
|
9
|
+
* @module Effectable/runtime/BusDecorators
|
|
10
|
+
*/
|
|
11
|
+
import 'reflect-metadata';
|
|
12
|
+
import { CommandBus } from './CommandBus';
|
|
13
|
+
import { EventBus } from './EventBus';
|
|
14
|
+
import { QueryBus } from './QueryBus';
|
|
15
|
+
import type { RuntimeCommand, RuntimeEvent, RuntimeQuery } from './types';
|
|
16
|
+
/**
|
|
17
|
+
* Marks a field for CommandBus instance injection in `wireRuntimeBuses`.
|
|
18
|
+
*
|
|
19
|
+
* @returns {PropertyDecorator} property decorator
|
|
20
|
+
*/
|
|
21
|
+
export declare function UseCommandBus(): PropertyDecorator;
|
|
22
|
+
/**
|
|
23
|
+
* Marks a field for QueryBus instance injection in `wireRuntimeBuses`.
|
|
24
|
+
*
|
|
25
|
+
* @returns {PropertyDecorator} property decorator
|
|
26
|
+
*/
|
|
27
|
+
export declare function UseQueryBus(): PropertyDecorator;
|
|
28
|
+
/**
|
|
29
|
+
* Marks a field for EventBus instance injection in `wireRuntimeBuses`.
|
|
30
|
+
*
|
|
31
|
+
* @returns {PropertyDecorator} property decorator
|
|
32
|
+
*/
|
|
33
|
+
export declare function UseEventBus(): PropertyDecorator;
|
|
34
|
+
/**
|
|
35
|
+
* Registers a method as the sole command handler for the given type (via CommandBus.register).
|
|
36
|
+
*
|
|
37
|
+
* @param {string} commandType - string command type
|
|
38
|
+
* @returns {MethodDecorator} method decorator
|
|
39
|
+
*/
|
|
40
|
+
export declare function OnCommand(commandType: string): MethodDecorator;
|
|
41
|
+
/**
|
|
42
|
+
* Registers a method as the sole query handler for the given type (via QueryBus.register).
|
|
43
|
+
*
|
|
44
|
+
* @param {string} queryType - string query type
|
|
45
|
+
* @returns {MethodDecorator} method decorator
|
|
46
|
+
*/
|
|
47
|
+
export declare function OnQuery(queryType: string): MethodDecorator;
|
|
48
|
+
/**
|
|
49
|
+
* Subscribes a method to events of the given type (via EventBus.subscribe).
|
|
50
|
+
*
|
|
51
|
+
* @param {string} eventType - string event type
|
|
52
|
+
* @returns {MethodDecorator} method decorator
|
|
53
|
+
*/
|
|
54
|
+
export declare function OnEvent(eventType: string): MethodDecorator;
|
|
55
|
+
/**
|
|
56
|
+
* Bundle of three buses of one compatible type family.
|
|
57
|
+
*/
|
|
58
|
+
export interface RuntimeBusesBundle<TCommand extends RuntimeCommand = RuntimeCommand, TQuery extends RuntimeQuery = RuntimeQuery, TEvent extends RuntimeEvent = RuntimeEvent> {
|
|
59
|
+
commandBus: CommandBus<TCommand>;
|
|
60
|
+
queryBus: QueryBus<TQuery>;
|
|
61
|
+
eventBus: EventBus<TEvent>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Creates a new bus bundle (without hidden auto-binding to global state).
|
|
65
|
+
*
|
|
66
|
+
* @template TCommand
|
|
67
|
+
* @template TQuery
|
|
68
|
+
* @template TEvent
|
|
69
|
+
* @returns {RuntimeBusesBundle<TCommand, TQuery, TEvent>} three new bus instances
|
|
70
|
+
*/
|
|
71
|
+
export declare function createRuntimeBuses<TCommand extends RuntimeCommand = RuntimeCommand, TQuery extends RuntimeQuery = RuntimeQuery, TEvent extends RuntimeEvent = RuntimeEvent>(): RuntimeBusesBundle<TCommand, TQuery, TEvent>;
|
|
72
|
+
/**
|
|
73
|
+
* Returns true if the instance (or its base classes) has metadata for {@link wireRuntimeBuses}.
|
|
74
|
+
*
|
|
75
|
+
* @param {object} instance - component instance
|
|
76
|
+
* @returns {boolean}
|
|
77
|
+
*/
|
|
78
|
+
export declare function instanceUsesRuntimeBusDecorators(instance: object): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Calls {@link wireRuntimeBuses} only if the constructor chain has relevant decorators.
|
|
81
|
+
*
|
|
82
|
+
* @template TCommand
|
|
83
|
+
* @template TQuery
|
|
84
|
+
* @template TEvent
|
|
85
|
+
* @param {object} instance - instance
|
|
86
|
+
* @param {RuntimeBusesBundle<TCommand, TQuery, TEvent>} buses - buses
|
|
87
|
+
* @returns {(() => void) | null} disposer or null if wiring is not needed
|
|
88
|
+
*/
|
|
89
|
+
export declare function wireRuntimeBusesIfDecorated<TCommand extends RuntimeCommand, TQuery extends RuntimeQuery, TEvent extends RuntimeEvent>(instance: object, buses: RuntimeBusesBundle<TCommand, TQuery, TEvent>): (() => void) | null;
|
|
90
|
+
/**
|
|
91
|
+
* Injects buses into `@Use*Bus` fields and registers `@OnCommand` / `@OnQuery` / `@OnEvent` handlers.
|
|
92
|
+
*
|
|
93
|
+
* @template TCommand
|
|
94
|
+
* @template TQuery
|
|
95
|
+
* @template TEvent
|
|
96
|
+
* @param {object} instance - class instance with decorator metadata
|
|
97
|
+
* @param {RuntimeBusesBundle<TCommand, TQuery, TEvent>} buses - bus bundle
|
|
98
|
+
* @returns {() => void} disposer: removes registrations and subscriptions created by this call
|
|
99
|
+
*/
|
|
100
|
+
export declare function wireRuntimeBuses<TCommand extends RuntimeCommand, TQuery extends RuntimeQuery, TEvent extends RuntimeEvent>(instance: object, buses: RuntimeBusesBundle<TCommand, TQuery, TEvent>): () => void;
|
|
101
|
+
/**
|
|
102
|
+
* Wires multiple instances to one bus bundle: calls {@link wireRuntimeBuses} for each.
|
|
103
|
+
* Order in `instances` defines wiring order; the disposer unregisters in reverse order.
|
|
104
|
+
*
|
|
105
|
+
* @template TCommand
|
|
106
|
+
* @template TQuery
|
|
107
|
+
* @template TEvent
|
|
108
|
+
* @param buses - shared {@link RuntimeBusesBundle} (including the three fields from `BootstrapHandle.runtime`)
|
|
109
|
+
* @param instances - instances with `@Use*Bus` / `@OnCommand` / `@OnQuery` / `@OnEvent` decorators
|
|
110
|
+
* @returns {() => void} single disposer for all wiring calls
|
|
111
|
+
*/
|
|
112
|
+
export declare function wireRuntimeBusesAll<TCommand extends RuntimeCommand, TQuery extends RuntimeQuery, TEvent extends RuntimeEvent>(buses: RuntimeBusesBundle<TCommand, TQuery, TEvent>, instances: readonly object[]): () => void;
|
|
113
|
+
//# sourceMappingURL=BusDecorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BusDecorators.d.ts","sourceRoot":"","sources":["../../src/runtime/BusDecorators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,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Ac,EAC/B,MAAM,SAAS,YAAY,EAC3B,MAAM,SAAS,YAAY,EAE3B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,GAClD,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAMrB;AAeD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,SAAS,cAAc,EAC/B,MAAM,SAAS,YAAY,EAC3B,MAAM,SAAS,YAAY,EAE3B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,GAClD,MAAM,IAAI,CAsEZ;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,SAAS,cAAc,EAC/B,MAAM,SAAS,YAAY,EAC3B,MAAM,SAAS,YAAY,EAE3B,KAAK,EAAE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EACnD,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,MAAM,IAAI,CAWZ"}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Decorators and wiring for CommandBus / QueryBus / EventBus.
|
|
4
|
+
*
|
|
5
|
+
* Property: `@UseCommandBus()`, `@UseQueryBus()`, `@UseEventBus()` — inject a bus instance into a field.
|
|
6
|
+
* Method: `@OnCommand(type)`, `@OnQuery(type)`, `@OnEvent(type)` — register a method as a handler.
|
|
7
|
+
*
|
|
8
|
+
* After creating an instance, call `wireRuntimeBuses(instance, buses)`; it returns a disposer.
|
|
9
|
+
*
|
|
10
|
+
* @module Effectable/runtime/BusDecorators
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.UseCommandBus = UseCommandBus;
|
|
14
|
+
exports.UseQueryBus = UseQueryBus;
|
|
15
|
+
exports.UseEventBus = UseEventBus;
|
|
16
|
+
exports.OnCommand = OnCommand;
|
|
17
|
+
exports.OnQuery = OnQuery;
|
|
18
|
+
exports.OnEvent = OnEvent;
|
|
19
|
+
exports.createRuntimeBuses = createRuntimeBuses;
|
|
20
|
+
exports.instanceUsesRuntimeBusDecorators = instanceUsesRuntimeBusDecorators;
|
|
21
|
+
exports.wireRuntimeBusesIfDecorated = wireRuntimeBusesIfDecorated;
|
|
22
|
+
exports.wireRuntimeBuses = wireRuntimeBuses;
|
|
23
|
+
exports.wireRuntimeBusesAll = wireRuntimeBusesAll;
|
|
24
|
+
require("reflect-metadata");
|
|
25
|
+
const CommandBus_1 = require("./CommandBus");
|
|
26
|
+
const EventBus_1 = require("./EventBus");
|
|
27
|
+
const QueryBus_1 = require("./QueryBus");
|
|
28
|
+
const USE_COMMAND_BUS_PROPS = 'effectable:runtime:UseCommandBus:props';
|
|
29
|
+
const USE_QUERY_BUS_PROPS = 'effectable:runtime:UseQueryBus:props';
|
|
30
|
+
const USE_EVENT_BUS_PROPS = 'effectable:runtime:UseEventBus:props';
|
|
31
|
+
const ON_COMMAND_ENTRIES = 'effectable:runtime:OnCommand:entries';
|
|
32
|
+
const ON_QUERY_ENTRIES = 'effectable:runtime:OnQuery:entries';
|
|
33
|
+
const ON_EVENT_ENTRIES = 'effectable:runtime:OnEvent:entries';
|
|
34
|
+
function appendPropKey(ctor, metaKey, propertyKey) {
|
|
35
|
+
const key = String(propertyKey);
|
|
36
|
+
const current = Reflect.getMetadata(metaKey, ctor);
|
|
37
|
+
const next = typeof current === 'undefined' ? [key] : [...current, key];
|
|
38
|
+
Reflect.defineMetadata(metaKey, next, ctor);
|
|
39
|
+
}
|
|
40
|
+
function appendHandlerEntry(ctor, metaKey, entry) {
|
|
41
|
+
const current = Reflect.getMetadata(metaKey, ctor);
|
|
42
|
+
const next = typeof current === 'undefined' ? [entry] : [...current, entry];
|
|
43
|
+
Reflect.defineMetadata(metaKey, next, ctor);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Marks a field for CommandBus instance injection in `wireRuntimeBuses`.
|
|
47
|
+
*
|
|
48
|
+
* @returns {PropertyDecorator} property decorator
|
|
49
|
+
*/
|
|
50
|
+
function UseCommandBus() {
|
|
51
|
+
return (target, propertyKey) => {
|
|
52
|
+
appendPropKey(target.constructor, USE_COMMAND_BUS_PROPS, propertyKey);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Marks a field for QueryBus instance injection in `wireRuntimeBuses`.
|
|
57
|
+
*
|
|
58
|
+
* @returns {PropertyDecorator} property decorator
|
|
59
|
+
*/
|
|
60
|
+
function UseQueryBus() {
|
|
61
|
+
return (target, propertyKey) => {
|
|
62
|
+
appendPropKey(target.constructor, USE_QUERY_BUS_PROPS, propertyKey);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Marks a field for EventBus instance injection in `wireRuntimeBuses`.
|
|
67
|
+
*
|
|
68
|
+
* @returns {PropertyDecorator} property decorator
|
|
69
|
+
*/
|
|
70
|
+
function UseEventBus() {
|
|
71
|
+
return (target, propertyKey) => {
|
|
72
|
+
appendPropKey(target.constructor, USE_EVENT_BUS_PROPS, propertyKey);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Registers a method as the sole command handler for the given type (via CommandBus.register).
|
|
77
|
+
*
|
|
78
|
+
* @param {string} commandType - string command type
|
|
79
|
+
* @returns {MethodDecorator} method decorator
|
|
80
|
+
*/
|
|
81
|
+
function OnCommand(commandType) {
|
|
82
|
+
return (target, propertyKey) => {
|
|
83
|
+
appendHandlerEntry(target.constructor, ON_COMMAND_ENTRIES, {
|
|
84
|
+
type: commandType,
|
|
85
|
+
method: String(propertyKey),
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Registers a method as the sole query handler for the given type (via QueryBus.register).
|
|
91
|
+
*
|
|
92
|
+
* @param {string} queryType - string query type
|
|
93
|
+
* @returns {MethodDecorator} method decorator
|
|
94
|
+
*/
|
|
95
|
+
function OnQuery(queryType) {
|
|
96
|
+
return (target, propertyKey) => {
|
|
97
|
+
appendHandlerEntry(target.constructor, ON_QUERY_ENTRIES, {
|
|
98
|
+
type: queryType,
|
|
99
|
+
method: String(propertyKey),
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Subscribes a method to events of the given type (via EventBus.subscribe).
|
|
105
|
+
*
|
|
106
|
+
* @param {string} eventType - string event type
|
|
107
|
+
* @returns {MethodDecorator} method decorator
|
|
108
|
+
*/
|
|
109
|
+
function OnEvent(eventType) {
|
|
110
|
+
return (target, propertyKey) => {
|
|
111
|
+
appendHandlerEntry(target.constructor, ON_EVENT_ENTRIES, {
|
|
112
|
+
type: eventType,
|
|
113
|
+
method: String(propertyKey),
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Creates a new bus bundle (without hidden auto-binding to global state).
|
|
119
|
+
*
|
|
120
|
+
* @template TCommand
|
|
121
|
+
* @template TQuery
|
|
122
|
+
* @template TEvent
|
|
123
|
+
* @returns {RuntimeBusesBundle<TCommand, TQuery, TEvent>} three new bus instances
|
|
124
|
+
*/
|
|
125
|
+
function createRuntimeBuses() {
|
|
126
|
+
return {
|
|
127
|
+
commandBus: new CommandBus_1.CommandBus(),
|
|
128
|
+
queryBus: new QueryBus_1.QueryBus(),
|
|
129
|
+
eventBus: new EventBus_1.EventBus(),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function getStringPropKeys(ctor, metaKey) {
|
|
133
|
+
const own = Reflect.getMetadata(metaKey, ctor);
|
|
134
|
+
return typeof own === 'undefined' ? [] : [...own];
|
|
135
|
+
}
|
|
136
|
+
function getHandlerEntries(ctor, metaKey) {
|
|
137
|
+
const own = Reflect.getMetadata(metaKey, ctor);
|
|
138
|
+
return typeof own === 'undefined' ? [] : [...own];
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Constructor chain from leaf (instance.constructor) to base (prototype chain of functions).
|
|
142
|
+
* Needed for `connect` HOC: decorator metadata often lives on the base class while the instance is a subclass.
|
|
143
|
+
*
|
|
144
|
+
* @param {Function} leafCtor - instance constructor (subclass)
|
|
145
|
+
* @returns {Function[]} leaf-first: [Child, Parent, ...]
|
|
146
|
+
*/
|
|
147
|
+
function getConstructorChainLeafFirst(leafCtor) {
|
|
148
|
+
const chain = [];
|
|
149
|
+
const seen = new Set();
|
|
150
|
+
let current = leafCtor;
|
|
151
|
+
while (current != null && typeof current === 'function' && !seen.has(current)) {
|
|
152
|
+
seen.add(current);
|
|
153
|
+
chain.push(current);
|
|
154
|
+
const next = Object.getPrototypeOf(current);
|
|
155
|
+
if (typeof next !== 'function' || next === null) {
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
current = next;
|
|
159
|
+
}
|
|
160
|
+
return chain;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Returns true if the instance (or its base classes) has metadata for {@link wireRuntimeBuses}.
|
|
164
|
+
*
|
|
165
|
+
* @param {object} instance - component instance
|
|
166
|
+
* @returns {boolean}
|
|
167
|
+
*/
|
|
168
|
+
function instanceUsesRuntimeBusDecorators(instance) {
|
|
169
|
+
const leafCtor = instance.constructor;
|
|
170
|
+
const chain = getConstructorChainLeafFirst(leafCtor);
|
|
171
|
+
for (const ctor of chain) {
|
|
172
|
+
if (getStringPropKeys(ctor, USE_COMMAND_BUS_PROPS).length > 0 ||
|
|
173
|
+
getStringPropKeys(ctor, USE_QUERY_BUS_PROPS).length > 0 ||
|
|
174
|
+
getStringPropKeys(ctor, USE_EVENT_BUS_PROPS).length > 0 ||
|
|
175
|
+
getHandlerEntries(ctor, ON_COMMAND_ENTRIES).length > 0 ||
|
|
176
|
+
getHandlerEntries(ctor, ON_QUERY_ENTRIES).length > 0 ||
|
|
177
|
+
getHandlerEntries(ctor, ON_EVENT_ENTRIES).length > 0) {
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Calls {@link wireRuntimeBuses} only if the constructor chain has relevant decorators.
|
|
185
|
+
*
|
|
186
|
+
* @template TCommand
|
|
187
|
+
* @template TQuery
|
|
188
|
+
* @template TEvent
|
|
189
|
+
* @param {object} instance - instance
|
|
190
|
+
* @param {RuntimeBusesBundle<TCommand, TQuery, TEvent>} buses - buses
|
|
191
|
+
* @returns {(() => void) | null} disposer or null if wiring is not needed
|
|
192
|
+
*/
|
|
193
|
+
function wireRuntimeBusesIfDecorated(instance, buses) {
|
|
194
|
+
if (!instanceUsesRuntimeBusDecorators(instance)) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
return wireRuntimeBuses(instance, buses);
|
|
198
|
+
}
|
|
199
|
+
function assignBusProps(instance, ctor, metaKey, value) {
|
|
200
|
+
const keys = getStringPropKeys(ctor, metaKey);
|
|
201
|
+
const record = instance;
|
|
202
|
+
for (const key of keys) {
|
|
203
|
+
record[key] = value;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Injects buses into `@Use*Bus` fields and registers `@OnCommand` / `@OnQuery` / `@OnEvent` handlers.
|
|
208
|
+
*
|
|
209
|
+
* @template TCommand
|
|
210
|
+
* @template TQuery
|
|
211
|
+
* @template TEvent
|
|
212
|
+
* @param {object} instance - class instance with decorator metadata
|
|
213
|
+
* @param {RuntimeBusesBundle<TCommand, TQuery, TEvent>} buses - bus bundle
|
|
214
|
+
* @returns {() => void} disposer: removes registrations and subscriptions created by this call
|
|
215
|
+
*/
|
|
216
|
+
function wireRuntimeBuses(instance, buses) {
|
|
217
|
+
const leafCtor = instance.constructor;
|
|
218
|
+
const ctorChain = getConstructorChainLeafFirst(leafCtor);
|
|
219
|
+
const disposers = [];
|
|
220
|
+
// Base → leaf: last assign wins when field names collide.
|
|
221
|
+
for (let i = ctorChain.length - 1; i >= 0; i -= 1) {
|
|
222
|
+
const ctor = ctorChain[i];
|
|
223
|
+
assignBusProps(instance, ctor, USE_COMMAND_BUS_PROPS, buses.commandBus);
|
|
224
|
+
assignBusProps(instance, ctor, USE_QUERY_BUS_PROPS, buses.queryBus);
|
|
225
|
+
assignBusProps(instance, ctor, USE_EVENT_BUS_PROPS, buses.eventBus);
|
|
226
|
+
}
|
|
227
|
+
const mergedCommand = new Map();
|
|
228
|
+
const mergedQuery = new Map();
|
|
229
|
+
const mergedEvent = new Map();
|
|
230
|
+
for (let i = ctorChain.length - 1; i >= 0; i -= 1) {
|
|
231
|
+
const ctor = ctorChain[i];
|
|
232
|
+
for (const { type, method } of getHandlerEntries(ctor, ON_COMMAND_ENTRIES)) {
|
|
233
|
+
mergedCommand.set(type, method);
|
|
234
|
+
}
|
|
235
|
+
for (const { type, method } of getHandlerEntries(ctor, ON_QUERY_ENTRIES)) {
|
|
236
|
+
mergedQuery.set(type, method);
|
|
237
|
+
}
|
|
238
|
+
for (const { type, method } of getHandlerEntries(ctor, ON_EVENT_ENTRIES)) {
|
|
239
|
+
mergedEvent.set(type, method);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const record = instance;
|
|
243
|
+
for (const [type, method] of mergedCommand) {
|
|
244
|
+
const raw = record[method];
|
|
245
|
+
if (typeof raw !== 'function') {
|
|
246
|
+
throw new Error(`wireRuntimeBuses: OnCommand handler is not a function: ${method}`);
|
|
247
|
+
}
|
|
248
|
+
const handler = (command) => {
|
|
249
|
+
return raw.call(instance, command);
|
|
250
|
+
};
|
|
251
|
+
disposers.push(buses.commandBus.register(type, handler));
|
|
252
|
+
}
|
|
253
|
+
for (const [type, method] of mergedQuery) {
|
|
254
|
+
const raw = record[method];
|
|
255
|
+
if (typeof raw !== 'function') {
|
|
256
|
+
throw new Error(`wireRuntimeBuses: OnQuery handler is not a function: ${method}`);
|
|
257
|
+
}
|
|
258
|
+
const handler = (query) => {
|
|
259
|
+
return raw.call(instance, query);
|
|
260
|
+
};
|
|
261
|
+
disposers.push(buses.queryBus.register(type, handler));
|
|
262
|
+
}
|
|
263
|
+
for (const [type, method] of mergedEvent) {
|
|
264
|
+
const raw = record[method];
|
|
265
|
+
if (typeof raw !== 'function') {
|
|
266
|
+
throw new Error(`wireRuntimeBuses: OnEvent handler is not a function: ${method}`);
|
|
267
|
+
}
|
|
268
|
+
const handler = (event) => {
|
|
269
|
+
raw.call(instance, event);
|
|
270
|
+
};
|
|
271
|
+
disposers.push(buses.eventBus.subscribe(type, handler));
|
|
272
|
+
}
|
|
273
|
+
return () => {
|
|
274
|
+
for (const dispose of disposers.reverse()) {
|
|
275
|
+
dispose();
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Wires multiple instances to one bus bundle: calls {@link wireRuntimeBuses} for each.
|
|
281
|
+
* Order in `instances` defines wiring order; the disposer unregisters in reverse order.
|
|
282
|
+
*
|
|
283
|
+
* @template TCommand
|
|
284
|
+
* @template TQuery
|
|
285
|
+
* @template TEvent
|
|
286
|
+
* @param buses - shared {@link RuntimeBusesBundle} (including the three fields from `BootstrapHandle.runtime`)
|
|
287
|
+
* @param instances - instances with `@Use*Bus` / `@OnCommand` / `@OnQuery` / `@OnEvent` decorators
|
|
288
|
+
* @returns {() => void} single disposer for all wiring calls
|
|
289
|
+
*/
|
|
290
|
+
function wireRuntimeBusesAll(buses, instances) {
|
|
291
|
+
const disposers = [];
|
|
292
|
+
for (let i = 0; i < instances.length; i += 1) {
|
|
293
|
+
const instance = instances[i];
|
|
294
|
+
disposers.push(wireRuntimeBuses(instance, buses));
|
|
295
|
+
}
|
|
296
|
+
return () => {
|
|
297
|
+
for (let j = disposers.length - 1; j >= 0; j -= 1) {
|
|
298
|
+
disposers[j]();
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
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,mBAAmB,CAKjC,KAAmD,EACnD,SAA4B;IAE5B,MAAM,SAAS,GAAsB,EAAE,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7C,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAC9B,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,GAAG,EAAE;QACV,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAClD,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QACjB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight command bus implementation.
|
|
3
|
+
*
|
|
4
|
+
* @module Effectable/runtime/CommandBus
|
|
5
|
+
*/
|
|
6
|
+
import type { CommandHandler, RuntimeCommand } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Command bus with a single handler per command type.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CommandBus<TCommand extends RuntimeCommand = RuntimeCommand> {
|
|
11
|
+
private readonly handlers;
|
|
12
|
+
/**
|
|
13
|
+
* Registers a command handler.
|
|
14
|
+
*
|
|
15
|
+
* @param {TCommand['type']} commandType - command type
|
|
16
|
+
* @param {CommandHandler<TCommand, TResult>} handler - command handler
|
|
17
|
+
* @returns {() => void} unregister function
|
|
18
|
+
* @throws {Error} if a handler is already registered
|
|
19
|
+
*/
|
|
20
|
+
register<TResult>(commandType: TCommand['type'], handler: CommandHandler<TCommand, TResult>): () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Executes a command through the registered handler.
|
|
23
|
+
*
|
|
24
|
+
* @param {TCommand} command - command
|
|
25
|
+
* @returns {Promise<TResult>} command handling result
|
|
26
|
+
* @throws {Error} if no handler is found
|
|
27
|
+
*/
|
|
28
|
+
execute<TResult>(command: TCommand): Promise<TResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Unregisters a command handler.
|
|
31
|
+
*
|
|
32
|
+
* @param {TCommand['type']} commandType - command type
|
|
33
|
+
* @returns {void}
|
|
34
|
+
*/
|
|
35
|
+
unregister(commandType: TCommand['type']): void;
|
|
36
|
+
/**
|
|
37
|
+
* Clears all registered handlers.
|
|
38
|
+
*
|
|
39
|
+
* @returns {void}
|
|
40
|
+
*/
|
|
41
|
+
clear(): void;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=CommandBus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandBus.d.ts","sourceRoot":"","sources":["../../src/runtime/CommandBus.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9D;;GAEG;AACH,qBAAa,UAAU,CAAC,QAAQ,SAAS,cAAc,GAAG,cAAc;IACtE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwD;IAEjF;;;;;;;OAOG;IACI,QAAQ,CAAC,OAAO,EACrB,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,EAC7B,OAAO,EAAE,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,GACzC,MAAM,IAAI;IAWb;;;;;;OAMG;IACU,OAAO,CAAC,OAAO,EAAG,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAUnE;;;;;OAKG;IACI,UAAU,CAAE,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI;IAIvD;;;;OAIG;IACI,KAAK,IAAK,IAAI;CAGtB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Lightweight command bus implementation.
|
|
4
|
+
*
|
|
5
|
+
* @module Effectable/runtime/CommandBus
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.CommandBus = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Command bus with a single handler per command type.
|
|
11
|
+
*/
|
|
12
|
+
class CommandBus {
|
|
13
|
+
handlers = new Map();
|
|
14
|
+
/**
|
|
15
|
+
* Registers a command handler.
|
|
16
|
+
*
|
|
17
|
+
* @param {TCommand['type']} commandType - command type
|
|
18
|
+
* @param {CommandHandler<TCommand, TResult>} handler - command handler
|
|
19
|
+
* @returns {() => void} unregister function
|
|
20
|
+
* @throws {Error} if a handler is already registered
|
|
21
|
+
*/
|
|
22
|
+
register(commandType, handler) {
|
|
23
|
+
if (this.handlers.has(commandType)) {
|
|
24
|
+
throw new Error(`Command handler is already registered: ${commandType}`);
|
|
25
|
+
}
|
|
26
|
+
this.handlers.set(commandType, handler);
|
|
27
|
+
return () => {
|
|
28
|
+
this.unregister(commandType);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Executes a command through the registered handler.
|
|
33
|
+
*
|
|
34
|
+
* @param {TCommand} command - command
|
|
35
|
+
* @returns {Promise<TResult>} command handling result
|
|
36
|
+
* @throws {Error} if no handler is found
|
|
37
|
+
*/
|
|
38
|
+
async execute(command) {
|
|
39
|
+
const handler = this.handlers.get(command.type);
|
|
40
|
+
if (typeof handler === 'undefined') {
|
|
41
|
+
throw new Error(`Command handler is not registered: ${command.type}`);
|
|
42
|
+
}
|
|
43
|
+
const result = await handler(command);
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Unregisters a command handler.
|
|
48
|
+
*
|
|
49
|
+
* @param {TCommand['type']} commandType - command type
|
|
50
|
+
* @returns {void}
|
|
51
|
+
*/
|
|
52
|
+
unregister(commandType) {
|
|
53
|
+
this.handlers.delete(commandType);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Clears all registered handlers.
|
|
57
|
+
*
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
60
|
+
clear() {
|
|
61
|
+
this.handlers.clear();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.CommandBus = CommandBus;
|
|
65
|
+
//# sourceMappingURL=CommandBus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandBus.js","sourceRoot":"","sources":["../../src/runtime/CommandBus.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH;;GAEG;AACH,MAAa,UAAU;IACJ,QAAQ,GAAG,IAAI,GAAG,EAA6C,CAAC;IAEjF;;;;;;;OAOG;IACI,QAAQ,CACb,WAA6B,EAC7B,OAA0C;QAE1C,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,0CAA0C,WAAW,EAAE,CAAC,CAAC;QAC3E,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,OAA4C,CAAC,CAAC;QAC7E,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC/B,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,OAAO,CAAW,OAAiB;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,sCAAsC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QACtC,OAAO,MAAiB,CAAC;IAC3B,CAAC;IAED;;;;;O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