@wirestate/core 0.6.1 → 0.7.0-experimental.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -1
- package/README.md +186 -232
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.js","sources":["../../../../../../../src/wirestate-core/test-utils/mock-bind-service.ts","../../../../../../../src/wirestate-core/test-utils/mock-bind-entry.ts","../../../../../../../src/wirestate-core/test-utils/mock-container.ts","../../../../../../../src/wirestate-core/test-utils/mock-service.ts","../../../../../../../src/wirestate-core/test-utils/mock-unbind-service.ts"],"sourcesContent":[null,null,null,null,null],"names":["
|
|
1
|
+
{"version":3,"file":"test-utils.js","sources":["../../../../../../../src/wirestate-core/test-utils/mock-bind-service.ts","../../../../../../../src/wirestate-core/test-utils/mock-bind-entry.ts","../../../../../../../src/wirestate-core/test-utils/mock-container.ts","../../../../../../../src/wirestate-core/test-utils/mock-service.ts","../../../../../../../src/wirestate-core/test-utils/mock-unbind-service.ts"],"sourcesContent":[null,null,null,null,null],"names":["createContainer","require","mockBindService","container","ServiceClass","options","skipLifecycle","bindService","isWithIgnoreLifecycle","mockBindEntry","entry","bindEntry","mockContainer","_a","activate","_b","entries","length","serviceTokens","map","s","getEntryToken","_i","activate_1","token","includes","WirestateError","ERROR_CODE_INVALID_ARGUMENTS","parent","seeds","seed","_c","entries_1","_d","activate_2","it_2","get","exports","mockService","service","mockUnbindService","unbind"],"mappings":"AAqBA,aAAA,IAAAA,EAAAC,QAAA,qBAoBgBC,EACdC,EACAC,EACAC,QAAA,IAAAA,IAAAA,EAAA,CAAA,GAEQ,IAAAC,EAAkBD,EAAOC,cAEjCC,EAAAA,EAAYJ,EAAWC,EAAc,CACnCI,sBAAuBF,GAE3B,UCRgBG,EACdN,EACAO,EACAL,QAAA,IAAAA,IAAAA,EAAA,CAAA,GAEQ,IAAAC,EAAkBD,EAAOC,cAEjCK,EAAAA,EAAUR,EAAWO,EAAO,CAC1BF,sBAAuBF,GAE3B,CCgCM,SAA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ify';
|
|
2
|
-
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';
|
|
2
|
+
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';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Util to resolve circular dependencies by wrapping the service identifier in a lazy identifier.
|
|
6
|
+
*
|
|
7
|
+
* @group External-inversify
|
|
8
|
+
* @see {@link https://inversify.io/}
|
|
9
|
+
*
|
|
10
|
+
* @param forward - A function that returns the service identifier.
|
|
11
|
+
* @returns A lazy service identifier.
|
|
12
|
+
*/
|
|
4
13
|
function forwardRef(forward) {
|
|
5
14
|
return new LazyServiceIdentifier(forward);
|
|
6
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alias.js","sources":["../../../../../../../src/wirestate-core/alias.ts"],"sourcesContent":[null],"names":["forwardRef","forward","LazyServiceIdentifier"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"alias.js","sources":["../../../../../../../src/wirestate-core/alias.ts"],"sourcesContent":[null],"names":["forwardRef","forward","LazyServiceIdentifier"],"mappings":";;;AAgFA;;;;;;;;AAQG;AACG,SAAUA,UAAUA,CACxBC,OAA2C,EAAA;AAE3C,EAAA,OAAO,IAAIC,qBAAqB,CAACD,OAAO,CAAC;AAC3C;;;;"}
|
|
@@ -3,16 +3,37 @@ import { ERROR_CODE_BINDING_SCOPE } from '../error/error-code.js';
|
|
|
3
3
|
import { WirestateError } from '../error/wirestate-error.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Binds a constant value to a
|
|
6
|
+
* Binds a constant value to a service identifier in the container.
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Use this to register configuration values, primitive constants, or pre-instantiated objects.
|
|
10
|
+
* Constant values are bound with a singleton scope by default.
|
|
11
|
+
*
|
|
12
|
+
* @group Bind
|
|
13
|
+
*
|
|
14
|
+
* @template T - Type of the service being bound.
|
|
15
|
+
*
|
|
16
|
+
* @param container - Target Inversify {@link Container}.
|
|
17
|
+
* @param entry - Descriptor containing `id` (token) and `value` (constant).
|
|
18
|
+
* @returns Inversify fluent syntax for additional constraints.
|
|
19
|
+
*
|
|
20
|
+
* @throws {@link WirestateError} If `entry.scopeBindingType` is not `Singleton`.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const API_URL: unique symbol = Symbol("API_URL");
|
|
25
|
+
*
|
|
26
|
+
* bindConstant(container, {
|
|
27
|
+
* id: API_URL,
|
|
28
|
+
* value: "https://api.example.com"
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
10
31
|
*/
|
|
11
32
|
function bindConstant(container, entry) {
|
|
12
33
|
if (entry.scopeBindingType && entry.scopeBindingType !== bindingScopeValues.Singleton) {
|
|
13
34
|
throw new WirestateError(ERROR_CODE_BINDING_SCOPE, "Provided unexpected binding scope for constant value.");
|
|
14
35
|
}
|
|
15
|
-
container.bind(entry.id).toConstantValue(entry.value);
|
|
36
|
+
return container.bind(entry.id).toConstantValue(entry.value);
|
|
16
37
|
}
|
|
17
38
|
|
|
18
39
|
export { bindConstant };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-constant.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-constant.ts"],"sourcesContent":[null],"names":["bindConstant","container","entry","scopeBindingType","ScopeBindingType","Singleton","WirestateError","ERROR_CODE_BINDING_SCOPE","bind","id","toConstantValue","value"],"mappings":";;;;AAUA
|
|
1
|
+
{"version":3,"file":"bind-constant.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-constant.ts"],"sourcesContent":[null],"names":["bindConstant","container","entry","scopeBindingType","ScopeBindingType","Singleton","WirestateError","ERROR_CODE_BINDING_SCOPE","bind","id","toConstantValue","value"],"mappings":";;;;AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AACG,SAAUA,YAAYA,CAAIC,SAAoB,EAAEC,KAA2B,EAAA;EAQ/E,IAAIA,KAAK,CAACC,gBAAgB,IAAID,KAAK,CAACC,gBAAgB,KAAKC,kBAAgB,CAACC,SAAS,EAAE;AACnF,IAAA,MAAM,IAAIC,cAAc,CAACC,wBAAwB,EAAE,uDAAuD,CAAC;AAC7G,EAAA;AAEA,EAAA,OAAON,SAAS,CAACO,IAAI,CAAIN,KAAK,CAACO,EAA0B,CAAC,CAACC,eAAe,CAACR,KAAK,CAACS,KAAU,CAAC;AAC9F;;;;"}
|
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import { bindingScopeValues } from 'inversify';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Binds a
|
|
4
|
+
* Binds a dynamic value (factory-based) to an identifier in the container.
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Use this when the value depends on runtime state or requires logic during resolution.
|
|
8
|
+
* The binding uses `entry.factory` if provided; otherwise, it falls back to `entry.value`.
|
|
9
|
+
* Supports custom scoping via `entry.scopeBindingType`.
|
|
10
|
+
*
|
|
11
|
+
* @group Bind
|
|
12
|
+
*
|
|
13
|
+
* @template T - Type of the value being bound.
|
|
14
|
+
*
|
|
15
|
+
* @param container - Target Inversify {@link Container}.
|
|
16
|
+
* @param entry - Descriptor containing `id`, `factory` or `value`, and optional `scopeBindingType`.
|
|
17
|
+
* @returns Inversify fluent syntax for additional constraints.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const DATE_NOW: unique symbol = Symbol("DATE_NOW");
|
|
22
|
+
*
|
|
23
|
+
* bindDynamicValue(container, {
|
|
24
|
+
* id: DATE_NOW,
|
|
25
|
+
* factory: () => new Date()
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
8
28
|
*/
|
|
9
29
|
function bindDynamicValue(container, entry) {
|
|
10
30
|
var binding = container.bind(entry.id).toDynamicValue(function () {
|
|
@@ -14,13 +34,13 @@ function bindDynamicValue(container, entry) {
|
|
|
14
34
|
return entry.value;
|
|
15
35
|
});
|
|
16
36
|
if (!entry.scopeBindingType) {
|
|
17
|
-
return;
|
|
37
|
+
return binding;
|
|
18
38
|
} else if (entry.scopeBindingType === bindingScopeValues.Transient) {
|
|
19
|
-
binding.inTransientScope();
|
|
39
|
+
return binding.inTransientScope();
|
|
20
40
|
} else if (entry.scopeBindingType === bindingScopeValues.Request) {
|
|
21
|
-
binding.inRequestScope();
|
|
41
|
+
return binding.inRequestScope();
|
|
22
42
|
} else {
|
|
23
|
-
binding.inSingletonScope();
|
|
43
|
+
return binding.inSingletonScope();
|
|
24
44
|
}
|
|
25
45
|
}
|
|
26
46
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-dynamic-value.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-dynamic-value.ts"],"sourcesContent":[null],"names":["bindDynamicValue","container","entry","binding","bind","id","toDynamicValue","factory","value","scopeBindingType","bindingScopeValues","Transient","inTransientScope","Request","inRequestScope","inSingletonScope"],"mappings":";;AAOA
|
|
1
|
+
{"version":3,"file":"bind-dynamic-value.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-dynamic-value.ts"],"sourcesContent":[null],"names":["bindDynamicValue","container","entry","binding","bind","id","toDynamicValue","factory","value","scopeBindingType","bindingScopeValues","Transient","inTransientScope","Request","inRequestScope","inSingletonScope"],"mappings":";;AAOA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AACG,SAAUA,gBAAgBA,CAAIC,SAAoB,EAAEC,KAA2B,EAAA;AAMnF,EAAA,IAAMC,OAAO,GAAgCF,SAAS,CAACG,IAAI,CAACF,KAAK,CAACG,EAAE,CAAC,CAACC,cAAc,CAAC,YAAA;IACnF,IAAIJ,KAAK,CAACK,OAAO,EAAE;AACjB,MAAA,OAAOL,KAAK,CAACK,OAAO,EAAE;AACxB,IAAA;IAEA,OAAOL,KAAK,CAACM,KAAK;AACpB,EAAA,CAAC,CAAgC;AAEjC,EAAA,IAAI,CAACN,KAAK,CAACO,gBAAgB,EAAE;AAC3B,IAAA,OAAON,OAAO;EAChB,CAAC,MAAM,IAAID,KAAK,CAACO,gBAAgB,KAAKC,kBAAkB,CAACC,SAAS,EAAE;AAClE,IAAA,OAAOR,OAAO,CAACS,gBAAgB,EAAE;EACnC,CAAC,MAAM,IAAIV,KAAK,CAACO,gBAAgB,KAAKC,kBAAkB,CAACG,OAAO,EAAE;AAChE,IAAA,OAAOV,OAAO,CAACW,cAAc,EAAE;AACjC,EAAA,CAAC,MAAM;AACL,IAAA,OAAOX,OAAO,CAACY,gBAAgB,EAAE;AACnC,EAAA;AACF;;;;"}
|
|
@@ -4,35 +4,68 @@ import { bindDynamicValue } from './bind-dynamic-value.js';
|
|
|
4
4
|
import { bindService } from './bind-service.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Binds
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
14
|
-
* - Instance
|
|
15
|
-
*
|
|
16
|
-
* @
|
|
17
|
-
*
|
|
18
|
-
* @
|
|
19
|
-
*
|
|
7
|
+
* Binds an entry to the Inversify {@link Container} using the appropriate strategy.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This is a high-level dispatching function that selects the binding method based on the `entry` type:
|
|
11
|
+
* - **Class Constructor**: Binds as a singleton service via {@link bindService}.
|
|
12
|
+
* - **ConstantValue**: Binds a fixed value via {@link bindConstant}.
|
|
13
|
+
* - **DynamicValue**: Binds a factory-generated value via {@link bindDynamicValue}.
|
|
14
|
+
* - **Instance**: Binds a value as a class instance via {@link bindService}.
|
|
15
|
+
*
|
|
16
|
+
* @group Bind
|
|
17
|
+
*
|
|
18
|
+
* @template T - Type of the object being bound.
|
|
19
|
+
*
|
|
20
|
+
* @param container - Target Inversify {@link Container}.
|
|
21
|
+
* @param entry - Class constructor or {@link InjectableDescriptor} describing the service.
|
|
22
|
+
* @param options - Optional binding configuration (primarily used for class-based services).
|
|
23
|
+
*
|
|
24
|
+
* @throws {@link WirestateError} If `entry.scopeBindingType` is not `Singleton` for constant values.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Binding a class constructor (defaults to singleton)
|
|
29
|
+
* class MyService {}
|
|
30
|
+
*
|
|
31
|
+
* bindEntry(container, MyService);
|
|
32
|
+
*
|
|
33
|
+
* // Binding a constant value
|
|
34
|
+
* const API_URL: unique symbol = Symbol("API_URL");
|
|
35
|
+
*
|
|
36
|
+
* bindEntry(container, {
|
|
37
|
+
* id: API_URL,
|
|
38
|
+
* value: "https://api.example.com"
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // Binding a dynamic value (factory)
|
|
42
|
+
* const CURRENT_TIME: unique symbol = Symbol("CURRENT_TIME");
|
|
43
|
+
*
|
|
44
|
+
* bindEntry(container, {
|
|
45
|
+
* id: CURRENT_TIME,
|
|
46
|
+
* bindingType: "DynamicValue",
|
|
47
|
+
* factory: () => new Date()
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
20
50
|
*/
|
|
21
51
|
function bindEntry(container, entry, options) {
|
|
22
52
|
if (options === void 0) {
|
|
23
53
|
options = {};
|
|
24
54
|
}
|
|
25
55
|
if (typeof entry === "function") {
|
|
26
|
-
|
|
56
|
+
bindService(container, entry, options);
|
|
57
|
+
return;
|
|
27
58
|
}
|
|
28
59
|
if (!entry.bindingType || entry.bindingType === bindingTypeValues.ConstantValue) {
|
|
29
|
-
|
|
60
|
+
bindConstant(container, entry);
|
|
61
|
+
return;
|
|
30
62
|
}
|
|
31
63
|
if (entry.bindingType === bindingTypeValues.DynamicValue) {
|
|
32
|
-
|
|
64
|
+
bindDynamicValue(container, entry);
|
|
65
|
+
return;
|
|
33
66
|
}
|
|
34
67
|
// Default: treat as class descriptor (Instance binding).
|
|
35
|
-
|
|
68
|
+
bindService(container, entry.value, options);
|
|
36
69
|
}
|
|
37
70
|
|
|
38
71
|
export { bindEntry };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-entry.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-entry.ts"],"sourcesContent":[null],"names":["bindEntry","container","entry","options","bindService","bindingType","bindingTypeValues","ConstantValue","bindConstant","DynamicValue","bindDynamicValue","value"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"bind-entry.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-entry.ts"],"sourcesContent":[null],"names":["bindEntry","container","entry","options","bindService","bindingType","bindingTypeValues","ConstantValue","bindConstant","DynamicValue","bindDynamicValue","value"],"mappings":";;;;;AA0BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CG;SACaA,SAASA,CACvBC,SAAoB,EACpBC,KAAwC,EACxCC,OAA8B,EAAA;AAA9B,EAAA,IAAAA,OAAA,KAAA,MAAA,EAAA;IAAAA,OAAA,GAAA,EAA8B;AAAA,EAAA;AAE9B,EAAA,IAAI,OAAOD,KAAK,KAAK,UAAU,EAAE;AAC/BE,IAAAA,WAAW,CAACH,SAAS,EAAEC,KAAK,EAAEC,OAAO,CAAC;AAEtC,IAAA;AACF,EAAA;AAEA,EAAA,IAAI,CAACD,KAAK,CAACG,WAAW,IAAIH,KAAK,CAACG,WAAW,KAAKC,iBAAiB,CAACC,aAAa,EAAE;AAC/EC,IAAAA,YAAY,CAACP,SAAS,EAAEC,KAAK,CAAC;AAE9B,IAAA;AACF,EAAA;AAEA,EAAA,IAAIA,KAAK,CAACG,WAAW,KAAKC,iBAAiB,CAACG,YAAY,EAAE;AAMxDC,IAAAA,gBAAgB,CAACT,SAAS,EAAEC,KAAK,CAAC;AAElC,IAAA;AACF,EAAA;AAOA;EACAE,WAAW,CAACH,SAAS,EAAEC,KAAK,CAACS,KAA8B,EAAER,OAAO,CAAC;AACvE;;;;"}
|
|
@@ -10,12 +10,56 @@ import { getActivatedHandlerMetadata } from '../service/get-activated-handler-me
|
|
|
10
10
|
import { getDeactivationHandlerMetadata } from '../service/get-deactivation-handler-metadata.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* Ensures container references, event subscriptions, command and query handlers are managed correctly.
|
|
13
|
+
* Binds a service class in the {@link Container} with full lifecycle and messaging integration.
|
|
15
14
|
*
|
|
16
|
-
* @
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Binds the class in singleton scope and configures Inversify activation/deactivation hooks to:
|
|
17
|
+
* - Manage the `IS_DISPOSED` lifecycle state flag.
|
|
18
|
+
* - Trigger `@OnActivated` and `@OnDeactivation` decorated methods.
|
|
19
|
+
* - Register/unregister `@OnCommand`, `@OnEvent` and `@OnQuery` handlers.
|
|
20
|
+
* - Set up event dispatching and bus subscriptions.
|
|
21
|
+
* - Track and dispose injected {@link WireScope} instances.
|
|
22
|
+
*
|
|
23
|
+
* @group Bind
|
|
24
|
+
*
|
|
25
|
+
* @template T - Type of the service instance.
|
|
26
|
+
*
|
|
27
|
+
* @param container - Target Inversify {@link Container}.
|
|
28
|
+
* @param entry - Service class constructor.
|
|
29
|
+
* @param options - Configuration options for the binding.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* @Injectable()
|
|
34
|
+
* class UserService {
|
|
35
|
+
* @OnActivated()
|
|
36
|
+
* public onActivated(): void {
|
|
37
|
+
* console.log("UserService activated");
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* @OnDeactivation()
|
|
41
|
+
* public onDeactivation(): void {
|
|
42
|
+
* console.log("UserService deactivating");
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* @OnEvent("USER_LOGGED_IN")
|
|
46
|
+
* private onUserLoggedIn(event: UserLoggedInEvent) {
|
|
47
|
+
* console.log('User logged in:', event.payload);
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* @OnCommand("LOG_DATE_NOW")
|
|
51
|
+
* private onLogDateNow(): void {
|
|
52
|
+
* console.log("Date now:", new Date());
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* @OnQuery("DATE_NOW")
|
|
56
|
+
* private onQueryDateNow(): void {
|
|
57
|
+
* return new Date();
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* bindService(container, UserService);
|
|
62
|
+
* ```
|
|
19
63
|
*/
|
|
20
64
|
function bindService(container, entry, options) {
|
|
21
65
|
// Inversify's fluent binding API only allows a single `.onActivation` /
|
|
@@ -109,9 +153,10 @@ function bindService(container, entry, options) {
|
|
|
109
153
|
/**
|
|
110
154
|
* Attaches a event subscription to a service.
|
|
111
155
|
*
|
|
112
|
-
* @param service - service instance
|
|
113
|
-
* @param handler - event handler
|
|
114
156
|
* @internal
|
|
157
|
+
*
|
|
158
|
+
* @param service - Service instance.
|
|
159
|
+
* @param handler - Event handler.
|
|
115
160
|
*/
|
|
116
161
|
function attachEventsSubscription(service, handler) {
|
|
117
162
|
var _a;
|
|
@@ -123,8 +168,9 @@ function attachEventsSubscription(service, handler) {
|
|
|
123
168
|
/**
|
|
124
169
|
* Detaches the event subscription from a service.
|
|
125
170
|
*
|
|
126
|
-
* @param service - service instance
|
|
127
171
|
* @internal
|
|
172
|
+
*
|
|
173
|
+
* @param service - Service instance.
|
|
128
174
|
*/
|
|
129
175
|
function detachEventSubscription(service) {
|
|
130
176
|
var unsubscribe = EVENT_UNSUBSCRIBERS_BY_SERVICE.get(service);
|
|
@@ -136,9 +182,10 @@ function detachEventSubscription(service) {
|
|
|
136
182
|
/**
|
|
137
183
|
* Registers a query unregister function for a service.
|
|
138
184
|
*
|
|
139
|
-
* @param service - service instance
|
|
140
|
-
* @param unregister - query unregister function
|
|
141
185
|
* @internal
|
|
186
|
+
*
|
|
187
|
+
* @param service - Service instance.
|
|
188
|
+
* @param unregister - Query unregister function.
|
|
142
189
|
*/
|
|
143
190
|
function attachQueryUnregister(service, unregister) {
|
|
144
191
|
var list = QUERY_UNREGISTERS_BY_SERVICE.get(service);
|
|
@@ -151,8 +198,9 @@ function attachQueryUnregister(service, unregister) {
|
|
|
151
198
|
/**
|
|
152
199
|
* Executes and removes all query unregister functions for a service.
|
|
153
200
|
*
|
|
154
|
-
* @param service - service instance
|
|
155
201
|
* @internal
|
|
202
|
+
*
|
|
203
|
+
* @param service - Service instance.
|
|
156
204
|
*/
|
|
157
205
|
function detachQueryUnregister(service) {
|
|
158
206
|
var list = QUERY_UNREGISTERS_BY_SERVICE.get(service);
|
|
@@ -168,9 +216,10 @@ function detachQueryUnregister(service) {
|
|
|
168
216
|
/**
|
|
169
217
|
* Registers a command unregister function for a service.
|
|
170
218
|
*
|
|
171
|
-
* @param service - service instance
|
|
172
|
-
* @param unregister - command unregister function
|
|
173
219
|
* @internal
|
|
220
|
+
*
|
|
221
|
+
* @param service - Service instance.
|
|
222
|
+
* @param unregister - Command unregister function.
|
|
174
223
|
*/
|
|
175
224
|
function attachCommandUnregister(service, unregister) {
|
|
176
225
|
var list = COMMAND_UNREGISTERS_BY_SERVICE.get(service);
|
|
@@ -183,8 +232,9 @@ function attachCommandUnregister(service, unregister) {
|
|
|
183
232
|
/**
|
|
184
233
|
* Executes and removes all command unregister functions for a service.
|
|
185
234
|
*
|
|
186
|
-
* @param service - service instance
|
|
187
235
|
* @internal
|
|
236
|
+
*
|
|
237
|
+
* @param service - Service instance.
|
|
188
238
|
*/
|
|
189
239
|
function detachCommandUnregister(service) {
|
|
190
240
|
var list = COMMAND_UNREGISTERS_BY_SERVICE.get(service);
|
|
@@ -202,11 +252,12 @@ function detachCommandUnregister(service) {
|
|
|
202
252
|
* Property iteration happens only when the constructor metadata declares a WireScope
|
|
203
253
|
* parameter, avoiding false positives from manually created or subclassed scopes.
|
|
204
254
|
*
|
|
205
|
-
*
|
|
255
|
+
* Todo: Simplify this part..
|
|
206
256
|
*
|
|
207
|
-
* @param service - service instance
|
|
208
|
-
* @param Service - service constructor
|
|
209
257
|
* @internal
|
|
258
|
+
*
|
|
259
|
+
* @param service - Service instance.
|
|
260
|
+
* @param Service - Service constructor.
|
|
210
261
|
*/
|
|
211
262
|
function attachWireScopes(service, Service) {
|
|
212
263
|
var paramTypes = Reflect.getMetadata("design:paramtypes", Service);
|
|
@@ -231,10 +282,11 @@ function attachWireScopes(service, Service) {
|
|
|
231
282
|
* Marks all injected WireScope instances for this service as disposed and removes
|
|
232
283
|
* the stored references.
|
|
233
284
|
*
|
|
234
|
-
*
|
|
285
|
+
* Todo: Simplify this part..
|
|
235
286
|
*
|
|
236
|
-
* @param service - service instance
|
|
237
287
|
* @internal
|
|
288
|
+
*
|
|
289
|
+
* @param service - Service instance.
|
|
238
290
|
*/
|
|
239
291
|
function detachWireScopes(service) {
|
|
240
292
|
var scopes = WIRE_SCOPES_BY_SERVICE.get(service);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-service.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-service.ts"],"sourcesContent":[null],"names":["bindService","container","entry","options","whenBind","bind","to","inSingletonScope","onActivation","context","instance","IS_DISPOSED","CONTAINER_REFS_BY_SERVICE","set","attachWireScopes","dispatcher","buildEventDispatcher","attachEventsSubscription","queryBus","get","QueryBus","_i","_a","getQueryHandlerMetadata","length","meta","method","methodName","unregister","register","type","attachQueryUnregister","commandBus","CommandBus","_b","_c","getCommandHandlerMetadata","attachCommandUnregister","isWithIgnoreLifecycle","result","call","then","catch","error","console","name","String","_d","_e","getActivatedHandlerMetadata","onDeactivation","getDeactivationHandlerMetadata","detachWireScopes","detachCommandUnregister","detachQueryUnregister","detachEventSubscription","delete","service","handler","bus","EventBus","EVENT_UNSUBSCRIBERS_BY_SERVICE","subscribe","unsubscribe","list","QUERY_UNREGISTERS_BY_SERVICE","push","list_1","COMMAND_UNREGISTERS_BY_SERVICE","list_2","Service","paramTypes","Reflect","getMetadata","some","WireScope","scopes","Object","getOwnPropertyNames","key","value","constructor","WIRE_SCOPES_BY_SERVICE","scopes_1","scope","isDisposed"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"bind-service.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-service.ts"],"sourcesContent":[null],"names":["bindService","container","entry","options","whenBind","bind","to","inSingletonScope","onActivation","context","instance","IS_DISPOSED","CONTAINER_REFS_BY_SERVICE","set","attachWireScopes","dispatcher","buildEventDispatcher","attachEventsSubscription","queryBus","get","QueryBus","_i","_a","getQueryHandlerMetadata","length","meta","method","methodName","unregister","register","type","attachQueryUnregister","commandBus","CommandBus","_b","_c","getCommandHandlerMetadata","attachCommandUnregister","isWithIgnoreLifecycle","result","call","then","catch","error","console","name","String","_d","_e","getActivatedHandlerMetadata","onDeactivation","getDeactivationHandlerMetadata","detachWireScopes","detachCommandUnregister","detachQueryUnregister","detachEventSubscription","delete","service","handler","bus","EventBus","EVENT_UNSUBSCRIBERS_BY_SERVICE","subscribe","unsubscribe","list","QUERY_UNREGISTERS_BY_SERVICE","push","list_1","COMMAND_UNREGISTERS_BY_SERVICE","list_2","Service","paramTypes","Reflect","getMetadata","some","WireScope","scopes","Object","getOwnPropertyNames","key","value","constructor","WIRE_SCOPES_BY_SERVICE","scopes_1","scope","isDisposed"],"mappings":";;;;;;;;;;;AAyCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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vD,EAAA,GAAA,CAAM,EAAN8D,QAAA,GAAAP,MAAM,EAANvD,oBAAM,EAANA,EAAA,EAAM,EAAE;AAAvB,IAAA,IAAM+D,KAAK,GAAAD,QAAA,CAAA9D,EAAA,CAAA;IACb+D,KAAiC,CAACC,UAAU,GAAG,IAAI;IACnDD,KAAuD,CAACnF,SAAS,GAAG,IAAI;AAC3E,EAAA;AAEAiF,EAAAA,sBAAsB,CAAC1B,MAAM,CAACC,OAAO,CAAC;AACxC;;;;"}
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* For plain service classes the class itself is the token;
|
|
4
|
-
* for descriptors the `id` field is used.
|
|
2
|
+
* Resolves the identifier for a given entry.
|
|
5
3
|
*
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Handles both plain service classes and injectable descriptors:
|
|
6
|
+
* - If `entry` is a class constructor, it is returned as the identifier.
|
|
7
|
+
* - If `entry` is an {@link InjectableDescriptor}, its `id` field is returned.
|
|
8
|
+
*
|
|
9
|
+
* @group Bind
|
|
10
|
+
*
|
|
11
|
+
* @template T - Type of the injectable object.
|
|
12
|
+
*
|
|
13
|
+
* @param entry - Class constructor or descriptor to get the identifier for.
|
|
14
|
+
* @returns Identifier token for Inversify.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* class MyService {}
|
|
19
|
+
*
|
|
20
|
+
* getEntryToken(MyService); // returns MyService
|
|
21
|
+
*
|
|
22
|
+
* getEntryToken({ id: "my-service" }); // returns "my-service"
|
|
23
|
+
* ```
|
|
8
24
|
*/
|
|
9
25
|
function getEntryToken(entry) {
|
|
10
26
|
return typeof entry === "function" ? entry : entry.id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-entry-token.js","sources":["../../../../../../../../src/wirestate-core/bind/get-entry-token.ts"],"sourcesContent":[null],"names":["getEntryToken","entry","id"],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"get-entry-token.js","sources":["../../../../../../../../src/wirestate-core/bind/get-entry-token.ts"],"sourcesContent":[null],"names":["getEntryToken","entry","id"],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,SAAUA,aAAaA,CAA4BC,KAAwC,EAAA;EAC/F,OAAO,OAAOA,KAAK,KAAK,UAAU,GAAGA,KAAK,GAAGA,KAAK,CAACC,EAAE;AACvD;;;;"}
|