inversify 6.1.4 → 6.1.5-beta.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 +11 -1
- package/README.md +6 -15
- package/es/container/container.d.ts +2 -0
- package/es/container/module_activation_store.d.ts +2 -2
- package/es/interfaces/interfaces.d.ts +2 -2
- package/es/inversify.d.ts +1 -0
- package/es/inversify.js +3 -2
- package/es/inversify.js.LICENSE.txt +14 -0
- package/lib/annotation/decorator_utils.js +31 -25
- package/lib/annotation/inject.js +20 -10
- package/lib/annotation/inject_base.js +6 -6
- package/lib/annotation/injectable.js +20 -10
- package/lib/annotation/multi_inject.js +20 -10
- package/lib/annotation/named.js +20 -10
- package/lib/annotation/optional.js +20 -10
- package/lib/annotation/post_construct.js +21 -11
- package/lib/annotation/pre_destroy.js +21 -11
- package/lib/annotation/property_event_decorator.js +4 -4
- package/lib/annotation/tagged.js +2 -2
- package/lib/annotation/target_name.js +21 -11
- package/lib/annotation/unmanaged.js +21 -11
- package/lib/bindings/binding.js +23 -10
- package/lib/constants/error_msgs.js +15 -29
- package/lib/constants/literal_types.js +3 -3
- package/lib/container/container.d.ts +2 -0
- package/lib/container/container.js +317 -566
- package/lib/container/container_module.js +11 -9
- package/lib/container/container_snapshot.js +10 -8
- package/lib/container/lookup.js +61 -56
- package/lib/container/module_activation_store.d.ts +2 -2
- package/lib/container/module_activation_store.js +21 -24
- package/lib/interfaces/interfaces.d.ts +2 -2
- package/lib/inversify.d.ts +1 -0
- package/lib/inversify.js +19 -8
- package/lib/planning/context.js +12 -9
- package/lib/planning/metadata.js +27 -16
- package/lib/planning/metadata_reader.js +29 -24
- package/lib/planning/plan.js +5 -4
- package/lib/planning/planner.js +62 -53
- package/lib/planning/queryable_string.js +16 -16
- package/lib/planning/reflection_utils.js +25 -17
- package/lib/planning/request.js +15 -8
- package/lib/resolution/instantiation.js +59 -119
- package/lib/resolution/resolver.js +89 -134
- package/lib/scope/scope.js +17 -62
- package/lib/syntax/binding_in_syntax.js +12 -12
- package/lib/syntax/binding_in_when_on_syntax.js +50 -47
- package/lib/syntax/binding_on_syntax.js +9 -9
- package/lib/syntax/binding_to_syntax.js +70 -49
- package/lib/syntax/binding_when_on_syntax.js +42 -40
- package/lib/syntax/binding_when_syntax.js +54 -76
- package/lib/syntax/constraint_helpers.js +31 -23
- package/lib/utils/async.js +1 -1
- package/lib/utils/binding_utils.js +31 -29
- package/lib/utils/exceptions.js +19 -9
- package/lib/utils/id.js +1 -1
- package/lib/utils/js.js +2 -3
- package/lib/utils/serialization.js +42 -33
- package/package.json +14 -15
- package/amd/annotation/decorator_utils.d.ts +0 -16
- package/amd/annotation/decorator_utils.js +0 -119
- package/amd/annotation/inject.d.ts +0 -5
- package/amd/annotation/inject.js +0 -31
- package/amd/annotation/inject_base.d.ts +0 -4
- package/amd/annotation/inject_base.js +0 -16
- package/amd/annotation/injectable.d.ts +0 -2
- package/amd/annotation/injectable.js +0 -40
- package/amd/annotation/lazy_service_identifier.js +0 -4
- package/amd/annotation/multi_inject.d.ts +0 -5
- package/amd/annotation/multi_inject.js +0 -31
- package/amd/annotation/named.d.ts +0 -2
- package/amd/annotation/named.js +0 -32
- package/amd/annotation/optional.d.ts +0 -2
- package/amd/annotation/optional.js +0 -32
- package/amd/annotation/post_construct.d.ts +0 -4
- package/amd/annotation/post_construct.js +0 -32
- package/amd/annotation/pre_destroy.d.ts +0 -4
- package/amd/annotation/pre_destroy.js +0 -32
- package/amd/annotation/property_event_decorator.d.ts +0 -4
- package/amd/annotation/property_event_decorator.js +0 -16
- package/amd/annotation/tagged.d.ts +0 -2
- package/amd/annotation/tagged.js +0 -8
- package/amd/annotation/target_name.d.ts +0 -3
- package/amd/annotation/target_name.js +0 -35
- package/amd/annotation/unmanaged.d.ts +0 -3
- package/amd/annotation/unmanaged.js +0 -35
- package/amd/bindings/binding.d.ts +0 -20
- package/amd/bindings/binding.js +0 -40
- package/amd/bindings/binding_count.d.ts +0 -5
- package/amd/bindings/binding_count.js +0 -11
- package/amd/constants/error_msgs.d.ts +0 -30
- package/amd/constants/error_msgs.js +0 -75
- package/amd/constants/literal_types.d.ts +0 -5
- package/amd/constants/literal_types.js +0 -28
- package/amd/constants/metadata_keys.d.ts +0 -13
- package/amd/constants/metadata_keys.js +0 -28
- package/amd/container/container.d.ts +0 -73
- package/amd/container/container.js +0 -766
- package/amd/container/container_module.d.ts +0 -11
- package/amd/container/container_module.js +0 -21
- package/amd/container/container_snapshot.d.ts +0 -10
- package/amd/container/container_snapshot.js +0 -20
- package/amd/container/lookup.d.ts +0 -17
- package/amd/container/lookup.js +0 -132
- package/amd/container/module_activation_store.d.ts +0 -10
- package/amd/container/module_activation_store.js +0 -51
- package/amd/interfaces/interfaces.d.ts +0 -269
- package/amd/interfaces/interfaces.js +0 -4
- package/amd/inversify.d.ts +0 -24
- package/amd/inversify.js +0 -57
- package/amd/planning/context.d.ts +0 -11
- package/amd/planning/context.js +0 -19
- package/amd/planning/metadata.d.ts +0 -8
- package/amd/planning/metadata.js +0 -45
- package/amd/planning/metadata_reader.d.ts +0 -6
- package/amd/planning/metadata_reader.js +0 -49
- package/amd/planning/plan.d.ts +0 -7
- package/amd/planning/plan.js +0 -13
- package/amd/planning/planner.d.ts +0 -5
- package/amd/planning/planner.js +0 -187
- package/amd/planning/queryable_string.d.ts +0 -10
- package/amd/planning/queryable_string.js +0 -33
- package/amd/planning/reflection_utils.d.ts +0 -5
- package/amd/planning/reflection_utils.js +0 -55
- package/amd/planning/request.d.ts +0 -14
- package/amd/planning/request.js +0 -24
- package/amd/planning/target.js +0 -111
- package/amd/resolution/instantiation.d.ts +0 -3
- package/amd/resolution/instantiation.js +0 -219
- package/amd/resolution/resolver.d.ts +0 -3
- package/amd/resolution/resolver.js +0 -234
- package/amd/scope/scope.d.ts +0 -3
- package/amd/scope/scope.js +0 -93
- package/amd/syntax/binding_in_syntax.d.ts +0 -9
- package/amd/syntax/binding_in_syntax.js +0 -24
- package/amd/syntax/binding_in_when_on_syntax.d.ts +0 -29
- package/amd/syntax/binding_in_when_on_syntax.js +0 -75
- package/amd/syntax/binding_on_syntax.d.ts +0 -8
- package/amd/syntax/binding_on_syntax.js +0 -20
- package/amd/syntax/binding_to_syntax.d.ts +0 -18
- package/amd/syntax/binding_to_syntax.js +0 -116
- package/amd/syntax/binding_when_on_syntax.d.ts +0 -25
- package/amd/syntax/binding_when_on_syntax.js +0 -65
- package/amd/syntax/binding_when_syntax.d.ts +0 -21
- package/amd/syntax/binding_when_syntax.js +0 -107
- package/amd/syntax/constraint_helpers.d.ts +0 -6
- package/amd/syntax/constraint_helpers.js +0 -66
- package/amd/utils/async.d.ts +0 -3
- package/amd/utils/async.js +0 -17
- package/amd/utils/binding_utils.d.ts +0 -4
- package/amd/utils/binding_utils.js +0 -86
- package/amd/utils/clonable.d.ts +0 -3
- package/amd/utils/clonable.js +0 -11
- package/amd/utils/exceptions.d.ts +0 -2
- package/amd/utils/exceptions.js +0 -46
- package/amd/utils/factory_type.d.ts +0 -5
- package/amd/utils/factory_type.js +0 -11
- package/amd/utils/id.d.ts +0 -2
- package/amd/utils/id.js +0 -9
- package/amd/utils/js.d.ts +0 -1
- package/amd/utils/js.js +0 -18
- package/amd/utils/serialization.d.ts +0 -10
- package/amd/utils/serialization.js +0 -135
- package/es6/annotation/decorator_utils.d.ts +0 -16
- package/es6/annotation/decorator_utils.js +0 -114
- package/es6/annotation/inject.d.ts +0 -5
- package/es6/annotation/inject.js +0 -30
- package/es6/annotation/inject_base.d.ts +0 -4
- package/es6/annotation/inject_base.js +0 -17
- package/es6/annotation/injectable.d.ts +0 -2
- package/es6/annotation/injectable.js +0 -38
- package/es6/annotation/lazy_service_identifier.js +0 -2
- package/es6/annotation/multi_inject.d.ts +0 -5
- package/es6/annotation/multi_inject.js +0 -30
- package/es6/annotation/named.d.ts +0 -2
- package/es6/annotation/named.js +0 -32
- package/es6/annotation/optional.d.ts +0 -2
- package/es6/annotation/optional.js +0 -32
- package/es6/annotation/post_construct.d.ts +0 -4
- package/es6/annotation/post_construct.js +0 -31
- package/es6/annotation/pre_destroy.d.ts +0 -4
- package/es6/annotation/pre_destroy.js +0 -31
- package/es6/annotation/property_event_decorator.d.ts +0 -4
- package/es6/annotation/property_event_decorator.js +0 -15
- package/es6/annotation/tagged.d.ts +0 -2
- package/es6/annotation/tagged.js +0 -8
- package/es6/annotation/target_name.d.ts +0 -3
- package/es6/annotation/target_name.js +0 -35
- package/es6/annotation/unmanaged.d.ts +0 -3
- package/es6/annotation/unmanaged.js +0 -35
- package/es6/bindings/binding.d.ts +0 -20
- package/es6/bindings/binding.js +0 -39
- package/es6/bindings/binding_count.d.ts +0 -5
- package/es6/bindings/binding_count.js +0 -9
- package/es6/constants/error_msgs.d.ts +0 -30
- package/es6/constants/error_msgs.js +0 -59
- package/es6/constants/literal_types.d.ts +0 -5
- package/es6/constants/literal_types.js +0 -26
- package/es6/constants/metadata_keys.d.ts +0 -13
- package/es6/constants/metadata_keys.js +0 -26
- package/es6/container/container.d.ts +0 -73
- package/es6/container/container.js +0 -545
- package/es6/container/container_module.d.ts +0 -11
- package/es6/container/container_module.js +0 -18
- package/es6/container/container_snapshot.d.ts +0 -10
- package/es6/container/container_snapshot.js +0 -15
- package/es6/container/lookup.d.ts +0 -17
- package/es6/container/lookup.js +0 -125
- package/es6/container/module_activation_store.d.ts +0 -10
- package/es6/container/module_activation_store.js +0 -49
- package/es6/interfaces/interfaces.d.ts +0 -269
- package/es6/interfaces/interfaces.js +0 -2
- package/es6/inversify.d.ts +0 -24
- package/es6/inversify.js +0 -76
- package/es6/planning/context.d.ts +0 -11
- package/es6/planning/context.js +0 -17
- package/es6/planning/metadata.d.ts +0 -8
- package/es6/planning/metadata.js +0 -42
- package/es6/planning/metadata_reader.d.ts +0 -6
- package/es6/planning/metadata_reader.js +0 -44
- package/es6/planning/plan.d.ts +0 -7
- package/es6/planning/plan.js +0 -10
- package/es6/planning/planner.d.ts +0 -5
- package/es6/planning/planner.js +0 -194
- package/es6/planning/queryable_string.d.ts +0 -10
- package/es6/planning/queryable_string.js +0 -30
- package/es6/planning/reflection_utils.d.ts +0 -5
- package/es6/planning/reflection_utils.js +0 -53
- package/es6/planning/request.d.ts +0 -14
- package/es6/planning/request.js +0 -22
- package/es6/planning/target.js +0 -105
- package/es6/resolution/instantiation.d.ts +0 -3
- package/es6/resolution/instantiation.js +0 -158
- package/es6/resolution/resolver.d.ts +0 -3
- package/es6/resolution/resolver.js +0 -193
- package/es6/scope/scope.d.ts +0 -3
- package/es6/scope/scope.js +0 -57
- package/es6/syntax/binding_in_syntax.d.ts +0 -9
- package/es6/syntax/binding_in_syntax.js +0 -23
- package/es6/syntax/binding_in_when_on_syntax.d.ts +0 -29
- package/es6/syntax/binding_in_when_on_syntax.js +0 -75
- package/es6/syntax/binding_on_syntax.d.ts +0 -8
- package/es6/syntax/binding_on_syntax.js +0 -18
- package/es6/syntax/binding_to_syntax.d.ts +0 -18
- package/es6/syntax/binding_to_syntax.js +0 -110
- package/es6/syntax/binding_when_on_syntax.d.ts +0 -25
- package/es6/syntax/binding_when_on_syntax.js +0 -64
- package/es6/syntax/binding_when_syntax.d.ts +0 -21
- package/es6/syntax/binding_when_syntax.js +0 -84
- package/es6/syntax/constraint_helpers.d.ts +0 -6
- package/es6/syntax/constraint_helpers.js +0 -63
- package/es6/utils/async.d.ts +0 -3
- package/es6/utils/async.js +0 -15
- package/es6/utils/binding_utils.d.ts +0 -4
- package/es6/utils/binding_utils.js +0 -79
- package/es6/utils/clonable.d.ts +0 -3
- package/es6/utils/clonable.js +0 -9
- package/es6/utils/exceptions.d.ts +0 -2
- package/es6/utils/exceptions.js +0 -44
- package/es6/utils/factory_type.d.ts +0 -5
- package/es6/utils/factory_type.js +0 -9
- package/es6/utils/id.d.ts +0 -2
- package/es6/utils/id.js +0 -7
- package/es6/utils/js.d.ts +0 -1
- package/es6/utils/js.js +0 -15
- package/es6/utils/serialization.d.ts +0 -10
- package/es6/utils/serialization.js +0 -132
|
@@ -15,103 +15,124 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.BindingToSyntax = void 0;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
const ERROR_MSGS = __importStar(require("../constants/error_msgs"));
|
|
38
|
+
const literal_types_1 = require("../constants/literal_types");
|
|
39
|
+
const binding_in_when_on_syntax_1 = require("./binding_in_when_on_syntax");
|
|
40
|
+
const binding_when_on_syntax_1 = require("./binding_when_on_syntax");
|
|
41
|
+
class BindingToSyntax {
|
|
42
|
+
_binding;
|
|
43
|
+
constructor(binding) {
|
|
33
44
|
this._binding = binding;
|
|
34
45
|
}
|
|
35
|
-
|
|
46
|
+
to(constructor) {
|
|
36
47
|
this._binding.type = literal_types_1.BindingTypeEnum.Instance;
|
|
37
48
|
this._binding.implementationType = constructor;
|
|
38
49
|
return new binding_in_when_on_syntax_1.BindingInWhenOnSyntax(this._binding);
|
|
39
|
-
}
|
|
40
|
-
|
|
50
|
+
}
|
|
51
|
+
toSelf() {
|
|
41
52
|
if (typeof this._binding.serviceIdentifier !== 'function') {
|
|
42
53
|
throw new Error(ERROR_MSGS.INVALID_TO_SELF_VALUE);
|
|
43
54
|
}
|
|
44
|
-
|
|
55
|
+
const self = this._binding
|
|
45
56
|
.serviceIdentifier;
|
|
46
57
|
return this.to(self);
|
|
47
|
-
}
|
|
48
|
-
|
|
58
|
+
}
|
|
59
|
+
toConstantValue(value) {
|
|
49
60
|
this._binding.type = literal_types_1.BindingTypeEnum.ConstantValue;
|
|
50
61
|
this._binding.cache = value;
|
|
51
62
|
this._binding.dynamicValue = null;
|
|
52
63
|
this._binding.implementationType = null;
|
|
53
64
|
this._binding.scope = literal_types_1.BindingScopeEnum.Singleton;
|
|
54
65
|
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
|
55
|
-
}
|
|
56
|
-
|
|
66
|
+
}
|
|
67
|
+
toDynamicValue(func) {
|
|
57
68
|
this._binding.type = literal_types_1.BindingTypeEnum.DynamicValue;
|
|
58
69
|
this._binding.cache = null;
|
|
59
70
|
this._binding.dynamicValue = func;
|
|
60
71
|
this._binding.implementationType = null;
|
|
61
72
|
return new binding_in_when_on_syntax_1.BindingInWhenOnSyntax(this._binding);
|
|
62
|
-
}
|
|
63
|
-
|
|
73
|
+
}
|
|
74
|
+
toConstructor(constructor) {
|
|
64
75
|
this._binding.type = literal_types_1.BindingTypeEnum.Constructor;
|
|
65
76
|
this._binding.implementationType = constructor;
|
|
66
77
|
this._binding.scope = literal_types_1.BindingScopeEnum.Singleton;
|
|
67
78
|
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
|
68
|
-
}
|
|
69
|
-
|
|
79
|
+
}
|
|
80
|
+
toFactory(factory) {
|
|
70
81
|
this._binding.type = literal_types_1.BindingTypeEnum.Factory;
|
|
71
82
|
this._binding.factory = factory;
|
|
72
83
|
this._binding.scope = literal_types_1.BindingScopeEnum.Singleton;
|
|
73
84
|
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
|
74
|
-
}
|
|
75
|
-
|
|
85
|
+
}
|
|
86
|
+
toFunction(func) {
|
|
76
87
|
if (typeof func !== 'function') {
|
|
77
88
|
throw new Error(ERROR_MSGS.INVALID_FUNCTION_BINDING);
|
|
78
89
|
}
|
|
79
|
-
|
|
90
|
+
const bindingWhenOnSyntax = this.toConstantValue(func);
|
|
80
91
|
this._binding.type = literal_types_1.BindingTypeEnum.Function;
|
|
81
92
|
this._binding.scope = literal_types_1.BindingScopeEnum.Singleton;
|
|
82
93
|
return bindingWhenOnSyntax;
|
|
83
|
-
}
|
|
84
|
-
|
|
94
|
+
}
|
|
95
|
+
toAutoFactory(serviceIdentifier) {
|
|
85
96
|
this._binding.type = literal_types_1.BindingTypeEnum.Factory;
|
|
86
|
-
this._binding.factory =
|
|
87
|
-
|
|
88
|
-
return context.container.get(serviceIdentifier);
|
|
89
|
-
};
|
|
97
|
+
this._binding.factory = (context) => {
|
|
98
|
+
const autofactory = () => context.container.get(serviceIdentifier);
|
|
90
99
|
return autofactory;
|
|
91
100
|
};
|
|
92
101
|
this._binding.scope = literal_types_1.BindingScopeEnum.Singleton;
|
|
93
102
|
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
|
94
|
-
}
|
|
95
|
-
|
|
103
|
+
}
|
|
104
|
+
toAutoNamedFactory(serviceIdentifier) {
|
|
96
105
|
this._binding.type = literal_types_1.BindingTypeEnum.Factory;
|
|
97
|
-
this._binding.factory =
|
|
98
|
-
return
|
|
99
|
-
return context.container.getNamed(serviceIdentifier, named);
|
|
100
|
-
};
|
|
106
|
+
this._binding.factory = (context) => {
|
|
107
|
+
return (named) => context.container.getNamed(serviceIdentifier, named);
|
|
101
108
|
};
|
|
102
109
|
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
|
103
|
-
}
|
|
104
|
-
|
|
110
|
+
}
|
|
111
|
+
toProvider(provider) {
|
|
105
112
|
this._binding.type = literal_types_1.BindingTypeEnum.Provider;
|
|
106
113
|
this._binding.provider = provider;
|
|
107
114
|
this._binding.scope = literal_types_1.BindingScopeEnum.Singleton;
|
|
108
115
|
return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
this.
|
|
112
|
-
|
|
116
|
+
}
|
|
117
|
+
toService(service) {
|
|
118
|
+
this._binding.type = literal_types_1.BindingTypeEnum.DynamicValue;
|
|
119
|
+
Object.defineProperty(this._binding, 'cache', {
|
|
120
|
+
configurable: true,
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get() {
|
|
123
|
+
return null;
|
|
124
|
+
},
|
|
125
|
+
set(_value) { },
|
|
113
126
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
127
|
+
this._binding.dynamicValue = (context) => {
|
|
128
|
+
try {
|
|
129
|
+
return context.container.get(service);
|
|
130
|
+
}
|
|
131
|
+
catch (_error) {
|
|
132
|
+
return context.container.getAsync(service);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
this._binding.implementationType = null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
117
138
|
exports.BindingToSyntax = BindingToSyntax;
|
|
@@ -1,65 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BindingWhenOnSyntax = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const binding_on_syntax_1 = require("./binding_on_syntax");
|
|
5
|
+
const binding_when_syntax_1 = require("./binding_when_syntax");
|
|
6
|
+
class BindingWhenOnSyntax {
|
|
7
|
+
_bindingWhenSyntax;
|
|
8
|
+
_bindingOnSyntax;
|
|
9
|
+
_binding;
|
|
10
|
+
constructor(binding) {
|
|
8
11
|
this._binding = binding;
|
|
9
12
|
this._bindingWhenSyntax = new binding_when_syntax_1.BindingWhenSyntax(this._binding);
|
|
10
13
|
this._bindingOnSyntax = new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
11
14
|
}
|
|
12
|
-
|
|
15
|
+
when(constraint) {
|
|
13
16
|
return this._bindingWhenSyntax.when(constraint);
|
|
14
|
-
}
|
|
15
|
-
|
|
17
|
+
}
|
|
18
|
+
whenTargetNamed(name) {
|
|
16
19
|
return this._bindingWhenSyntax.whenTargetNamed(name);
|
|
17
|
-
}
|
|
18
|
-
|
|
20
|
+
}
|
|
21
|
+
whenTargetIsDefault() {
|
|
19
22
|
return this._bindingWhenSyntax.whenTargetIsDefault();
|
|
20
|
-
}
|
|
21
|
-
|
|
23
|
+
}
|
|
24
|
+
whenTargetTagged(tag, value) {
|
|
22
25
|
return this._bindingWhenSyntax.whenTargetTagged(tag, value);
|
|
23
|
-
}
|
|
24
|
-
|
|
26
|
+
}
|
|
27
|
+
whenInjectedInto(parent) {
|
|
25
28
|
return this._bindingWhenSyntax.whenInjectedInto(parent);
|
|
26
|
-
}
|
|
27
|
-
|
|
29
|
+
}
|
|
30
|
+
whenParentNamed(name) {
|
|
28
31
|
return this._bindingWhenSyntax.whenParentNamed(name);
|
|
29
|
-
}
|
|
30
|
-
|
|
32
|
+
}
|
|
33
|
+
whenParentTagged(tag, value) {
|
|
31
34
|
return this._bindingWhenSyntax.whenParentTagged(tag, value);
|
|
32
|
-
}
|
|
33
|
-
|
|
35
|
+
}
|
|
36
|
+
whenAnyAncestorIs(ancestor) {
|
|
34
37
|
return this._bindingWhenSyntax.whenAnyAncestorIs(ancestor);
|
|
35
|
-
}
|
|
36
|
-
|
|
38
|
+
}
|
|
39
|
+
whenNoAncestorIs(ancestor) {
|
|
37
40
|
return this._bindingWhenSyntax.whenNoAncestorIs(ancestor);
|
|
38
|
-
}
|
|
39
|
-
|
|
41
|
+
}
|
|
42
|
+
whenAnyAncestorNamed(name) {
|
|
40
43
|
return this._bindingWhenSyntax.whenAnyAncestorNamed(name);
|
|
41
|
-
}
|
|
42
|
-
|
|
44
|
+
}
|
|
45
|
+
whenAnyAncestorTagged(tag, value) {
|
|
43
46
|
return this._bindingWhenSyntax.whenAnyAncestorTagged(tag, value);
|
|
44
|
-
}
|
|
45
|
-
|
|
47
|
+
}
|
|
48
|
+
whenNoAncestorNamed(name) {
|
|
46
49
|
return this._bindingWhenSyntax.whenNoAncestorNamed(name);
|
|
47
|
-
}
|
|
48
|
-
|
|
50
|
+
}
|
|
51
|
+
whenNoAncestorTagged(tag, value) {
|
|
49
52
|
return this._bindingWhenSyntax.whenNoAncestorTagged(tag, value);
|
|
50
|
-
}
|
|
51
|
-
|
|
53
|
+
}
|
|
54
|
+
whenAnyAncestorMatches(constraint) {
|
|
52
55
|
return this._bindingWhenSyntax.whenAnyAncestorMatches(constraint);
|
|
53
|
-
}
|
|
54
|
-
|
|
56
|
+
}
|
|
57
|
+
whenNoAncestorMatches(constraint) {
|
|
55
58
|
return this._bindingWhenSyntax.whenNoAncestorMatches(constraint);
|
|
56
|
-
}
|
|
57
|
-
|
|
59
|
+
}
|
|
60
|
+
onActivation(handler) {
|
|
58
61
|
return this._bindingOnSyntax.onActivation(handler);
|
|
59
|
-
}
|
|
60
|
-
|
|
62
|
+
}
|
|
63
|
+
onDeactivation(handler) {
|
|
61
64
|
return this._bindingOnSyntax.onDeactivation(handler);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
}());
|
|
65
|
+
}
|
|
66
|
+
}
|
|
65
67
|
exports.BindingWhenOnSyntax = BindingWhenOnSyntax;
|
|
@@ -1,107 +1,85 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BindingWhenSyntax = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const binding_on_syntax_1 = require("./binding_on_syntax");
|
|
5
|
+
const constraint_helpers_1 = require("./constraint_helpers");
|
|
6
|
+
class BindingWhenSyntax {
|
|
7
|
+
_binding;
|
|
8
|
+
constructor(binding) {
|
|
8
9
|
this._binding = binding;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
when(constraint) {
|
|
11
12
|
this._binding.constraint = constraint;
|
|
12
13
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
13
|
-
}
|
|
14
|
-
|
|
14
|
+
}
|
|
15
|
+
whenTargetNamed(name) {
|
|
15
16
|
this._binding.constraint = (0, constraint_helpers_1.namedConstraint)(name);
|
|
16
17
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
this._binding.constraint =
|
|
18
|
+
}
|
|
19
|
+
whenTargetIsDefault() {
|
|
20
|
+
this._binding.constraint = (request) => {
|
|
20
21
|
if (request === null) {
|
|
21
22
|
return false;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
+
const targetIsDefault = request.target !== null &&
|
|
24
25
|
!request.target.isNamed() &&
|
|
25
26
|
!request.target.isTagged();
|
|
26
27
|
return targetIsDefault;
|
|
27
28
|
};
|
|
28
29
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
29
|
-
}
|
|
30
|
-
|
|
30
|
+
}
|
|
31
|
+
whenTargetTagged(tag, value) {
|
|
31
32
|
this._binding.constraint = (0, constraint_helpers_1.taggedConstraint)(tag)(value);
|
|
32
33
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
this._binding.constraint =
|
|
36
|
-
return request !== null && (0, constraint_helpers_1.typeConstraint)(parent)(request.parentRequest);
|
|
37
|
-
};
|
|
34
|
+
}
|
|
35
|
+
whenInjectedInto(parent) {
|
|
36
|
+
this._binding.constraint = (request) => request !== null && (0, constraint_helpers_1.typeConstraint)(parent)(request.parentRequest);
|
|
38
37
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
this._binding.constraint =
|
|
42
|
-
return request !== null && (0, constraint_helpers_1.namedConstraint)(name)(request.parentRequest);
|
|
43
|
-
};
|
|
38
|
+
}
|
|
39
|
+
whenParentNamed(name) {
|
|
40
|
+
this._binding.constraint = (request) => request !== null && (0, constraint_helpers_1.namedConstraint)(name)(request.parentRequest);
|
|
44
41
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
this._binding.constraint =
|
|
48
|
-
return request !== null && (0, constraint_helpers_1.taggedConstraint)(tag)(value)(request.parentRequest);
|
|
49
|
-
};
|
|
42
|
+
}
|
|
43
|
+
whenParentTagged(tag, value) {
|
|
44
|
+
this._binding.constraint = (request) => request !== null && (0, constraint_helpers_1.taggedConstraint)(tag)(value)(request.parentRequest);
|
|
50
45
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
this._binding.constraint =
|
|
54
|
-
return request !== null && (0, constraint_helpers_1.traverseAncerstors)(request, (0, constraint_helpers_1.typeConstraint)(ancestor));
|
|
55
|
-
};
|
|
46
|
+
}
|
|
47
|
+
whenAnyAncestorIs(ancestor) {
|
|
48
|
+
this._binding.constraint = (request) => request !== null && (0, constraint_helpers_1.traverseAncerstors)(request, (0, constraint_helpers_1.typeConstraint)(ancestor));
|
|
56
49
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
this._binding.constraint =
|
|
60
|
-
|
|
61
|
-
!(0, constraint_helpers_1.traverseAncerstors)(request, (0, constraint_helpers_1.typeConstraint)(ancestor));
|
|
62
|
-
};
|
|
50
|
+
}
|
|
51
|
+
whenNoAncestorIs(ancestor) {
|
|
52
|
+
this._binding.constraint = (request) => request !== null &&
|
|
53
|
+
!(0, constraint_helpers_1.traverseAncerstors)(request, (0, constraint_helpers_1.typeConstraint)(ancestor));
|
|
63
54
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
this._binding.constraint =
|
|
67
|
-
return request !== null && (0, constraint_helpers_1.traverseAncerstors)(request, (0, constraint_helpers_1.namedConstraint)(name));
|
|
68
|
-
};
|
|
55
|
+
}
|
|
56
|
+
whenAnyAncestorNamed(name) {
|
|
57
|
+
this._binding.constraint = (request) => request !== null && (0, constraint_helpers_1.traverseAncerstors)(request, (0, constraint_helpers_1.namedConstraint)(name));
|
|
69
58
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
this._binding.constraint =
|
|
73
|
-
return request !== null && !(0, constraint_helpers_1.traverseAncerstors)(request, (0, constraint_helpers_1.namedConstraint)(name));
|
|
74
|
-
};
|
|
59
|
+
}
|
|
60
|
+
whenNoAncestorNamed(name) {
|
|
61
|
+
this._binding.constraint = (request) => request !== null && !(0, constraint_helpers_1.traverseAncerstors)(request, (0, constraint_helpers_1.namedConstraint)(name));
|
|
75
62
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
this._binding.constraint =
|
|
79
|
-
|
|
80
|
-
(0, constraint_helpers_1.traverseAncerstors)(request, (0, constraint_helpers_1.taggedConstraint)(tag)(value));
|
|
81
|
-
};
|
|
63
|
+
}
|
|
64
|
+
whenAnyAncestorTagged(tag, value) {
|
|
65
|
+
this._binding.constraint = (request) => request !== null &&
|
|
66
|
+
(0, constraint_helpers_1.traverseAncerstors)(request, (0, constraint_helpers_1.taggedConstraint)(tag)(value));
|
|
82
67
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
this._binding.constraint =
|
|
86
|
-
|
|
87
|
-
!(0, constraint_helpers_1.traverseAncerstors)(request, (0, constraint_helpers_1.taggedConstraint)(tag)(value));
|
|
88
|
-
};
|
|
68
|
+
}
|
|
69
|
+
whenNoAncestorTagged(tag, value) {
|
|
70
|
+
this._binding.constraint = (request) => request !== null &&
|
|
71
|
+
!(0, constraint_helpers_1.traverseAncerstors)(request, (0, constraint_helpers_1.taggedConstraint)(tag)(value));
|
|
89
72
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
this._binding.constraint =
|
|
93
|
-
|
|
94
|
-
(0, constraint_helpers_1.traverseAncerstors)(request, constraint);
|
|
95
|
-
};
|
|
73
|
+
}
|
|
74
|
+
whenAnyAncestorMatches(constraint) {
|
|
75
|
+
this._binding.constraint = (request) => request !== null &&
|
|
76
|
+
(0, constraint_helpers_1.traverseAncerstors)(request, constraint);
|
|
96
77
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
this._binding.constraint =
|
|
100
|
-
|
|
101
|
-
!(0, constraint_helpers_1.traverseAncerstors)(request, constraint);
|
|
102
|
-
};
|
|
78
|
+
}
|
|
79
|
+
whenNoAncestorMatches(constraint) {
|
|
80
|
+
this._binding.constraint = (request) => request !== null &&
|
|
81
|
+
!(0, constraint_helpers_1.traverseAncerstors)(request, constraint);
|
|
103
82
|
return new binding_on_syntax_1.BindingOnSyntax(this._binding);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
}());
|
|
83
|
+
}
|
|
84
|
+
}
|
|
107
85
|
exports.BindingWhenSyntax = BindingWhenSyntax;
|
|
@@ -15,19 +15,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.typeConstraint = exports.namedConstraint = exports.taggedConstraint = exports.traverseAncerstors = void 0;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
const METADATA_KEY = __importStar(require("../constants/metadata_keys"));
|
|
38
|
+
const metadata_1 = require("../planning/metadata");
|
|
39
|
+
const traverseAncerstors = (request, constraint) => {
|
|
40
|
+
const parent = request.parentRequest;
|
|
31
41
|
if (parent !== null) {
|
|
32
42
|
return constraint(parent) ? true : traverseAncerstors(parent, constraint);
|
|
33
43
|
}
|
|
@@ -36,30 +46,28 @@ var traverseAncerstors = function (request, constraint) {
|
|
|
36
46
|
}
|
|
37
47
|
};
|
|
38
48
|
exports.traverseAncerstors = traverseAncerstors;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
request.target.matchesTag(key)(value);
|
|
44
|
-
};
|
|
49
|
+
const taggedConstraint = (key) => (value) => {
|
|
50
|
+
const constraint = (request) => request !== null &&
|
|
51
|
+
request.target !== null &&
|
|
52
|
+
request.target.matchesTag(key)(value);
|
|
45
53
|
constraint.metaData = new metadata_1.Metadata(key, value);
|
|
46
54
|
return constraint;
|
|
47
|
-
};
|
|
55
|
+
};
|
|
48
56
|
exports.taggedConstraint = taggedConstraint;
|
|
49
|
-
|
|
57
|
+
const namedConstraint = taggedConstraint(METADATA_KEY.NAMED_TAG);
|
|
50
58
|
exports.namedConstraint = namedConstraint;
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
const typeConstraint = (type) => (request) => {
|
|
60
|
+
let binding = null;
|
|
53
61
|
if (request !== null) {
|
|
54
62
|
binding = request.bindings[0];
|
|
55
63
|
if (typeof type === 'string') {
|
|
56
64
|
return binding.serviceIdentifier === type;
|
|
57
65
|
}
|
|
58
66
|
else {
|
|
59
|
-
|
|
67
|
+
const constructor = request.bindings[0].implementationType;
|
|
60
68
|
return type === constructor;
|
|
61
69
|
}
|
|
62
70
|
}
|
|
63
71
|
return false;
|
|
64
|
-
};
|
|
72
|
+
};
|
|
65
73
|
exports.typeConstraint = typeConstraint;
|
package/lib/utils/async.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isPromise = isPromise;
|
|
4
4
|
exports.isPromiseOrContainsPromise = isPromiseOrContainsPromise;
|
|
5
5
|
function isPromise(object) {
|
|
6
|
-
|
|
6
|
+
const isObjectOrFunction = (typeof object === 'object' && object !== null) ||
|
|
7
7
|
typeof object === 'function';
|
|
8
8
|
return (isObjectOrFunction && typeof object.then === 'function');
|
|
9
9
|
}
|
|
@@ -15,35 +15,37 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getFactoryDetails = exports.ensureFullyBound = exports.multiBindToService = void 0;
|
|
27
|
-
var ERROR_MSGS = __importStar(require("../constants/error_msgs"));
|
|
28
|
-
var literal_types_1 = require("../constants/literal_types");
|
|
29
|
-
var serialization_1 = require("../utils/serialization");
|
|
30
|
-
var factory_type_1 = require("./factory_type");
|
|
31
|
-
var multiBindToService = function (container) {
|
|
32
|
-
return function (service) {
|
|
33
|
-
return function () {
|
|
34
|
-
var types = [];
|
|
35
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
36
|
-
types[_i] = arguments[_i];
|
|
37
|
-
}
|
|
38
|
-
types.forEach(function (t) {
|
|
39
|
-
container.bind(t).toService(service);
|
|
40
|
-
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
41
24
|
};
|
|
25
|
+
return ownKeys(o);
|
|
42
26
|
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getFactoryDetails = exports.ensureFullyBound = exports.multiBindToService = void 0;
|
|
37
|
+
const ERROR_MSGS = __importStar(require("../constants/error_msgs"));
|
|
38
|
+
const literal_types_1 = require("../constants/literal_types");
|
|
39
|
+
const serialization_1 = require("../utils/serialization");
|
|
40
|
+
const factory_type_1 = require("./factory_type");
|
|
41
|
+
const multiBindToService = (container) => (service) => (...types) => {
|
|
42
|
+
types.forEach((t) => {
|
|
43
|
+
container.bind(t).toService(service);
|
|
44
|
+
});
|
|
43
45
|
};
|
|
44
46
|
exports.multiBindToService = multiBindToService;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
const ensureFullyBound = (binding) => {
|
|
48
|
+
let boundValue = null;
|
|
47
49
|
switch (binding.type) {
|
|
48
50
|
case literal_types_1.BindingTypeEnum.ConstantValue:
|
|
49
51
|
case literal_types_1.BindingTypeEnum.Function:
|
|
@@ -64,12 +66,12 @@ var ensureFullyBound = function (binding) {
|
|
|
64
66
|
break;
|
|
65
67
|
}
|
|
66
68
|
if (boundValue === null) {
|
|
67
|
-
|
|
68
|
-
throw new Error(
|
|
69
|
+
const serviceIdentifierAsString = (0, serialization_1.getServiceIdentifierAsString)(binding.serviceIdentifier);
|
|
70
|
+
throw new Error(`${ERROR_MSGS.INVALID_BINDING_TYPE} ${serviceIdentifierAsString}`);
|
|
69
71
|
}
|
|
70
72
|
};
|
|
71
73
|
exports.ensureFullyBound = ensureFullyBound;
|
|
72
|
-
|
|
74
|
+
const getFactoryDetails = (binding) => {
|
|
73
75
|
switch (binding.type) {
|
|
74
76
|
case literal_types_1.BindingTypeEnum.Factory:
|
|
75
77
|
return { factory: binding.factory, factoryType: factory_type_1.FactoryType.Factory };
|
|
@@ -81,7 +83,7 @@ var getFactoryDetails = function (binding) {
|
|
|
81
83
|
factoryType: factory_type_1.FactoryType.DynamicValue,
|
|
82
84
|
};
|
|
83
85
|
default:
|
|
84
|
-
throw new Error(
|
|
86
|
+
throw new Error(`Unexpected factory type ${binding.type}`);
|
|
85
87
|
}
|
|
86
88
|
};
|
|
87
89
|
exports.getFactoryDetails = getFactoryDetails;
|