@inversifyjs/core 3.4.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/lib/cjs/binding/models/BaseBinding.d.ts +2 -2
- package/lib/cjs/binding/models/BaseBinding.d.ts.map +1 -1
- package/lib/cjs/binding/models/Binding.d.ts +2 -1
- package/lib/cjs/binding/models/Binding.d.ts.map +1 -1
- package/lib/cjs/binding/models/{BindingMetadata.d.ts → BindingConstraints.d.ts} +3 -3
- package/lib/cjs/binding/models/BindingConstraints.d.ts.map +1 -0
- package/lib/cjs/binding/models/{BindingMetadata.js → BindingConstraints.js} +1 -1
- package/lib/cjs/binding/models/BindingConstraints.js.map +1 -0
- package/lib/cjs/binding/models/{BindingMetadataImplementation.d.ts → BindingConstraintsImplementation.d.ts} +7 -7
- package/lib/cjs/binding/models/BindingConstraintsImplementation.d.ts.map +1 -0
- package/lib/cjs/binding/models/{BindingMetadataImplementation.js → BindingConstraintsImplementation.js} +8 -8
- package/lib/cjs/binding/models/BindingConstraintsImplementation.js.map +1 -0
- package/lib/cjs/binding/models/BindingConstraintsImplementation.spec.d.ts +2 -0
- package/lib/cjs/binding/models/BindingConstraintsImplementation.spec.d.ts.map +1 -0
- package/lib/cjs/binding/models/BindingType.d.ts +1 -1
- package/lib/cjs/binding/models/BindingType.d.ts.map +1 -1
- package/lib/cjs/binding/models/BindingType.js +1 -0
- package/lib/cjs/binding/models/BindingType.js.map +1 -1
- package/lib/cjs/binding/models/ResolvedValueBinding.d.ts +9 -0
- package/lib/cjs/binding/models/ResolvedValueBinding.d.ts.map +1 -0
- package/lib/cjs/binding/models/ResolvedValueBinding.js +3 -0
- package/lib/cjs/binding/models/ResolvedValueBinding.js.map +1 -0
- package/lib/cjs/binding/models/ScopedBinding.d.ts +2 -2
- package/lib/cjs/binding/models/ScopedBinding.d.ts.map +1 -1
- package/lib/cjs/index.d.ts +8 -3
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/metadata/models/BaseResolvedValueElementMetadata.d.ts +4 -0
- package/lib/cjs/metadata/models/BaseResolvedValueElementMetadata.d.ts.map +1 -0
- package/lib/cjs/metadata/models/BaseResolvedValueElementMetadata.js +3 -0
- package/lib/cjs/metadata/models/BaseResolvedValueElementMetadata.js.map +1 -0
- package/lib/cjs/metadata/models/ResolvedValueElementMetadata.d.ts +12 -0
- package/lib/cjs/metadata/models/ResolvedValueElementMetadata.d.ts.map +1 -0
- package/lib/cjs/metadata/models/ResolvedValueElementMetadata.js +3 -0
- package/lib/cjs/metadata/models/ResolvedValueElementMetadata.js.map +1 -0
- package/lib/cjs/metadata/models/ResolvedValueElementMetadataKind.d.ts +5 -0
- package/lib/cjs/metadata/models/ResolvedValueElementMetadataKind.d.ts.map +1 -0
- package/lib/cjs/metadata/models/ResolvedValueElementMetadataKind.js +9 -0
- package/lib/cjs/metadata/models/ResolvedValueElementMetadataKind.js.map +1 -0
- package/lib/cjs/metadata/models/ResolvedValueMetadata.d.ts +5 -0
- package/lib/cjs/metadata/models/ResolvedValueMetadata.d.ts.map +1 -0
- package/lib/cjs/metadata/models/ResolvedValueMetadata.js +3 -0
- package/lib/cjs/metadata/models/ResolvedValueMetadata.js.map +1 -0
- package/lib/cjs/planning/calculations/buildFilteredServiceBindings.d.ts +2 -2
- package/lib/cjs/planning/calculations/buildFilteredServiceBindings.d.ts.map +1 -1
- package/lib/cjs/planning/calculations/buildFilteredServiceBindings.js +3 -3
- package/lib/cjs/planning/calculations/buildFilteredServiceBindings.js.map +1 -1
- package/lib/cjs/planning/calculations/checkPlanServiceRedirectionBindingNodeSingleInjectionBindings.d.ts +2 -2
- package/lib/cjs/planning/calculations/checkPlanServiceRedirectionBindingNodeSingleInjectionBindings.d.ts.map +1 -1
- package/lib/cjs/planning/calculations/checkPlanServiceRedirectionBindingNodeSingleInjectionBindings.js +3 -3
- package/lib/cjs/planning/calculations/checkPlanServiceRedirectionBindingNodeSingleInjectionBindings.js.map +1 -1
- package/lib/cjs/planning/calculations/checkServiceNodeSingleInjectionBindings.d.ts +2 -2
- package/lib/cjs/planning/calculations/checkServiceNodeSingleInjectionBindings.d.ts.map +1 -1
- package/lib/cjs/planning/calculations/checkServiceNodeSingleInjectionBindings.js +3 -3
- package/lib/cjs/planning/calculations/checkServiceNodeSingleInjectionBindings.js.map +1 -1
- package/lib/cjs/planning/calculations/isInstanceBindingNode.d.ts +4 -0
- package/lib/cjs/planning/calculations/isInstanceBindingNode.d.ts.map +1 -0
- package/lib/cjs/planning/calculations/isInstanceBindingNode.js +8 -0
- package/lib/cjs/planning/calculations/isInstanceBindingNode.js.map +1 -0
- package/lib/cjs/planning/calculations/isInstanceBindingNode.spec.d.ts +2 -0
- package/lib/cjs/planning/calculations/isInstanceBindingNode.spec.d.ts.map +1 -0
- package/lib/cjs/planning/calculations/plan.d.ts.map +1 -1
- package/lib/cjs/planning/calculations/plan.js +89 -27
- package/lib/cjs/planning/calculations/plan.js.map +1 -1
- package/lib/cjs/planning/calculations/throwErrorWhenUnexpectedBindingsAmountFound.d.ts +2 -2
- package/lib/cjs/planning/calculations/throwErrorWhenUnexpectedBindingsAmountFound.d.ts.map +1 -1
- package/lib/cjs/planning/calculations/throwErrorWhenUnexpectedBindingsAmountFound.js +16 -16
- package/lib/cjs/planning/calculations/throwErrorWhenUnexpectedBindingsAmountFound.js.map +1 -1
- package/lib/cjs/planning/models/PlanServiceNodeParent.d.ts +3 -1
- package/lib/cjs/planning/models/PlanServiceNodeParent.d.ts.map +1 -1
- package/lib/cjs/planning/models/ResolvedValueBindingNode.d.ts +7 -0
- package/lib/cjs/planning/models/ResolvedValueBindingNode.d.ts.map +1 -0
- package/lib/cjs/planning/models/ResolvedValueBindingNode.js +3 -0
- package/lib/cjs/planning/models/ResolvedValueBindingNode.js.map +1 -0
- package/lib/cjs/resolution/actions/cacheResolvedValue.d.ts +6 -0
- package/lib/cjs/resolution/actions/cacheResolvedValue.d.ts.map +1 -0
- package/lib/cjs/resolution/actions/cacheResolvedValue.js +18 -0
- package/lib/cjs/resolution/actions/cacheResolvedValue.js.map +1 -0
- package/lib/cjs/resolution/actions/cacheResolvedValue.spec.d.ts +2 -0
- package/lib/cjs/resolution/actions/cacheResolvedValue.spec.d.ts.map +1 -0
- package/lib/cjs/resolution/actions/resolve.d.ts.map +1 -1
- package/lib/cjs/resolution/actions/resolve.js +9 -0
- package/lib/cjs/resolution/actions/resolve.js.map +1 -1
- package/lib/cjs/resolution/actions/resolveResolvedValueBindingNode.d.ts +6 -0
- package/lib/cjs/resolution/actions/resolveResolvedValueBindingNode.d.ts.map +1 -0
- package/lib/cjs/resolution/actions/resolveResolvedValueBindingNode.js +14 -0
- package/lib/cjs/resolution/actions/resolveResolvedValueBindingNode.js.map +1 -0
- package/lib/cjs/resolution/actions/resolveResolvedValueBindingNode.spec.d.ts +2 -0
- package/lib/cjs/resolution/actions/resolveResolvedValueBindingNode.spec.d.ts.map +1 -0
- package/lib/cjs/resolution/actions/resolveResolvedValueBindingParams.d.ts +6 -0
- package/lib/cjs/resolution/actions/resolveResolvedValueBindingParams.d.ts.map +1 -0
- package/lib/cjs/resolution/actions/resolveResolvedValueBindingParams.js +16 -0
- package/lib/cjs/resolution/actions/resolveResolvedValueBindingParams.js.map +1 -0
- package/lib/cjs/resolution/actions/resolveResolvedValueBindingParams.spec.d.ts +2 -0
- package/lib/cjs/resolution/actions/resolveResolvedValueBindingParams.spec.d.ts.map +1 -0
- package/lib/cjs/resolution/actions/resolveScoped.d.ts.map +1 -1
- package/lib/cjs/resolution/actions/resolveScoped.js +5 -11
- package/lib/cjs/resolution/actions/resolveScoped.js.map +1 -1
- package/lib/cjs/resolution/actions/resolveScopedResolvedValueBindingNode.d.ts +6 -0
- package/lib/cjs/resolution/actions/resolveScopedResolvedValueBindingNode.d.ts.map +1 -0
- package/lib/cjs/resolution/actions/resolveScopedResolvedValueBindingNode.js +8 -0
- package/lib/cjs/resolution/actions/resolveScopedResolvedValueBindingNode.js.map +1 -0
- package/lib/cjs/resolution/actions/resolveSingletonScopedBinding.d.ts.map +1 -1
- package/lib/cjs/resolution/actions/resolveSingletonScopedBinding.js +2 -5
- package/lib/cjs/resolution/actions/resolveSingletonScopedBinding.js.map +1 -1
- package/lib/cjs/resolution/calculations/getResolvedValueNodeBinding.d.ts +4 -0
- package/lib/cjs/resolution/calculations/getResolvedValueNodeBinding.d.ts.map +1 -0
- package/lib/cjs/resolution/calculations/getResolvedValueNodeBinding.js +7 -0
- package/lib/cjs/resolution/calculations/getResolvedValueNodeBinding.js.map +1 -0
- package/lib/cjs/resolution/calculations/getResolvedValueNodeBinding.spec.d.ts +2 -0
- package/lib/cjs/resolution/calculations/getResolvedValueNodeBinding.spec.d.ts.map +1 -0
- package/lib/esm/index.d.ts +37 -8
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/package.json +6 -6
- package/lib/cjs/binding/models/BindingMetadata.d.ts.map +0 -1
- package/lib/cjs/binding/models/BindingMetadata.js.map +0 -1
- package/lib/cjs/binding/models/BindingMetadataImplementation.d.ts.map +0 -1
- package/lib/cjs/binding/models/BindingMetadataImplementation.js.map +0 -1
- package/lib/cjs/binding/models/BindingMetadataImplementation.spec.d.ts +0 -2
- package/lib/cjs/binding/models/BindingMetadataImplementation.spec.d.ts.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveResolvedValueBindingParams = resolveResolvedValueBindingParams;
|
|
4
|
+
const common_1 = require("@inversifyjs/common");
|
|
5
|
+
function resolveResolvedValueBindingParams(resolveServiceNode) {
|
|
6
|
+
return (params, node) => {
|
|
7
|
+
const paramsResolvedValues = [];
|
|
8
|
+
for (const param of node.params) {
|
|
9
|
+
paramsResolvedValues.push(resolveServiceNode(params, param));
|
|
10
|
+
}
|
|
11
|
+
return paramsResolvedValues.some(common_1.isPromise)
|
|
12
|
+
? Promise.all(paramsResolvedValues)
|
|
13
|
+
: paramsResolvedValues;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=resolveResolvedValueBindingParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveResolvedValueBindingParams.js","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveResolvedValueBindingParams.ts"],"names":[],"mappings":";;AAOA,8EA2BC;AAlCD,gDAAgD;AAOhD,SAAgB,iCAAiC,CAK/C,kBAGY;IAKZ,OAAO,CACL,MAAwB,EACxB,IAAwC,EACR,EAAE;QAClC,MAAM,oBAAoB,GAAc,EAAE,CAAC;QAE3C,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChC,oBAAoB,CAAC,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QAC/D,CAAC;QAED,OAAO,oBAAoB,CAAC,IAAI,CAAC,kBAAS,CAAC;YACzC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;YACnC,CAAC,CAAC,oBAAoB,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveResolvedValueBindingParams.spec.d.ts","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveResolvedValueBindingParams.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveScoped.d.ts","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveScoped.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEb,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveScoped.d.ts","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveScoped.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEb,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAI9C,wBAAgB,aAAa,CAC3B,UAAU,EACV,IAAI,EACJ,KAAK,SAAS,WAAW,EAEzB,QAAQ,SAAS,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,CAAC,EAE/D,UAAU,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,QAAQ,EACnC,OAAO,EAAE,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,IAAI,KAAK,QAAQ,CAAC,UAAU,CAAC,GACrE,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,IAAI,KAAK,QAAQ,CAAC,UAAU,CAAC,CA6C/D"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveScoped = resolveScoped;
|
|
4
4
|
const BindingScope_1 = require("../../binding/models/BindingScope");
|
|
5
|
+
const cacheResolvedValue_1 = require("./cacheResolvedValue");
|
|
5
6
|
const resolveBindingActivations_1 = require("./resolveBindingActivations");
|
|
6
7
|
function resolveScoped(getBinding, resolve) {
|
|
7
8
|
return (params, arg) => {
|
|
@@ -11,27 +12,20 @@ function resolveScoped(getBinding, resolve) {
|
|
|
11
12
|
if (binding.cache.isRight) {
|
|
12
13
|
return binding.cache.value;
|
|
13
14
|
}
|
|
14
|
-
const resolvedValue =
|
|
15
|
-
binding
|
|
16
|
-
isRight: true,
|
|
17
|
-
value: resolvedValue,
|
|
18
|
-
};
|
|
19
|
-
return resolvedValue;
|
|
15
|
+
const resolvedValue = (0, resolveBindingActivations_1.resolveBindingActivations)(params, binding, resolve(params, arg));
|
|
16
|
+
return (0, cacheResolvedValue_1.cacheResolvedValue)(binding, resolvedValue);
|
|
20
17
|
}
|
|
21
18
|
case BindingScope_1.bindingScopeValues.Request: {
|
|
22
19
|
if (params.requestScopeCache.has(binding.id)) {
|
|
23
20
|
return params.requestScopeCache.get(binding.id);
|
|
24
21
|
}
|
|
25
|
-
const resolvedValue =
|
|
22
|
+
const resolvedValue = (0, resolveBindingActivations_1.resolveBindingActivations)(params, binding, resolve(params, arg));
|
|
26
23
|
params.requestScopeCache.set(binding.id, resolvedValue);
|
|
27
24
|
return resolvedValue;
|
|
28
25
|
}
|
|
29
26
|
case BindingScope_1.bindingScopeValues.Transient:
|
|
30
|
-
return
|
|
27
|
+
return (0, resolveBindingActivations_1.resolveBindingActivations)(params, binding, resolve(params, arg));
|
|
31
28
|
}
|
|
32
29
|
};
|
|
33
30
|
}
|
|
34
|
-
function resolveAndActivate(params, arg, binding, resolve) {
|
|
35
|
-
return (0, resolveBindingActivations_1.resolveBindingActivations)(params, binding, resolve(params, arg));
|
|
36
|
-
}
|
|
37
31
|
//# sourceMappingURL=resolveScoped.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveScoped.js","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveScoped.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"resolveScoped.js","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveScoped.ts"],"names":[],"mappings":";;AAWA,sCAsDC;AAjED,oEAG2C;AAK3C,6DAA0D;AAC1D,2EAAwE;AAExE,SAAgB,aAAa,CAO3B,UAAmC,EACnC,OAAsE;IAEtE,OAAO,CAAC,MAAwB,EAAE,GAAS,EAAwB,EAAE;QACnE,MAAM,OAAO,GAAa,UAAU,CAAC,GAAG,CAAC,CAAC;QAE1C,QAAQ,OAAO,CAAC,KAAK,EAAE,CAAC;YACtB,KAAK,iCAAkB,CAAC,SAAS,CAAC,CAAC,CAAC;gBAClC,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;oBAC1B,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;gBAC7B,CAAC;gBAED,MAAM,aAAa,GACjB,IAAA,qDAAyB,EACvB,MAAM,EACN,OAAO,EACP,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CACrB,CAAC;gBAEJ,OAAO,IAAA,uCAAkB,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YACpD,CAAC;YACD,KAAK,iCAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;gBAChC,IAAI,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;oBAC7C,OAAO,MAAM,CAAC,iBAAiB,CAAC,GAAG,CACjC,OAAO,CAAC,EAAE,CACa,CAAC;gBAC5B,CAAC;gBAED,MAAM,aAAa,GACjB,IAAA,qDAAyB,EACvB,MAAM,EACN,OAAO,EACP,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CACrB,CAAC;gBAEJ,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;gBAExD,OAAO,aAAa,CAAC;YACvB,CAAC;YACD,KAAK,iCAAkB,CAAC,SAAS;gBAC/B,OAAO,IAAA,qDAAyB,EAC9B,MAAM,EACN,OAAO,EACP,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CACrB,CAAC;QACN,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ResolvedValueBinding } from '../../binding/models/ResolvedValueBinding';
|
|
2
|
+
import { ResolvedValueBindingNode } from '../../planning/models/ResolvedValueBindingNode';
|
|
3
|
+
import { ResolutionParams } from '../models/ResolutionParams';
|
|
4
|
+
import { Resolved } from '../models/Resolved';
|
|
5
|
+
export declare const resolveScopedResolvedValueBindingNode: <TActivated>(resolve: (params: ResolutionParams, node: ResolvedValueBindingNode<ResolvedValueBinding<TActivated>>) => Resolved<TActivated>) => (params: ResolutionParams, node: ResolvedValueBindingNode<ResolvedValueBinding<TActivated>>) => Resolved<TActivated>;
|
|
6
|
+
//# sourceMappingURL=resolveScopedResolvedValueBindingNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveScopedResolvedValueBindingNode.d.ts","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveScopedResolvedValueBindingNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAE1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C,eAAO,MAAM,qCAAqC,EAAE,CAAC,UAAU,EAC7D,OAAO,EAAE,CACP,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,wBAAwB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,KAC7D,QAAQ,CAAC,UAAU,CAAC,KACtB,CACH,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,wBAAwB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,KAC7D,QAAQ,CAAC,UAAU,CAKgC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveScopedResolvedValueBindingNode = void 0;
|
|
4
|
+
const getResolvedValueNodeBinding_1 = require("../calculations/getResolvedValueNodeBinding");
|
|
5
|
+
const resolveScoped_1 = require("./resolveScoped");
|
|
6
|
+
const resolveScopedResolvedValueBindingNode = (resolve) => (0, resolveScoped_1.resolveScoped)(getResolvedValueNodeBinding_1.getResolvedValueNodeBinding, resolve);
|
|
7
|
+
exports.resolveScopedResolvedValueBindingNode = resolveScopedResolvedValueBindingNode;
|
|
8
|
+
//# sourceMappingURL=resolveScopedResolvedValueBindingNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveScopedResolvedValueBindingNode.js","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveScopedResolvedValueBindingNode.ts"],"names":[],"mappings":";;;AAEA,6FAA0F;AAG1F,mDAAgD;AAEzC,MAAM,qCAAqC,GAQtB,CAC1B,OAGyB,EACzB,EAAE,CAAC,IAAA,6BAAa,EAAC,yDAA2B,EAAE,OAAO,CAAC,CAAC;AAb5C,QAAA,qCAAqC,yCAaO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveSingletonScopedBinding.d.ts","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveSingletonScopedBinding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveSingletonScopedBinding.d.ts","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveSingletonScopedBinding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAI9C,wBAAgB,6BAA6B,CAC3C,UAAU,EACV,KAAK,SAAS,WAAW,EACzB,QAAQ,SAAS,aAAa,CAC5B,KAAK,EACL,OAAO,kBAAkB,CAAC,SAAS,EACnC,UAAU,CACX,EAED,OAAO,EAAE,CACP,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,QAAQ,KACd,QAAQ,CAAC,UAAU,CAAC,GACxB,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,KAAK,QAAQ,CAAC,UAAU,CAAC,CAiBvE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveSingletonScopedBinding = resolveSingletonScopedBinding;
|
|
4
|
+
const cacheResolvedValue_1 = require("./cacheResolvedValue");
|
|
4
5
|
const resolveBindingActivations_1 = require("./resolveBindingActivations");
|
|
5
6
|
function resolveSingletonScopedBinding(resolve) {
|
|
6
7
|
return (params, binding) => {
|
|
@@ -8,11 +9,7 @@ function resolveSingletonScopedBinding(resolve) {
|
|
|
8
9
|
return binding.cache.value;
|
|
9
10
|
}
|
|
10
11
|
const resolvedValue = (0, resolveBindingActivations_1.resolveBindingActivations)(params, binding, resolve(params, binding));
|
|
11
|
-
binding
|
|
12
|
-
isRight: true,
|
|
13
|
-
value: resolvedValue,
|
|
14
|
-
};
|
|
15
|
-
return resolvedValue;
|
|
12
|
+
return (0, cacheResolvedValue_1.cacheResolvedValue)(binding, resolvedValue);
|
|
16
13
|
};
|
|
17
14
|
}
|
|
18
15
|
//# sourceMappingURL=resolveSingletonScopedBinding.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveSingletonScopedBinding.js","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveSingletonScopedBinding.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"resolveSingletonScopedBinding.js","sourceRoot":"","sources":["../../../../src/resolution/actions/resolveSingletonScopedBinding.ts"],"names":[],"mappings":";;AAQA,sEA8BC;AAjCD,6DAA0D;AAC1D,2EAAwE;AAExE,SAAgB,6BAA6B,CAS3C,OAGyB;IAEzB,OAAO,CACL,MAAwB,EACxB,OAAiB,EACK,EAAE;QACxB,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YAC1B,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;QAC7B,CAAC;QAED,MAAM,aAAa,GAAyB,IAAA,qDAAyB,EACnE,MAAM,EACN,OAAO,EACP,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CACzB,CAAC;QAEF,OAAO,IAAA,uCAAkB,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IACpD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ResolvedValueBinding } from '../../binding/models/ResolvedValueBinding';
|
|
2
|
+
import { ResolvedValueBindingNode } from '../../planning/models/ResolvedValueBindingNode';
|
|
3
|
+
export declare function getResolvedValueNodeBinding<TActivated>(node: ResolvedValueBindingNode<ResolvedValueBinding<TActivated>>): ResolvedValueBinding<TActivated>;
|
|
4
|
+
//# sourceMappingURL=getResolvedValueNodeBinding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getResolvedValueNodeBinding.d.ts","sourceRoot":"","sources":["../../../../src/resolution/calculations/getResolvedValueNodeBinding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAE1F,wBAAgB,2BAA2B,CAAC,UAAU,EACpD,IAAI,EAAE,wBAAwB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,GAC/D,oBAAoB,CAAC,UAAU,CAAC,CAElC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getResolvedValueNodeBinding = getResolvedValueNodeBinding;
|
|
4
|
+
function getResolvedValueNodeBinding(node) {
|
|
5
|
+
return node.binding;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=getResolvedValueNodeBinding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getResolvedValueNodeBinding.js","sourceRoot":"","sources":["../../../../src/resolution/calculations/getResolvedValueNodeBinding.ts"],"names":[],"mappings":";;AAGA,kEAIC;AAJD,SAAgB,2BAA2B,CACzC,IAAgE;IAEhE,OAAO,IAAI,CAAC,OAAO,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getResolvedValueNodeBinding.spec.d.ts","sourceRoot":"","sources":["../../../../src/resolution/calculations/getResolvedValueNodeBinding.spec.ts"],"names":[],"mappings":""}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -4,14 +4,14 @@ type MetadataName = number | string | symbol;
|
|
|
4
4
|
|
|
5
5
|
type MetadataTag = number | string | symbol;
|
|
6
6
|
|
|
7
|
-
interface
|
|
7
|
+
interface BindingConstraints {
|
|
8
8
|
readonly name: MetadataName | undefined;
|
|
9
9
|
readonly tags: Map<MetadataTag, unknown>;
|
|
10
10
|
readonly serviceIdentifier: ServiceIdentifier;
|
|
11
|
-
getAncestor():
|
|
11
|
+
getAncestor(): BindingConstraints | undefined;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
type BindingType = 'ConstantValue' | 'DynamicValue' | 'Factory' | 'Instance' | 'Provider' | 'ServiceRedirection';
|
|
14
|
+
type BindingType = 'ConstantValue' | 'DynamicValue' | 'Factory' | 'Instance' | 'Provider' | 'ResolvedValue' | 'ServiceRedirection';
|
|
15
15
|
declare const bindingTypeValues: {
|
|
16
16
|
[TKey in BindingType]: TKey;
|
|
17
17
|
};
|
|
@@ -21,7 +21,7 @@ interface BaseBinding<TType extends BindingType, TActivated> {
|
|
|
21
21
|
readonly moduleId: number | undefined;
|
|
22
22
|
readonly serviceIdentifier: ServiceIdentifier<TActivated>;
|
|
23
23
|
readonly type: TType;
|
|
24
|
-
isSatisfiedBy(
|
|
24
|
+
isSatisfiedBy(constraints: BindingConstraints): boolean;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
type Resolved<TActivated> = SyncResolved<TActivated> | Promise<SyncResolved<TActivated>>;
|
|
@@ -62,7 +62,7 @@ type BindingActivation<T = unknown> = (context: ResolutionContext, injectable: T
|
|
|
62
62
|
type BindingDeactivation<T = unknown> = (injectable: T) => void | Promise<void>;
|
|
63
63
|
|
|
64
64
|
interface ScopedBinding<TType extends BindingType, TScope extends BindingScope, TActivated> extends BaseBinding<TType, TActivated> {
|
|
65
|
-
cache: Either<undefined,
|
|
65
|
+
cache: Either<undefined, SyncResolved<TActivated>>;
|
|
66
66
|
readonly onActivation: BindingActivation<TActivated> | undefined;
|
|
67
67
|
readonly onDeactivation: BindingDeactivation<TActivated> | undefined;
|
|
68
68
|
readonly scope: TScope;
|
|
@@ -94,11 +94,36 @@ interface ProviderBinding<TActivated extends Provider<unknown>> extends ScopedBi
|
|
|
94
94
|
readonly provider: (context: ResolutionContext) => TActivated;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
interface BaseResolvedValueElementMetadata<TKind> {
|
|
98
|
+
kind: TKind;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
declare enum ResolvedValueElementMetadataKind {
|
|
102
|
+
multipleInjection = 0,
|
|
103
|
+
singleInjection = 1
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface ResolvedValueElementMetadata extends BaseResolvedValueElementMetadata<ResolvedValueElementMetadataKind> {
|
|
107
|
+
name: MetadataName | undefined;
|
|
108
|
+
optional: boolean;
|
|
109
|
+
tags: Map<MetadataTag, unknown>;
|
|
110
|
+
value: ServiceIdentifier | LazyServiceIdentifier;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface ResolvedValueMetadata {
|
|
114
|
+
arguments: ResolvedValueElementMetadata[];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
interface ResolvedValueBinding<TActivated> extends ScopedBinding<typeof bindingTypeValues.ResolvedValue, BindingScope, TActivated> {
|
|
118
|
+
readonly factory: (...args: any[]) => TActivated | Promise<TActivated>;
|
|
119
|
+
readonly metadata: ResolvedValueMetadata;
|
|
120
|
+
}
|
|
121
|
+
|
|
97
122
|
interface ServiceRedirectionBinding<TActivated> extends BaseBinding<typeof bindingTypeValues.ServiceRedirection, TActivated> {
|
|
98
123
|
targetServiceIdentifier: ServiceIdentifier;
|
|
99
124
|
}
|
|
100
125
|
|
|
101
|
-
type Binding<TActivated = any> = ConstantValueBinding<TActivated> | DynamicValueBinding<TActivated> | (TActivated extends Factory<unknown> ? FactoryBinding<TActivated> : never) | InstanceBinding<TActivated> | (TActivated extends Provider<unknown> ? ProviderBinding<TActivated> : never) | ServiceRedirectionBinding<TActivated>;
|
|
126
|
+
type Binding<TActivated = any> = ConstantValueBinding<TActivated> | DynamicValueBinding<TActivated> | (TActivated extends Factory<unknown> ? FactoryBinding<TActivated> : never) | InstanceBinding<TActivated> | (TActivated extends Provider<unknown> ? ProviderBinding<TActivated> : never) | ResolvedValueBinding<TActivated> | ServiceRedirectionBinding<TActivated>;
|
|
102
127
|
|
|
103
128
|
interface Cloneable<T> {
|
|
104
129
|
clone(): T;
|
|
@@ -269,7 +294,11 @@ interface InstanceBindingNode<TBinding extends InstanceBinding<any> = InstanceBi
|
|
|
269
294
|
readonly propertyParams: Map<string | symbol, PlanServiceNode>;
|
|
270
295
|
}
|
|
271
296
|
|
|
272
|
-
|
|
297
|
+
interface ResolvedValueBindingNode<TBinding extends ResolvedValueBinding<any> = ResolvedValueBinding<any>> extends BaseBindingNode<TBinding> {
|
|
298
|
+
readonly params: PlanServiceNode[];
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
type PlanServiceNodeParent<TActivated = any> = InstanceBindingNode<InstanceBinding<TActivated>> | ResolvedValueBindingNode<ResolvedValueBinding<TActivated>>;
|
|
273
302
|
|
|
274
303
|
type PlanBindingNode = PlanServiceNodeParent | PlanServiceRedirectionBindingNode | LeafBindingNode;
|
|
275
304
|
|
|
@@ -339,4 +368,4 @@ declare function resolveModuleDeactivations(params: DeactivationParams, moduleId
|
|
|
339
368
|
|
|
340
369
|
declare function resolveServiceDeactivations(params: DeactivationParams, serviceIdentifier: ServiceIdentifier): void | Promise<void>;
|
|
341
370
|
|
|
342
|
-
export { ActivationsService, type BaseBinding, type BaseBindingNode, type BasePlanParams, type Binding, type BindingActivation, type BindingActivationRelation, type
|
|
371
|
+
export { ActivationsService, type BaseBinding, type BaseBindingNode, type BasePlanParams, type Binding, type BindingActivation, type BindingActivationRelation, type BindingConstraints, type BindingDeactivation, type BindingDeactivationRelation, type BindingScope, BindingService, type BindingType, type ClassElementMetadata, ClassElementMetadataKind, type ClassMetadata, type ClassMetadataLifecycle, type ConstantValueBinding, type DeactivationParams, DeactivationsService, type DynamicValueBinding, type DynamicValueBuilder, type Factory, type FactoryBinding, type GetOptions, type GetOptionsTagConstraint, type GetPlanOptions, type InstanceBinding, type LeafBindingNode, type ManagedClassElementMetadata, type MetadataName, type MetadataTag, type OptionalGetOptions, type PlanBindingNode, type PlanParams, type PlanParamsConstraint, type PlanParamsTagConstraint, type PlanResult, PlanResultCacheService, type PlanServiceNode, type PlanServiceNodeParent, type PlanServiceRedirectionBindingNode, type PlanTree, type Provider, type ProviderBinding, type ResolutionContext, type ResolutionParams, type Resolved, type ResolvedValueBinding, type ResolvedValueBindingNode, type ResolvedValueElementMetadata, ResolvedValueElementMetadataKind, type ResolvedValueMetadata, type ScopedBinding, type ServiceRedirectionBinding, type UnmanagedClassElementMetadata, bindingScopeValues, bindingTypeValues, decorate, getClassMetadata, inject, injectFromBase, injectable, multiInject, named, optional, plan, postConstruct, preDestroy, resolve, resolveModuleDeactivations, resolveServiceDeactivations, tagged, unmanaged };
|
package/lib/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getOwnReflectMetadata as e,updateOwnReflectMetadata as t,setReflectMetadata as n}from"@inversifyjs/reflect-metadata-utils";import{getBaseType as i}from"@inversifyjs/prototype-utils";import{stringifyServiceIdentifier as o,LazyServiceIdentifier as r,isPromise as a}from"@inversifyjs/common";const s={Request:"Request",Singleton:"Singleton",Transient:"Transient"},c={ConstantValue:"ConstantValue",DynamicValue:"DynamicValue",Factory:"Factory",Instance:"Instance",Provider:"Provider",ServiceRedirection:"ServiceRedirection"};function*u(...e){for(const t of e)yield*t}class d{#e;#t;#n;constructor(e){this.#e=new Map,this.#t={};for(const t of Reflect.ownKeys(e))this.#t[t]=new Map;this.#n=e}add(e,t){this.#i(e).push(t);for(const n of Reflect.ownKeys(t))this.#o(n,t[n]).push(e)}clone(){const e=Reflect.ownKeys(this.#n),t=new d(this.#n);this.#r(this.#e,t.#e);for(const n of e)this.#r(this.#t[n],t.#t[n]);return t}get(e,t){return this.#t[e].get(t)}getAllKeys(e){return this.#t[e].keys()}removeByRelation(e,t){const n=this.get(e,t);if(void 0===n)return;const i=new Set(n);for(const n of i){const i=this.#e.get(n);if(void 0===i)throw new Error("Expecting model relation, none found");for(const o of i)o[e]===t&&this.#a(n,o);this.#e.delete(n)}}#i(e){let t=this.#e.get(e);return void 0===t&&(t=[],this.#e.set(e,t)),t}#o(e,t){let n=this.#t[e].get(t);return void 0===n&&(n=[],this.#t[e].set(t,n)),n}#r(e,t){for(const[n,i]of e)t.set(n,[...i])}#a(e,t){for(const n of Reflect.ownKeys(t))this.#s(e,n,t[n])}#s(e,t,n){const i=this.#t[t].get(n);if(void 0!==i){const o=i.indexOf(e);-1!==o&&i.splice(o,1),0===i.length&&this.#t[t].delete(n)}}}var l,p,f;!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(l||(l={}));class g{#c;#u;constructor(e,t){this.#c=t??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#u=e}static build(e){return new g(e)}add(e,t){this.#c.add(e,t)}clone(){return new g(this.#u,this.#c.clone())}get(e){const t=[],n=this.#c.get(l.serviceId,e);void 0!==n&&t.push(n);const i=this.#u?.get(e);if(void 0!==i&&t.push(i),0!==t.length)return u(...t)}removeAllByModuleId(e){this.#c.removeByRelation(l.moduleId,e)}removeAllByServiceId(e){this.#c.removeByRelation(l.serviceId,e)}}!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(p||(p={}));class m{#d;#u;constructor(e,t){this.#d=t??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#u=e}static build(e){return new m(e)}clone(){return new m(this.#u,this.#d.clone())}get(e){return this.getNonParentBindings(e)??this.#u?.get(e)}getNonParentBindings(e){return this.#d.get(p.serviceId,e)}getNonParentBoundServices(){return this.#d.getAllKeys(p.serviceId)}getByModuleId(e){return this.#d.get(p.moduleId,e)??this.#u?.getByModuleId(e)}removeAllByModuleId(e){this.#d.removeByRelation(p.moduleId,e)}removeAllByServiceId(e){this.#d.removeByRelation(p.serviceId,e)}set(e){const t={[p.serviceId]:e.serviceIdentifier};void 0!==e.moduleId&&(t[p.moduleId]=e.moduleId),this.#d.add(e,t)}}!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(f||(f={}));class h{#l;#u;constructor(e,t){this.#l=t??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#u=e}static build(e){return new h(e)}add(e,t){this.#l.add(e,t)}clone(){return new h(this.#u,this.#l.clone())}get(e){const t=[],n=this.#l.get(f.serviceId,e);void 0!==n&&t.push(n);const i=this.#u?.get(e);if(void 0!==i&&t.push(i),0!==t.length)return u(...t)}removeAllByModuleId(e){this.#l.removeByRelation(f.moduleId,e)}removeAllByServiceId(e){this.#l.removeByRelation(f.serviceId,e)}}function v(e,t,n){const i=Array.isArray(e)?e:[e];if(void 0!==n)if("number"!=typeof n)Reflect.decorate(i,t.prototype,n);else for(const e of i)e(t,void 0,n);else Reflect.decorate(i,t)}const y="@inversifyjs/core/classMetadataReflectKey";function M(){return{constructorArguments:[],lifecycle:{postConstructMethodName:void 0,preDestroyMethodName:void 0},properties:new Map,scope:void 0}}const I="@inversifyjs/core/pendingClassMetadataCountReflectKey";const w=Symbol.for("@inversifyjs/core/InversifyCoreError");class b extends Error{[w];kind;constructor(e,t,n){super(t,n),this[w]=!0,this.kind=e}static is(e){return"object"==typeof e&&null!==e&&!0===e[w]}static isErrorOfKind(e,t){return b.is(e)&&e.kind===t}}var j,T,S;function C(t){const n=e(t,y)??M();if(!function(t){const n=e(t,I);return void 0!==n&&0!==n}(t))return function(e,t){const n=[];if(t.length<e.length)throw new b(j.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}". "${e.name}" constructor requires at least ${e.length.toString()} arguments, found ${t.length.toString()} instead.\nAre you using @inject, @multiInject or @unmanaged decorators in every non optional constructor argument?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`);for(let e=0;e<t.length;++e)void 0===t[e]&&n.push(e);if(n.length>0)throw new b(j.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}" at constructor indexes "${n.join('", "')}".\n\nAre you using @inject, @multiInject or @unmanaged decorators at those indexes?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`)}(t,n.constructorArguments),n;!function(e,t){const n=[];for(let i=0;i<t.constructorArguments.length;++i){const o=t.constructorArguments[i];void 0!==o&&o.kind!==T.unknown||n.push(` - Missing or incomplete metadata for type "${e.name}" at constructor argument with index ${i.toString()}.\nEvery constructor parameter must be decorated either with @inject, @multiInject or @unmanaged decorator.`)}for(const[i,o]of t.properties)o.kind===T.unknown&&n.push(` - Missing or incomplete metadata for type "${e.name}" at property "${i.toString()}".\nThis property must be decorated either with @inject or @multiInject decorator.`);if(0===n.length)throw new b(j.unknown,`Unexpected class metadata for type "${e.name}" with uncompletion traces.\nThis might be caused by one of the following reasons:\n\n1. A third party library is targeting inversify reflection metadata.\n2. A bug is causing the issue. Consider submiting an issue to fix it.`);throw new b(j.missingInjectionDecorator,`Invalid class metadata at type ${e.name}:\n\n${n.join("\n\n")}`)}(t,n)}function A(){return 0}function $(e){return n=>{void 0!==n&&n.kind===T.unknown&&t(e,I,A,(e=>e-1))}}function x(e,t){return(...n)=>i=>{if(void 0===i)return e(...n);if(i.kind===S.unmanaged)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found");return t(i,...n)}}function R(e){if(e.kind!==T.unknown&&!0!==e.isFromTypescriptParamType)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found")}!function(e){e[e.injectionDecoratorConflict=0]="injectionDecoratorConflict",e[e.missingInjectionDecorator=1]="missingInjectionDecorator",e[e.planning=2]="planning",e[e.resolution=3]="resolution",e[e.unknown=4]="unknown"}(j||(j={})),function(e){e[e.unknown=32]="unknown"}(T||(T={})),function(e){e[e.multipleInjection=0]="multipleInjection",e[e.singleInjection=1]="singleInjection",e[e.unmanaged=2]="unmanaged"}(S||(S={}));const B=x((function(e,t){return{kind:e,name:void 0,optional:!1,tags:new Map,value:t}}),(function(e,t,n){return R(e),{...e,kind:t,value:n}}));function k(e,t){return n=>{const i=n.properties.get(t);return n.properties.set(t,e(i)),n}}var D;function P(e,t,n,i){if(b.isErrorOfKind(i,j.injectionDecoratorConflict)){const o=function(e,t,n){if(void 0===n){if(void 0===t)throw new b(j.unknown,"Unexpected undefined property and index values");return{kind:D.property,property:t,targetClass:e.constructor}}return"number"==typeof n?{index:n,kind:D.parameter,targetClass:e}:{kind:D.method,method:t,targetClass:e}}(e,t,n);throw new b(j.injectionDecoratorConflict,`Unexpected injection error.\n\nCause:\n\n${i.message}\n\nDetails\n\n${function(e){switch(e.kind){case D.method:return`[class: "${e.targetClass.name}", method: "${e.method.toString()}"]`;case D.parameter:return`[class: "${e.targetClass.name}", index: "${e.index.toString()}"]`;case D.property:return`[class: "${e.targetClass.name}", property: "${e.property.toString()}"]`}}(o)}`,{cause:i})}throw i}function F(e,n){return(i,o,r)=>{try{void 0===r?function(e,n){const i=V(e,n);return(e,n)=>{t(e.constructor,y,M,k(i(e),n))}}(e,n)(i,o):"number"==typeof r?function(e,n){const i=V(e,n);return(e,n,o)=>{if(!function(e,t){return"function"==typeof e&&void 0===t}(e,n))throw new b(j.injectionDecoratorConflict,`Found an @inject decorator in a non constructor parameter.\nFound @inject decorator at method "${n?.toString()??""}" at class "${e.constructor.name}"`);t(e,y,M,function(e,t){return n=>{const i=n.constructorArguments[t];return n.constructorArguments[t]=e(i),n}}(i(e),o))}}(e,n)(i,o,r):function(e,n){const i=V(e,n);return(e,n,o)=>{if(!function(e){return void 0!==e.set}(o))throw new b(j.injectionDecoratorConflict,`Found an @inject decorator in a non setter property method.\nFound @inject decorator at method "${n.toString()}" at class "${e.constructor.name}"`);t(e.constructor,y,M,k(i(e),n))}}(e,n)(i,o,r)}catch(e){P(i,o,r,e)}}}function V(e,t){return n=>{const i=t(n);return t=>(i(t),e(t))}}function O(e){return F(B(S.singleInjection,e),$)}!function(e){e[e.method=0]="method",e[e.parameter=1]="parameter",e[e.property=2]="property"}(D||(D={}));const N="@inversifyjs/core/classIsInjectableFlagReflectKey";const E=[Array,BigInt,Boolean,Function,Number,Object,String];function U(n){const i=e(n,"design:paramtypes");void 0!==i&&t(n,y,M,function(e){return t=>(e.forEach(((e,n)=>{var i;void 0!==t.constructorArguments[n]||(i=e,E.includes(i))||(t.constructorArguments[n]=function(e){return{isFromTypescriptParamType:!0,kind:S.singleInjection,name:void 0,optional:!1,tags:new Map,value:e}}(e))})),t)}(i))}function K(i){return o=>{!function(t){if(void 0!==e(t,N))throw new b(j.injectionDecoratorConflict,`Cannot apply @injectable decorator multiple times at class "${t.name}"`);n(t,N,!0)}(o),U(o),void 0!==i&&t(o,y,M,(e=>({...e,scope:i})))}}function q(e,t,n){let i;return e.extendConstructorArguments??!0?(i=[...t.constructorArguments],n.constructorArguments.map(((e,t)=>{i[t]=e}))):i=n.constructorArguments,i}function z(e,t,n){let i;return i=e.extendProperties??!0?new Map(u(t.properties,n.properties)):n.properties,i}function G(e){return n=>{const i=C(e.type);t(n,y,M,function(e,t){const n=n=>({constructorArguments:q(e,t,n),lifecycle:n.lifecycle,properties:z(e,t,n),scope:n.scope});return n}(e,i))}}function H(e){return t=>{const n=i(t);if(void 0===n)throw new b(j.injectionDecoratorConflict,`Expected base type for type "${t.name}", none found.`);G({...e,type:n})(t)}}function J(e){return F(B(S.multipleInjection,e),$)}function L(e){return n=>{void 0===n&&t(e,I,A,(e=>e+1))}}function Q(e){return t=>{const n=t??{kind:T.unknown,name:void 0,optional:!1,tags:new Map};if(n.kind===S.unmanaged)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return e(n)}}function W(e){const t=Q(function(e){return t=>{if(void 0!==t.name)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated named decorator");return t.name=e,t}}(e));return F(t,L)}function X(e){if(e.optional)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated optional decorator");return e.optional=!0,e}function Y(){return F(Q(X),L)}function Z(){return(e,n,i)=>{try{t(e.constructor,y,M,(o=n,e=>{if(void 0!==e.lifecycle.postConstructMethodName)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated postConstruct decorator");return e.lifecycle.postConstructMethodName=o,e}))}catch(t){P(e,n,void 0,t)}var o}}function _(){return(e,n,i)=>{try{t(e.constructor,y,M,(o=n,e=>{if(void 0!==e.lifecycle.preDestroyMethodName)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated preDestroy decorator");return e.lifecycle.preDestroyMethodName=o,e}))}catch(t){P(e,n,void 0,t)}var o}}function ee(e,t){const n=Q(function(e,t){return n=>{if(n.tags.has(e))throw new b(j.injectionDecoratorConflict,"Unexpected duplicated tag decorator with existing tag");return n.tags.set(e,t),n}}(e,t));return F(n,L)}function te(){return{kind:S.unmanaged}}const ne=x(te,(function(e){if(R(e),function(e){return void 0!==e.name||e.optional||e.tags.size>0}(e))throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return te()}));function ie(){return F(ne(),$)}class oe{#p;constructor(e){this.#p=e}get name(){return this.#p.elem.name}get tags(){return this.#p.elem.tags}get serviceIdentifier(){return this.#p.elem.serviceIdentifier}getAncestor(){if(void 0!==this.#p.previous)return new oe(this.#p.previous)}}class re{last;constructor(e){this.last=e}concat(e){return new re({elem:e,previous:this.last})}[Symbol.iterator](){let e=this.last;return{next:()=>{if(void 0===e)return{done:!0,value:void 0};const t=e.elem;return e=e.previous,{done:!1,value:t}}}}}function ae(e,t){e.servicesBranch.has(t)&&function(e,t){const n=(i=[...e.servicesBranch,t],[...i].map(o).join(" -> "));var i;throw new b(j.planning,`Circular dependency found: ${n}`)}(e,t),e.servicesBranch.add(t)}function se(e,t,n){const i=n?.customServiceIdentifier??t.serviceIdentifier,o=[...e.getBindings(i)??[]].filter((e=>e.isSatisfiedBy(t)));if(0===o.length&&void 0!==e.autobindOptions&&"function"==typeof i){const t=function(e,t){return{cache:{isRight:!1,value:void 0},id:0,implementationType:t,isSatisfiedBy:()=>!0,moduleId:void 0,onActivation:void 0,onDeactivation:void 0,scope:e.scope,serviceIdentifier:t,type:c.Instance}}(e.autobindOptions,i);e.setBinding(t),o.push(t)}return o}function ce(e){return void 0!==e.redirections}function ue(e,t,n,i){let r,a;ce(n)?(r=n.binding.targetServiceIdentifier,a=n.binding.serviceIdentifier):(r=n.serviceIdentifier,a=n.parent?.binding.serviceIdentifier),Array.isArray(e)?function(e,t,n,i,r){if(0!==e.length){const t=`Ambiguous bindings found for service: "${o(n)}".\n\nRegistered bindings:\n\n${e.map((e=>function(e){switch(e.type){case c.Instance:return`[ type: "${e.type}", serviceIdentifier: "${o(e.serviceIdentifier)}", scope: "${e.scope}", implementationType: "${e.implementationType.name}" ]`;case c.ServiceRedirection:return`[ type: "${e.type}", serviceIdentifier: "${o(e.serviceIdentifier)}", redirection: "${o(e.targetServiceIdentifier)}" ]`;default:return`[ type: "${e.type}", serviceIdentifier: "${o(e.serviceIdentifier)}", scope: "${e.scope}" ]`}}(e.binding))).join("\n")}\n\nTrying to resolve bindings for "${le(n,i)}".\n\n${pe(r)}`;throw new b(j.planning,t)}t||de(n,i,r)}(e,t,r,a,i):function(e,t,n,i,o){if(void 0!==e||t)return;de(n,i,o)}(e,t,r,a,i)}function de(e,t,n){const i=`No bindings found for service: "${o(e)}".\n\nTrying to resolve bindings for "${le(e,t)}".\n\n${pe(n)}`;throw new b(j.planning,i)}function le(e,t){return void 0===t?`${o(e)} (Root service)`:o(t)}function pe(e){const t=0===e.tags.size?"":`\n- tags:\n - ${[...e.tags.keys()].map((e=>e.toString())).join("\n - ")}`;return`Binding metadata:\n- service identifier: ${o(e.serviceIdentifier)}\n- name: ${e.name?.toString()??"-"}${t}`}function fe(e,t,n){if(1!==e.redirections.length)ue(e.redirections,t,e,n);else{const[i]=e.redirections;ce(i)&&fe(i,t,n)}}function ge(e,t,n){if(Array.isArray(e.bindings)&&1===e.bindings.length){const[i]=e.bindings;ce(i)&&fe(i,t,n)}else ue(e.bindings,t,e,n)}function me(e){const t=new Map;void 0!==e.rootConstraints.tag&&t.set(e.rootConstraints.tag.key,e.rootConstraints.tag.value);const n=new re({elem:{name:e.rootConstraints.name,serviceIdentifier:e.rootConstraints.serviceIdentifier,tags:t},previous:void 0}),i=new oe(n.last),o=se(e,i),r=[],a={bindings:r,parent:void 0,serviceIdentifier:e.rootConstraints.serviceIdentifier};if(r.push(...ye(e,n,o,a)),!e.rootConstraints.isMultiple){ge(a,e.rootConstraints.isOptional??!1,i);const[t]=r;a.bindings=t}return{tree:{root:a}}}function he(e,t,n,i){const o={binding:t,classMetadata:e.getClassMetadata(t.implementationType),constructorParams:[],parent:i,propertyParams:new Map};return function(e,t){const n=e.node.classMetadata;for(const[i,o]of n.constructorArguments.entries())e.node.constructorParams[i]=ve(e,t,o);for(const[i,o]of n.properties){const n=ve(e,t,o);void 0!==n&&e.node.propertyParams.set(i,n)}return e.node}({autobindOptions:e.autobindOptions,getBindings:e.getBindings,getClassMetadata:e.getClassMetadata,node:o,servicesBranch:e.servicesBranch,setBinding:e.setBinding},n)}function ve(e,t,n){if(n.kind===S.unmanaged)return;const i=r.is(n.value)?n.value.unwrap():n.value,o=t.concat({name:n.name,serviceIdentifier:i,tags:n.tags}),a=new oe(o.last),s=se(e,a),c=[],u={bindings:c,parent:e.node,serviceIdentifier:i};if(c.push(...ye(e,o,s,u)),n.kind===S.singleInjection){ge(u,n.optional,a);const[e]=c;u.bindings=e}return u}function ye(e,t,n,i){const o=ce(i)?i.binding.targetServiceIdentifier:i.serviceIdentifier;ae(e,o);const r=[];for(const o of n)switch(o.type){case c.Instance:r.push(he(e,o,t,i));break;case c.ServiceRedirection:{const n=Me(e,t,o,i);r.push(n);break}default:r.push({binding:o,parent:i})}return e.servicesBranch.delete(o),r}function Me(e,t,n,i){const o={binding:n,parent:i,redirections:[]},r=se(e,new oe(t.last),{customServiceIdentifier:n.targetServiceIdentifier});return o.redirections.push(...ye(e,t,r,o)),o}var Ie;!function(e){e[e.singleMandatory=0]="singleMandatory",e[e.singleOptional=1]="singleOptional",e[e.multipleMandatory=2]="multipleMandatory",e[e.multipleOptional=3]="multipleOptional",e[e.length=4]="length"}(Ie||(Ie={}));class we{#f;#g;#m;#h;#v;constructor(){this.#f=this.#y(),this.#g=this.#y(),this.#h=this.#y(),this.#m=this.#y(),this.#v=[]}clearCache(){for(const e of this.#M())e.clear();for(const e of this.#v)e.clearCache()}get(e){return void 0===e.name?void 0===e.tag?this.#I(this.#f,e).get(e.serviceIdentifier):this.#I(this.#m,e).get(e.serviceIdentifier)?.get(e.tag.key)?.get(e.tag.value):void 0===e.tag?this.#I(this.#g,e).get(e.serviceIdentifier)?.get(e.name):this.#I(this.#h,e).get(e.serviceIdentifier)?.get(e.name)?.get(e.tag.key)?.get(e.tag.value)}set(e,t){void 0===e.name?void 0===e.tag?this.#I(this.#f,e).set(e.serviceIdentifier,t):this.#w(this.#w(this.#I(this.#m,e),e.serviceIdentifier),e.tag.key).set(e.tag.value,t):void 0===e.tag?this.#w(this.#I(this.#g,e),e.serviceIdentifier).set(e.name,t):this.#w(this.#w(this.#w(this.#I(this.#h,e),e.serviceIdentifier),e.name),e.tag.key).set(e.tag.value,t)}subscribe(e){this.#v.push(e)}#y(){const e=new Array(Ie.length);for(let t=0;t<e.length;++t)e[t]=new Map;return e}#w(e,t){let n=e.get(t);return void 0===n&&(n=new Map,e.set(t,n)),n}#I(e,t){return e[this.#b(t)]}#M(){return[...this.#f,...this.#g,...this.#h,...this.#m]}#b(e){return e.isMultiple?!0===e.optional?Ie.multipleOptional:Ie.multipleMandatory:!0===e.optional?Ie.singleOptional:Ie.singleMandatory}}function be(e,t,n){const i=e.getActivations(t);return void 0===i?n:a(n)?je(e,n,i[Symbol.iterator]()):function(e,t,n){let i=t,o=n.next();for(;!0!==o.done;){const t=o.value(e.context,i);if(a(t))return je(e,t,n);i=t,o=n.next()}return i}(e,n,i[Symbol.iterator]())}async function je(e,t,n){let i=await t,o=n.next();for(;!0!==o.done;)i=await o.value(e.context,i),o=n.next();return i}function Te(e,t,n){let i=n;if(void 0!==t.onActivation){const n=t.onActivation;i=a(i)?i.then((t=>n(e.context,t))):n(e.context,i)}return be(e,t.serviceIdentifier,i)}function Se(e){return(t,n)=>{if(n.cache.isRight)return n.cache.value;const i=Te(t,n,e(t,n));return n.cache={isRight:!0,value:i},i}}const Ce=Se((function(e,t){return t.value}));function Ae(e){return e}function $e(e,t){return(n,i)=>{const o=e(i);switch(o.scope){case s.Singleton:{if(o.cache.isRight)return o.cache.value;const e=xe(n,i,o,t);return o.cache={isRight:!0,value:e},e}case s.Request:{if(n.requestScopeCache.has(o.id))return n.requestScopeCache.get(o.id);const e=xe(n,i,o,t);return n.requestScopeCache.set(o.id,e),e}case s.Transient:return xe(n,i,o,t)}}}function xe(e,t,n,i){return Te(e,n,i(e,t))}const Re=(e=>$e(Ae,e))((function(e,t){return t.value(e.context)}));const Be=Se((function(e,t){return t.factory(e.context)}));function ke(e,t,n){const i=function(e,t,n){if(void 0===n)return;if(!(n in e))throw new b(j.resolution,`Expecting a "${n.toString()}" property when resolving "${t.implementationType.name}" class @postConstruct decorated method, none found.`);if("function"!=typeof e[n])throw new b(j.resolution,`Expecting a "${n.toString()}" method when resolving "${t.implementationType.name}" class @postConstruct decorated method, a non function property was found instead.`);{let i;try{i=e[n]()}catch(e){throw new b(j.resolution,`Unexpected error found when calling "${n.toString()}" @postConstruct decorated method on class "${t.implementationType.name}"`,{cause:e})}if(a(i))return async function(e,t,n){try{await n}catch(n){throw new b(j.resolution,`Unexpected error found when calling "${t.toString()}" @postConstruct decorated method on class "${e.implementationType.name}"`,{cause:n})}}(t,n,i)}}(e,t,n);return a(i)?i.then((()=>e)):e}function De(e){return(t,n,i)=>{const o=new i.binding.implementationType(...t),r=e(n,o,i);return a(r)?r.then((()=>ke(o,i.binding,i.classMetadata.lifecycle.postConstructMethodName))):ke(o,i.binding,i.classMetadata.lifecycle.postConstructMethodName)}}const Pe=Se((function(e,t){return t.provider(e.context)}));function Fe(e){return e.binding}const Ve=function(e){return(t,n,i)=>{const o=[];for(const[r,s]of i.propertyParams){const c=i.classMetadata.properties.get(r);if(void 0===c)throw new b(j.resolution,`Expecting metadata at property "${r.toString()}", none found`);c.kind!==S.unmanaged&&void 0!==s.bindings&&(n[r]=e(t,s),a(n[r])&&o.push((async()=>{n[r]=await n[r]})()))}if(o.length>0)return Promise.all(o).then((()=>{}))}}(qe),Oe=function(e){return function t(n,i){const o=[];for(const r of i.redirections)ce(r)?o.push(...t(n,r)):o.push(e(n,r));return o}}(Ke),Ne=function(e,t,n){return(i,o)=>{const r=e(i,o);return a(r)?t(r,i,o):n(r,i,o)}}(function(e){return(t,n)=>{const i=[];for(const o of n.constructorParams)void 0===o?i.push(void 0):i.push(e(t,o));return i.some(a)?Promise.all(i):i}}(qe),function(e){return async(t,n,i)=>{const o=await t;return e(o,n,i)}}(De(Ve)),De(Ve)),Ee=(e=>$e(Fe,e))(Ne);function Ue(e){return qe(e,e.planResult.tree.root)}function Ke(e,t){switch(t.binding.type){case c.ConstantValue:return Ce(e,t.binding);case c.DynamicValue:return Re(e,t.binding);case c.Factory:return Be(e,t.binding);case c.Instance:return Ee(e,t);case c.Provider:return Pe(e,t.binding)}}function qe(e,t){if(void 0!==t.bindings)return Array.isArray(t.bindings)?function(e,t){const n=[];for(const i of t)ce(i)?n.push(...Oe(e,i)):n.push(Ke(e,i));if(n.some(a))return Promise.all(n);return n}(e,t.bindings):function(e,t){if(ce(t)){const n=Oe(e,t);if(1===n.length)return n[0];throw new b(j.resolution,"Unexpected multiple resolved values on single injection")}return Ke(e,t)}(e,t.bindings)}function ze(e){return void 0!==e.scope}function Ge(e,t){if(void 0!==e.lifecycle.preDestroyMethodName&&"function"==typeof t[e.lifecycle.preDestroyMethodName])return t[e.lifecycle.preDestroyMethodName]()}function He(e,t,n){const i=e.getDeactivations(t);if(void 0!==i)return a(n)?Je(n,i[Symbol.iterator]()):function(e,t){let n=t.next();for(;!0!==n.done;){const i=n.value(e);if(a(i))return Je(e,t);n=t.next()}}(n,i[Symbol.iterator]())}async function Je(e,t){const n=await e;let i=t.next();for(;!0!==i.done;)await i.value(n),i=t.next()}function Le(e,t){const n=function(e,t){if(t.type===c.Instance){const n=e.getClassMetadata(t.implementationType),i=t.cache.value;return a(i)?i.then((e=>Ge(n,e))):Ge(n,i)}}(e,t);return void 0===n?Qe(e,t):n.then((()=>Qe(e,t)))}function Qe(e,t){const n=t.cache;return a(n.value)?n.value.then((n=>We(e,t,n))):We(e,t,n.value)}function We(e,t,n){let i;if(void 0!==t.onDeactivation){i=(0,t.onDeactivation)(n)}return void 0===i?He(e,t.serviceIdentifier,n):i.then((()=>He(e,t.serviceIdentifier,n)))}function Xe(e,t){if(void 0===t)return;const n=function(e){const t=[];for(const n of e)ze(n)&&n.scope===s.Singleton&&n.cache.isRight&&t.push(n);return t}(t),i=[];for(const t of n){const n=Le(e,t);void 0!==n&&i.push(n)}return i.length>0?Promise.all(i).then((()=>{})):void 0}function Ye(e,t){const n=e.getBindingsFromModule(t);return Xe(e,n)}function Ze(e,t){const n=e.getBindings(t);return Xe(e,n)}export{g as ActivationsService,m as BindingService,S as ClassElementMetadataKind,h as DeactivationsService,we as PlanResultCacheService,s as bindingScopeValues,c as bindingTypeValues,v as decorate,C as getClassMetadata,O as inject,H as injectFromBase,K as injectable,J as multiInject,W as named,Y as optional,me as plan,Z as postConstruct,_ as preDestroy,Ue as resolve,Ye as resolveModuleDeactivations,Ze as resolveServiceDeactivations,ee as tagged,ie as unmanaged};
|
|
1
|
+
import{getOwnReflectMetadata as e,updateOwnReflectMetadata as t,setReflectMetadata as n}from"@inversifyjs/reflect-metadata-utils";import{getBaseType as i}from"@inversifyjs/prototype-utils";import{stringifyServiceIdentifier as o,LazyServiceIdentifier as r,isPromise as a}from"@inversifyjs/common";const s={Request:"Request",Singleton:"Singleton",Transient:"Transient"},c={ConstantValue:"ConstantValue",DynamicValue:"DynamicValue",Factory:"Factory",Instance:"Instance",Provider:"Provider",ResolvedValue:"ResolvedValue",ServiceRedirection:"ServiceRedirection"};function*u(...e){for(const t of e)yield*t}class d{#e;#t;#n;constructor(e){this.#e=new Map,this.#t={};for(const t of Reflect.ownKeys(e))this.#t[t]=new Map;this.#n=e}add(e,t){this.#i(e).push(t);for(const n of Reflect.ownKeys(t))this.#o(n,t[n]).push(e)}clone(){const e=Reflect.ownKeys(this.#n),t=new d(this.#n);this.#r(this.#e,t.#e);for(const n of e)this.#r(this.#t[n],t.#t[n]);return t}get(e,t){return this.#t[e].get(t)}getAllKeys(e){return this.#t[e].keys()}removeByRelation(e,t){const n=this.get(e,t);if(void 0===n)return;const i=new Set(n);for(const n of i){const i=this.#e.get(n);if(void 0===i)throw new Error("Expecting model relation, none found");for(const o of i)o[e]===t&&this.#a(n,o);this.#e.delete(n)}}#i(e){let t=this.#e.get(e);return void 0===t&&(t=[],this.#e.set(e,t)),t}#o(e,t){let n=this.#t[e].get(t);return void 0===n&&(n=[],this.#t[e].set(t,n)),n}#r(e,t){for(const[n,i]of e)t.set(n,[...i])}#a(e,t){for(const n of Reflect.ownKeys(t))this.#s(e,n,t[n])}#s(e,t,n){const i=this.#t[t].get(n);if(void 0!==i){const o=i.indexOf(e);-1!==o&&i.splice(o,1),0===i.length&&this.#t[t].delete(n)}}}var l,p,f;!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(l||(l={}));class g{#c;#u;constructor(e,t){this.#c=t??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#u=e}static build(e){return new g(e)}add(e,t){this.#c.add(e,t)}clone(){return new g(this.#u,this.#c.clone())}get(e){const t=[],n=this.#c.get(l.serviceId,e);void 0!==n&&t.push(n);const i=this.#u?.get(e);if(void 0!==i&&t.push(i),0!==t.length)return u(...t)}removeAllByModuleId(e){this.#c.removeByRelation(l.moduleId,e)}removeAllByServiceId(e){this.#c.removeByRelation(l.serviceId,e)}}!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(p||(p={}));class m{#d;#u;constructor(e,t){this.#d=t??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#u=e}static build(e){return new m(e)}clone(){return new m(this.#u,this.#d.clone())}get(e){return this.getNonParentBindings(e)??this.#u?.get(e)}getNonParentBindings(e){return this.#d.get(p.serviceId,e)}getNonParentBoundServices(){return this.#d.getAllKeys(p.serviceId)}getByModuleId(e){return this.#d.get(p.moduleId,e)??this.#u?.getByModuleId(e)}removeAllByModuleId(e){this.#d.removeByRelation(p.moduleId,e)}removeAllByServiceId(e){this.#d.removeByRelation(p.serviceId,e)}set(e){const t={[p.serviceId]:e.serviceIdentifier};void 0!==e.moduleId&&(t[p.moduleId]=e.moduleId),this.#d.add(e,t)}}!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(f||(f={}));class h{#l;#u;constructor(e,t){this.#l=t??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#u=e}static build(e){return new h(e)}add(e,t){this.#l.add(e,t)}clone(){return new h(this.#u,this.#l.clone())}get(e){const t=[],n=this.#l.get(f.serviceId,e);void 0!==n&&t.push(n);const i=this.#u?.get(e);if(void 0!==i&&t.push(i),0!==t.length)return u(...t)}removeAllByModuleId(e){this.#l.removeByRelation(f.moduleId,e)}removeAllByServiceId(e){this.#l.removeByRelation(f.serviceId,e)}}function v(e,t,n){const i=Array.isArray(e)?e:[e];if(void 0!==n)if("number"!=typeof n)Reflect.decorate(i,t.prototype,n);else for(const e of i)e(t,void 0,n);else Reflect.decorate(i,t)}const y="@inversifyjs/core/classMetadataReflectKey";function M(){return{constructorArguments:[],lifecycle:{postConstructMethodName:void 0,preDestroyMethodName:void 0},properties:new Map,scope:void 0}}const I="@inversifyjs/core/pendingClassMetadataCountReflectKey";const w=Symbol.for("@inversifyjs/core/InversifyCoreError");class b extends Error{[w];kind;constructor(e,t,n){super(t,n),this[w]=!0,this.kind=e}static is(e){return"object"==typeof e&&null!==e&&!0===e[w]}static isErrorOfKind(e,t){return b.is(e)&&e.kind===t}}var j,T,C;function S(t){const n=e(t,y)??M();if(!function(t){const n=e(t,I);return void 0!==n&&0!==n}(t))return function(e,t){const n=[];if(t.length<e.length)throw new b(j.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}". "${e.name}" constructor requires at least ${e.length.toString()} arguments, found ${t.length.toString()} instead.\nAre you using @inject, @multiInject or @unmanaged decorators in every non optional constructor argument?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`);for(let e=0;e<t.length;++e)void 0===t[e]&&n.push(e);if(n.length>0)throw new b(j.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}" at constructor indexes "${n.join('", "')}".\n\nAre you using @inject, @multiInject or @unmanaged decorators at those indexes?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`)}(t,n.constructorArguments),n;!function(e,t){const n=[];for(let i=0;i<t.constructorArguments.length;++i){const o=t.constructorArguments[i];void 0!==o&&o.kind!==T.unknown||n.push(` - Missing or incomplete metadata for type "${e.name}" at constructor argument with index ${i.toString()}.\nEvery constructor parameter must be decorated either with @inject, @multiInject or @unmanaged decorator.`)}for(const[i,o]of t.properties)o.kind===T.unknown&&n.push(` - Missing or incomplete metadata for type "${e.name}" at property "${i.toString()}".\nThis property must be decorated either with @inject or @multiInject decorator.`);if(0===n.length)throw new b(j.unknown,`Unexpected class metadata for type "${e.name}" with uncompletion traces.\nThis might be caused by one of the following reasons:\n\n1. A third party library is targeting inversify reflection metadata.\n2. A bug is causing the issue. Consider submiting an issue to fix it.`);throw new b(j.missingInjectionDecorator,`Invalid class metadata at type ${e.name}:\n\n${n.join("\n\n")}`)}(t,n)}function A(){return 0}function $(e){return n=>{void 0!==n&&n.kind===T.unknown&&t(e,I,A,(e=>e-1))}}function x(e,t){return(...n)=>i=>{if(void 0===i)return e(...n);if(i.kind===C.unmanaged)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found");return t(i,...n)}}function B(e){if(e.kind!==T.unknown&&!0!==e.isFromTypescriptParamType)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found")}!function(e){e[e.injectionDecoratorConflict=0]="injectionDecoratorConflict",e[e.missingInjectionDecorator=1]="missingInjectionDecorator",e[e.planning=2]="planning",e[e.resolution=3]="resolution",e[e.unknown=4]="unknown"}(j||(j={})),function(e){e[e.unknown=32]="unknown"}(T||(T={})),function(e){e[e.multipleInjection=0]="multipleInjection",e[e.singleInjection=1]="singleInjection",e[e.unmanaged=2]="unmanaged"}(C||(C={}));const R=x((function(e,t){return{kind:e,name:void 0,optional:!1,tags:new Map,value:t}}),(function(e,t,n){return B(e),{...e,kind:t,value:n}}));function k(e,t){return n=>{const i=n.properties.get(t);return n.properties.set(t,e(i)),n}}var P;function D(e,t,n,i){if(b.isErrorOfKind(i,j.injectionDecoratorConflict)){const o=function(e,t,n){if(void 0===n){if(void 0===t)throw new b(j.unknown,"Unexpected undefined property and index values");return{kind:P.property,property:t,targetClass:e.constructor}}return"number"==typeof n?{index:n,kind:P.parameter,targetClass:e}:{kind:P.method,method:t,targetClass:e}}(e,t,n);throw new b(j.injectionDecoratorConflict,`Unexpected injection error.\n\nCause:\n\n${i.message}\n\nDetails\n\n${function(e){switch(e.kind){case P.method:return`[class: "${e.targetClass.name}", method: "${e.method.toString()}"]`;case P.parameter:return`[class: "${e.targetClass.name}", index: "${e.index.toString()}"]`;case P.property:return`[class: "${e.targetClass.name}", property: "${e.property.toString()}"]`}}(o)}`,{cause:i})}throw i}function V(e,n){return(i,o,r)=>{try{void 0===r?function(e,n){const i=F(e,n);return(e,n)=>{t(e.constructor,y,M,k(i(e),n))}}(e,n)(i,o):"number"==typeof r?function(e,n){const i=F(e,n);return(e,n,o)=>{if(!function(e,t){return"function"==typeof e&&void 0===t}(e,n))throw new b(j.injectionDecoratorConflict,`Found an @inject decorator in a non constructor parameter.\nFound @inject decorator at method "${n?.toString()??""}" at class "${e.constructor.name}"`);t(e,y,M,function(e,t){return n=>{const i=n.constructorArguments[t];return n.constructorArguments[t]=e(i),n}}(i(e),o))}}(e,n)(i,o,r):function(e,n){const i=F(e,n);return(e,n,o)=>{if(!function(e){return void 0!==e.set}(o))throw new b(j.injectionDecoratorConflict,`Found an @inject decorator in a non setter property method.\nFound @inject decorator at method "${n.toString()}" at class "${e.constructor.name}"`);t(e.constructor,y,M,k(i(e),n))}}(e,n)(i,o,r)}catch(e){D(i,o,r,e)}}}function F(e,t){return n=>{const i=t(n);return t=>(i(t),e(t))}}function O(e){return V(R(C.singleInjection,e),$)}!function(e){e[e.method=0]="method",e[e.parameter=1]="parameter",e[e.property=2]="property"}(P||(P={}));const N="@inversifyjs/core/classIsInjectableFlagReflectKey";const E=[Array,BigInt,Boolean,Function,Number,Object,String];function U(n){const i=e(n,"design:paramtypes");void 0!==i&&t(n,y,M,function(e){return t=>(e.forEach(((e,n)=>{var i;void 0!==t.constructorArguments[n]||(i=e,E.includes(i))||(t.constructorArguments[n]=function(e){return{isFromTypescriptParamType:!0,kind:C.singleInjection,name:void 0,optional:!1,tags:new Map,value:e}}(e))})),t)}(i))}function K(i){return o=>{!function(t){if(void 0!==e(t,N))throw new b(j.injectionDecoratorConflict,`Cannot apply @injectable decorator multiple times at class "${t.name}"`);n(t,N,!0)}(o),U(o),void 0!==i&&t(o,y,M,(e=>({...e,scope:i})))}}function q(e,t,n){let i;return e.extendConstructorArguments??!0?(i=[...t.constructorArguments],n.constructorArguments.map(((e,t)=>{i[t]=e}))):i=n.constructorArguments,i}function z(e,t,n){let i;return i=e.extendProperties??!0?new Map(u(t.properties,n.properties)):n.properties,i}function G(e){return n=>{const i=S(e.type);t(n,y,M,function(e,t){const n=n=>({constructorArguments:q(e,t,n),lifecycle:n.lifecycle,properties:z(e,t,n),scope:n.scope});return n}(e,i))}}function H(e){return t=>{const n=i(t);if(void 0===n)throw new b(j.injectionDecoratorConflict,`Expected base type for type "${t.name}", none found.`);G({...e,type:n})(t)}}function J(e){return V(R(C.multipleInjection,e),$)}function L(e){return n=>{void 0===n&&t(e,I,A,(e=>e+1))}}function Q(e){return t=>{const n=t??{kind:T.unknown,name:void 0,optional:!1,tags:new Map};if(n.kind===C.unmanaged)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return e(n)}}function W(e){const t=Q(function(e){return t=>{if(void 0!==t.name)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated named decorator");return t.name=e,t}}(e));return V(t,L)}function X(e){if(e.optional)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated optional decorator");return e.optional=!0,e}function Y(){return V(Q(X),L)}function Z(){return(e,n,i)=>{try{t(e.constructor,y,M,(o=n,e=>{if(void 0!==e.lifecycle.postConstructMethodName)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated postConstruct decorator");return e.lifecycle.postConstructMethodName=o,e}))}catch(t){D(e,n,void 0,t)}var o}}function _(){return(e,n,i)=>{try{t(e.constructor,y,M,(o=n,e=>{if(void 0!==e.lifecycle.preDestroyMethodName)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated preDestroy decorator");return e.lifecycle.preDestroyMethodName=o,e}))}catch(t){D(e,n,void 0,t)}var o}}function ee(e,t){const n=Q(function(e,t){return n=>{if(n.tags.has(e))throw new b(j.injectionDecoratorConflict,"Unexpected duplicated tag decorator with existing tag");return n.tags.set(e,t),n}}(e,t));return V(n,L)}function te(){return{kind:C.unmanaged}}const ne=x(te,(function(e){if(B(e),function(e){return void 0!==e.name||e.optional||e.tags.size>0}(e))throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return te()}));function ie(){return V(ne(),$)}var oe;!function(e){e[e.multipleInjection=0]="multipleInjection",e[e.singleInjection=1]="singleInjection"}(oe||(oe={}));class re{#p;constructor(e){this.#p=e}get name(){return this.#p.elem.name}get serviceIdentifier(){return this.#p.elem.serviceIdentifier}get tags(){return this.#p.elem.tags}getAncestor(){if(void 0!==this.#p.previous)return new re(this.#p.previous)}}class ae{last;constructor(e){this.last=e}concat(e){return new ae({elem:e,previous:this.last})}[Symbol.iterator](){let e=this.last;return{next:()=>{if(void 0===e)return{done:!0,value:void 0};const t=e.elem;return e=e.previous,{done:!1,value:t}}}}}function se(e,t){e.servicesBranch.has(t)&&function(e,t){const n=(i=[...e.servicesBranch,t],[...i].map(o).join(" -> "));var i;throw new b(j.planning,`Circular dependency found: ${n}`)}(e,t),e.servicesBranch.add(t)}function ce(e,t,n){const i=n?.customServiceIdentifier??t.serviceIdentifier,o=[...e.getBindings(i)??[]].filter((e=>e.isSatisfiedBy(t)));if(0===o.length&&void 0!==e.autobindOptions&&"function"==typeof i){const t=function(e,t){return{cache:{isRight:!1,value:void 0},id:0,implementationType:t,isSatisfiedBy:()=>!0,moduleId:void 0,onActivation:void 0,onDeactivation:void 0,scope:e.scope,serviceIdentifier:t,type:c.Instance}}(e.autobindOptions,i);e.setBinding(t),o.push(t)}return o}function ue(e){return void 0!==e.redirections}function de(e,t,n,i){let r,a;ue(n)?(r=n.binding.targetServiceIdentifier,a=n.binding.serviceIdentifier):(r=n.serviceIdentifier,a=n.parent?.binding.serviceIdentifier),Array.isArray(e)?function(e,t,n,i,r){if(0!==e.length){const t=`Ambiguous bindings found for service: "${o(n)}".\n\nRegistered bindings:\n\n${e.map((e=>function(e){switch(e.type){case c.Instance:return`[ type: "${e.type}", serviceIdentifier: "${o(e.serviceIdentifier)}", scope: "${e.scope}", implementationType: "${e.implementationType.name}" ]`;case c.ServiceRedirection:return`[ type: "${e.type}", serviceIdentifier: "${o(e.serviceIdentifier)}", redirection: "${o(e.targetServiceIdentifier)}" ]`;default:return`[ type: "${e.type}", serviceIdentifier: "${o(e.serviceIdentifier)}", scope: "${e.scope}" ]`}}(e.binding))).join("\n")}\n\nTrying to resolve bindings for "${pe(n,i)}".\n\n${fe(r)}`;throw new b(j.planning,t)}t||le(n,i,r)}(e,t,r,a,i):function(e,t,n,i,o){if(void 0!==e||t)return;le(n,i,o)}(e,t,r,a,i)}function le(e,t,n){const i=`No bindings found for service: "${o(e)}".\n\nTrying to resolve bindings for "${pe(e,t)}".\n\n${fe(n)}`;throw new b(j.planning,i)}function pe(e,t){return void 0===t?`${o(e)} (Root service)`:o(t)}function fe(e){const t=0===e.tags.size?"":`\n- tags:\n - ${[...e.tags.keys()].map((e=>e.toString())).join("\n - ")}`;return`Binding constraints:\n- service identifier: ${o(e.serviceIdentifier)}\n- name: ${e.name?.toString()??"-"}${t}`}function ge(e,t,n){if(1!==e.redirections.length)de(e.redirections,t,e,n);else{const[i]=e.redirections;ue(i)&&ge(i,t,n)}}function me(e,t,n){if(Array.isArray(e.bindings)&&1===e.bindings.length){const[i]=e.bindings;ue(i)&&ge(i,t,n)}else de(e.bindings,t,e,n)}function he(e){const t=new Map;void 0!==e.rootConstraints.tag&&t.set(e.rootConstraints.tag.key,e.rootConstraints.tag.value);const n=new ae({elem:{name:e.rootConstraints.name,serviceIdentifier:e.rootConstraints.serviceIdentifier,tags:t},previous:void 0}),i=new re(n.last),o=ce(e,i),r=[],a={bindings:r,parent:void 0,serviceIdentifier:e.rootConstraints.serviceIdentifier};if(r.push(...we(e,n,o,a)),!e.rootConstraints.isMultiple){me(a,e.rootConstraints.isOptional??!1,i);const[t]=r;a.bindings=t}return{tree:{root:a}}}function ve(e,t,n,i){const o={binding:t,classMetadata:e.getClassMetadata(t.implementationType),constructorParams:[],parent:i,propertyParams:new Map};return je({autobindOptions:e.autobindOptions,getBindings:e.getBindings,getClassMetadata:e.getClassMetadata,node:o,servicesBranch:e.servicesBranch,setBinding:e.setBinding},n)}function ye(e,t,n){if(n.kind===C.unmanaged)return;const i=r.is(n.value)?n.value.unwrap():n.value,o=t.concat({name:n.name,serviceIdentifier:i,tags:n.tags}),a=new re(o.last),s=ce(e,a),c=[],u={bindings:c,parent:e.node,serviceIdentifier:i};if(c.push(...we(e,o,s,u)),n.kind===C.singleInjection){me(u,n.optional,a);const[e]=c;u.bindings=e}return u}function Me(e,t,n){const i=r.is(n.value)?n.value.unwrap():n.value,o=t.concat({name:n.name,serviceIdentifier:i,tags:n.tags}),a=new re(o.last),s=ce(e,a),c=[],u={bindings:c,parent:e.node,serviceIdentifier:i};if(c.push(...we(e,o,s,u)),n.kind===oe.singleInjection){me(u,n.optional,a);const[e]=c;u.bindings=e}return u}function Ie(e,t,n,i){const o={binding:t,params:[],parent:i};return je({autobindOptions:e.autobindOptions,getBindings:e.getBindings,getClassMetadata:e.getClassMetadata,node:o,servicesBranch:e.servicesBranch,setBinding:e.setBinding},n)}function we(e,t,n,i){const o=ue(i)?i.binding.targetServiceIdentifier:i.serviceIdentifier;se(e,o);const r=[];for(const o of n)switch(o.type){case c.Instance:r.push(ve(e,o,t,i));break;case c.ResolvedValue:r.push(Ie(e,o,t,i));break;case c.ServiceRedirection:{const n=be(e,t,o,i);r.push(n);break}default:r.push({binding:o,parent:i})}return e.servicesBranch.delete(o),r}function be(e,t,n,i){const o={binding:n,parent:i,redirections:[]},r=ce(e,new re(t.last),{customServiceIdentifier:n.targetServiceIdentifier});return o.redirections.push(...we(e,t,r,o)),o}function je(e,t){return e.node.binding.type===c.Instance?function(e,t,n){const i=t.classMetadata;for(const[o,r]of i.constructorArguments.entries())t.constructorParams[o]=ye(e,n,r);for(const[o,r]of i.properties){const i=ye(e,n,r);void 0!==i&&t.propertyParams.set(o,i)}return e.node}(e,e.node,t):function(e,t,n){const i=t.binding.metadata;for(const[o,r]of i.arguments.entries())t.params[o]=Me(e,n,r);return e.node}(e,e.node,t)}var Te;!function(e){e[e.singleMandatory=0]="singleMandatory",e[e.singleOptional=1]="singleOptional",e[e.multipleMandatory=2]="multipleMandatory",e[e.multipleOptional=3]="multipleOptional",e[e.length=4]="length"}(Te||(Te={}));class Ce{#f;#g;#m;#h;#v;constructor(){this.#f=this.#y(),this.#g=this.#y(),this.#h=this.#y(),this.#m=this.#y(),this.#v=[]}clearCache(){for(const e of this.#M())e.clear();for(const e of this.#v)e.clearCache()}get(e){return void 0===e.name?void 0===e.tag?this.#I(this.#f,e).get(e.serviceIdentifier):this.#I(this.#m,e).get(e.serviceIdentifier)?.get(e.tag.key)?.get(e.tag.value):void 0===e.tag?this.#I(this.#g,e).get(e.serviceIdentifier)?.get(e.name):this.#I(this.#h,e).get(e.serviceIdentifier)?.get(e.name)?.get(e.tag.key)?.get(e.tag.value)}set(e,t){void 0===e.name?void 0===e.tag?this.#I(this.#f,e).set(e.serviceIdentifier,t):this.#w(this.#w(this.#I(this.#m,e),e.serviceIdentifier),e.tag.key).set(e.tag.value,t):void 0===e.tag?this.#w(this.#I(this.#g,e),e.serviceIdentifier).set(e.name,t):this.#w(this.#w(this.#w(this.#I(this.#h,e),e.serviceIdentifier),e.name),e.tag.key).set(e.tag.value,t)}subscribe(e){this.#v.push(e)}#y(){const e=new Array(Te.length);for(let t=0;t<e.length;++t)e[t]=new Map;return e}#w(e,t){let n=e.get(t);return void 0===n&&(n=new Map,e.set(t,n)),n}#I(e,t){return e[this.#b(t)]}#M(){return[...this.#f,...this.#g,...this.#h,...this.#m]}#b(e){return e.isMultiple?!0===e.optional?Te.multipleOptional:Te.multipleMandatory:!0===e.optional?Te.singleOptional:Te.singleMandatory}}function Se(e,t){return a(t)?t.then((t=>Ae(e,t))):Ae(e,t)}function Ae(e,t){return e.cache={isRight:!0,value:t},t}function $e(e,t,n){const i=e.getActivations(t);return void 0===i?n:a(n)?xe(e,n,i[Symbol.iterator]()):function(e,t,n){let i=t,o=n.next();for(;!0!==o.done;){const t=o.value(e.context,i);if(a(t))return xe(e,t,n);i=t,o=n.next()}return i}(e,n,i[Symbol.iterator]())}async function xe(e,t,n){let i=await t,o=n.next();for(;!0!==o.done;)i=await o.value(e.context,i),o=n.next();return i}function Be(e,t,n){let i=n;if(void 0!==t.onActivation){const n=t.onActivation;i=a(i)?i.then((t=>n(e.context,t))):n(e.context,i)}return $e(e,t.serviceIdentifier,i)}function Re(e){return(t,n)=>{if(n.cache.isRight)return n.cache.value;return Se(n,Be(t,n,e(t,n)))}}const ke=Re((function(e,t){return t.value}));function Pe(e){return e}function De(e,t){return(n,i)=>{const o=e(i);switch(o.scope){case s.Singleton:if(o.cache.isRight)return o.cache.value;return Se(o,Be(n,o,t(n,i)));case s.Request:{if(n.requestScopeCache.has(o.id))return n.requestScopeCache.get(o.id);const e=Be(n,o,t(n,i));return n.requestScopeCache.set(o.id,e),e}case s.Transient:return Be(n,o,t(n,i))}}}const Ve=(e=>De(Pe,e))((function(e,t){return t.value(e.context)}));const Fe=Re((function(e,t){return t.factory(e.context)}));function Oe(e,t,n){const i=function(e,t,n){if(void 0===n)return;if(!(n in e))throw new b(j.resolution,`Expecting a "${n.toString()}" property when resolving "${t.implementationType.name}" class @postConstruct decorated method, none found.`);if("function"!=typeof e[n])throw new b(j.resolution,`Expecting a "${n.toString()}" method when resolving "${t.implementationType.name}" class @postConstruct decorated method, a non function property was found instead.`);{let i;try{i=e[n]()}catch(e){throw new b(j.resolution,`Unexpected error found when calling "${n.toString()}" @postConstruct decorated method on class "${t.implementationType.name}"`,{cause:e})}if(a(i))return async function(e,t,n){try{await n}catch(n){throw new b(j.resolution,`Unexpected error found when calling "${t.toString()}" @postConstruct decorated method on class "${e.implementationType.name}"`,{cause:n})}}(t,n,i)}}(e,t,n);return a(i)?i.then((()=>e)):e}function Ne(e){return(t,n,i)=>{const o=new i.binding.implementationType(...t),r=e(n,o,i);return a(r)?r.then((()=>Oe(o,i.binding,i.classMetadata.lifecycle.postConstructMethodName))):Oe(o,i.binding,i.classMetadata.lifecycle.postConstructMethodName)}}const Ee=Re((function(e,t){return t.provider(e.context)}));function Ue(e){return e.binding}function Ke(e){return e.binding}const qe=function(e){return(t,n,i)=>{const o=[];for(const[r,s]of i.propertyParams){const c=i.classMetadata.properties.get(r);if(void 0===c)throw new b(j.resolution,`Expecting metadata at property "${r.toString()}", none found`);c.kind!==C.unmanaged&&void 0!==s.bindings&&(n[r]=e(t,s),a(n[r])&&o.push((async()=>{n[r]=await n[r]})()))}if(o.length>0)return Promise.all(o).then((()=>{}))}}(Xe),ze=function(e){return function t(n,i){const o=[];for(const r of i.redirections)ue(r)?o.push(...t(n,r)):o.push(e(n,r));return o}}(We),Ge=function(e,t,n){return(i,o)=>{const r=e(i,o);return a(r)?t(r,i,o):n(r,i,o)}}(function(e){return(t,n)=>{const i=[];for(const o of n.constructorParams)void 0===o?i.push(void 0):i.push(e(t,o));return i.some(a)?Promise.all(i):i}}(Xe),function(e){return async(t,n,i)=>{const o=await t;return e(o,n,i)}}(Ne(qe)),Ne(qe)),He=function(e){return(t,n)=>{const i=e(t,n);return a(i)?i.then((e=>n.binding.factory(...e))):n.binding.factory(...i)}}(function(e){return(t,n)=>{const i=[];for(const o of n.params)i.push(e(t,o));return i.some(a)?Promise.all(i):i}}(Xe)),Je=(e=>De(Ue,e))(Ge),Le=(e=>De(Ke,e))(He);function Qe(e){return Xe(e,e.planResult.tree.root)}function We(e,t){switch(t.binding.type){case c.ConstantValue:return ke(e,t.binding);case c.DynamicValue:return Ve(e,t.binding);case c.Factory:return Fe(e,t.binding);case c.Instance:return Je(e,t);case c.Provider:return Ee(e,t.binding);case c.ResolvedValue:return Le(e,t)}}function Xe(e,t){if(void 0!==t.bindings)return Array.isArray(t.bindings)?function(e,t){const n=[];for(const i of t)ue(i)?n.push(...ze(e,i)):n.push(We(e,i));if(n.some(a))return Promise.all(n);return n}(e,t.bindings):function(e,t){if(ue(t)){const n=ze(e,t);if(1===n.length)return n[0];throw new b(j.resolution,"Unexpected multiple resolved values on single injection")}return We(e,t)}(e,t.bindings)}function Ye(e){return void 0!==e.scope}function Ze(e,t){if(void 0!==e.lifecycle.preDestroyMethodName&&"function"==typeof t[e.lifecycle.preDestroyMethodName])return t[e.lifecycle.preDestroyMethodName]()}function _e(e,t,n){const i=e.getDeactivations(t);if(void 0!==i)return a(n)?et(n,i[Symbol.iterator]()):function(e,t){let n=t.next();for(;!0!==n.done;){const i=n.value(e);if(a(i))return et(e,t);n=t.next()}}(n,i[Symbol.iterator]())}async function et(e,t){const n=await e;let i=t.next();for(;!0!==i.done;)await i.value(n),i=t.next()}function tt(e,t){const n=function(e,t){if(t.type===c.Instance){const n=e.getClassMetadata(t.implementationType),i=t.cache.value;return a(i)?i.then((e=>Ze(n,e))):Ze(n,i)}}(e,t);return void 0===n?nt(e,t):n.then((()=>nt(e,t)))}function nt(e,t){const n=t.cache;return a(n.value)?n.value.then((n=>it(e,t,n))):it(e,t,n.value)}function it(e,t,n){let i;if(void 0!==t.onDeactivation){i=(0,t.onDeactivation)(n)}return void 0===i?_e(e,t.serviceIdentifier,n):i.then((()=>_e(e,t.serviceIdentifier,n)))}function ot(e,t){if(void 0===t)return;const n=function(e){const t=[];for(const n of e)Ye(n)&&n.scope===s.Singleton&&n.cache.isRight&&t.push(n);return t}(t),i=[];for(const t of n){const n=tt(e,t);void 0!==n&&i.push(n)}return i.length>0?Promise.all(i).then((()=>{})):void 0}function rt(e,t){const n=e.getBindingsFromModule(t);return ot(e,n)}function at(e,t){const n=e.getBindings(t);return ot(e,n)}export{g as ActivationsService,m as BindingService,C as ClassElementMetadataKind,h as DeactivationsService,Ce as PlanResultCacheService,oe as ResolvedValueElementMetadataKind,s as bindingScopeValues,c as bindingTypeValues,v as decorate,S as getClassMetadata,O as inject,H as injectFromBase,K as injectable,J as multiInject,W as named,Y as optional,he as plan,Z as postConstruct,_ as preDestroy,Qe as resolve,rt as resolveModuleDeactivations,at as resolveServiceDeactivations,ee as tagged,ie as unmanaged};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|