inversify 4.11.1 → 5.0.5
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/.auditignore +2 -0
- package/.nyc_output/24cbca0e-b065-453e-9d1e-2a381e69663d.json +1 -0
- package/.nyc_output/processinfo/24cbca0e-b065-453e-9d1e-2a381e69663d.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/CHANGELOG.md +24 -0
- package/README.md +8 -8
- package/amd/annotation/decorator_utils.js +2 -1
- package/amd/annotation/inject.js +1 -0
- package/amd/annotation/injectable.js +1 -0
- package/amd/annotation/multi_inject.js +1 -0
- package/amd/annotation/named.js +1 -0
- package/amd/annotation/optional.js +1 -0
- package/amd/annotation/post_construct.js +1 -0
- package/amd/annotation/tagged.js +1 -0
- package/amd/annotation/target_name.js +1 -0
- package/amd/annotation/unmanaged.js +1 -0
- package/amd/bindings/binding.js +3 -2
- package/amd/bindings/binding_count.js +1 -0
- package/amd/constants/error_msgs.js +11 -2
- package/amd/constants/literal_types.js +1 -0
- package/amd/constants/metadata_keys.js +1 -0
- package/amd/container/container.js +40 -37
- package/amd/container/container_module.js +4 -3
- package/amd/container/container_snapshot.js +1 -0
- package/amd/container/lookup.js +1 -0
- package/amd/inversify.js +27 -26
- package/amd/planning/context.js +3 -2
- package/amd/planning/metadata.js +1 -0
- package/amd/planning/metadata_reader.js +1 -0
- package/amd/planning/plan.js +1 -0
- package/amd/planning/planner.js +8 -0
- package/amd/planning/queryable_string.js +1 -0
- package/amd/planning/reflection_utils.js +12 -8
- package/amd/planning/request.js +3 -2
- package/amd/planning/target.js +3 -2
- package/amd/resolution/instantiation.js +9 -1
- package/amd/resolution/resolver.js +5 -4
- package/amd/syntax/binding_in_syntax.js +1 -0
- package/amd/syntax/binding_in_when_on_syntax.js +1 -0
- package/amd/syntax/binding_on_syntax.js +1 -0
- package/amd/syntax/binding_to_syntax.js +1 -0
- package/amd/syntax/binding_when_on_syntax.js +1 -0
- package/amd/syntax/binding_when_syntax.js +1 -0
- package/amd/syntax/constraint_helpers.js +1 -0
- package/amd/utils/binding_utils.js +1 -0
- package/amd/utils/exceptions.js +1 -0
- package/amd/utils/id.js +10 -0
- package/amd/utils/serialization.js +1 -0
- package/dts/annotation/inject.d.ts +1 -1
- package/dts/bindings/binding.d.ts +1 -1
- package/dts/constants/error_msgs.d.ts +2 -2
- package/dts/container/container.d.ts +5 -5
- package/dts/container/container_module.d.ts +2 -2
- package/dts/container/lookup.d.ts +1 -1
- package/dts/interfaces/interfaces.d.ts +12 -13
- package/dts/inversify.d.ts +1 -1
- package/dts/planning/context.d.ts +1 -1
- package/dts/planning/reflection_utils.d.ts +3 -1
- package/dts/planning/request.d.ts +1 -1
- package/dts/planning/target.d.ts +1 -1
- package/dts/syntax/binding_to_syntax.d.ts +1 -3
- package/dts/syntax/constraint_helpers.d.ts +2 -2
- package/dts/utils/binding_utils.d.ts +1 -1
- package/dts/utils/cat.d.ts +5 -0
- package/dts/utils/dog.d.ts +3 -0
- package/dts/utils/id.d.ts +2 -0
- package/es/annotation/decorator_utils.js +1 -1
- package/es/bindings/binding.js +2 -2
- package/es/constants/error_msgs.js +10 -2
- package/es/container/container.js +39 -37
- package/es/container/container_module.js +3 -3
- package/es/inversify.js +1 -1
- package/es/planning/context.js +2 -2
- package/es/planning/planner.js +8 -1
- package/es/planning/reflection_utils.js +10 -9
- package/es/planning/request.js +2 -2
- package/es/planning/target.js +2 -2
- package/es/resolution/instantiation.js +8 -1
- package/es/resolution/resolver.js +4 -4
- package/es/utils/id.js +5 -0
- package/lib/annotation/decorator_utils.js +2 -1
- package/lib/annotation/inject.js +1 -0
- package/lib/annotation/injectable.js +1 -0
- package/lib/annotation/multi_inject.js +1 -0
- package/lib/annotation/named.js +1 -0
- package/lib/annotation/optional.js +1 -0
- package/lib/annotation/post_construct.js +1 -0
- package/lib/annotation/tagged.js +1 -0
- package/lib/annotation/target_name.js +1 -0
- package/lib/annotation/unmanaged.js +1 -0
- package/lib/bindings/binding.js +3 -2
- package/lib/bindings/binding_count.js +1 -0
- package/lib/constants/error_msgs.js +11 -2
- package/lib/constants/literal_types.js +1 -0
- package/lib/constants/metadata_keys.js +1 -0
- package/lib/container/container.js +40 -37
- package/lib/container/container_module.js +4 -3
- package/lib/container/container_snapshot.js +1 -0
- package/lib/container/lookup.js +1 -0
- package/lib/inversify.js +27 -26
- package/lib/planning/context.js +3 -2
- package/lib/planning/metadata.js +1 -0
- package/lib/planning/metadata_reader.js +1 -0
- package/lib/planning/plan.js +1 -0
- package/lib/planning/planner.js +8 -0
- package/lib/planning/queryable_string.js +1 -0
- package/lib/planning/reflection_utils.js +12 -8
- package/lib/planning/request.js +3 -2
- package/lib/planning/target.js +3 -2
- package/lib/resolution/instantiation.js +9 -1
- package/lib/resolution/resolver.js +5 -4
- package/lib/syntax/binding_in_syntax.js +1 -0
- package/lib/syntax/binding_in_when_on_syntax.js +1 -0
- package/lib/syntax/binding_on_syntax.js +1 -0
- package/lib/syntax/binding_to_syntax.js +1 -0
- package/lib/syntax/binding_when_on_syntax.js +1 -0
- package/lib/syntax/binding_when_syntax.js +1 -0
- package/lib/syntax/constraint_helpers.js +1 -0
- package/lib/utils/binding_utils.js +1 -0
- package/lib/utils/exceptions.js +1 -0
- package/lib/utils/id.js +8 -0
- package/lib/utils/serialization.js +1 -0
- package/mocha.opts +3 -0
- package/package.json +39 -33
- package/amd/utils/guid.js +0 -14
- package/appveyor.yml +0 -34
- package/dts/utils/guid.d.ts +0 -2
- package/es/utils/guid.js +0 -10
- package/lib/utils/guid.js +0 -12
package/amd/planning/planner.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "../bindings/binding_count", "../constants/error_msgs", "../constants/literal_types", "../constants/metadata_keys", "../utils/exceptions", "../utils/serialization", "./context", "./metadata", "./plan", "./reflection_utils", "./request", "./target"], function (require, exports, binding_count_1, ERROR_MSGS, literal_types_1, METADATA_KEY, exceptions_1, serialization_1, context_1, metadata_1, plan_1, reflection_utils_1, request_1, target_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getBindingDictionary = exports.createMockRequest = exports.plan = void 0;
|
|
4
5
|
function getBindingDictionary(cntnr) {
|
|
5
6
|
return cntnr._bindingDictionary;
|
|
6
7
|
}
|
|
@@ -93,6 +94,13 @@ define(["require", "exports", "../bindings/binding_count", "../constants/error_m
|
|
|
93
94
|
}
|
|
94
95
|
if (binding.type === literal_types_1.BindingTypeEnum.Instance && binding.implementationType !== null) {
|
|
95
96
|
var dependencies = reflection_utils_1.getDependencies(metadataReader, binding.implementationType);
|
|
97
|
+
if (!context.container.options.skipBaseClassChecks) {
|
|
98
|
+
var baseClassDependencyCount = reflection_utils_1.getBaseClassDependencyCount(metadataReader, binding.implementationType);
|
|
99
|
+
if (dependencies.length < baseClassDependencyCount) {
|
|
100
|
+
var error = ERROR_MSGS.ARGUMENTS_LENGTH_MISMATCH(reflection_utils_1.getFunctionName(binding.implementationType));
|
|
101
|
+
throw new Error(error);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
96
104
|
dependencies.forEach(function (dependency) {
|
|
97
105
|
_createSubRequests(metadataReader, false, dependency.serviceIdentifier, context, subChildRequest, dependency);
|
|
98
106
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports"], function (require, exports) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.QueryableString = void 0;
|
|
4
5
|
var QueryableString = (function () {
|
|
5
6
|
function QueryableString(str) {
|
|
6
7
|
this.str = str;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
2
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
3
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
4
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
5
|
+
r[k] = a[j];
|
|
6
|
+
return r;
|
|
7
|
+
};
|
|
1
8
|
define(["require", "exports", "../annotation/inject", "../constants/error_msgs", "../constants/literal_types", "../constants/metadata_keys", "../utils/serialization", "./target"], function (require, exports, inject_1, ERROR_MSGS, literal_types_1, METADATA_KEY, serialization_1, target_1) {
|
|
2
9
|
"use strict";
|
|
3
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.getFunctionName = exports.getBaseClassDependencyCount = exports.getDependencies = void 0;
|
|
12
|
+
Object.defineProperty(exports, "getFunctionName", { enumerable: true, get: function () { return serialization_1.getFunctionName; } });
|
|
4
13
|
function getDependencies(metadataReader, func) {
|
|
5
14
|
var constructorName = serialization_1.getFunctionName(func);
|
|
6
15
|
var targets = getTargets(metadataReader, constructorName, func, false);
|
|
@@ -20,13 +29,7 @@ define(["require", "exports", "../annotation/inject", "../constants/error_msgs",
|
|
|
20
29
|
var iterations = (hasUserDeclaredUnknownInjections) ? keys.length : func.length;
|
|
21
30
|
var constructorTargets = getConstructorArgsAsTargets(isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata, iterations);
|
|
22
31
|
var propertyTargets = getClassPropsAsTargets(metadataReader, func);
|
|
23
|
-
var targets = constructorTargets
|
|
24
|
-
var baseClassDependencyCount = getBaseClassDependencyCount(metadataReader, func);
|
|
25
|
-
if (targets.length < baseClassDependencyCount) {
|
|
26
|
-
var error = ERROR_MSGS.ARGUMENTS_LENGTH_MISMATCH_1 +
|
|
27
|
-
constructorName + ERROR_MSGS.ARGUMENTS_LENGTH_MISMATCH_2;
|
|
28
|
-
throw new Error(error);
|
|
29
|
-
}
|
|
32
|
+
var targets = __spreadArrays(constructorTargets, propertyTargets);
|
|
30
33
|
return targets;
|
|
31
34
|
}
|
|
32
35
|
function getConstructorArgsAsTarget(index, isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata) {
|
|
@@ -82,7 +85,7 @@ define(["require", "exports", "../annotation/inject", "../constants/error_msgs",
|
|
|
82
85
|
var baseConstructor = Object.getPrototypeOf(constructorFunc.prototype).constructor;
|
|
83
86
|
if (baseConstructor !== Object) {
|
|
84
87
|
var baseTargets = getClassPropsAsTargets(metadataReader, baseConstructor);
|
|
85
|
-
targets = targets
|
|
88
|
+
targets = __spreadArrays(targets, baseTargets);
|
|
86
89
|
}
|
|
87
90
|
return targets;
|
|
88
91
|
}
|
|
@@ -109,6 +112,7 @@ define(["require", "exports", "../annotation/inject", "../constants/error_msgs",
|
|
|
109
112
|
return 0;
|
|
110
113
|
}
|
|
111
114
|
}
|
|
115
|
+
exports.getBaseClassDependencyCount = getBaseClassDependencyCount;
|
|
112
116
|
function formatTargetMetadata(targetMetadata) {
|
|
113
117
|
var targetMetadataMap = {};
|
|
114
118
|
targetMetadata.forEach(function (m) {
|
package/amd/planning/request.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
define(["require", "exports", "../utils/
|
|
1
|
+
define(["require", "exports", "../utils/id"], function (require, exports, id_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Request = void 0;
|
|
4
5
|
var Request = (function () {
|
|
5
6
|
function Request(serviceIdentifier, parentContext, parentRequest, bindings, target) {
|
|
6
|
-
this.
|
|
7
|
+
this.id = id_1.id();
|
|
7
8
|
this.serviceIdentifier = serviceIdentifier;
|
|
8
9
|
this.parentContext = parentContext;
|
|
9
10
|
this.parentRequest = parentRequest;
|
package/amd/planning/target.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
define(["require", "exports", "../constants/metadata_keys", "../utils/
|
|
1
|
+
define(["require", "exports", "../constants/metadata_keys", "../utils/id", "./metadata", "./queryable_string"], function (require, exports, METADATA_KEY, id_1, metadata_1, queryable_string_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Target = void 0;
|
|
4
5
|
var Target = (function () {
|
|
5
6
|
function Target(type, name, serviceIdentifier, namedOrTagged) {
|
|
6
|
-
this.
|
|
7
|
+
this.id = id_1.id();
|
|
7
8
|
this.type = type;
|
|
8
9
|
this.serviceIdentifier = serviceIdentifier;
|
|
9
10
|
this.name = new queryable_string_1.QueryableString(name || "");
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
2
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
3
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
4
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
5
|
+
r[k] = a[j];
|
|
6
|
+
return r;
|
|
7
|
+
};
|
|
1
8
|
define(["require", "exports", "../constants/error_msgs", "../constants/literal_types", "../constants/metadata_keys"], function (require, exports, error_msgs_1, literal_types_1, METADATA_KEY) {
|
|
2
9
|
"use strict";
|
|
3
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.resolveInstance = void 0;
|
|
4
12
|
function _injectProperties(instance, childRequests, resolveRequest) {
|
|
5
13
|
var propertyInjectionsRequests = childRequests.filter(function (childRequest) {
|
|
6
14
|
return (childRequest.target !== null &&
|
|
@@ -16,7 +24,7 @@ define(["require", "exports", "../constants/error_msgs", "../constants/literal_t
|
|
|
16
24
|
return instance;
|
|
17
25
|
}
|
|
18
26
|
function _createInstance(Func, injections) {
|
|
19
|
-
return new (Func.bind.apply(Func, [void 0]
|
|
27
|
+
return new (Func.bind.apply(Func, __spreadArrays([void 0], injections)))();
|
|
20
28
|
}
|
|
21
29
|
function _postConstruct(constr, result) {
|
|
22
30
|
if (Reflect.hasMetadata(METADATA_KEY.POST_CONSTRUCT, constr)) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "../constants/error_msgs", "../constants/literal_types", "../utils/exceptions", "../utils/serialization", "./instantiation"], function (require, exports, ERROR_MSGS, literal_types_1, exceptions_1, serialization_1, instantiation_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.resolve = void 0;
|
|
4
5
|
var invokeFactory = function (factoryType, serviceIdentifier, fn) {
|
|
5
6
|
try {
|
|
6
7
|
return fn();
|
|
@@ -43,8 +44,8 @@ define(["require", "exports", "../constants/error_msgs", "../constants/literal_t
|
|
|
43
44
|
}
|
|
44
45
|
if (isRequestSingleton &&
|
|
45
46
|
requestScope !== null &&
|
|
46
|
-
requestScope.has(binding_1.
|
|
47
|
-
return requestScope.get(binding_1.
|
|
47
|
+
requestScope.has(binding_1.id)) {
|
|
48
|
+
return requestScope.get(binding_1.id);
|
|
48
49
|
}
|
|
49
50
|
if (binding_1.type === literal_types_1.BindingTypeEnum.ConstantValue) {
|
|
50
51
|
result = binding_1.cache;
|
|
@@ -80,8 +81,8 @@ define(["require", "exports", "../constants/error_msgs", "../constants/literal_t
|
|
|
80
81
|
}
|
|
81
82
|
if (isRequestSingleton &&
|
|
82
83
|
requestScope !== null &&
|
|
83
|
-
!requestScope.has(binding_1.
|
|
84
|
-
requestScope.set(binding_1.
|
|
84
|
+
!requestScope.has(binding_1.id)) {
|
|
85
|
+
requestScope.set(binding_1.id, result);
|
|
85
86
|
}
|
|
86
87
|
return result;
|
|
87
88
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "../constants/literal_types", "./binding_when_on_syntax"], function (require, exports, literal_types_1, binding_when_on_syntax_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.BindingInSyntax = void 0;
|
|
4
5
|
var BindingInSyntax = (function () {
|
|
5
6
|
function BindingInSyntax(binding) {
|
|
6
7
|
this._binding = binding;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "./binding_in_syntax", "./binding_on_syntax", "./binding_when_syntax"], function (require, exports, binding_in_syntax_1, binding_on_syntax_1, binding_when_syntax_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.BindingInWhenOnSyntax = void 0;
|
|
4
5
|
var BindingInWhenOnSyntax = (function () {
|
|
5
6
|
function BindingInWhenOnSyntax(binding) {
|
|
6
7
|
this._binding = binding;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "./binding_when_syntax"], function (require, exports, binding_when_syntax_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.BindingOnSyntax = void 0;
|
|
4
5
|
var BindingOnSyntax = (function () {
|
|
5
6
|
function BindingOnSyntax(binding) {
|
|
6
7
|
this._binding = binding;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "../constants/error_msgs", "../constants/literal_types", "./binding_in_when_on_syntax", "./binding_when_on_syntax"], function (require, exports, ERROR_MSGS, literal_types_1, binding_in_when_on_syntax_1, binding_when_on_syntax_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.BindingToSyntax = void 0;
|
|
4
5
|
var BindingToSyntax = (function () {
|
|
5
6
|
function BindingToSyntax(binding) {
|
|
6
7
|
this._binding = binding;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "./binding_on_syntax", "./binding_when_syntax"], function (require, exports, binding_on_syntax_1, binding_when_syntax_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.BindingWhenOnSyntax = void 0;
|
|
4
5
|
var BindingWhenOnSyntax = (function () {
|
|
5
6
|
function BindingWhenOnSyntax(binding) {
|
|
6
7
|
this._binding = binding;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "./binding_on_syntax", "./constraint_helpers"], function (require, exports, binding_on_syntax_1, constraint_helpers_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.BindingWhenSyntax = void 0;
|
|
4
5
|
var BindingWhenSyntax = (function () {
|
|
5
6
|
function BindingWhenSyntax(binding) {
|
|
6
7
|
this._binding = binding;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "../constants/metadata_keys", "../planning/metadata"], function (require, exports, METADATA_KEY, metadata_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.typeConstraint = exports.namedConstraint = exports.taggedConstraint = exports.traverseAncerstors = void 0;
|
|
4
5
|
var traverseAncerstors = function (request, constraint) {
|
|
5
6
|
var parent = request.parentRequest;
|
|
6
7
|
if (parent !== null) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports"], function (require, exports) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.multiBindToService = void 0;
|
|
4
5
|
exports.multiBindToService = function (container) {
|
|
5
6
|
return function (service) {
|
|
6
7
|
return function () {
|
package/amd/utils/exceptions.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "../constants/error_msgs"], function (require, exports, ERROR_MSGS) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.isStackOverflowExeption = void 0;
|
|
4
5
|
function isStackOverflowExeption(error) {
|
|
5
6
|
return (error instanceof RangeError ||
|
|
6
7
|
error.message === ERROR_MSGS.STACK_OVERFLOW);
|
package/amd/utils/id.js
ADDED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
define(["require", "exports", "../constants/error_msgs"], function (require, exports, ERROR_MSGS) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.circularDependencyToException = exports.listMetadataForTarget = exports.listRegisteredBindingsForServiceIdentifier = exports.getServiceIdentifierAsString = exports.getFunctionName = void 0;
|
|
4
5
|
function getServiceIdentifierAsString(serviceIdentifier) {
|
|
5
6
|
if (typeof serviceIdentifier === "function") {
|
|
6
7
|
var _serviceIdentifier = serviceIdentifier;
|
|
@@ -3,7 +3,7 @@ export declare type ServiceIdentifierOrFunc = interfaces.ServiceIdentifier<any>
|
|
|
3
3
|
export declare class LazyServiceIdentifer<T = any> {
|
|
4
4
|
private _cb;
|
|
5
5
|
constructor(cb: () => interfaces.ServiceIdentifier<T>);
|
|
6
|
-
unwrap():
|
|
6
|
+
unwrap(): interfaces.ServiceIdentifier<T>;
|
|
7
7
|
}
|
|
8
8
|
declare function inject(serviceIdentifier: ServiceIdentifierOrFunc): (target: any, targetKey: string, index?: number | undefined) => void;
|
|
9
9
|
export { inject };
|
|
@@ -16,11 +16,11 @@ export declare const INVALID_MIDDLEWARE_RETURN = "Invalid return type in middlew
|
|
|
16
16
|
export declare const INVALID_FUNCTION_BINDING = "Value provided to function binding must be a function!";
|
|
17
17
|
export declare const INVALID_TO_SELF_VALUE: string;
|
|
18
18
|
export declare const INVALID_DECORATOR_OPERATION: string;
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const ARGUMENTS_LENGTH_MISMATCH_2 = " must be >= than the number of constructor arguments of its base class.";
|
|
19
|
+
export declare const ARGUMENTS_LENGTH_MISMATCH: (...values: any[]) => string;
|
|
21
20
|
export declare const CONTAINER_OPTIONS_MUST_BE_AN_OBJECT: string;
|
|
22
21
|
export declare const CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE: string;
|
|
23
22
|
export declare const CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE: string;
|
|
23
|
+
export declare const CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK: string;
|
|
24
24
|
export declare const MULTIPLE_POST_CONSTRUCT_METHODS = "Cannot apply @postConstruct decorator multiple times in the same class";
|
|
25
25
|
export declare const POST_CONSTRUCT_ERROR: (...values: any[]) => string;
|
|
26
26
|
export declare const CIRCULAR_DEPENDENCY_IN_FACTORY: (...values: any[]) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { interfaces } from "../interfaces/interfaces";
|
|
2
2
|
declare class Container implements interfaces.Container {
|
|
3
|
-
|
|
3
|
+
id: number;
|
|
4
4
|
parent: interfaces.Container | null;
|
|
5
5
|
readonly options: interfaces.ContainerOptions;
|
|
6
6
|
private _middleware;
|
|
@@ -21,7 +21,7 @@ declare class Container implements interfaces.Container {
|
|
|
21
21
|
isBoundTagged(serviceIdentifier: interfaces.ServiceIdentifier<any>, key: string | number | symbol, value: any): boolean;
|
|
22
22
|
snapshot(): void;
|
|
23
23
|
restore(): void;
|
|
24
|
-
createChild(): Container;
|
|
24
|
+
createChild(containerOptions?: interfaces.ContainerOptions): Container;
|
|
25
25
|
applyMiddleware(...middlewares: interfaces.Middleware[]): void;
|
|
26
26
|
applyCustomMetadataReader(metadataReader: interfaces.MetadataReader): void;
|
|
27
27
|
get<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>): T;
|
|
@@ -31,8 +31,8 @@ declare class Container implements interfaces.Container {
|
|
|
31
31
|
getAllTagged<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>, key: string | number | symbol, value: any): T[];
|
|
32
32
|
getAllNamed<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>, named: string | number | symbol): T[];
|
|
33
33
|
resolve<T>(constructorFunction: interfaces.Newable<T>): T;
|
|
34
|
-
private _getContainerModuleHelpersFactory
|
|
35
|
-
private _get
|
|
36
|
-
private _planAndResolve
|
|
34
|
+
private _getContainerModuleHelpersFactory;
|
|
35
|
+
private _get;
|
|
36
|
+
private _planAndResolve;
|
|
37
37
|
}
|
|
38
38
|
export { Container };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { interfaces } from "../interfaces/interfaces";
|
|
2
2
|
export declare class ContainerModule implements interfaces.ContainerModule {
|
|
3
|
-
|
|
3
|
+
id: number;
|
|
4
4
|
registry: interfaces.ContainerModuleCallBack;
|
|
5
5
|
constructor(registry: interfaces.ContainerModuleCallBack);
|
|
6
6
|
}
|
|
7
7
|
export declare class AsyncContainerModule implements interfaces.AsyncContainerModule {
|
|
8
|
-
|
|
8
|
+
id: number;
|
|
9
9
|
registry: interfaces.AsyncContainerModuleCallBack;
|
|
10
10
|
constructor(registry: interfaces.AsyncContainerModuleCallBack);
|
|
11
11
|
}
|
|
@@ -2,7 +2,7 @@ import { interfaces } from "../interfaces/interfaces";
|
|
|
2
2
|
declare class Lookup<T extends interfaces.Clonable<T>> implements interfaces.Lookup<T> {
|
|
3
3
|
private _map;
|
|
4
4
|
constructor();
|
|
5
|
-
getMap(): Map<
|
|
5
|
+
getMap(): Map<interfaces.ServiceIdentifier<any>, T[]>;
|
|
6
6
|
add(serviceIdentifier: interfaces.ServiceIdentifier<any>, value: T): void;
|
|
7
7
|
get(serviceIdentifier: interfaces.ServiceIdentifier<any>): T[];
|
|
8
8
|
remove(serviceIdentifier: interfaces.ServiceIdentifier<any>): void;
|
|
@@ -22,9 +22,7 @@ declare namespace interfaces {
|
|
|
22
22
|
ClassProperty: interfaces.TargetType;
|
|
23
23
|
Variable: interfaces.TargetType;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
new (...args: any[]): T;
|
|
27
|
-
}
|
|
25
|
+
type Newable<T> = new (...args: any[]) => T;
|
|
28
26
|
interface Abstract<T> {
|
|
29
27
|
prototype: T;
|
|
30
28
|
}
|
|
@@ -33,7 +31,7 @@ declare namespace interfaces {
|
|
|
33
31
|
clone(): T;
|
|
34
32
|
}
|
|
35
33
|
interface Binding<T> extends Clonable<Binding<T>> {
|
|
36
|
-
|
|
34
|
+
id: number;
|
|
37
35
|
moduleId: string;
|
|
38
36
|
activated: boolean;
|
|
39
37
|
serviceIdentifier: ServiceIdentifier<T>;
|
|
@@ -64,7 +62,7 @@ declare namespace interfaces {
|
|
|
64
62
|
type Middleware = (next: Next) => Next;
|
|
65
63
|
type ContextInterceptor = (context: interfaces.Context) => interfaces.Context;
|
|
66
64
|
interface Context {
|
|
67
|
-
|
|
65
|
+
id: number;
|
|
68
66
|
container: Container;
|
|
69
67
|
plan: Plan;
|
|
70
68
|
currentRequest: Request;
|
|
@@ -92,7 +90,7 @@ declare namespace interfaces {
|
|
|
92
90
|
type ResolveRequestHandler = (request: interfaces.Request) => any;
|
|
93
91
|
type RequestScope = Map<any, any> | null;
|
|
94
92
|
interface Request {
|
|
95
|
-
|
|
93
|
+
id: number;
|
|
96
94
|
serviceIdentifier: ServiceIdentifier<any>;
|
|
97
95
|
parentContext: Context;
|
|
98
96
|
parentRequest: Request | null;
|
|
@@ -103,7 +101,7 @@ declare namespace interfaces {
|
|
|
103
101
|
addChildRequest(serviceIdentifier: ServiceIdentifier<any>, bindings: (Binding<any> | Binding<any>[]), target: Target): Request;
|
|
104
102
|
}
|
|
105
103
|
interface Target {
|
|
106
|
-
|
|
104
|
+
id: number;
|
|
107
105
|
serviceIdentifier: ServiceIdentifier<any>;
|
|
108
106
|
type: TargetType;
|
|
109
107
|
name: QueryableString;
|
|
@@ -122,9 +120,10 @@ declare namespace interfaces {
|
|
|
122
120
|
interface ContainerOptions {
|
|
123
121
|
autoBindInjectable?: boolean;
|
|
124
122
|
defaultScope?: BindingScope;
|
|
123
|
+
skipBaseClassChecks?: boolean;
|
|
125
124
|
}
|
|
126
125
|
interface Container {
|
|
127
|
-
|
|
126
|
+
id: number;
|
|
128
127
|
parent: Container | null;
|
|
129
128
|
options: ContainerOptions;
|
|
130
129
|
bind<T>(serviceIdentifier: ServiceIdentifier<T>): BindingToSyntax<T>;
|
|
@@ -138,6 +137,8 @@ declare namespace interfaces {
|
|
|
138
137
|
getNamed<T>(serviceIdentifier: ServiceIdentifier<T>, named: string | number | symbol): T;
|
|
139
138
|
getTagged<T>(serviceIdentifier: ServiceIdentifier<T>, key: string | number | symbol, value: any): T;
|
|
140
139
|
getAll<T>(serviceIdentifier: ServiceIdentifier<T>): T[];
|
|
140
|
+
getAllTagged<T>(serviceIdentifier: ServiceIdentifier<T>, key: string | number | symbol, value: any): T[];
|
|
141
|
+
getAllNamed<T>(serviceIdentifier: ServiceIdentifier<T>, named: string | number | symbol): T[];
|
|
141
142
|
resolve<T>(constructorFunction: interfaces.Newable<T>): T;
|
|
142
143
|
load(...modules: ContainerModule[]): void;
|
|
143
144
|
loadAsync(...modules: AsyncContainerModule[]): Promise<void>;
|
|
@@ -153,11 +154,11 @@ declare namespace interfaces {
|
|
|
153
154
|
type Unbind = <T>(serviceIdentifier: ServiceIdentifier<T>) => void;
|
|
154
155
|
type IsBound = <T>(serviceIdentifier: ServiceIdentifier<T>) => boolean;
|
|
155
156
|
interface ContainerModule {
|
|
156
|
-
|
|
157
|
+
id: number;
|
|
157
158
|
registry: ContainerModuleCallBack;
|
|
158
159
|
}
|
|
159
160
|
interface AsyncContainerModule {
|
|
160
|
-
|
|
161
|
+
id: number;
|
|
161
162
|
registry: AsyncContainerModuleCallBack;
|
|
162
163
|
}
|
|
163
164
|
type ContainerModuleCallBack = (bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind) => void;
|
|
@@ -206,9 +207,7 @@ declare namespace interfaces {
|
|
|
206
207
|
interface BindingInWhenOnSyntax<T> extends BindingInSyntax<T>, BindingWhenOnSyntax<T> {
|
|
207
208
|
}
|
|
208
209
|
interface BindingToSyntax<T> {
|
|
209
|
-
to(constructor:
|
|
210
|
-
new (...args: any[]): T;
|
|
211
|
-
}): BindingInWhenOnSyntax<T>;
|
|
210
|
+
to(constructor: new (...args: any[]) => T): BindingInWhenOnSyntax<T>;
|
|
212
211
|
toSelf(): BindingInWhenOnSyntax<T>;
|
|
213
212
|
toConstantValue(value: T): BindingWhenOnSyntax<T>;
|
|
214
213
|
toDynamicValue(func: (context: Context) => T): BindingInWhenOnSyntax<T>;
|
package/dts/inversify.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { multiInject } from "./annotation/multi_inject";
|
|
|
13
13
|
export { targetName } from "./annotation/target_name";
|
|
14
14
|
export { postConstruct } from "./annotation/post_construct";
|
|
15
15
|
export { MetadataReader } from "./planning/metadata_reader";
|
|
16
|
-
export {
|
|
16
|
+
export { id } from "./utils/id";
|
|
17
17
|
export { interfaces } from "./interfaces/interfaces";
|
|
18
18
|
export { decorate } from "./annotation/decorator_utils";
|
|
19
19
|
export { traverseAncerstors, taggedConstraint, namedConstraint, typeConstraint } from "./syntax/constraint_helpers";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { interfaces } from "../interfaces/interfaces";
|
|
2
|
+
import { getFunctionName } from "../utils/serialization";
|
|
2
3
|
declare function getDependencies(metadataReader: interfaces.MetadataReader, func: Function): interfaces.Target[];
|
|
3
|
-
|
|
4
|
+
declare function getBaseClassDependencyCount(metadataReader: interfaces.MetadataReader, func: Function): number;
|
|
5
|
+
export { getDependencies, getBaseClassDependencyCount, getFunctionName };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { interfaces } from "../interfaces/interfaces";
|
|
2
2
|
declare class Request implements interfaces.Request {
|
|
3
|
-
|
|
3
|
+
id: number;
|
|
4
4
|
serviceIdentifier: interfaces.ServiceIdentifier<any>;
|
|
5
5
|
parentContext: interfaces.Context;
|
|
6
6
|
parentRequest: interfaces.Request | null;
|
package/dts/planning/target.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { interfaces } from "../interfaces/interfaces";
|
|
2
2
|
import { Metadata } from "./metadata";
|
|
3
3
|
declare class Target implements interfaces.Target {
|
|
4
|
-
|
|
4
|
+
id: number;
|
|
5
5
|
type: interfaces.TargetType;
|
|
6
6
|
serviceIdentifier: interfaces.ServiceIdentifier<any>;
|
|
7
7
|
name: interfaces.QueryableString;
|
|
@@ -2,9 +2,7 @@ import { interfaces } from "../interfaces/interfaces";
|
|
|
2
2
|
declare class BindingToSyntax<T> implements interfaces.BindingToSyntax<T> {
|
|
3
3
|
private _binding;
|
|
4
4
|
constructor(binding: interfaces.Binding<T>);
|
|
5
|
-
to(constructor:
|
|
6
|
-
new (...args: any[]): T;
|
|
7
|
-
}): interfaces.BindingInWhenOnSyntax<T>;
|
|
5
|
+
to(constructor: new (...args: any[]) => T): interfaces.BindingInWhenOnSyntax<T>;
|
|
8
6
|
toSelf(): interfaces.BindingInWhenOnSyntax<T>;
|
|
9
7
|
toConstantValue(value: T): interfaces.BindingWhenOnSyntax<T>;
|
|
10
8
|
toDynamicValue(func: (context: interfaces.Context) => T): interfaces.BindingInWhenOnSyntax<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { interfaces } from "../interfaces/interfaces";
|
|
2
2
|
declare const traverseAncerstors: (request: interfaces.Request, constraint: interfaces.ConstraintFunction) => boolean;
|
|
3
|
-
declare const taggedConstraint: (key:
|
|
3
|
+
declare const taggedConstraint: (key: string | number | symbol) => (value: any) => interfaces.ConstraintFunction;
|
|
4
4
|
declare const namedConstraint: (value: any) => interfaces.ConstraintFunction;
|
|
5
|
-
declare const typeConstraint: (type:
|
|
5
|
+
declare const typeConstraint: (type: (Function | string)) => (request: interfaces.Request | null) => boolean;
|
|
6
6
|
export { traverseAncerstors, taggedConstraint, namedConstraint, typeConstraint };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { interfaces } from "../inversify";
|
|
2
|
-
export declare const multiBindToService: (container: interfaces.Container) => (service:
|
|
2
|
+
export declare const multiBindToService: (container: interfaces.Container) => (service: interfaces.ServiceIdentifier<any>) => (...types: interfaces.ServiceIdentifier<any>[]) => void;
|
|
@@ -26,7 +26,7 @@ function _tagParameterOrProperty(metadataKey, annotationTarget, propertyName, me
|
|
|
26
26
|
for (var _i = 0, paramOrPropertyMetadata_1 = paramOrPropertyMetadata; _i < paramOrPropertyMetadata_1.length; _i++) {
|
|
27
27
|
var m = paramOrPropertyMetadata_1[_i];
|
|
28
28
|
if (m.key === metadata.key) {
|
|
29
|
-
throw new Error(ERROR_MSGS.DUPLICATED_METADATA + " " + m.key);
|
|
29
|
+
throw new Error(ERROR_MSGS.DUPLICATED_METADATA + " " + m.key.toString());
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
package/es/bindings/binding.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BindingTypeEnum } from "../constants/literal_types";
|
|
2
|
-
import {
|
|
2
|
+
import { id } from "../utils/id";
|
|
3
3
|
var Binding = (function () {
|
|
4
4
|
function Binding(serviceIdentifier, scope) {
|
|
5
|
-
this.
|
|
5
|
+
this.id = id();
|
|
6
6
|
this.activated = false;
|
|
7
7
|
this.serviceIdentifier = serviceIdentifier;
|
|
8
8
|
this.scope = scope;
|
|
@@ -22,14 +22,22 @@ export var INVALID_TO_SELF_VALUE = "The toSelf function can only be applied when
|
|
|
22
22
|
"used as service identifier";
|
|
23
23
|
export var INVALID_DECORATOR_OPERATION = "The @inject @multiInject @tagged and @named decorators " +
|
|
24
24
|
"must be applied to the parameters of a class constructor or a class property.";
|
|
25
|
-
export var
|
|
26
|
-
|
|
25
|
+
export var ARGUMENTS_LENGTH_MISMATCH = function () {
|
|
26
|
+
var values = [];
|
|
27
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
28
|
+
values[_i] = arguments[_i];
|
|
29
|
+
}
|
|
30
|
+
return "The number of constructor arguments in the derived class " +
|
|
31
|
+
(values[0] + " must be >= than the number of constructor arguments of its base class.");
|
|
32
|
+
};
|
|
27
33
|
export var CONTAINER_OPTIONS_MUST_BE_AN_OBJECT = "Invalid Container constructor argument. Container options " +
|
|
28
34
|
"must be an object.";
|
|
29
35
|
export var CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE = "Invalid Container option. Default scope must " +
|
|
30
36
|
"be a string ('singleton' or 'transient').";
|
|
31
37
|
export var CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE = "Invalid Container option. Auto bind injectable must " +
|
|
32
38
|
"be a boolean";
|
|
39
|
+
export var CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = "Invalid Container option. Skip base check must " +
|
|
40
|
+
"be a boolean";
|
|
33
41
|
export var MULTIPLE_POST_CONSTRUCT_METHODS = "Cannot apply @postConstruct decorator multiple times in the same class";
|
|
34
42
|
export var POST_CONSTRUCT_ERROR = function () {
|
|
35
43
|
var values = [];
|