@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,11 +1,25 @@
|
|
|
1
|
-
import { SEEDS_TOKEN } from '
|
|
1
|
+
import { SEEDS_TOKEN } from './tokens.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Applies seeds to the container
|
|
5
|
-
* This allows multiple providers to co-exist without wiping each other's seeds.
|
|
4
|
+
* Applies targeted seeds to the container's internal seed map.
|
|
6
5
|
*
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
6
|
+
* @remarks
|
|
7
|
+
* This function updates the existing {@link SeedsMap} instance instead of replacing it.
|
|
8
|
+
* This ensures that multiple providers can co-exist and contribute their own seeds
|
|
9
|
+
* without overwriting each other's data.
|
|
10
|
+
*
|
|
11
|
+
* @group Seeds
|
|
12
|
+
*
|
|
13
|
+
* @param container - The Inversify {@link Container} where seeds should be applied.
|
|
14
|
+
* @param seeds - An array of {@link SeedEntries} to add to the container.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* applySeeds(container, [
|
|
19
|
+
* [UserService, { initialUser: "admin" }],
|
|
20
|
+
* ["API_KEY", "12345"]
|
|
21
|
+
* ]);
|
|
22
|
+
* ```
|
|
9
23
|
*/
|
|
10
24
|
function applySeeds(container, seeds) {
|
|
11
25
|
var existing = container.get(SEEDS_TOKEN);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-seeds.js","sources":["../../../../../../../../src/wirestate-core/seeds/apply-seeds.ts"],"sourcesContent":[null],"names":["applySeeds","container","seeds","existing","get","SEEDS_TOKEN","_i","seeds_1","_a","key","state","set"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"apply-seeds.js","sources":["../../../../../../../../src/wirestate-core/seeds/apply-seeds.ts"],"sourcesContent":[null],"names":["applySeeds","container","seeds","existing","get","SEEDS_TOKEN","_i","seeds_1","_a","key","state","set"],"mappings":";;AASA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAUA,UAAUA,CAACC,SAAoB,EAAEC,KAAkB,EAAA;AACjE,EAAA,IAAMC,QAAQ,GAAaF,SAAS,CAACG,GAAG,CAACC,WAAW,CAAC;AAIrD,EAAA,KAA2B,IAAAC,EAAA,GAAA,CAAK,EAALC,OAAA,GAAAL,KAAK,EAALI,mBAAK,EAALA,EAAA,EAAK,EAAE;AAAvB,IAAA,IAAAE,gBAAY;AAAXC,MAAAA,GAAG,GAAAD,EAAA,CAAA,CAAA,CAAA;AAAEE,MAAAA,KAAK,GAAAF,EAAA,CAAA,CAAA,CAAA;AACpBL,IAAAA,QAAQ,CAACQ,GAAG,CAACF,GAAG,EAAEC,KAAK,CAAC;AAC1B,EAAA;AACF;;;;"}
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import { SEED_TOKEN } from '
|
|
1
|
+
import { SEED_TOKEN } from './tokens.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Rebinds the global shared seed object in the container.
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Unlike targeted seeds, there is only one shared seed object per container.
|
|
8
|
+
* This function uses `rebind` to ensure the new shared seed replaces the previous one.
|
|
9
|
+
* The shared seed is typically used for global configuration or common state.
|
|
10
|
+
*
|
|
11
|
+
* @group Seeds
|
|
12
|
+
*
|
|
13
|
+
* @param container - The Inversify {@link Container} to update.
|
|
14
|
+
* @param seed - The new shared seed object.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* applySharedSeed(container, { theme: "dark", lang: "en" });
|
|
19
|
+
* ```
|
|
8
20
|
*/
|
|
9
21
|
function applySharedSeed(container, seed) {
|
|
10
22
|
container.rebind(SEED_TOKEN).toConstantValue(seed);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-shared-seed.js","sources":["../../../../../../../../src/wirestate-core/seeds/apply-shared-seed.ts"],"sourcesContent":[null],"names":["applySharedSeed","container","seed","rebind","SEED_TOKEN","toConstantValue"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"apply-shared-seed.js","sources":["../../../../../../../../src/wirestate-core/seeds/apply-shared-seed.ts"],"sourcesContent":[null],"names":["applySharedSeed","container","seed","rebind","SEED_TOKEN","toConstantValue"],"mappings":";;AASA;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAUA,eAAeA,CAACC,SAAoB,EAAEC,IAAe,EAAA;EAGnED,SAAS,CAACE,MAAM,CAAYC,UAAU,CAAC,CAACC,eAAe,CAACH,IAAI,CAAC;AAC/D;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unique symbol used as a token for the container-scoped seeds map.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This token is used to bind and resolve the {@link SeedsMap} in the Inversify {@link Container}.
|
|
6
|
+
*
|
|
7
|
+
* @group Seeds
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const seedsMap: SeedsMap = container.get(SEEDS_TOKEN);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
var SEEDS_TOKEN = Symbol("@wirestate/core/seeds");
|
|
15
|
+
/**
|
|
16
|
+
* Unique symbol used as a token for the container-scoped shared seed object.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* This token is used to bind and resolve the global shared seed object in the Inversify {@link Container}.
|
|
20
|
+
*
|
|
21
|
+
* @group Seeds
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const sharedSeed: AnyObject = container.get(SEED_TOKEN);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
var SEED_TOKEN = Symbol("@wirestate/core/seed");
|
|
29
|
+
|
|
30
|
+
export { SEEDS_TOKEN, SEED_TOKEN };
|
|
31
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sources":["../../../../../../../../src/wirestate-core/seeds/tokens.ts"],"sourcesContent":[null],"names":["SEEDS_TOKEN","Symbol","SEED_TOKEN"],"mappings":"AAAA;;;;;;;;;;;;AAYG;IACUA,WAAW,GAAkBC,MAAM,CAAC,uBAAuB;AAExE;;;;;;;;;;;;AAYG;IACUC,UAAU,GAAkBD,MAAM,CAAC,sBAAsB;;;;"}
|
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
import { SEEDS_TOKEN } from '
|
|
1
|
+
import { SEEDS_TOKEN } from './tokens.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Removes specific seeds from the container.
|
|
5
|
-
* Used during provider unmounting to clean up only the entries owned by that provider.
|
|
4
|
+
* Removes specific targeted seeds from the container's internal seed map.
|
|
6
5
|
*
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This is typically called during provider unmounting to ensure that only
|
|
8
|
+
* the seeds owned by that specific provider are removed, leaving other
|
|
9
|
+
* providers' seeds intact.
|
|
10
|
+
*
|
|
11
|
+
* @group Seeds
|
|
12
|
+
*
|
|
13
|
+
* @param container - The Inversify {@link Container} to clean up.
|
|
14
|
+
* @param seeds - The targeted {@link SeedEntries} to remove.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* unapplySeeds(container, [[UserService, { initialUser: "admin" }]]);
|
|
19
|
+
* ```
|
|
9
20
|
*/
|
|
10
21
|
function unapplySeeds(container, seeds) {
|
|
11
22
|
var existing = container.get(SEEDS_TOKEN);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unapply-seeds.js","sources":["../../../../../../../../src/wirestate-core/seeds/unapply-seeds.ts"],"sourcesContent":[null],"names":["unapplySeeds","container","seeds","existing","get","SEEDS_TOKEN","_i","seeds_1","key","delete"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"unapply-seeds.js","sources":["../../../../../../../../src/wirestate-core/seeds/unapply-seeds.ts"],"sourcesContent":[null],"names":["unapplySeeds","container","seeds","existing","get","SEEDS_TOKEN","_i","seeds_1","key","delete"],"mappings":";;AASA;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAUA,YAAYA,CAACC,SAAoB,EAAEC,KAAkB,EAAA;AACnE,EAAA,IAAMC,QAAQ,GAAaF,SAAS,CAACG,GAAG,CAACC,WAAW,CAAC;AAIrD,EAAA,KAAoB,IAAAC,EAAA,GAAA,CAAK,EAALC,OAAA,GAAAL,KAAK,EAALI,mBAAK,EAALA,EAAA,EAAK,EAAE;IAAf,IAAAE,GAAG,GAAAD,OAAA,CAAAD,EAAA,CAAA,CAAA,CAAA,CAAA;AACbH,IAAAA,QAAQ,CAACM,MAAM,CAACD,GAAG,CAAC;AACtB,EAAA;AACF;;;;"}
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { ACTIVATED_HANDLER_METADATA } from '../registry.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Retrieves
|
|
5
|
-
* Returns method names ordered from base to derived class.
|
|
4
|
+
* Retrieves the names of methods decorated with {@link OnActivated} by traversing the prototype chain.
|
|
6
5
|
*
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This utility ensures that handlers are returned in parent-to-child order (base class handlers first),
|
|
8
|
+
* maintaining a predictable initialization sequence for inherited services.
|
|
9
|
+
*
|
|
10
|
+
* @group Service
|
|
9
11
|
* @internal
|
|
12
|
+
*
|
|
13
|
+
* @param instance - The service instance to scan for activation handlers.
|
|
14
|
+
* @returns A read-only array of method names (strings or symbols).
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const methods = getActivatedHandlerMetadata(myService);
|
|
19
|
+
*
|
|
20
|
+
* methods.forEach(methodName => (myService as any)[methodName]());
|
|
21
|
+
* ```
|
|
10
22
|
*/
|
|
11
23
|
function getActivatedHandlerMetadata(instance) {
|
|
12
24
|
var constructor = instance.constructor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-activated-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/service/get-activated-handler-metadata.ts"],"sourcesContent":[null],"names":["getActivatedHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","ACTIVATED_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAMA
|
|
1
|
+
{"version":3,"file":"get-activated-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/service/get-activated-handler-metadata.ts"],"sourcesContent":[null],"names":["getActivatedHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","ACTIVATED_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAUA,2BAA2BA,CAACC,QAAgB,EAAA;AAG1D,EAAA,IAAIC,WAAW,GAAYD,QAAQ,CAACC,WAAW;EAE/C,IAAMC,KAAK,GAAkC,EAAE;AAE/C;AACA,EAAA,OAAO,OAAOD,WAAW,KAAK,UAAU,IAAIA,WAAW,KAAKE,MAAM,IAAIF,WAAW,KAAKG,QAAQ,CAACC,SAAS,EAAE;AACxG,IAAA,IAAMC,GAAG,GAAkCC,0BAA0B,CAACC,GAAG,CAACP,WAAqB,CAAC;AAEhG,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;AAIA;EACA,OAAOC,KAAK,CAACU,OAAO,EAAE,CAACC,IAAI,EAAE;AAC/B;;;;"}
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { DEACTIVATION_HANDLER_METADATA } from '../registry.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Retrieves
|
|
5
|
-
* Returns method names ordered from base to derived class.
|
|
4
|
+
* Retrieves the names of methods decorated with {@link OnDeactivation} by traversing the prototype chain.
|
|
6
5
|
*
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This utility ensures that handlers are returned in parent-to-child order (base class handlers first),
|
|
8
|
+
* maintaining a predictable cleanup sequence for inherited services.
|
|
9
|
+
*
|
|
10
|
+
* @group Service
|
|
9
11
|
* @internal
|
|
12
|
+
*
|
|
13
|
+
* @param instance - The service instance to scan for deactivation handlers.
|
|
14
|
+
* @returns A read-only array of method names (strings or symbols).
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const methods = getDeactivationHandlerMetadata(myService);
|
|
19
|
+
*
|
|
20
|
+
* methods.forEach(methodName => (myService as any)[methodName]());
|
|
21
|
+
* ```
|
|
10
22
|
*/
|
|
11
23
|
function getDeactivationHandlerMetadata(instance) {
|
|
12
24
|
var constructor = instance.constructor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-deactivation-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/service/get-deactivation-handler-metadata.ts"],"sourcesContent":[null],"names":["getDeactivationHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","DEACTIVATION_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAMA
|
|
1
|
+
{"version":3,"file":"get-deactivation-handler-metadata.js","sources":["../../../../../../../../src/wirestate-core/service/get-deactivation-handler-metadata.ts"],"sourcesContent":[null],"names":["getDeactivationHandlerMetadata","instance","constructor","chain","Object","Function","prototype","own","DEACTIVATION_HANDLER_METADATA","get","length","push","getPrototypeOf","reverse","flat"],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAUA,8BAA8BA,CAACC,QAAgB,EAAA;AAG7D,EAAA,IAAIC,WAAW,GAAYD,QAAQ,CAACC,WAAW;EAE/C,IAAMC,KAAK,GAAkC,EAAE;AAE/C;AACA,EAAA,OAAO,OAAOD,WAAW,KAAK,UAAU,IAAIA,WAAW,KAAKE,MAAM,IAAIF,WAAW,KAAKG,QAAQ,CAACC,SAAS,EAAE;AACxG,IAAA,IAAMC,GAAG,GAAkCC,6BAA6B,CAACC,GAAG,CAACP,WAAqB,CAAC;AAEnG,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;;;;"}
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import { ACTIVATED_HANDLER_METADATA } from '../registry.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Decorator for service methods that
|
|
4
|
+
* Decorator for service methods that should be executed after the service instance is activated.
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
6
|
+
* @remarks
|
|
7
|
+
* Methods decorated with `@OnActivated` are automatically invoked when the service
|
|
8
|
+
* is resolved from the container and its activation lifecycle hook is triggered.
|
|
9
|
+
*
|
|
10
|
+
* It is commonly used for initial setup, subscribing to events, or starting background tasks.
|
|
11
|
+
* Multiple `@OnActivated` methods can exist in the same class hierarchy; they are executed
|
|
12
|
+
* in parent-to-child order.
|
|
13
|
+
*
|
|
14
|
+
* @group Service
|
|
15
|
+
*
|
|
16
|
+
* @returns A method decorator function.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* class MyService {
|
|
21
|
+
* @OnActivated()
|
|
22
|
+
* public onActivated(): void {
|
|
23
|
+
* console.log("Service activated!");
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
7
27
|
*/
|
|
8
28
|
function OnActivated() {
|
|
9
29
|
return function (target, propertyKey) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-activated.js","sources":["../../../../../../../../src/wirestate-core/service/on-activated.ts"],"sourcesContent":[null],"names":["OnActivated","target","propertyKey","constructor","list","ACTIVATED_HANDLER_METADATA","get","set","push"],"mappings":";;AAMA
|
|
1
|
+
{"version":3,"file":"on-activated.js","sources":["../../../../../../../../src/wirestate-core/service/on-activated.ts"],"sourcesContent":[null],"names":["OnActivated","target","propertyKey","constructor","list","ACTIVATED_HANDLER_METADATA","get","set","push"],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;SACaA,WAAWA,GAAA;AACzB,EAAA,OAAO,UAACC,MAAM,EAAEC,WAAW,EAAA;AAQzB,IAAA,IAAMC,WAAW,GAAIF,MAAiB,CAACE,WAAW;AAElD,IAAA,IAAIC,IAAI,GAAkCC,0BAA0B,CAACC,GAAG,CAACH,WAAW,CAAC;IAErF,IAAI,CAACC,IAAI,EAAE;AACTA,MAAAA,IAAI,GAAG,EAAE;AACTC,MAAAA,0BAA0B,CAACE,GAAG,CAACJ,WAAW,EAAEC,IAAI,CAAC;AACnD,IAAA;AAEAA,IAAAA,IAAI,CAACI,IAAI,CAACN,WAAW,CAAC;EACxB,CAAC;AACH;;;;"}
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import { DEACTIVATION_HANDLER_METADATA } from '../registry.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Decorator for service methods that
|
|
4
|
+
* Decorator for service methods that should be executed before the service instance is deactivated.
|
|
5
5
|
*
|
|
6
|
-
* @
|
|
6
|
+
* @remarks
|
|
7
|
+
* Methods decorated with `@OnDeactivation` are automatically invoked when the service
|
|
8
|
+
* is being removed from the container or when the container itself is being disposed.
|
|
9
|
+
*
|
|
10
|
+
* It is commonly used for cleanup, unsubscribing from events, or stopping background tasks.
|
|
11
|
+
* Multiple `@OnDeactivation` methods can exist in the same class hierarchy; they are executed
|
|
12
|
+
* in parent-to-child order.
|
|
13
|
+
*
|
|
14
|
+
* @group Service
|
|
15
|
+
*
|
|
16
|
+
* @returns A method decorator function.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* class MyService {
|
|
21
|
+
* @OnDeactivation()
|
|
22
|
+
* public onDeactivation(): void {
|
|
23
|
+
* console.log("Service deactivating!");
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
7
27
|
*/
|
|
8
28
|
function OnDeactivation() {
|
|
9
29
|
return function (target, propertyKey) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-deactivation.js","sources":["../../../../../../../../src/wirestate-core/service/on-deactivation.ts"],"sourcesContent":[null],"names":["OnDeactivation","target","propertyKey","constructor","list","DEACTIVATION_HANDLER_METADATA","get","set","push"],"mappings":";;AAMA
|
|
1
|
+
{"version":3,"file":"on-deactivation.js","sources":["../../../../../../../../src/wirestate-core/service/on-deactivation.ts"],"sourcesContent":[null],"names":["OnDeactivation","target","propertyKey","constructor","list","DEACTIVATION_HANDLER_METADATA","get","set","push"],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;SACaA,cAAcA,GAAA;AAC5B,EAAA,OAAO,UAACC,MAAM,EAAEC,WAAW,EAAA;AAQzB,IAAA,IAAMC,WAAW,GAAIF,MAAiB,CAACE,WAAW;AAElD,IAAA,IAAIC,IAAI,GAAkCC,6BAA6B,CAACC,GAAG,CAACH,WAAW,CAAC;IAExF,IAAI,CAACC,IAAI,EAAE;AACTA,MAAAA,IAAI,GAAG,EAAE;AACTC,MAAAA,6BAA6B,CAACE,GAAG,CAACJ,WAAW,EAAEC,IAAI,CAAC;AACtD,IAAA;AAEAA,IAAAA,IAAI,CAACI,IAAI,CAACN,WAAW,CAAC;EACxB,CAAC;AACH;;;;"}
|
|
@@ -2,20 +2,30 @@ import { bindEntry } from '../bind/bind-entry.js';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Binds a service entry to the IoC container for testing purposes.
|
|
5
|
-
* This utility uses {@link bindEntry} internally.
|
|
6
|
-
* It supports both service classes and injectable descriptors (constants, dynamic values, etc.).
|
|
7
5
|
*
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This utility is a testing wrapper for {@link bindEntry}.
|
|
8
|
+
* It supports both service classes and {@link InjectableDescriptor} objects.
|
|
9
|
+
*
|
|
10
|
+
* @group Test-utils
|
|
11
|
+
*
|
|
12
|
+
* @template T - The type of the service being bound.
|
|
13
|
+
*
|
|
14
|
+
* @param container - The Inversify {@link Container} to bind the entry to.
|
|
15
|
+
* @param entry - The service class constructor or {@link InjectableDescriptor} to bind.
|
|
16
|
+
* @param options - Configuration options for the mock binding.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* mockBindEntry(container, UserService, { skipLifecycle: true });
|
|
21
|
+
* ```
|
|
12
22
|
*/
|
|
13
23
|
function mockBindEntry(container, entry, options) {
|
|
14
24
|
if (options === void 0) {
|
|
15
25
|
options = {};
|
|
16
26
|
}
|
|
17
27
|
var skipLifecycle = options.skipLifecycle;
|
|
18
|
-
|
|
28
|
+
bindEntry(container, entry, {
|
|
19
29
|
isWithIgnoreLifecycle: skipLifecycle
|
|
20
30
|
});
|
|
21
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-bind-entry.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-bind-entry.ts"],"sourcesContent":[null],"names":["mockBindEntry","container","entry","options","skipLifecycle","bindEntry","isWithIgnoreLifecycle"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"mock-bind-entry.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-bind-entry.ts"],"sourcesContent":[null],"names":["mockBindEntry","container","entry","options","skipLifecycle","bindEntry","isWithIgnoreLifecycle"],"mappings":";;AAuBA;;;;;;;;;;;;;;;;;;;AAmBG;SACaA,aAAaA,CAC3BC,SAAoB,EACpBC,KAAwC,EACxCC,OAAkC,EAAA;AAAlC,EAAA,IAAAA,OAAA,KAAA,MAAA,EAAA;IAAAA,OAAA,GAAA,EAAkC;AAAA,EAAA;AAE1B,EAAA,IAAAC,aAAa,GAAKD,OAAO,CAAAC,aAAZ;AAErBC,EAAAA,SAAS,CAACJ,SAAS,EAAEC,KAAK,EAAE;AAC1BI,IAAAA,qBAAqB,EAAEF;AACxB,GAAA,CAAC;AACJ;;;;"}
|
|
@@ -2,20 +2,30 @@ import { bindService } from '../bind/bind-service.js';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Binds a service class to the IoC container for testing purposes.
|
|
5
|
-
* This utility uses {@link bindService} internally to ensure the service is correctly registered
|
|
6
|
-
* with the appropriate scope and metadata.
|
|
7
5
|
*
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This utility is a testing wrapper for {@link bindService}.
|
|
8
|
+
* It ensures the service is correctly registered with singleton scope and lifecycle metadata.
|
|
9
|
+
*
|
|
10
|
+
* @group Test-utils
|
|
11
|
+
*
|
|
12
|
+
* @template T - The type of the service being bound.
|
|
13
|
+
*
|
|
14
|
+
* @param container - The Inversify {@link Container} to bind the service to.
|
|
15
|
+
* @param ServiceClass - The service class constructor to bind.
|
|
16
|
+
* @param options - Configuration options for the mock binding.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* mockBindService(container, AnalyticsService);
|
|
21
|
+
* ```
|
|
12
22
|
*/
|
|
13
23
|
function mockBindService(container, ServiceClass, options) {
|
|
14
24
|
if (options === void 0) {
|
|
15
25
|
options = {};
|
|
16
26
|
}
|
|
17
27
|
var skipLifecycle = options.skipLifecycle;
|
|
18
|
-
|
|
28
|
+
bindService(container, ServiceClass, {
|
|
19
29
|
isWithIgnoreLifecycle: skipLifecycle
|
|
20
30
|
});
|
|
21
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-bind-service.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-bind-service.ts"],"sourcesContent":[null],"names":["mockBindService","container","ServiceClass","options","skipLifecycle","bindService","isWithIgnoreLifecycle"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"mock-bind-service.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-bind-service.ts"],"sourcesContent":[null],"names":["mockBindService","container","ServiceClass","options","skipLifecycle","bindService","isWithIgnoreLifecycle"],"mappings":";;AAqBA;;;;;;;;;;;;;;;;;;;AAmBG;SACaA,eAAeA,CAC7BC,SAAoB,EACpBC,YAAwB,EACxBC,OAAoC,EAAA;AAApC,EAAA,IAAAA,OAAA,KAAA,MAAA,EAAA;IAAAA,OAAA,GAAA,EAAoC;AAAA,EAAA;AAE5B,EAAA,IAAAC,aAAa,GAAKD,OAAO,CAAAC,aAAZ;AAErBC,EAAAA,WAAW,CAACJ,SAAS,EAAEC,YAAY,EAAE;AACnCI,IAAAA,qBAAqB,EAAEF;AACxB,GAAA,CAAC;AACJ;;;;"}
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
import { getEntryToken } from '../bind/get-entry-token.js';
|
|
2
|
-
import {
|
|
2
|
+
import { createContainer } from '../container/create-container.js';
|
|
3
3
|
import { ERROR_CODE_INVALID_ARGUMENTS } from '../error/error-code.js';
|
|
4
4
|
import { WirestateError } from '../error/wirestate-error.js';
|
|
5
5
|
import { mockBindEntry } from './mock-bind-entry.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* This utility initializes a new container and binds the provided services or descriptors using {@link mockBindEntry}.
|
|
10
|
-
* It also supports optional immediate activation of services.
|
|
8
|
+
* Mocks and configures an Inversify {@link Container} for testing.
|
|
11
9
|
*
|
|
12
|
-
* @
|
|
13
|
-
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* This utility initializes a new container via {@link createContainer} and
|
|
12
|
+
* binds the provided `entries` using {@link mockBindEntry}. It can also
|
|
13
|
+
* automatically resolve (activate) a subset of services.
|
|
14
14
|
*
|
|
15
|
-
* @
|
|
15
|
+
* @group Test-utils
|
|
16
|
+
*
|
|
17
|
+
* @param options - Configuration options for the mock container.
|
|
18
|
+
* @returns A configured Inversify {@link Container}.
|
|
19
|
+
*
|
|
20
|
+
* @throws {WirestateError} If an identifier in `activate` is not found in `entries`.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const container: Container = mockContainer({
|
|
25
|
+
* entries: [UserService, AuthService],
|
|
26
|
+
* activate: [AuthService]
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
16
29
|
*/
|
|
17
30
|
function mockContainer(options) {
|
|
18
31
|
if (options === void 0) {
|
|
@@ -34,7 +47,11 @@ function mockContainer(options) {
|
|
|
34
47
|
}
|
|
35
48
|
}
|
|
36
49
|
}
|
|
37
|
-
var container =
|
|
50
|
+
var container = createContainer({
|
|
51
|
+
parent: options.parent,
|
|
52
|
+
seeds: options.seeds,
|
|
53
|
+
seed: options.seed
|
|
54
|
+
});
|
|
38
55
|
for (var _c = 0, entries_1 = entries; _c < entries_1.length; _c++) {
|
|
39
56
|
var it_1 = entries_1[_c];
|
|
40
57
|
mockBindEntry(container, it_1, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-container.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-container.ts"],"sourcesContent":[null],"names":["mockContainer","options","_a","activate","_b","entries","skipLifecycle","length","serviceTokens","map","s","getEntryToken","_i","activate_1","token","includes","WirestateError","ERROR_CODE_INVALID_ARGUMENTS","container","
|
|
1
|
+
{"version":3,"file":"mock-container.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-container.ts"],"sourcesContent":[null],"names":["mockContainer","options","_a","activate","_b","entries","skipLifecycle","length","serviceTokens","map","s","getEntryToken","_i","activate_1","token","includes","WirestateError","ERROR_CODE_INVALID_ARGUMENTS","container","createContainer","parent","seeds","seed","_c","entries_1","it_1","mockBindEntry","_d","activate_2","it_2","get"],"mappings":";;;;;;AA8DA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACG,SAAUA,aAAaA,CAACC,OAAkC,EAAA;AAAlC,EAAA,IAAAA,OAAA,KAAA,MAAA,EAAA;IAAAA,OAAA,GAAA,EAAkC;AAAA,EAAA;AACtD,EAAA,IAAAC,EAAA,GAA+CD,OAAO,CAAAE,QAAzC;IAAbA,QAAQ,GAAAD,EAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,EAAA;IAAEE,EAAA,GAAgCH,OAAO,QAA3B;IAAZI,OAAO,mBAAG,EAAE,GAAAD,EAAA;IAAEE,aAAa,GAAKL,OAAO,CAAAK,aAAZ;EAElD,IAAIH,QAAQ,CAACI,MAAM,EAAE;IACnB,IAAMC,aAAa,GAA6BH,OAAO,CAACI,GAAG,CAAC,UAACC,CAAC,EAAA;MAAK,OAAAC,aAAa,CAACD,CAAC,CAAC;AAAhB,IAAA,CAAgB,CAAC;AAEpF,IAAA,KAAoB,IAAAE,EAAA,GAAA,CAAQ,EAARC,UAAA,GAAAV,QAAQ,EAARS,sBAAQ,EAARA,EAAA,EAAQ,EAAE;AAAzB,MAAA,IAAME,KAAK,GAAAD,UAAA,CAAAD,EAAA,CAAA;AACd,MAAA,IAAI,CAACJ,aAAa,CAACO,QAAQ,CAACD,KAAK,CAAC,EAAE;AAClC,QAAA,MAAM,IAAIE,cAAc,CACtBC,4BAA4B,EAC5B,yEAAyE,CAC1E;AACH,MAAA;AACF,IAAA;AACF,EAAA;EAEA,IAAMC,SAAS,GAAcC,eAAe,CAAC;IAAEC,MAAM,EAAEnB,OAAO,CAACmB,MAAM;IAAEC,KAAK,EAAEpB,OAAO,CAACoB,KAAK;IAAEC,IAAI,EAAErB,OAAO,CAACqB;AAAI,GAAE,CAAC;AAElH,EAAA,KAAiB,IAAAC,EAAA,GAAA,CAAO,EAAPC,SAAA,GAAAnB,OAAO,EAAPkB,qBAAO,EAAPA,EAAA,EAAO,EAAE;AAArB,IAAA,IAAME,IAAE,GAAAD,SAAA,CAAAD,EAAA,CAAA;AACXG,IAAAA,aAAa,CAACR,SAAS,EAAEO,IAAE,EAAE;AAAEnB,MAAAA,aAAa,EAAEA;AAAa,KAAE,CAAC;AAChE,EAAA;AAEA,EAAA,KAAiB,IAAAqB,EAAA,GAAA,CAAQ,EAARC,UAAA,GAAAzB,QAAQ,EAARwB,sBAAQ,EAARA,EAAA,EAAQ,EAAE;AAAtB,IAAA,IAAME,IAAE,GAAAD,UAAA,CAAAD,EAAA,CAAA;AACXT,IAAAA,SAAS,CAACY,GAAG,CAACD,IAAE,CAAC;AACnB,EAAA;AAEA,EAAA,OAAOX,SAAS;AAClB;;;;"}
|
|
@@ -2,12 +2,25 @@ import { mockBindService } from './mock-bind-service.js';
|
|
|
2
2
|
import { mockContainer } from './mock-container.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Mocks a service by binding it to an IoC container and returning its instance.
|
|
5
|
+
* Mocks a service by binding it to an IoC container and returning its resolved instance.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This is a high-level utility that combines {@link mockContainer} and {@link mockBindService}.
|
|
9
|
+
* If no container is provided, a fresh one is created.
|
|
10
|
+
*
|
|
11
|
+
* @group Test-utils
|
|
12
|
+
*
|
|
13
|
+
* @template T - The type of the service being mocked.
|
|
14
|
+
*
|
|
15
|
+
* @param service - The service class constructor to mock.
|
|
16
|
+
* @param container - The Inversify container to use (defaults to a new mock container).
|
|
17
|
+
* @param options - Additional options for mocking.
|
|
18
|
+
* @returns The resolved service instance.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const service: MyService = mockService(MyService);
|
|
23
|
+
* ```
|
|
11
24
|
*/
|
|
12
25
|
function mockService(service, container, options) {
|
|
13
26
|
if (container === void 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-service.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-service.ts"],"sourcesContent":[null],"names":["mockService","service","container","options","mockContainer","mockBindService","skipLifecycle","get"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"mock-service.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-service.ts"],"sourcesContent":[null],"names":["mockService","service","container","options","mockContainer","mockBindService","skipLifecycle","get"],"mappings":";;;AAmBA;;;;;;;;;;;;;;;;;;;;AAoBG;SACaA,WAAWA,CACzBC,OAAmB,EACnBC,SAA2B,EAC3BC,OAAgC,EAAA;AADhC,EAAA,IAAAD,SAAA,KAAA,MAAA,EAAA;IAAAA,SAAA,GAAYE,aAAa,EAAE;AAAA,EAAA;AAC3B,EAAA,IAAAD,OAAA,KAAA,MAAA,EAAA;IAAAA,OAAA,GAAA,EAAgC;AAAA,EAAA;AAEhCE,EAAAA,eAAe,CAACH,SAAS,EAAED,OAAO,EAAE;IAClCK,aAAa,EAAEH,OAAO,CAACG;AACxB,GAAA,CAAC;AAEF,EAAA,OAAOJ,SAAS,CAACK,GAAG,CAACN,OAAO,CAAM;AACpC;;;;"}
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Unbinds a service from the IoC container.
|
|
3
|
-
* This is useful in tests to reset or override specific service registrations.
|
|
4
3
|
*
|
|
5
|
-
* @
|
|
6
|
-
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This is a convenience wrapper for `container.unbind`.
|
|
6
|
+
* It is useful in tests to reset or override specific service registrations
|
|
7
|
+
* between test cases.
|
|
8
|
+
*
|
|
9
|
+
* @group Test-utils
|
|
10
|
+
*
|
|
11
|
+
* @template T - The type of the service to unbind.
|
|
12
|
+
*
|
|
13
|
+
* @param container - The Inversify {@link Container} to unbind from.
|
|
14
|
+
* @param ServiceClass - The service class constructor to unbind.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* mockUnbindService(container, LegacyService);
|
|
19
|
+
* ```
|
|
7
20
|
*/
|
|
8
21
|
function mockUnbindService(container, ServiceClass) {
|
|
9
22
|
container.unbind(ServiceClass);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-unbind-service.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-unbind-service.ts"],"sourcesContent":[null],"names":["mockUnbindService","container","ServiceClass","unbind"],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"mock-unbind-service.js","sources":["../../../../../../../../src/wirestate-core/test-utils/mock-unbind-service.ts"],"sourcesContent":[null],"names":["mockUnbindService","container","ServiceClass","unbind"],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAUA,iBAAiBA,CAAmBC,SAAoB,EAAEC,YAAwB,EAAA;AAChGD,EAAAA,SAAS,CAACE,MAAM,CAACD,YAAY,CAAC;AAChC;;;;"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Represents the current state of a command execution.
|
|
3
|
+
*
|
|
4
|
+
* @group Commands
|
|
3
5
|
*/
|
|
4
6
|
var CommandStatus;
|
|
5
7
|
(function (CommandStatus) {
|
|
8
|
+
/** The command task has started but not yet completed. */
|
|
6
9
|
CommandStatus["PENDING"] = "pending";
|
|
10
|
+
/** The command task has successfully completed. */
|
|
7
11
|
CommandStatus["SETTLED"] = "settled";
|
|
12
|
+
/** The command task failed with an error. */
|
|
8
13
|
CommandStatus["ERROR"] = "error";
|
|
9
14
|
})(CommandStatus || (CommandStatus = {}));
|
|
10
15
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sources":["../../../../../../../../src/wirestate-core/types/commands.ts"],"sourcesContent":[null],"names":["CommandStatus"],"mappings":"
|
|
1
|
+
{"version":3,"file":"commands.js","sources":["../../../../../../../../src/wirestate-core/types/commands.ts"],"sourcesContent":[null],"names":["CommandStatus"],"mappings":"AAmEA;;;;AAIG;IACSA;AAAZ,CAAA,UAAYA,aAAa,EAAA;AACvB;AACAA,EAAAA,aAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB;AACAA,EAAAA,aAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB;AACAA,EAAAA,aAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACjB,CAAC,EAPWA,aAAa,KAAbA,aAAa,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/esm/production/alias.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LazyServiceIdentifier as e}from"inversify";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";function n(n){return new e(n)}export{n as forwardRef};//# sourceMappingURL=alias.js.map
|
|
1
|
+
import{LazyServiceIdentifier as e}from"inversify";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";function n(n){return new e(n)}export{n as forwardRef};//# sourceMappingURL=alias.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alias.js","sources":["../../../../../../../src/wirestate-core/alias.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"alias.js","sources":["../../../../../../../src/wirestate-core/alias.ts"],"sourcesContent":[null],"names":["LazyServiceIdentifier","bindingTypeValues","Container","ContainerModule","inject","injectFromBase","injectFromHierarchy","injectable","multiInject","named","optional","postConstruct","preDestroy","bindingScopeValues","tagged","unmanaged","forwardRef","forward"],"mappings":"gCAgFAA,MAAA,mBAAAC,iCAAAC,UAAAC,gBAAAC,iBAAAC,iCAAAC,2CAAAC,yBAAAP,sBAAAQ,2BAAAC,eAAAC,qBAAAC,+BAAAC,yBAAAC,uCAAAC,iBAAAC,uBAAAF,mBAAAZ,sBAAA,YASM,SAAUe,EACdC,GAEA,OAAO,IAAIjB,EAAsBiB,EACnC,QAAAD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bindingScopeValues as r}from"inversify";import{ERROR_CODE_BINDING_SCOPE as e}from"../error/error-code.js";import{WirestateError as o}from"../error/wirestate-error.js";function
|
|
1
|
+
import{bindingScopeValues as r}from"inversify";import{ERROR_CODE_BINDING_SCOPE as e}from"../error/error-code.js";import{WirestateError as o}from"../error/wirestate-error.js";function n(n,i){if(i.scopeBindingType&&i.scopeBindingType!==r.Singleton)throw new o(e,"Provided unexpected binding scope for constant value.");return n.bind(i.id).toConstantValue(i.value)}export{n as bindConstant};//# sourceMappingURL=bind-constant.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-constant.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-constant.ts"],"sourcesContent":[null],"names":["bindingScopeValues","ERROR_CODE_BINDING_SCOPE","WirestateError","bindConstant","container","entry","scopeBindingType","ScopeBindingType","Singleton","bind","id","toConstantValue","value"],"mappings":"6BAUAA,MAAA,+CAAAC,MAAA,kDAAAC,MAAA,
|
|
1
|
+
{"version":3,"file":"bind-constant.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-constant.ts"],"sourcesContent":[null],"names":["bindingScopeValues","ERROR_CODE_BINDING_SCOPE","WirestateError","bindConstant","container","entry","scopeBindingType","ScopeBindingType","Singleton","bind","id","toConstantValue","value"],"mappings":"6BAUAA,MAAA,+CAAAC,MAAA,kDAAAC,MAAA,8BA2BM,SAAUC,EAAgBC,EAAsBC,GAQpD,GAAIA,EAAMC,kBAAoBD,EAAMC,mBAAqBC,EAAiBC,UACxE,MAAM,IAAIN,EAAeD,EAA0B,yDAGrD,OAAOG,EAAUK,KAAQJ,EAAMK,IAA4BC,gBAAgBN,EAAMO,MACnF,QAAAT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bindingScopeValues as n}from"inversify";function e(e,i){var o=e.bind(i.id).toDynamicValue((function(){return i.factory?i.factory():i.value}));i.scopeBindingType
|
|
1
|
+
import{bindingScopeValues as n}from"inversify";function e(e,i){var o=e.bind(i.id).toDynamicValue((function(){return i.factory?i.factory():i.value}));return i.scopeBindingType?i.scopeBindingType===n.Transient?o.inTransientScope():i.scopeBindingType===n.Request?o.inRequestScope():o.inSingletonScope():o}export{e as bindDynamicValue};//# sourceMappingURL=bind-dynamic-value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-dynamic-value.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-dynamic-value.ts"],"sourcesContent":[null],"names":["bindingScopeValues","bindDynamicValue","container","entry","binding","bind","id","toDynamicValue","factory","value","scopeBindingType","Transient","inTransientScope","Request","inRequestScope","inSingletonScope"],"mappings":"6BAOAA,MAAA,
|
|
1
|
+
{"version":3,"file":"bind-dynamic-value.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-dynamic-value.ts"],"sourcesContent":[null],"names":["bindingScopeValues","bindDynamicValue","container","entry","binding","bind","id","toDynamicValue","factory","value","scopeBindingType","Transient","inTransientScope","Request","inRequestScope","inSingletonScope"],"mappings":"6BAOAA,MAAA,YA0BM,SAAUC,EAAoBC,EAAsBC,GAMxD,IAAMC,EAAuCF,EAAUG,KAAKF,EAAMG,IAAIC,gBAAe,WACnF,OAAIJ,EAAMK,QACDL,EAAMK,UAGRL,EAAMM,KACf,IAEA,OAAKN,EAAMO,iBAEAP,EAAMO,mBAAqBV,EAAmBW,UAChDP,EAAQQ,mBACNT,EAAMO,mBAAqBV,EAAmBa,QAChDT,EAAQU,iBAERV,EAAQW,mBANRX,CAQX,QAAAH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bindingTypeValues as i}from"inversify";import{bindConstant as n}from"./bind-constant.js";import{bindDynamicValue as o}from"./bind-dynamic-value.js";import{bindService as e}from"./bind-service.js";function
|
|
1
|
+
import{bindingTypeValues as i}from"inversify";import{bindConstant as n}from"./bind-constant.js";import{bindDynamicValue as o}from"./bind-dynamic-value.js";import{bindService as e}from"./bind-service.js";function t(t,r,m){void 0===m&&(m={}),"function"!=typeof r?r.bindingType&&r.bindingType!==i.ConstantValue?r.bindingType!==i.DynamicValue?e(t,r.value,m):o(t,r):n(t,r):e(t,r,m)}export{t as bindEntry};//# sourceMappingURL=bind-entry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind-entry.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-entry.ts"],"sourcesContent":[null],"names":["bindingTypeValues","bindConstant","bindDynamicValue","bindService","bindEntry","container","entry","options","bindingType","ConstantValue","DynamicValue","value"],"mappings":"
|
|
1
|
+
{"version":3,"file":"bind-entry.js","sources":["../../../../../../../../src/wirestate-core/bind/bind-entry.ts"],"sourcesContent":[null],"names":["bindingTypeValues","bindConstant","bindDynamicValue","bindService","bindEntry","container","entry","options","bindingType","ConstantValue","DynamicValue","value"],"mappings":"4BA0BAA,MAAA,mCAAAC,MAAA,gDAAAC,MAAA,gDAAAC,MAAA,6BA6CgBC,EACdC,EACAC,EACAC,QAAA,IAAAA,IAAAA,EAAA,CAAA,GAEqB,mBAAVD,EAMNA,EAAME,aAAeF,EAAME,cAAgBR,EAAkBS,cAM9DH,EAAME,cAAgBR,EAAkBU,aAiB5CP,EAAYE,EAAWC,EAAMK,MAAgCJ,GAX3DL,EAAiBG,EAAWC,GAX5BL,EAAaI,EAAWC,GANxBH,EAAYE,EAAWC,EAAOC,EA6BlC,QAAAH"}
|