@wirestate/core 0.6.3 → 0.7.0-experimental.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -1
- package/README.md +48 -37
- package/cjs/development/index.js +325 -91
- package/cjs/development/index.js.map +1 -1
- package/cjs/development/lib.js +1033 -248
- package/cjs/development/lib.js.map +1 -1
- package/cjs/development/test-utils.js +95 -32
- package/cjs/development/test-utils.js.map +1 -1
- package/cjs/production/index.js +1 -1
- package/cjs/production/index.js.map +1 -1
- package/cjs/production/lib.js +1 -1
- package/cjs/production/lib.js.map +1 -1
- package/cjs/production/test-utils.js +1 -1
- package/cjs/production/test-utils.js.map +1 -1
- package/esm/development/alias.js +10 -1
- package/esm/development/alias.js.map +1 -1
- package/esm/development/bind/bind-constant.js +25 -4
- package/esm/development/bind/bind-constant.js.map +1 -1
- package/esm/development/bind/bind-dynamic-value.js +27 -7
- package/esm/development/bind/bind-dynamic-value.js.map +1 -1
- package/esm/development/bind/bind-entry.js +50 -17
- package/esm/development/bind/bind-entry.js.map +1 -1
- package/esm/development/bind/bind-service.js +71 -19
- package/esm/development/bind/bind-service.js.map +1 -1
- package/esm/development/bind/get-entry-token.js +21 -5
- package/esm/development/bind/get-entry-token.js.map +1 -1
- package/esm/development/commands/command-bus.js +93 -46
- package/esm/development/commands/command-bus.js.map +1 -1
- package/esm/development/commands/command-optional.js +28 -5
- package/esm/development/commands/command-optional.js.map +1 -1
- package/esm/development/commands/command.js +26 -5
- package/esm/development/commands/command.js.map +1 -1
- package/esm/development/commands/get-command-handler-metadata.js +8 -3
- package/esm/development/commands/get-command-handler-metadata.js.map +1 -1
- package/esm/development/commands/on-command.js +19 -3
- package/esm/development/commands/on-command.js.map +1 -1
- package/esm/development/container/create-base-container.js +57 -0
- package/esm/development/container/create-base-container.js.map +1 -0
- package/esm/development/container/create-container.js +78 -0
- package/esm/development/container/create-container.js.map +1 -0
- package/esm/development/container/wire-scope.js +236 -54
- package/esm/development/container/wire-scope.js.map +1 -1
- package/esm/development/error/error-code.js +2 -1
- package/esm/development/error/error-code.js.map +1 -1
- package/esm/development/error/wirestate-error.js +25 -4
- package/esm/development/error/wirestate-error.js.map +1 -1
- package/esm/development/events/build-event-dispatcher.js +20 -2
- package/esm/development/events/build-event-dispatcher.js.map +1 -1
- package/esm/development/events/emit-event.js +18 -5
- package/esm/development/events/emit-event.js.map +1 -1
- package/esm/development/events/event-bus.js +58 -9
- package/esm/development/events/event-bus.js.map +1 -1
- package/esm/development/events/get-event-handler-metadata.js +19 -4
- package/esm/development/events/get-event-handler-metadata.js.map +1 -1
- package/esm/development/events/on-event.js +31 -2
- package/esm/development/events/on-event.js.map +1 -1
- package/esm/development/index.js +5 -4
- package/esm/development/index.js.map +1 -1
- package/esm/development/queries/get-query-handler-metadata.js +20 -4
- package/esm/development/queries/get-query-handler-metadata.js.map +1 -1
- package/esm/development/queries/on-query.js +24 -2
- package/esm/development/queries/on-query.js.map +1 -1
- package/esm/development/queries/query-bus.js +82 -31
- package/esm/development/queries/query-bus.js.map +1 -1
- package/esm/development/queries/query-optional.js +19 -5
- package/esm/development/queries/query-optional.js.map +1 -1
- package/esm/development/queries/query.js +25 -5
- package/esm/development/queries/query.js.map +1 -1
- package/esm/development/registry.js +81 -24
- package/esm/development/registry.js.map +1 -1
- package/esm/development/seeds/apply-seeds.js +19 -5
- package/esm/development/seeds/apply-seeds.js.map +1 -1
- package/esm/development/seeds/apply-shared-seed.js +16 -4
- package/esm/development/seeds/apply-shared-seed.js.map +1 -1
- package/esm/development/seeds/tokens.js +31 -0
- package/esm/development/seeds/tokens.js.map +1 -0
- package/esm/development/seeds/unapply-seeds.js +16 -5
- package/esm/development/seeds/unapply-seeds.js.map +1 -1
- package/esm/development/service/get-activated-handler-metadata.js +16 -4
- package/esm/development/service/get-activated-handler-metadata.js.map +1 -1
- package/esm/development/service/get-deactivation-handler-metadata.js +16 -4
- package/esm/development/service/get-deactivation-handler-metadata.js.map +1 -1
- package/esm/development/service/on-activated.js +22 -2
- package/esm/development/service/on-activated.js.map +1 -1
- package/esm/development/service/on-deactivation.js +22 -2
- package/esm/development/service/on-deactivation.js.map +1 -1
- package/esm/development/test-utils/mock-bind-entry.js +17 -7
- package/esm/development/test-utils/mock-bind-entry.js.map +1 -1
- package/esm/development/test-utils/mock-bind-service.js +17 -7
- package/esm/development/test-utils/mock-bind-service.js.map +1 -1
- package/esm/development/test-utils/mock-container.js +25 -8
- package/esm/development/test-utils/mock-container.js.map +1 -1
- package/esm/development/test-utils/mock-service.js +18 -5
- package/esm/development/test-utils/mock-service.js.map +1 -1
- package/esm/development/test-utils/mock-unbind-service.js +16 -3
- package/esm/development/test-utils/mock-unbind-service.js.map +1 -1
- package/esm/development/types/commands.js +6 -1
- package/esm/development/types/commands.js.map +1 -1
- package/esm/production/alias.js +1 -1
- package/esm/production/alias.js.map +1 -1
- package/esm/production/bind/bind-constant.js +1 -1
- package/esm/production/bind/bind-constant.js.map +1 -1
- package/esm/production/bind/bind-dynamic-value.js +1 -1
- package/esm/production/bind/bind-dynamic-value.js.map +1 -1
- package/esm/production/bind/bind-entry.js +1 -1
- package/esm/production/bind/bind-entry.js.map +1 -1
- package/esm/production/bind/bind-service.js.map +1 -1
- package/esm/production/bind/get-entry-token.js.map +1 -1
- package/esm/production/commands/command-bus.js +1 -1
- package/esm/production/commands/command-bus.js.map +1 -1
- package/esm/production/commands/command-optional.js.map +1 -1
- package/esm/production/commands/command.js.map +1 -1
- package/esm/production/commands/get-command-handler-metadata.js.map +1 -1
- package/esm/production/commands/on-command.js.map +1 -1
- package/esm/production/container/create-base-container.js +1 -0
- package/esm/production/container/create-base-container.js.map +1 -0
- package/esm/production/container/create-container.js +1 -0
- package/esm/production/container/create-container.js.map +1 -0
- package/esm/production/container/wire-scope.js +1 -1
- package/esm/production/container/wire-scope.js.map +1 -1
- package/esm/production/error/error-code.js +1 -1
- package/esm/production/error/error-code.js.map +1 -1
- package/esm/production/error/wirestate-error.js.map +1 -1
- package/esm/production/events/build-event-dispatcher.js.map +1 -1
- package/esm/production/events/emit-event.js.map +1 -1
- package/esm/production/events/event-bus.js +1 -1
- package/esm/production/events/event-bus.js.map +1 -1
- package/esm/production/events/get-event-handler-metadata.js.map +1 -1
- package/esm/production/events/on-event.js.map +1 -1
- package/esm/production/index.js +1 -1
- package/esm/production/queries/get-query-handler-metadata.js.map +1 -1
- package/esm/production/queries/on-query.js.map +1 -1
- package/esm/production/queries/query-bus.js +1 -1
- package/esm/production/queries/query-bus.js.map +1 -1
- package/esm/production/queries/query-optional.js.map +1 -1
- package/esm/production/queries/query.js.map +1 -1
- package/esm/production/registry.js +1 -1
- package/esm/production/registry.js.map +1 -1
- package/esm/production/seeds/apply-seeds.js +1 -1
- package/esm/production/seeds/apply-seeds.js.map +1 -1
- package/esm/production/seeds/apply-shared-seed.js +1 -1
- package/esm/production/seeds/apply-shared-seed.js.map +1 -1
- package/esm/production/seeds/tokens.js +1 -0
- package/esm/production/seeds/tokens.js.map +1 -0
- package/esm/production/seeds/unapply-seeds.js +1 -1
- package/esm/production/seeds/unapply-seeds.js.map +1 -1
- package/esm/production/service/get-activated-handler-metadata.js.map +1 -1
- package/esm/production/service/get-deactivation-handler-metadata.js.map +1 -1
- package/esm/production/service/on-activated.js.map +1 -1
- package/esm/production/service/on-deactivation.js.map +1 -1
- package/esm/production/test-utils/mock-bind-entry.js +1 -1
- package/esm/production/test-utils/mock-bind-entry.js.map +1 -1
- package/esm/production/test-utils/mock-bind-service.js +1 -1
- package/esm/production/test-utils/mock-bind-service.js.map +1 -1
- package/esm/production/test-utils/mock-container.js +1 -1
- package/esm/production/test-utils/mock-container.js.map +1 -1
- package/esm/production/test-utils/mock-service.js.map +1 -1
- package/esm/production/test-utils/mock-unbind-service.js.map +1 -1
- package/esm/production/types/commands.js.map +1 -1
- package/index.d.ts +1159 -229
- package/lib.d.ts +128 -9
- package/package.json +1 -2
- package/test-utils.d.ts +140 -40
- package/esm/development/container/create-ioc-container.js +0 -35
- package/esm/development/container/create-ioc-container.js.map +0 -1
- package/esm/production/container/create-ioc-container.js +0 -1
- package/esm/production/container/create-ioc-container.js.map +0 -1
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { EVENT_HANDLER_METADATA } from '../registry.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Retrieves
|
|
5
|
-
* Returns handlers ordered from base to derived class.
|
|
4
|
+
* Retrieves event handler metadata for a service instance by traversing its prototype chain.
|
|
6
5
|
*
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This utility collects metadata registered via the {@link OnEvent} decorator.
|
|
8
|
+
* It ensures that handlers are returned in parent-to-child order (base class handlers first),
|
|
9
|
+
* which is critical for maintaining predictable event execution patterns in inherited services.
|
|
10
|
+
*
|
|
11
|
+
* @group Events
|
|
9
12
|
* @internal
|
|
13
|
+
*
|
|
14
|
+
* @param instance - The service instance to scan for event handlers.
|
|
15
|
+
* @returns A read-only array of event handler metadata, ordered from base to derived class.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const metadata = getEventHandlerMetadata(myService);
|
|
20
|
+
*
|
|
21
|
+
* metadata.forEach(meta => {
|
|
22
|
+
* console.log(`Method ${String(meta.propertyKey)} handles event ${String(meta.type)}`);
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
10
25
|
*/
|
|
11
26
|
function getEventHandlerMetadata(instance) {
|
|
12
27
|
var constructor = instance.constructor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-event-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/events/get-event-handler-metadata.ts"],"sourcesContent":[null],"names":["getEventHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","EVENT_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAOA
|
|
1
|
+
{"version":3,"file":"get-event-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/events/get-event-handler-metadata.ts"],"sourcesContent":[null],"names":["getEventHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","EVENT_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAOA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAUA,uBAAuBA,CAACC,QAAgB,EAAA;AAGtD,EAAA,IAAIC,WAAW,GAAYD,QAAQ,CAACC,WAAW;EAE/C,IAAMC,KAAK,GAAuC,EAAE;AAEpD;AACA,EAAA,OAAO,OAAOD,WAAW,KAAK,UAAU,IAAIA,WAAW,KAAKE,MAAM,IAAIF,WAAW,KAAKG,QAAQ,CAACC,SAAS,EAAE;AACxG,IAAA,IAAMC,GAAG,GAAuCC,sBAAsB,CAACC,GAAG,CAACP,WAAqB,CAAC;AAEjG,IAAA,IAAIK,GAAG,IAAIA,GAAG,CAACG,MAAM,GAAG,CAAC,EAAE;AACzBP,MAAAA,KAAK,CAACQ,IAAI,CAACJ,GAAG,CAAC;AACjB,IAAA;AAEAL,IAAAA,WAAW,GAAGE,MAAM,CAACQ,cAAc,CAACV,WAAW,CAAC;AAClD,EAAA;AAQA;EACA,OAAOC,KAAK,CAACU,OAAO,EAAE,CAACC,IAAI,EAAE;AAC/B;;;;"}
|
|
@@ -4,8 +4,37 @@ import { EVENT_HANDLER_METADATA } from '../registry.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Decorator for service methods that respond to events.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Methods decorated with `@OnEvent` are automatically registered as subscribers
|
|
9
|
+
* when the service is bound via {@link bindService}.
|
|
10
|
+
*
|
|
11
|
+
* You can specify one or more event types to handle. If `types` is omitted,
|
|
12
|
+
* the method acts as a catch-all handler for all events broadcasted to the {@link EventBus}.
|
|
13
|
+
*
|
|
14
|
+
* @group Events
|
|
15
|
+
*
|
|
16
|
+
* @param types - Event identifier(s) to handle. If omitted, handles all events.
|
|
17
|
+
* @returns Method decorator.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* class MyService {
|
|
22
|
+
* @OnEvent("USER_LOGGED_IN")
|
|
23
|
+
* private onLogin(event: Event<User>): void {
|
|
24
|
+
* console.log("User logged in:", event);
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* @OnEvent(["LOGOUT", "SESSION_EXPIRED"])
|
|
28
|
+
* private onSessionEnd(event: Event): void {
|
|
29
|
+
* console.log("Specific event received:", event);
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* @OnEvent()
|
|
33
|
+
* private onAnyEvent(event: Event): void {
|
|
34
|
+
* // Catch-all handler
|
|
35
|
+
* }
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
9
38
|
*/
|
|
10
39
|
function OnEvent(types) {
|
|
11
40
|
// Normalize types to an array or null for catch-all.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-event.js","sources":["../../../../../../../../src/wirestate-core/events/on-event.ts"],"sourcesContent":[null],"names":["OnEvent","types","normalized","undefined","Array","isArray","__spreadArray","target","propertyKey","constructor","list","EVENT_HANDLER_METADATA","get","set","push","methodName"],"mappings":";;;AAOA
|
|
1
|
+
{"version":3,"file":"on-event.js","sources":["../../../../../../../../src/wirestate-core/events/on-event.ts"],"sourcesContent":[null],"names":["OnEvent","types","normalized","undefined","Array","isArray","__spreadArray","target","propertyKey","constructor","list","EVENT_HANDLER_METADATA","get","set","push","methodName"],"mappings":";;;AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCG;AACG,SAAUA,OAAOA,CAACC,KAA4C,EAAA;AAClE;EACA,IAAMC,UAAU,GACdD,KAAK,KAAKE,SAAS,GAAG,IAAI,GAAGC,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,GAAEK,aAAA,CAAA,EAAA,EAAML,KAAkC,EAAA,IAAA,CAAA,GAAI,CAACA,KAAkB,CAAC;AAErH,EAAA,OAAO,UAACM,MAAM,EAAEC,WAAW,EAAA;AASzB,IAAA,IAAMC,WAAW,GAAGF,MAAM,CAACE,WAAW;AAEtC,IAAA,IAAIC,IAAI,GAAuCC,sBAAsB,CAACC,GAAG,CAACH,WAAW,CAAC;IAEtF,IAAI,CAACC,IAAI,EAAE;AACTA,MAAAA,IAAI,GAAG,EAAE;AACTC,MAAAA,sBAAsB,CAACE,GAAG,CAACJ,WAAW,EAAEC,IAAI,CAAC;AAC/C,IAAA;AAEA;IACAA,IAAI,CAACI,IAAI,CAAC;AAAEC,MAAAA,UAAU,EAAEP,WAAW;AAAEP,MAAAA,KAAK,EAAEC;AAAU,KAAE,CAAC;EAC3D,CAAC;AACH;;;;"}
|
package/esm/development/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export { forwardRef } from './alias.js';
|
|
2
|
-
export { bindEntry } from './bind/bind-entry.js';
|
|
3
2
|
export { bindConstant } from './bind/bind-constant.js';
|
|
3
|
+
export { bindDynamicValue } from './bind/bind-dynamic-value.js';
|
|
4
|
+
export { bindEntry } from './bind/bind-entry.js';
|
|
4
5
|
export { bindService } from './bind/bind-service.js';
|
|
5
6
|
export { getEntryToken } from './bind/get-entry-token.js';
|
|
6
7
|
export { command } from './commands/command.js';
|
|
7
8
|
export { commandOptional } from './commands/command-optional.js';
|
|
8
9
|
export { OnCommand } from './commands/on-command.js';
|
|
9
10
|
export { CommandBus } from './commands/command-bus.js';
|
|
10
|
-
export {
|
|
11
|
+
export { createContainer } from './container/create-container.js';
|
|
11
12
|
export { WireScope } from './container/wire-scope.js';
|
|
12
13
|
export { WirestateError } from './error/wirestate-error.js';
|
|
13
14
|
export { emitEvent } from './events/emit-event.js';
|
|
@@ -17,12 +18,12 @@ export { query } from './queries/query.js';
|
|
|
17
18
|
export { queryOptional } from './queries/query-optional.js';
|
|
18
19
|
export { QueryBus } from './queries/query-bus.js';
|
|
19
20
|
export { OnQuery } from './queries/on-query.js';
|
|
20
|
-
export { SEED_TOKEN as SEED, SEEDS_TOKEN as SEEDS } from './
|
|
21
|
+
export { SEED_TOKEN as SEED, SEEDS_TOKEN as SEEDS } from './seeds/tokens.js';
|
|
21
22
|
export { applySeeds } from './seeds/apply-seeds.js';
|
|
22
23
|
export { applySharedSeed } from './seeds/apply-shared-seed.js';
|
|
23
24
|
export { unapplySeeds } from './seeds/unapply-seeds.js';
|
|
24
25
|
export { OnActivated } from './service/on-activated.js';
|
|
25
26
|
export { OnDeactivation } from './service/on-deactivation.js';
|
|
26
27
|
export { CommandStatus } from './types/commands.js';
|
|
27
|
-
export { bindingTypeValues as BindingType, Container, ContainerModule, inject as Inject, injectable as Injectable, LazyServiceIdentifier, multiInject as MultiInject, named as Named, optional as Optional, postConstruct as PostConstruct, preDestroy as PreDestroy, bindingScopeValues as ScopeBindingType, tagged as Tagged } from 'inversify';
|
|
28
|
+
export { bindingTypeValues as BindingType, Container, ContainerModule, inject as Inject, injectFromBase as InjectFromBase, injectFromHierarchy as InjectFromHierarchy, injectable as Injectable, LazyServiceIdentifier, multiInject as MultiInject, named as Named, optional as Optional, postConstruct as PostConstruct, preDestroy as PreDestroy, bindingScopeValues as ScopeBindingType, tagged as Tagged, unmanaged as Unmanaged, bindingScopeValues, bindingTypeValues } from 'inversify';
|
|
28
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import { QUERY_HANDLER_METADATA } from '../registry.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Retrieves
|
|
5
|
-
* Returns handlers ordered from base to derived class.
|
|
4
|
+
* Retrieves query handler metadata for a service instance by traversing its prototype chain.
|
|
6
5
|
*
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This utility collects metadata registered via the {@link OnQuery} decorator.
|
|
8
|
+
* It ensures that handlers are returned in parent-to-child order (base class handlers first).
|
|
9
|
+
* Since queries support shadowing, child class handlers registered later will effectively
|
|
10
|
+
* override parent handlers for the same query type.
|
|
11
|
+
*
|
|
12
|
+
* @group Queries
|
|
9
13
|
* @internal
|
|
14
|
+
*
|
|
15
|
+
* @param instance - The service instance to scan for query handlers.
|
|
16
|
+
* @returns A read-only array of query handler metadata, ordered from base to derived class.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const metadata = getQueryHandlerMetadata(myService);
|
|
21
|
+
*
|
|
22
|
+
* metadata.forEach(meta => {
|
|
23
|
+
* console.log(`Method ${String(meta.methodName)} handles query ${String(meta.type)}`);
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
10
26
|
*/
|
|
11
27
|
function getQueryHandlerMetadata(instance) {
|
|
12
28
|
var constructor = instance.constructor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-query-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/queries/get-query-handler-metadata.ts"],"sourcesContent":[null],"names":["getQueryHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","QUERY_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAOA
|
|
1
|
+
{"version":3,"file":"get-query-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/queries/get-query-handler-metadata.ts"],"sourcesContent":[null],"names":["getQueryHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","QUERY_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAOA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,SAAUA,uBAAuBA,CAACC,QAAgB,EAAA;AAGtD,EAAA,IAAIC,WAAW,GAAYD,QAAQ,CAACC,WAAW;EAE/C,IAAMC,KAAK,GAAuC,EAAE;AAEpD;AACA,EAAA,OAAO,OAAOD,WAAW,KAAK,UAAU,IAAIA,WAAW,KAAKE,MAAM,IAAIF,WAAW,KAAKG,QAAQ,CAACC,SAAS,EAAE;AACxG,IAAA,IAAMC,GAAG,GAAuCC,sBAAsB,CAACC,GAAG,CAACP,WAAqB,CAAC;AAEjG,IAAA,IAAIK,GAAG,IAAIA,GAAG,CAACG,MAAM,GAAG,CAAC,EAAE;AACzBP,MAAAA,KAAK,CAACQ,IAAI,CAACJ,GAAG,CAAC;AACjB,IAAA;AAEAL,IAAAA,WAAW,GAAGE,MAAM,CAACQ,cAAc,CAACV,WAAW,CAAC;AAClD,EAAA;AAQA;EACA,OAAOC,KAAK,CAACU,OAAO,EAAE,CAACC,IAAI,EAAE;AAC/B;;;;"}
|
|
@@ -3,8 +3,30 @@ import { QUERY_HANDLER_METADATA } from '../registry.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Decorator for service methods that respond to a query.
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Methods decorated with `@OnQuery` are automatically registered as query handlers
|
|
8
|
+
* when the service is bound via {@link bindService}.
|
|
9
|
+
*
|
|
10
|
+
* Unlike events, queries MUST be handled by exactly one handler. If multiple handlers
|
|
11
|
+
* are registered for the same query type, the most recent one (usually the most
|
|
12
|
+
* specific in terms of class hierarchy or registration order) will shadow the others.
|
|
13
|
+
*
|
|
14
|
+
* @group Queries
|
|
15
|
+
*
|
|
16
|
+
* @param type - Unique query identifier to handle.
|
|
17
|
+
* @returns Method decorator.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* class UserProfileService {
|
|
22
|
+
* @OnQuery("GET_USER_AVATAR")
|
|
23
|
+
* private async onGetUserAvatar(userId: string): Promise<string> {
|
|
24
|
+
* const user: User = await this.userRepository.findById(userId);
|
|
25
|
+
*
|
|
26
|
+
* return user.avatarUrl;
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
8
30
|
*/
|
|
9
31
|
function OnQuery(type) {
|
|
10
32
|
return function (target, propertyKey) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-query.js","sources":["../../../../../../../../src/wirestate-core/queries/on-query.ts"],"sourcesContent":[null],"names":["OnQuery","type","target","propertyKey","constructor","list","QUERY_HANDLER_METADATA","get","set","push","methodName"],"mappings":";;AAOA
|
|
1
|
+
{"version":3,"file":"on-query.js","sources":["../../../../../../../../src/wirestate-core/queries/on-query.ts"],"sourcesContent":[null],"names":["OnQuery","type","target","propertyKey","constructor","list","QUERY_HANDLER_METADATA","get","set","push","methodName"],"mappings":";;AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACG,SAAUA,OAAOA,CAACC,IAAe,EAAA;AACrC,EAAA,OAAO,UAACC,MAAM,EAAEC,WAAW,EAAA;AASzB,IAAA,IAAMC,WAAW,GAAGF,MAAM,CAACE,WAAW;AAEtC,IAAA,IAAIC,IAAI,GAAuCC,sBAAsB,CAACC,GAAG,CAACH,WAAW,CAAC;IAEtF,IAAI,CAACC,IAAI,EAAE;AACTA,MAAAA,IAAI,GAAG,EAAE;AACTC,MAAAA,sBAAsB,CAACE,GAAG,CAACJ,WAAW,EAAEC,IAAI,CAAC;AAC/C,IAAA;AAEA;IACAA,IAAI,CAACI,IAAI,CAAC;AAAEC,MAAAA,UAAU,EAAEP,WAAW;AAAEF,MAAAA,IAAI,EAAAA;AAAA,KAAE,CAAC;EAC9C,CAAC;AACH;;;;"}
|
|
@@ -2,7 +2,15 @@ import { ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER } from '../error/error-code.
|
|
|
2
2
|
import { WirestateError } from '../error/wirestate-error.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Orchestrates query dispatching and handler registration.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* The `QueryBus` provides a request-response mechanism for decoupled communication.
|
|
9
|
+
* It supports handler shadowing: when multiple handlers are registered for the same type,
|
|
10
|
+
* the last registered one (e.g., at the component level) takes priority over earlier ones
|
|
11
|
+
* (e.g., at the global service level).
|
|
12
|
+
*
|
|
13
|
+
* @group Queries
|
|
6
14
|
*/
|
|
7
15
|
var QueryBus = /** @class */function () {
|
|
8
16
|
function QueryBus() {
|
|
@@ -13,12 +21,23 @@ var QueryBus = /** @class */function () {
|
|
|
13
21
|
this.handlers = new Map();
|
|
14
22
|
}
|
|
15
23
|
/**
|
|
16
|
-
* Registers a query
|
|
17
|
-
* Returns an unregister function.
|
|
24
|
+
* Registers a handler for a specific query type.
|
|
18
25
|
*
|
|
19
|
-
* @
|
|
20
|
-
*
|
|
21
|
-
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* If multiple handlers are registered for the same type, they are stored in a stack.
|
|
28
|
+
* The most recently registered handler will be used for resolution.
|
|
29
|
+
*
|
|
30
|
+
* @template D - Type of the query input data.
|
|
31
|
+
* @template R - Type of the query result.
|
|
32
|
+
*
|
|
33
|
+
* @param type - Unique query identifier.
|
|
34
|
+
* @param handler - Function to execute when the query is dispatched.
|
|
35
|
+
* @returns A function to unregister the handler.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const unregister: QueryUnregister = queryBus.register("GET_NOW", () => Date.now());
|
|
40
|
+
* ```
|
|
22
41
|
*/
|
|
23
42
|
QueryBus.prototype.register = function (type, handler) {
|
|
24
43
|
var _this = this;
|
|
@@ -29,28 +48,56 @@ var QueryBus = /** @class */function () {
|
|
|
29
48
|
}
|
|
30
49
|
stack.push(handler);
|
|
31
50
|
return function () {
|
|
32
|
-
|
|
33
|
-
if (!current) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
var index = current.indexOf(handler);
|
|
37
|
-
if (index >= 0) {
|
|
38
|
-
current.splice(index, 1);
|
|
39
|
-
}
|
|
40
|
-
// Clean empty stacks.
|
|
41
|
-
if (current.length === 0) {
|
|
42
|
-
_this.handlers.delete(type);
|
|
43
|
-
}
|
|
51
|
+
return _this.unregister(type, handler);
|
|
44
52
|
};
|
|
45
53
|
};
|
|
46
54
|
/**
|
|
47
|
-
*
|
|
55
|
+
* Removes a previously registered query handler.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
* If the handler was not registered for the given type, this operation does nothing.
|
|
59
|
+
*
|
|
60
|
+
* @template D - Type of the query input data.
|
|
61
|
+
* @template R - Type of the query result.
|
|
62
|
+
*
|
|
63
|
+
* @param type - Unique query identifier.
|
|
64
|
+
* @param handler - The handler function instance to remove.
|
|
65
|
+
*/
|
|
66
|
+
QueryBus.prototype.unregister = function (type, handler) {
|
|
67
|
+
var current = this.handlers.get(type);
|
|
68
|
+
if (!current) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
var index = current.indexOf(handler);
|
|
72
|
+
if (index >= 0) {
|
|
73
|
+
current.splice(index, 1);
|
|
74
|
+
}
|
|
75
|
+
// Clean empty stacks.
|
|
76
|
+
if (current.length === 0) {
|
|
77
|
+
this.handlers.delete(type);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Dispatches a query to the last registered handler and returns the result.
|
|
48
82
|
*
|
|
49
|
-
* @
|
|
50
|
-
*
|
|
51
|
-
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* Query handlers can be synchronous or asynchronous. The result is returned as-is
|
|
85
|
+
* (or as a Promise if the handler is async).
|
|
52
86
|
*
|
|
53
|
-
* @
|
|
87
|
+
* @template R - Type of the expected query result.
|
|
88
|
+
* @template D - Type of the data (payload) passed to the query.
|
|
89
|
+
* @template T - Type of the query identifier.
|
|
90
|
+
*
|
|
91
|
+
* @param type - Unique query identifier.
|
|
92
|
+
* @param data - Optional input data for the handler.
|
|
93
|
+
* @returns The result of the query execution.
|
|
94
|
+
*
|
|
95
|
+
* @throws {@link WirestateError} If no handler is registered for the given type.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const user: User = await queryBus.query<User, string>("FIND_USER", "user-id-123");
|
|
100
|
+
* ```
|
|
54
101
|
*/
|
|
55
102
|
QueryBus.prototype.query = function (type, data) {
|
|
56
103
|
var stack = this.handlers.get(type);
|
|
@@ -61,11 +108,15 @@ var QueryBus = /** @class */function () {
|
|
|
61
108
|
throw new WirestateError(ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER, "No query handler registered in container for type: '".concat(String(type), "'."));
|
|
62
109
|
};
|
|
63
110
|
/**
|
|
64
|
-
* Dispatches a query
|
|
111
|
+
* Dispatches a query if a handler exists, otherwise returns null.
|
|
112
|
+
*
|
|
113
|
+
* @template R - Type of the expected query result.
|
|
114
|
+
* @template D - Type of the data (payload) passed to the query.
|
|
115
|
+
* @template T - Type of the query identifier.
|
|
65
116
|
*
|
|
66
|
-
* @param type - query
|
|
67
|
-
* @param data -
|
|
68
|
-
* @returns query result or null if no handler is
|
|
117
|
+
* @param type - Unique query identifier.
|
|
118
|
+
* @param data - Optional input data for the handler.
|
|
119
|
+
* @returns The query result, or `null` if no handler is found.
|
|
69
120
|
*/
|
|
70
121
|
QueryBus.prototype.queryOptional = function (type, data) {
|
|
71
122
|
var stack = this.handlers.get(type);
|
|
@@ -75,17 +126,17 @@ var QueryBus = /** @class */function () {
|
|
|
75
126
|
return null;
|
|
76
127
|
};
|
|
77
128
|
/**
|
|
78
|
-
* Checks if
|
|
129
|
+
* Checks if at least one handler is registered for the given query type.
|
|
79
130
|
*
|
|
80
|
-
* @param type - query
|
|
81
|
-
* @returns true if handler
|
|
131
|
+
* @param type - Unique query identifier.
|
|
132
|
+
* @returns `true` if a handler is available, `false` otherwise.
|
|
82
133
|
*/
|
|
83
134
|
QueryBus.prototype.has = function (type) {
|
|
84
135
|
var stack = this.handlers.get(type);
|
|
85
136
|
return Boolean(stack && stack.length);
|
|
86
137
|
};
|
|
87
138
|
/**
|
|
88
|
-
* Removes all registered handlers.
|
|
139
|
+
* Removes all registered query handlers from the bus.
|
|
89
140
|
*
|
|
90
141
|
* @internal
|
|
91
142
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-bus.js","sources":["../../../../../../../../src/wirestate-core/queries/query-bus.ts"],"sourcesContent":[null],"names":["QueryBus","handlers","Map","prototype","register","type","handler","_this","stack","get","set","push","current","index","indexOf","splice","length","delete","query","data","WirestateError","ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER","concat","String","queryOptional","has","Boolean","clear"],"mappings":";;;AAQA
|
|
1
|
+
{"version":3,"file":"query-bus.js","sources":["../../../../../../../../src/wirestate-core/queries/query-bus.ts"],"sourcesContent":[null],"names":["QueryBus","handlers","Map","prototype","register","type","handler","_this","stack","get","set","push","unregister","current","index","indexOf","splice","length","delete","query","data","WirestateError","ERROR_CODE_FAILED_TO_RESOLVE_QUERY_HANDLER","concat","String","queryOptional","has","Boolean","clear"],"mappings":";;;AAQA;;;;;;;;;;AAUG;AACH,IAAAA,QAAA,gBAAA,YAAA;EAAA,SAAAA,QAAAA,GAAA;AACE;;;AAGG;AACc,IAAA,IAAA,CAAAC,QAAQ,GAAwC,IAAIC,GAAG,EAAE;AA6J5E,EAAA;AA3JE;;;;;;;;;;;;;;;;;;AAkBG;EACIF,QAAA,CAAAG,SAAA,CAAAC,QAAQ,GAAf,UAA0CC,IAAe,EAAEC,OAA2B,EAAA;IAAtF,IAAAC,KAAA,GAAA,IAAA;IAOE,IAAIC,KAAK,GAA+B,IAAI,CAACP,QAAQ,CAACQ,GAAG,CAACJ,IAAI,CAAC;IAE/D,IAAI,CAACG,KAAK,EAAE;AACVA,MAAAA,KAAK,GAAG,EAAE;MACV,IAAI,CAACP,QAAQ,CAACS,GAAG,CAACL,IAAI,EAAEG,KAAK,CAAC;AAChC,IAAA;AAEAA,IAAAA,KAAK,CAACG,IAAI,CAACL,OAAuB,CAAC;AAEnC,IAAA,OAAO,YAAA;AAAM,MAAA,OAAAC,KAAI,CAACK,UAAU,CAACP,IAAI,EAAEC,OAAuB,CAAC;IAA9C,CAA8C;EAC7D,CAAC;AAED;;;;;;;;;;;AAWG;EACIN,QAAA,CAAAG,SAAA,CAAAS,UAAU,GAAjB,UAA4CP,IAAe,EAAEC,OAA2B,EAAA;IAOtF,IAAMO,OAAO,GAA+B,IAAI,CAACZ,QAAQ,CAACQ,GAAG,CAACJ,IAAI,CAAC;IAEnE,IAAI,CAACQ,OAAO,EAAE;AACZ,MAAA;AACF,IAAA;AAEA,IAAA,IAAMC,KAAK,GAAWD,OAAO,CAACE,OAAO,CAACT,OAAuB,CAAC;IAE9D,IAAIQ,KAAK,IAAI,CAAC,EAAE;AACdD,MAAAA,OAAO,CAACG,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;AAC1B,IAAA;AAEA;AACA,IAAA,IAAID,OAAO,CAACI,MAAM,KAAK,CAAC,EAAE;AACxB,MAAA,IAAI,CAAChB,QAAQ,CAACiB,MAAM,CAACb,IAAI,CAAC;AAC5B,IAAA;EACF,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;AAqBG;EACIL,QAAA,CAAAG,SAAA,CAAAgB,KAAK,GAAZ,UAAwEd,IAAO,EAAEe,IAAQ,EAAA;IACvF,IAAMZ,KAAK,GAA+B,IAAI,CAACP,QAAQ,CAACQ,GAAG,CAACJ,IAAI,CAAC;AAEjE;AACA,IAAA,IAAIG,KAAK,aAALA,KAAK,KAAA,MAAA,GAAA,MAAA,GAALA,KAAK,CAAES,MAAM,EAAE;MACjB,OAAQT,KAAK,CAACA,KAAK,CAACS,MAAM,GAAG,CAAC,CAAwB,CAACG,IAAS,CAAC;AACnE,IAAA;AAEA,IAAA,MAAM,IAAIC,cAAc,CACtBC,0CAA0C,EAC1C,sDAAA,CAAAC,MAAA,CAAuDC,MAAM,CAACnB,IAAI,CAAC,EAAA,IAAA,CAAI,CACxE;EACH,CAAC;AAED;;;;;;;;;;AAUG;EACIL,QAAA,CAAAG,SAAA,CAAAsB,aAAa,GAApB,UACEpB,IAAO,EACPe,IAAQ,EAAA;IAER,IAAMZ,KAAK,GAA+B,IAAI,CAACP,QAAQ,CAACQ,GAAG,CAACJ,IAAI,CAAC;AAEjE,IAAA,IAAIG,KAAK,aAALA,KAAK,KAAA,MAAA,GAAA,MAAA,GAALA,KAAK,CAAES,MAAM,EAAE;MACjB,OAAQT,KAAK,CAACA,KAAK,CAACS,MAAM,GAAG,CAAC,CAAwB,CAACG,IAAS,CAAC;AACnE,IAAA;AAEA,IAAA,OAAO,IAAI;EACb,CAAC;AAED;;;;;AAKG;AACIpB,EAAAA,QAAA,CAAAG,SAAA,CAAAuB,GAAG,GAAV,UAAWrB,IAAe,EAAA;IACxB,IAAMG,KAAK,GAA+B,IAAI,CAACP,QAAQ,CAACQ,GAAG,CAACJ,IAAI,CAAC;AAEjE,IAAA,OAAOsB,OAAO,CAACnB,KAAK,IAAIA,KAAK,CAACS,MAAM,CAAC;EACvC,CAAC;AAED;;;;AAIG;AACIjB,EAAAA,QAAA,CAAAG,SAAA,CAAAyB,KAAK,GAAZ,YAAA;AACE,IAAA,IAAI,CAAC3B,QAAQ,CAAC2B,KAAK,EAAE;EACvB,CAAC;AACH,EAAA,OAAA5B,QAAC;AAAD,CAAC;;;;"}
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import { QueryBus } from './query-bus.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Dispatches a query
|
|
4
|
+
* Dispatches a query through the {@link QueryBus}, returning null if no handler is registered.
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This is a convenience wrapper around the `QueryBus.queryOptional` method.
|
|
8
|
+
* Use this when the query resolution is optional and you want to avoid catching errors.
|
|
9
|
+
*
|
|
10
|
+
* @group Queries
|
|
11
|
+
*
|
|
12
|
+
* @template R - Type of the expected query result.
|
|
13
|
+
* @template D - Type of the input data (payload).
|
|
14
|
+
*
|
|
15
|
+
* @param container - Inversify {@link Container} to resolve the {@link QueryBus} from.
|
|
16
|
+
* @param type - Unique query identifier.
|
|
17
|
+
* @param data - Optional input data for the query handler.
|
|
18
|
+
* @returns The query result or `null` if no handler exists.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const config: Config | null = await queryOptional<Config>(container, "GET_OPTIONAL_CONFIG");
|
|
23
|
+
* ```
|
|
10
24
|
*/
|
|
11
25
|
function queryOptional(container, type, data) {
|
|
12
26
|
return container.get(QueryBus).queryOptional(type, data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-optional.js","sources":["../../../../../../../../src/wirestate-core/queries/query-optional.ts"],"sourcesContent":[null],"names":["queryOptional","container","type","data","get","QueryBus"],"mappings":";;AAUA
|
|
1
|
+
{"version":3,"file":"query-optional.js","sources":["../../../../../../../../src/wirestate-core/queries/query-optional.ts"],"sourcesContent":[null],"names":["queryOptional","container","type","data","get","QueryBus"],"mappings":";;AAUA;;;;;;;;;;;;;;;;;;;;;AAqBG;SACaA,aAAaA,CAC3BC,SAAoB,EACpBC,IAAe,EACfC,IAAQ,EAAA;AAIR,EAAA,OAAOF,SAAS,CAACG,GAAG,CAACC,QAAQ,CAAC,CAACL,aAAa,CAAOE,IAAI,EAAEC,IAAI,CAAC;AAChE;;;;"}
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import { QueryBus } from './query-bus.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Dispatches a query
|
|
4
|
+
* Dispatches a query through the {@link QueryBus} resolved from the container.
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This is a convenience wrapper around the `QueryBus.query` method.
|
|
8
|
+
* Queries allow for decoupled request-response communication between services.
|
|
9
|
+
*
|
|
10
|
+
* @group Queries
|
|
11
|
+
*
|
|
12
|
+
* @template R - Type of the expected query result.
|
|
13
|
+
* @template D - Type of the input data (payload).
|
|
14
|
+
*
|
|
15
|
+
* @param container - Inversify {@link Container} to resolve the {@link QueryBus} from.
|
|
16
|
+
* @param type - Unique query identifier.
|
|
17
|
+
* @param data - Optional input data for the query handler.
|
|
18
|
+
* @returns The query result (can be a Promise).
|
|
19
|
+
*
|
|
20
|
+
* @throws {@link WirestateError} If no query handler is registered.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const result: string = await query<string, FindUserParameters>(
|
|
25
|
+
* container,
|
|
26
|
+
* "GET_USER_NAME",
|
|
27
|
+
* { id: 123 }
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
10
30
|
*/
|
|
11
31
|
function query(container, type, data) {
|
|
12
32
|
return container.get(QueryBus).query(type, data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sources":["../../../../../../../../src/wirestate-core/queries/query.ts"],"sourcesContent":[null],"names":["query","container","type","data","get","QueryBus"],"mappings":";;AAUA
|
|
1
|
+
{"version":3,"file":"query.js","sources":["../../../../../../../../src/wirestate-core/queries/query.ts"],"sourcesContent":[null],"names":["query","container","type","data","get","QueryBus"],"mappings":";;AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;SACaA,KAAKA,CAA2BC,SAAoB,EAAEC,IAAe,EAAEC,IAAQ,EAAA;AAG7F,EAAA,OAAOF,SAAS,CAACG,GAAG,CAACC,QAAQ,CAAC,CAACL,KAAK,CAAOE,IAAI,EAAEC,IAAI,CAAC;AACxD;;;;"}
|
|
@@ -1,56 +1,113 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Map of class constructors to their declared query handlers.
|
|
11
|
-
* Inherited via a prototype chain at resolve time.
|
|
2
|
+
* Registry of class constructors to their declared query handlers.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This map is populated by the {@link OnQuery} decorator. Handlers are
|
|
6
|
+
* inherited via the prototype chain at service resolution time.
|
|
7
|
+
*
|
|
8
|
+
* @group Queries
|
|
9
|
+
* @internal
|
|
12
10
|
*/
|
|
13
11
|
var QUERY_HANDLER_METADATA = new WeakMap();
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* Registry of class constructors to their declared command handlers.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* This map is populated by the {@link OnCommand} decorator. Handlers are
|
|
17
|
+
* inherited via the prototype chain at service resolution time.
|
|
18
|
+
*
|
|
19
|
+
* @group Commands
|
|
20
|
+
* @internal
|
|
17
21
|
*/
|
|
18
22
|
var COMMAND_HANDLER_METADATA = new WeakMap();
|
|
19
23
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
24
|
+
* Registry of class constructors to their `@OnActivated`-decorated method names.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* This map is populated by the {@link OnActivated} decorator. Activation hooks are
|
|
28
|
+
* executed in parent-to-child order during service initialization.
|
|
29
|
+
*
|
|
30
|
+
* @group Service
|
|
31
|
+
* @internal
|
|
22
32
|
*/
|
|
23
33
|
var ACTIVATED_HANDLER_METADATA = new WeakMap();
|
|
24
34
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
35
|
+
* Registry of class constructors to their `@OnDeactivation`-decorated method names.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* This map is populated by the {@link OnDeactivation} decorator. Deactivation hooks are
|
|
39
|
+
* executed in parent-to-child order during service disposal.
|
|
40
|
+
*
|
|
41
|
+
* @group Service
|
|
42
|
+
* @internal
|
|
27
43
|
*/
|
|
28
44
|
var DEACTIVATION_HANDLER_METADATA = new WeakMap();
|
|
29
45
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
46
|
+
* Registry of class constructors to their declared event handlers.
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* This map is populated by the {@link OnEvent} decorator. Event handlers are
|
|
50
|
+
* inherited via the prototype chain at service resolution time.
|
|
51
|
+
*
|
|
52
|
+
* @group Events
|
|
53
|
+
* @internal
|
|
32
54
|
*/
|
|
33
55
|
var EVENT_HANDLER_METADATA = new WeakMap();
|
|
34
56
|
/**
|
|
35
|
-
*
|
|
57
|
+
* Internal storage for mapping service instances to their originating Inversify containers.
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* Used during the service lifecycle to ensure that resolution and messaging
|
|
61
|
+
* occur within the correct container context.
|
|
62
|
+
*
|
|
63
|
+
* @group Bind
|
|
64
|
+
* @internal
|
|
36
65
|
*/
|
|
37
66
|
var CONTAINER_REFS_BY_SERVICE = new WeakMap();
|
|
38
67
|
/**
|
|
39
|
-
*
|
|
68
|
+
* Internal storage for managing injected {@link WireScope} instances per service.
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* Tracks the scopes associated with a service instance for lifecycle management
|
|
72
|
+
* and cleanup.
|
|
73
|
+
*
|
|
74
|
+
* @group Container
|
|
75
|
+
* @internal
|
|
40
76
|
*/
|
|
41
77
|
var WIRE_SCOPES_BY_SERVICE = new WeakMap();
|
|
42
78
|
/**
|
|
43
|
-
*
|
|
79
|
+
* Internal storage for service event unsubscribers.
|
|
80
|
+
*
|
|
81
|
+
* @remarks
|
|
82
|
+
* Stores the unsubscription functions returned when a service automatically
|
|
83
|
+
* subscribes to events via the {@link OnEvent} decorator.
|
|
84
|
+
*
|
|
85
|
+
* @group Events
|
|
86
|
+
* @internal
|
|
44
87
|
*/
|
|
45
88
|
var EVENT_UNSUBSCRIBERS_BY_SERVICE = new WeakMap();
|
|
46
89
|
/**
|
|
47
|
-
*
|
|
90
|
+
* Internal storage for service query unregisters.
|
|
91
|
+
*
|
|
92
|
+
* @remarks
|
|
93
|
+
* Stores the unregistration functions returned when a service automatically
|
|
94
|
+
* registers query handlers via the {@link OnQuery} decorator.
|
|
95
|
+
*
|
|
96
|
+
* @group Queries
|
|
97
|
+
* @internal
|
|
48
98
|
*/
|
|
49
99
|
var QUERY_UNREGISTERS_BY_SERVICE = new WeakMap();
|
|
50
100
|
/**
|
|
51
|
-
*
|
|
101
|
+
* Internal storage for service command unregisters.
|
|
102
|
+
*
|
|
103
|
+
* @remarks
|
|
104
|
+
* Stores the unregistration functions returned when a service automatically
|
|
105
|
+
* registers command handlers via the {@link OnCommand} decorator.
|
|
106
|
+
*
|
|
107
|
+
* @group Commands
|
|
108
|
+
* @internal
|
|
52
109
|
*/
|
|
53
110
|
var COMMAND_UNREGISTERS_BY_SERVICE = new WeakMap();
|
|
54
111
|
|
|
55
|
-
export { ACTIVATED_HANDLER_METADATA, COMMAND_HANDLER_METADATA, COMMAND_UNREGISTERS_BY_SERVICE, CONTAINER_REFS_BY_SERVICE, DEACTIVATION_HANDLER_METADATA, EVENT_HANDLER_METADATA, EVENT_UNSUBSCRIBERS_BY_SERVICE, QUERY_HANDLER_METADATA, QUERY_UNREGISTERS_BY_SERVICE,
|
|
112
|
+
export { ACTIVATED_HANDLER_METADATA, COMMAND_HANDLER_METADATA, COMMAND_UNREGISTERS_BY_SERVICE, CONTAINER_REFS_BY_SERVICE, DEACTIVATION_HANDLER_METADATA, EVENT_HANDLER_METADATA, EVENT_UNSUBSCRIBERS_BY_SERVICE, QUERY_HANDLER_METADATA, QUERY_UNREGISTERS_BY_SERVICE, WIRE_SCOPES_BY_SERVICE };
|
|
56
113
|
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sources":["../../../../../../../src/wirestate-core/registry.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"registry.js","sources":["../../../../../../../src/wirestate-core/registry.ts"],"sourcesContent":[null],"names":["QUERY_HANDLER_METADATA","WeakMap","COMMAND_HANDLER_METADATA","ACTIVATED_HANDLER_METADATA","DEACTIVATION_HANDLER_METADATA","EVENT_HANDLER_METADATA","CONTAINER_REFS_BY_SERVICE","WIRE_SCOPES_BY_SERVICE","EVENT_UNSUBSCRIBERS_BY_SERVICE","QUERY_UNREGISTERS_BY_SERVICE","COMMAND_UNREGISTERS_BY_SERVICE"],"mappings":"AAOA;;;;;;;;;AASG;IACUA,sBAAsB,GAAiD,IAAIC,OAAO;AAE/F;;;;;;;;;AASG;IACUC,wBAAwB,GAAmD,IAAID,OAAO;AAEnG;;;;;;;;;AASG;IACUE,0BAA0B,GAA4C,IAAIF,OAAO;AAE9F;;;;;;;;;AASG;IACUG,6BAA6B,GAA4C,IAAIH,OAAO;AAEjG;;;;;;;;;AASG;IACUI,sBAAsB,GAAiD,IAAIJ,OAAO;AAE/F;;;;;;;;;AASG;IACUK,yBAAyB,GAA+B,IAAIL,OAAO;AAEhF;;;;;;;;;AASG;IACUM,sBAAsB,GAAsC,IAAIN,OAAO;AAEpF;;;;;;;;;AASG;IACUO,8BAA8B,GAAuC,IAAIP,OAAO;AAE7F;;;;;;;;;AASG;IACUQ,4BAA4B,GAA4C,IAAIR,OAAO;AAEhG;;;;;;;;;AASG;IACUS,8BAA8B,GAA8C,IAAIT,OAAO;;;;"}
|