inversify 6.0.2 → 6.1.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 +95 -81
- package/LICENSE +22 -22
- package/README.md +311 -309
- package/amd/annotation/decorator_utils.js +119 -114
- package/amd/annotation/inject.js +31 -27
- package/amd/annotation/inject_base.js +16 -17
- package/amd/annotation/injectable.js +40 -37
- package/amd/annotation/lazy_service_identifier.js +4 -15
- package/amd/annotation/multi_inject.js +31 -27
- package/amd/annotation/named.js +32 -29
- package/amd/annotation/optional.js +32 -29
- package/amd/annotation/post_construct.js +32 -28
- package/amd/annotation/pre_destroy.js +32 -28
- package/amd/annotation/property_event_decorator.js +16 -17
- package/amd/annotation/tagged.js +8 -9
- package/amd/annotation/target_name.js +35 -32
- package/amd/annotation/unmanaged.js +35 -32
- package/amd/bindings/binding.js +40 -39
- package/amd/bindings/binding_count.js +11 -10
- package/amd/constants/error_msgs.js +74 -64
- package/amd/constants/literal_types.js +28 -28
- package/amd/constants/metadata_keys.js +28 -28
- package/amd/container/container.js +762 -719
- package/amd/container/container_module.js +21 -21
- package/amd/container/container_snapshot.js +20 -20
- package/amd/container/lookup.js +132 -127
- package/amd/container/module_activation_store.js +51 -53
- package/amd/interfaces/interfaces.js +4 -10
- package/amd/inversify.js +57 -55
- package/amd/planning/context.js +19 -19
- package/amd/planning/metadata.js +45 -41
- package/amd/planning/metadata_reader.js +49 -43
- package/amd/planning/plan.js +13 -13
- package/amd/planning/planner.js +184 -163
- package/amd/planning/queryable_string.js +33 -30
- package/amd/planning/reflection_utils.js +55 -157
- package/amd/planning/request.js +24 -26
- package/amd/planning/target.js +111 -101
- package/amd/resolution/instantiation.js +219 -211
- package/amd/resolution/resolver.js +234 -222
- package/amd/scope/scope.js +93 -93
- package/amd/syntax/binding_in_syntax.js +24 -24
- package/amd/syntax/binding_in_when_on_syntax.js +75 -75
- package/amd/syntax/binding_on_syntax.js +20 -20
- package/amd/syntax/binding_to_syntax.js +116 -105
- package/amd/syntax/binding_when_on_syntax.js +65 -65
- package/amd/syntax/binding_when_syntax.js +107 -102
- package/amd/syntax/constraint_helpers.js +66 -61
- package/amd/utils/async.js +17 -17
- package/amd/utils/binding_utils.js +86 -77
- package/amd/utils/clonable.js +11 -12
- package/amd/utils/exceptions.js +46 -42
- package/amd/utils/factory_type.js +11 -11
- package/amd/utils/id.js +9 -10
- package/amd/utils/js.js +18 -19
- package/amd/utils/serialization.js +135 -129
- package/es/annotation/decorator_utils.js +90 -88
- package/es/annotation/inject.js +4 -4
- package/es/annotation/inject_base.js +14 -14
- package/es/annotation/injectable.js +13 -13
- package/es/annotation/lazy_service_identifier.js +1 -10
- package/es/annotation/multi_inject.js +4 -4
- package/es/annotation/named.js +7 -7
- package/es/annotation/optional.js +7 -7
- package/es/annotation/post_construct.js +5 -5
- package/es/annotation/pre_destroy.js +5 -5
- package/es/annotation/property_event_decorator.js +13 -13
- package/es/annotation/tagged.js +6 -6
- package/es/annotation/target_name.js +10 -10
- package/es/annotation/unmanaged.js +10 -10
- package/es/bindings/binding.js +37 -36
- package/es/bindings/binding_count.js +6 -5
- package/es/constants/error_msgs.js +62 -52
- package/es/constants/literal_types.js +21 -21
- package/es/constants/metadata_keys.js +23 -23
- package/es/container/container.js +746 -707
- package/es/container/container_module.js +17 -17
- package/es/container/container_snapshot.js +15 -15
- package/es/container/lookup.js +105 -104
- package/es/container/module_activation_store.js +47 -49
- package/es/interfaces/interfaces.js +1 -5
- package/es/inversify.js +23 -25
- package/es/planning/context.js +15 -15
- package/es/planning/metadata.js +17 -17
- package/es/planning/metadata_reader.js +21 -19
- package/es/planning/plan.js +8 -8
- package/es/planning/planner.js +165 -147
- package/es/planning/queryable_string.js +28 -25
- package/es/planning/reflection_utils.js +27 -135
- package/es/planning/request.js +20 -22
- package/es/planning/target.js +87 -81
- package/es/resolution/instantiation.js +195 -190
- package/es/resolution/resolver.js +214 -205
- package/es/scope/scope.js +88 -88
- package/es/syntax/binding_in_syntax.js +21 -21
- package/es/syntax/binding_in_when_on_syntax.js +73 -73
- package/es/syntax/binding_on_syntax.js +16 -16
- package/es/syntax/binding_to_syntax.js +91 -84
- package/es/syntax/binding_when_on_syntax.js +62 -62
- package/es/syntax/binding_when_syntax.js +104 -99
- package/es/syntax/constraint_helpers.js +36 -35
- package/es/utils/async.js +12 -11
- package/es/utils/binding_utils.js +58 -53
- package/es/utils/clonable.js +7 -7
- package/es/utils/exceptions.js +16 -16
- package/es/utils/factory_type.js +6 -6
- package/es/utils/id.js +5 -5
- package/es/utils/js.js +13 -13
- package/es/utils/serialization.js +103 -100
- package/es6/annotation/decorator_utils.js +114 -109
- package/es6/annotation/inject.js +30 -26
- package/es6/annotation/inject_base.js +17 -18
- package/es6/annotation/injectable.js +38 -35
- package/es6/annotation/lazy_service_identifier.js +2 -12
- package/es6/annotation/multi_inject.js +30 -26
- package/es6/annotation/named.js +32 -29
- package/es6/annotation/optional.js +32 -29
- package/es6/annotation/post_construct.js +31 -27
- package/es6/annotation/pre_destroy.js +31 -27
- package/es6/annotation/property_event_decorator.js +15 -16
- package/es6/annotation/tagged.js +8 -9
- package/es6/annotation/target_name.js +35 -32
- package/es6/annotation/unmanaged.js +35 -32
- package/es6/bindings/binding.js +39 -38
- package/es6/bindings/binding_count.js +9 -8
- package/es6/constants/error_msgs.js +58 -53
- package/es6/constants/literal_types.js +26 -26
- package/es6/constants/metadata_keys.js +26 -26
- package/es6/container/container.js +541 -520
- package/es6/container/container_module.js +18 -18
- package/es6/container/container_snapshot.js +15 -15
- package/es6/container/lookup.js +125 -120
- package/es6/container/module_activation_store.js +49 -51
- package/es6/interfaces/interfaces.js +2 -8
- package/es6/inversify.js +76 -76
- package/es6/planning/context.js +17 -17
- package/es6/planning/metadata.js +42 -38
- package/es6/planning/metadata_reader.js +44 -38
- package/es6/planning/plan.js +10 -10
- package/es6/planning/planner.js +191 -170
- package/es6/planning/queryable_string.js +30 -27
- package/es6/planning/reflection_utils.js +53 -155
- package/es6/planning/request.js +22 -24
- package/es6/planning/target.js +105 -99
- package/es6/resolution/instantiation.js +158 -151
- package/es6/resolution/resolver.js +193 -187
- package/es6/scope/scope.js +57 -57
- package/es6/syntax/binding_in_syntax.js +23 -23
- package/es6/syntax/binding_in_when_on_syntax.js +75 -75
- package/es6/syntax/binding_on_syntax.js +18 -18
- package/es6/syntax/binding_to_syntax.js +110 -105
- package/es6/syntax/binding_when_on_syntax.js +64 -64
- package/es6/syntax/binding_when_syntax.js +84 -79
- package/es6/syntax/constraint_helpers.js +63 -58
- package/es6/utils/async.js +15 -15
- package/es6/utils/binding_utils.js +79 -68
- package/es6/utils/clonable.js +9 -10
- package/es6/utils/exceptions.js +44 -40
- package/es6/utils/factory_type.js +9 -9
- package/es6/utils/id.js +7 -8
- package/es6/utils/js.js +15 -16
- package/es6/utils/serialization.js +132 -126
- package/lib/annotation/decorator_utils.d.ts +16 -16
- package/lib/annotation/decorator_utils.js +118 -113
- package/lib/annotation/inject.d.ts +5 -2
- package/lib/annotation/inject.js +30 -26
- package/lib/annotation/inject_base.d.ts +4 -3
- package/lib/annotation/inject_base.js +17 -18
- package/lib/annotation/injectable.d.ts +2 -2
- package/lib/annotation/injectable.js +38 -35
- package/lib/annotation/lazy_service_identifier.d.ts +3 -7
- package/lib/annotation/lazy_service_identifier.js +2 -13
- package/lib/annotation/multi_inject.d.ts +5 -2
- package/lib/annotation/multi_inject.js +30 -26
- package/lib/annotation/named.d.ts +2 -2
- package/lib/annotation/named.js +32 -29
- package/lib/annotation/optional.d.ts +2 -2
- package/lib/annotation/optional.js +32 -29
- package/lib/annotation/post_construct.d.ts +4 -4
- package/lib/annotation/post_construct.js +31 -27
- package/lib/annotation/pre_destroy.d.ts +4 -4
- package/lib/annotation/pre_destroy.js +31 -27
- package/lib/annotation/property_event_decorator.d.ts +4 -4
- package/lib/annotation/property_event_decorator.js +15 -16
- package/lib/annotation/tagged.d.ts +2 -2
- package/lib/annotation/tagged.js +8 -9
- package/lib/annotation/target_name.d.ts +3 -3
- package/lib/annotation/target_name.js +35 -32
- package/lib/annotation/unmanaged.d.ts +3 -3
- package/lib/annotation/unmanaged.js +35 -32
- package/lib/bindings/binding.d.ts +20 -20
- package/lib/bindings/binding.js +40 -39
- package/lib/bindings/binding_count.d.ts +5 -5
- package/lib/bindings/binding_count.js +9 -8
- package/lib/constants/error_msgs.d.ts +30 -32
- package/lib/constants/error_msgs.js +72 -62
- package/lib/constants/literal_types.d.ts +5 -5
- package/lib/constants/literal_types.js +26 -26
- package/lib/constants/metadata_keys.d.ts +13 -13
- package/lib/constants/metadata_keys.js +26 -26
- package/lib/container/container.d.ts +73 -73
- package/lib/container/container.js +772 -729
- package/lib/container/container_module.d.ts +11 -11
- package/lib/container/container_module.js +20 -20
- package/lib/container/container_snapshot.d.ts +10 -10
- package/lib/container/container_snapshot.js +18 -18
- package/lib/container/lookup.d.ts +17 -16
- package/lib/container/lookup.js +131 -126
- package/lib/container/module_activation_store.d.ts +10 -10
- package/lib/container/module_activation_store.js +50 -52
- package/lib/interfaces/interfaces.d.ts +269 -284
- package/lib/interfaces/interfaces.js +2 -8
- package/lib/inversify.d.ts +24 -25
- package/lib/inversify.js +76 -76
- package/lib/planning/context.d.ts +11 -11
- package/lib/planning/context.js +18 -18
- package/lib/planning/metadata.d.ts +8 -8
- package/lib/planning/metadata.js +43 -39
- package/lib/planning/metadata_reader.d.ts +6 -6
- package/lib/planning/metadata_reader.js +47 -41
- package/lib/planning/plan.d.ts +7 -7
- package/lib/planning/plan.js +11 -11
- package/lib/planning/planner.d.ts +5 -5
- package/lib/planning/planner.js +192 -171
- package/lib/planning/queryable_string.d.ts +10 -11
- package/lib/planning/queryable_string.js +31 -28
- package/lib/planning/reflection_utils.d.ts +5 -5
- package/lib/planning/reflection_utils.js +55 -159
- package/lib/planning/request.d.ts +14 -14
- package/lib/planning/request.js +23 -25
- package/lib/planning/target.d.ts +23 -23
- package/lib/planning/target.js +113 -103
- package/lib/resolution/instantiation.d.ts +3 -3
- package/lib/resolution/instantiation.js +220 -212
- package/lib/resolution/resolver.d.ts +3 -3
- package/lib/resolution/resolver.js +239 -227
- package/lib/scope/scope.d.ts +3 -3
- package/lib/scope/scope.js +93 -93
- package/lib/syntax/binding_in_syntax.d.ts +9 -9
- package/lib/syntax/binding_in_syntax.js +24 -24
- package/lib/syntax/binding_in_when_on_syntax.d.ts +29 -29
- package/lib/syntax/binding_in_when_on_syntax.js +76 -76
- package/lib/syntax/binding_on_syntax.d.ts +8 -8
- package/lib/syntax/binding_on_syntax.js +19 -19
- package/lib/syntax/binding_to_syntax.d.ts +18 -18
- package/lib/syntax/binding_to_syntax.js +117 -106
- package/lib/syntax/binding_when_on_syntax.d.ts +25 -25
- package/lib/syntax/binding_when_on_syntax.js +65 -65
- package/lib/syntax/binding_when_syntax.d.ts +21 -21
- package/lib/syntax/binding_when_syntax.js +107 -102
- package/lib/syntax/constraint_helpers.d.ts +6 -6
- package/lib/syntax/constraint_helpers.js +65 -60
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/async.d.ts +3 -3
- package/lib/utils/async.js +15 -15
- package/lib/utils/binding_utils.d.ts +4 -4
- package/lib/utils/binding_utils.js +87 -78
- package/lib/utils/clonable.d.ts +3 -3
- package/lib/utils/clonable.js +9 -10
- package/lib/utils/exceptions.d.ts +2 -2
- package/lib/utils/exceptions.js +44 -40
- package/lib/utils/factory_type.d.ts +5 -5
- package/lib/utils/factory_type.js +9 -9
- package/lib/utils/id.d.ts +2 -2
- package/lib/utils/id.js +7 -8
- package/lib/utils/js.d.ts +1 -1
- package/lib/utils/js.js +16 -17
- package/lib/utils/serialization.d.ts +10 -10
- package/lib/utils/serialization.js +133 -127
- package/package.json +74 -61
- package/.nyc_output/16b95af9-19b9-451c-8475-9a8585677128.json +0 -1
- package/.nyc_output/processinfo/16b95af9-19b9-451c-8475-9a8585677128.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
|
@@ -1,284 +1,269 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type
|
|
6
|
-
export type
|
|
7
|
-
|
|
8
|
-
export type
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
export type
|
|
59
|
-
export type
|
|
60
|
-
export type
|
|
61
|
-
export type
|
|
62
|
-
export type
|
|
63
|
-
export
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
export type
|
|
81
|
-
export
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
export
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
export
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
id:
|
|
188
|
-
}
|
|
189
|
-
export
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
remove(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
export interface
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
export interface
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
export
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
export interface MetadataReader {
|
|
272
|
-
getConstructorMetadata(constructorFunc: NewableFunction): ConstructorMetadata;
|
|
273
|
-
getPropertiesMetadata(constructorFunc: NewableFunction): MetadataMap;
|
|
274
|
-
}
|
|
275
|
-
export interface MetadataMap {
|
|
276
|
-
[propertyNameOrArgumentIndex: string | symbol]: Metadata[];
|
|
277
|
-
}
|
|
278
|
-
export interface ConstructorMetadata {
|
|
279
|
-
compilerGeneratedMetadata: NewableFunction[] | undefined;
|
|
280
|
-
userGeneratedMetadata: MetadataMap;
|
|
281
|
-
}
|
|
282
|
-
export {};
|
|
283
|
-
}
|
|
284
|
-
export { interfaces };
|
|
1
|
+
import { Newable as CommonNewable, ServiceIdentifier as CommonServiceIdentifier } from '@inversifyjs/common';
|
|
2
|
+
import { LegacyTarget } from '@inversifyjs/core';
|
|
3
|
+
import { FactoryType } from '../utils/factory_type';
|
|
4
|
+
declare namespace interfaces {
|
|
5
|
+
export type DynamicValue<T> = (context: interfaces.Context) => T | Promise<T>;
|
|
6
|
+
export type ContainerResolution<T> = T | Promise<T> | (T | Promise<T>)[];
|
|
7
|
+
type AsyncCallback<TCallback> = TCallback extends (...args: infer TArgs) => infer TResult ? (...args: TArgs) => Promise<TResult> : never;
|
|
8
|
+
export type BindingScope = 'Singleton' | 'Transient' | 'Request';
|
|
9
|
+
export type BindingType = 'ConstantValue' | 'Constructor' | 'DynamicValue' | 'Factory' | 'Function' | 'Instance' | 'Invalid' | 'Provider';
|
|
10
|
+
export type TargetType = 'ConstructorArgument' | 'ClassProperty' | 'Variable';
|
|
11
|
+
export interface BindingScopeEnum {
|
|
12
|
+
Request: interfaces.BindingScope;
|
|
13
|
+
Singleton: interfaces.BindingScope;
|
|
14
|
+
Transient: interfaces.BindingScope;
|
|
15
|
+
}
|
|
16
|
+
export interface BindingTypeEnum {
|
|
17
|
+
ConstantValue: interfaces.BindingType;
|
|
18
|
+
Constructor: interfaces.BindingType;
|
|
19
|
+
DynamicValue: interfaces.BindingType;
|
|
20
|
+
Factory: interfaces.BindingType;
|
|
21
|
+
Function: interfaces.BindingType;
|
|
22
|
+
Instance: interfaces.BindingType;
|
|
23
|
+
Invalid: interfaces.BindingType;
|
|
24
|
+
Provider: interfaces.BindingType;
|
|
25
|
+
}
|
|
26
|
+
export interface TargetTypeEnum {
|
|
27
|
+
ConstructorArgument: interfaces.TargetType;
|
|
28
|
+
ClassProperty: interfaces.TargetType;
|
|
29
|
+
Variable: interfaces.TargetType;
|
|
30
|
+
}
|
|
31
|
+
export type Newable<TInstance = unknown> = CommonNewable<TInstance>;
|
|
32
|
+
export type Instance<T> = T & Record<string, () => void>;
|
|
33
|
+
export interface Abstract<T> {
|
|
34
|
+
prototype: T;
|
|
35
|
+
}
|
|
36
|
+
export type ServiceIdentifier<T = unknown> = CommonServiceIdentifier<T>;
|
|
37
|
+
export interface Clonable<T> {
|
|
38
|
+
clone(): T;
|
|
39
|
+
}
|
|
40
|
+
export type BindingActivation<T = unknown> = (context: interfaces.Context, injectable: T) => T | Promise<T>;
|
|
41
|
+
export type BindingDeactivation<T = unknown> = (injectable: T) => void | Promise<void>;
|
|
42
|
+
export interface Binding<TActivated = unknown> extends Clonable<Binding<TActivated>> {
|
|
43
|
+
id: number;
|
|
44
|
+
moduleId: ContainerModuleBase['id'];
|
|
45
|
+
activated: boolean;
|
|
46
|
+
serviceIdentifier: ServiceIdentifier<TActivated>;
|
|
47
|
+
constraint: ConstraintFunction;
|
|
48
|
+
dynamicValue: DynamicValue<TActivated> | null;
|
|
49
|
+
scope: BindingScope;
|
|
50
|
+
type: BindingType;
|
|
51
|
+
implementationType: Newable<TActivated> | TActivated | null;
|
|
52
|
+
factory: FactoryCreator<unknown> | null;
|
|
53
|
+
provider: ProviderCreator<unknown> | null;
|
|
54
|
+
onActivation: BindingActivation<TActivated> | null;
|
|
55
|
+
onDeactivation: BindingDeactivation<TActivated> | null;
|
|
56
|
+
cache: null | TActivated | Promise<TActivated>;
|
|
57
|
+
}
|
|
58
|
+
export type SimpleFactory<T, U extends unknown[] = unknown[]> = (...args: U) => T;
|
|
59
|
+
export type MultiFactory<T, U extends unknown[] = unknown[], V extends unknown[] = unknown[]> = (...args: U) => SimpleFactory<T, V>;
|
|
60
|
+
export type Factory<T, U extends unknown[] = unknown[], V extends unknown[] = unknown[]> = SimpleFactory<T, U> | MultiFactory<T, U, V>;
|
|
61
|
+
export type FactoryCreator<T, U extends unknown[] = unknown[], V extends unknown[] = unknown[]> = (context: Context) => Factory<T, U, V>;
|
|
62
|
+
export type AutoNamedFactory<T> = SimpleFactory<T, [string]>;
|
|
63
|
+
export type AutoFactory<T> = SimpleFactory<T, []>;
|
|
64
|
+
export type FactoryTypeFunction<T = unknown> = (context: interfaces.Context) => T | Promise<T>;
|
|
65
|
+
export interface FactoryDetails {
|
|
66
|
+
factoryType: FactoryType;
|
|
67
|
+
factory: FactoryTypeFunction | null;
|
|
68
|
+
}
|
|
69
|
+
export type Provider<T> = (...args: any[]) => ((...args: any[]) => Promise<T>) | Promise<T>;
|
|
70
|
+
export type ProviderCreator<T> = (context: Context) => Provider<T>;
|
|
71
|
+
export interface NextArgs<T = unknown> {
|
|
72
|
+
avoidConstraints: boolean;
|
|
73
|
+
contextInterceptor: (contexts: Context) => Context;
|
|
74
|
+
isMultiInject: boolean;
|
|
75
|
+
targetType: TargetType;
|
|
76
|
+
serviceIdentifier: interfaces.ServiceIdentifier<T>;
|
|
77
|
+
key?: string | number | symbol | undefined;
|
|
78
|
+
value?: unknown;
|
|
79
|
+
}
|
|
80
|
+
export type Next = (args: NextArgs) => unknown | unknown[];
|
|
81
|
+
export type Middleware = (next: Next) => Next;
|
|
82
|
+
export type ContextInterceptor = (context: interfaces.Context) => interfaces.Context;
|
|
83
|
+
export interface Context {
|
|
84
|
+
id: number;
|
|
85
|
+
container: Container;
|
|
86
|
+
plan: Plan;
|
|
87
|
+
currentRequest: Request;
|
|
88
|
+
addPlan(plan: Plan): void;
|
|
89
|
+
setCurrentRequest(request: Request): void;
|
|
90
|
+
}
|
|
91
|
+
export type MetadataOrMetadataArray = Metadata | Metadata[];
|
|
92
|
+
export interface Metadata<TValue = unknown> {
|
|
93
|
+
key: string | number | symbol;
|
|
94
|
+
value: TValue;
|
|
95
|
+
}
|
|
96
|
+
export interface Plan {
|
|
97
|
+
parentContext: Context;
|
|
98
|
+
rootRequest: Request;
|
|
99
|
+
}
|
|
100
|
+
export interface QueryableString {
|
|
101
|
+
startsWith(searchString: string): boolean;
|
|
102
|
+
endsWith(searchString: string): boolean;
|
|
103
|
+
contains(searchString: string): boolean;
|
|
104
|
+
equals(compareString: string): boolean;
|
|
105
|
+
value(): string;
|
|
106
|
+
}
|
|
107
|
+
export type ResolveRequestHandler = (request: interfaces.Request) => unknown;
|
|
108
|
+
export type RequestScope = Map<unknown, unknown>;
|
|
109
|
+
export interface Request {
|
|
110
|
+
id: number;
|
|
111
|
+
serviceIdentifier: ServiceIdentifier;
|
|
112
|
+
parentContext: Context;
|
|
113
|
+
parentRequest: Request | null;
|
|
114
|
+
childRequests: Request[];
|
|
115
|
+
target: Target;
|
|
116
|
+
bindings: Binding<unknown>[];
|
|
117
|
+
requestScope: RequestScope | null;
|
|
118
|
+
addChildRequest(serviceIdentifier: ServiceIdentifier, bindings: Binding<unknown> | Binding<unknown>[], target: Target): Request;
|
|
119
|
+
}
|
|
120
|
+
export type Target = LegacyTarget;
|
|
121
|
+
export interface ContainerOptions {
|
|
122
|
+
autoBindInjectable?: boolean;
|
|
123
|
+
defaultScope?: BindingScope | undefined;
|
|
124
|
+
skipBaseClassChecks?: boolean;
|
|
125
|
+
}
|
|
126
|
+
export interface Container {
|
|
127
|
+
id: number;
|
|
128
|
+
parent: Container | null;
|
|
129
|
+
options: ContainerOptions;
|
|
130
|
+
bind<T>(serviceIdentifier: ServiceIdentifier<T>): BindingToSyntax<T>;
|
|
131
|
+
rebind<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>): interfaces.BindingToSyntax<T>;
|
|
132
|
+
rebindAsync<T>(serviceIdentifier: interfaces.ServiceIdentifier<T>): Promise<interfaces.BindingToSyntax<T>>;
|
|
133
|
+
unbind(serviceIdentifier: ServiceIdentifier): void;
|
|
134
|
+
unbindAsync(serviceIdentifier: interfaces.ServiceIdentifier): Promise<void>;
|
|
135
|
+
unbindAll(): void;
|
|
136
|
+
unbindAllAsync(): Promise<void>;
|
|
137
|
+
isBound(serviceIdentifier: ServiceIdentifier): boolean;
|
|
138
|
+
isCurrentBound<T>(serviceIdentifier: ServiceIdentifier<T>): boolean;
|
|
139
|
+
isBoundNamed(serviceIdentifier: ServiceIdentifier, named: string | number | symbol): boolean;
|
|
140
|
+
isBoundTagged(serviceIdentifier: ServiceIdentifier, key: string | number | symbol, value: unknown): boolean;
|
|
141
|
+
get<T>(serviceIdentifier: ServiceIdentifier<T>): T;
|
|
142
|
+
getNamed<T>(serviceIdentifier: ServiceIdentifier<T>, named: string | number | symbol): T;
|
|
143
|
+
getTagged<T>(serviceIdentifier: ServiceIdentifier<T>, key: string | number | symbol, value: unknown): T;
|
|
144
|
+
getAll<T>(serviceIdentifier: ServiceIdentifier<T>): T[];
|
|
145
|
+
getAllTagged<T>(serviceIdentifier: ServiceIdentifier<T>, key: string | number | symbol, value: unknown): T[];
|
|
146
|
+
getAllNamed<T>(serviceIdentifier: ServiceIdentifier<T>, named: string | number | symbol): T[];
|
|
147
|
+
getAsync<T>(serviceIdentifier: ServiceIdentifier<T>): Promise<T>;
|
|
148
|
+
getNamedAsync<T>(serviceIdentifier: ServiceIdentifier<T>, named: string | number | symbol): Promise<T>;
|
|
149
|
+
getTaggedAsync<T>(serviceIdentifier: ServiceIdentifier<T>, key: string | number | symbol, value: unknown): Promise<T>;
|
|
150
|
+
getAllAsync<T>(serviceIdentifier: ServiceIdentifier<T>): Promise<T[]>;
|
|
151
|
+
getAllTaggedAsync<T>(serviceIdentifier: ServiceIdentifier<T>, key: string | number | symbol, value: unknown): Promise<T[]>;
|
|
152
|
+
getAllNamedAsync<T>(serviceIdentifier: ServiceIdentifier<T>, named: string | number | symbol): Promise<T[]>;
|
|
153
|
+
onActivation<T>(serviceIdentifier: ServiceIdentifier<T>, onActivation: BindingActivation<T>): void;
|
|
154
|
+
onDeactivation<T>(serviceIdentifier: ServiceIdentifier<T>, onDeactivation: BindingDeactivation<T>): void;
|
|
155
|
+
resolve<T>(constructorFunction: interfaces.Newable<T>): T;
|
|
156
|
+
load(...modules: ContainerModule[]): void;
|
|
157
|
+
loadAsync(...modules: AsyncContainerModule[]): Promise<void>;
|
|
158
|
+
unload(...modules: ContainerModuleBase[]): void;
|
|
159
|
+
unloadAsync(...modules: ContainerModuleBase[]): Promise<void>;
|
|
160
|
+
applyCustomMetadataReader(metadataReader: MetadataReader): void;
|
|
161
|
+
applyMiddleware(...middleware: Middleware[]): void;
|
|
162
|
+
snapshot(): void;
|
|
163
|
+
restore(): void;
|
|
164
|
+
createChild(): Container;
|
|
165
|
+
}
|
|
166
|
+
export type Bind = <T = unknown>(serviceIdentifier: ServiceIdentifier<T>) => BindingToSyntax<T>;
|
|
167
|
+
export type Rebind = <T = unknown>(serviceIdentifier: ServiceIdentifier<T>) => BindingToSyntax<T>;
|
|
168
|
+
export type Unbind = <T = unknown>(serviceIdentifier: ServiceIdentifier<T>) => void;
|
|
169
|
+
export type UnbindAsync = <T = unknown>(serviceIdentifier: ServiceIdentifier<T>) => Promise<void>;
|
|
170
|
+
export type IsBound = <T = unknown>(serviceIdentifier: ServiceIdentifier<T>) => boolean;
|
|
171
|
+
export interface ContainerModuleBase {
|
|
172
|
+
id: number;
|
|
173
|
+
}
|
|
174
|
+
export interface ContainerModule extends ContainerModuleBase {
|
|
175
|
+
registry: ContainerModuleCallBack;
|
|
176
|
+
}
|
|
177
|
+
export interface AsyncContainerModule extends ContainerModuleBase {
|
|
178
|
+
registry: AsyncContainerModuleCallBack;
|
|
179
|
+
}
|
|
180
|
+
export interface ModuleActivationHandlers {
|
|
181
|
+
onActivations: Lookup<BindingActivation<unknown>>;
|
|
182
|
+
onDeactivations: Lookup<BindingDeactivation<unknown>>;
|
|
183
|
+
}
|
|
184
|
+
export interface ModuleActivationStore extends Clonable<ModuleActivationStore> {
|
|
185
|
+
addDeactivation(moduleId: ContainerModuleBase['id'], serviceIdentifier: ServiceIdentifier<unknown>, onDeactivation: interfaces.BindingDeactivation<unknown>): void;
|
|
186
|
+
addActivation(moduleId: ContainerModuleBase['id'], serviceIdentifier: ServiceIdentifier<unknown>, onActivation: interfaces.BindingActivation<unknown>): void;
|
|
187
|
+
remove(moduleId: ContainerModuleBase['id']): ModuleActivationHandlers;
|
|
188
|
+
}
|
|
189
|
+
export type ContainerModuleCallBack = (bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind, unbindAsync: interfaces.UnbindAsync, onActivation: interfaces.Container['onActivation'], onDeactivation: interfaces.Container['onDeactivation']) => void;
|
|
190
|
+
export type AsyncContainerModuleCallBack = AsyncCallback<ContainerModuleCallBack>;
|
|
191
|
+
export interface ContainerSnapshot {
|
|
192
|
+
bindings: Lookup<Binding<unknown>>;
|
|
193
|
+
activations: Lookup<BindingActivation<unknown>>;
|
|
194
|
+
deactivations: Lookup<BindingDeactivation<unknown>>;
|
|
195
|
+
middleware: Next | null;
|
|
196
|
+
moduleActivationStore: interfaces.ModuleActivationStore;
|
|
197
|
+
}
|
|
198
|
+
export interface Lookup<T> extends Clonable<Lookup<T>> {
|
|
199
|
+
add(serviceIdentifier: ServiceIdentifier, value: T): void;
|
|
200
|
+
getMap(): Map<interfaces.ServiceIdentifier, T[]>;
|
|
201
|
+
get(serviceIdentifier: ServiceIdentifier): T[];
|
|
202
|
+
remove(serviceIdentifier: interfaces.ServiceIdentifier): void;
|
|
203
|
+
removeByCondition(condition: (item: T) => boolean): T[];
|
|
204
|
+
removeIntersection(lookup: interfaces.Lookup<T>): void;
|
|
205
|
+
hasKey(serviceIdentifier: ServiceIdentifier): boolean;
|
|
206
|
+
clone(): Lookup<T>;
|
|
207
|
+
traverse(func: (key: interfaces.ServiceIdentifier, value: T[]) => void): void;
|
|
208
|
+
}
|
|
209
|
+
export interface BindingOnSyntax<T> {
|
|
210
|
+
onActivation(fn: (context: Context, injectable: T) => T | Promise<T>): BindingWhenSyntax<T>;
|
|
211
|
+
onDeactivation(fn: (injectable: T) => void | Promise<void>): BindingWhenSyntax<T>;
|
|
212
|
+
}
|
|
213
|
+
export interface BindingWhenSyntax<T> {
|
|
214
|
+
when(constraint: (request: Request) => boolean): BindingOnSyntax<T>;
|
|
215
|
+
whenTargetNamed(name: string | number | symbol): BindingOnSyntax<T>;
|
|
216
|
+
whenTargetIsDefault(): BindingOnSyntax<T>;
|
|
217
|
+
whenTargetTagged(tag: string | number | symbol, value: unknown): BindingOnSyntax<T>;
|
|
218
|
+
whenInjectedInto(parent: NewableFunction | string): BindingOnSyntax<T>;
|
|
219
|
+
whenParentNamed(name: string | number | symbol): BindingOnSyntax<T>;
|
|
220
|
+
whenParentTagged(tag: string | number | symbol, value: unknown): BindingOnSyntax<T>;
|
|
221
|
+
whenAnyAncestorIs(ancestor: NewableFunction | string): BindingOnSyntax<T>;
|
|
222
|
+
whenNoAncestorIs(ancestor: NewableFunction | string): BindingOnSyntax<T>;
|
|
223
|
+
whenAnyAncestorNamed(name: string | number | symbol): BindingOnSyntax<T>;
|
|
224
|
+
whenAnyAncestorTagged(tag: string | number | symbol, value: unknown): BindingOnSyntax<T>;
|
|
225
|
+
whenNoAncestorNamed(name: string | number | symbol): BindingOnSyntax<T>;
|
|
226
|
+
whenNoAncestorTagged(tag: string | number | symbol, value: unknown): BindingOnSyntax<T>;
|
|
227
|
+
whenAnyAncestorMatches(constraint: (request: Request) => boolean): BindingOnSyntax<T>;
|
|
228
|
+
whenNoAncestorMatches(constraint: (request: Request) => boolean): BindingOnSyntax<T>;
|
|
229
|
+
}
|
|
230
|
+
export interface BindingWhenOnSyntax<T> extends BindingWhenSyntax<T>, BindingOnSyntax<T> {
|
|
231
|
+
}
|
|
232
|
+
export interface BindingInSyntax<T> {
|
|
233
|
+
inSingletonScope(): BindingWhenOnSyntax<T>;
|
|
234
|
+
inTransientScope(): BindingWhenOnSyntax<T>;
|
|
235
|
+
inRequestScope(): BindingWhenOnSyntax<T>;
|
|
236
|
+
}
|
|
237
|
+
export interface BindingInWhenOnSyntax<T> extends BindingInSyntax<T>, BindingWhenOnSyntax<T> {
|
|
238
|
+
}
|
|
239
|
+
export interface BindingToSyntax<T> {
|
|
240
|
+
to(constructor: Newable<T>): BindingInWhenOnSyntax<T>;
|
|
241
|
+
toSelf(): BindingInWhenOnSyntax<T>;
|
|
242
|
+
toConstantValue(value: T): BindingWhenOnSyntax<T>;
|
|
243
|
+
toDynamicValue(func: DynamicValue<T>): BindingInWhenOnSyntax<T>;
|
|
244
|
+
toConstructor<T2>(constructor: Newable<T2>): BindingWhenOnSyntax<T>;
|
|
245
|
+
toFactory<T2, T3 extends unknown[] = unknown[], T4 extends unknown[] = unknown[]>(factory: FactoryCreator<T2, T3, T4>): BindingWhenOnSyntax<T>;
|
|
246
|
+
toFunction(func: T): BindingWhenOnSyntax<T>;
|
|
247
|
+
toAutoFactory<T2>(serviceIdentifier: ServiceIdentifier<T2>): BindingWhenOnSyntax<T>;
|
|
248
|
+
toAutoNamedFactory<T2>(serviceIdentifier: ServiceIdentifier<T2>): BindingWhenOnSyntax<T>;
|
|
249
|
+
toProvider<T2>(provider: ProviderCreator<T2>): BindingWhenOnSyntax<T>;
|
|
250
|
+
toService(service: ServiceIdentifier<T>): void;
|
|
251
|
+
}
|
|
252
|
+
export interface ConstraintFunction {
|
|
253
|
+
(request: Request | null): boolean;
|
|
254
|
+
metaData?: Metadata;
|
|
255
|
+
}
|
|
256
|
+
export interface MetadataReader {
|
|
257
|
+
getConstructorMetadata(constructorFunc: NewableFunction): ConstructorMetadata;
|
|
258
|
+
getPropertiesMetadata(constructorFunc: NewableFunction): MetadataMap;
|
|
259
|
+
}
|
|
260
|
+
export interface MetadataMap {
|
|
261
|
+
[propertyNameOrArgumentIndex: string | symbol]: Metadata[];
|
|
262
|
+
}
|
|
263
|
+
export interface ConstructorMetadata {
|
|
264
|
+
compilerGeneratedMetadata: NewableFunction[] | undefined;
|
|
265
|
+
userGeneratedMetadata: MetadataMap;
|
|
266
|
+
}
|
|
267
|
+
export {};
|
|
268
|
+
}
|
|
269
|
+
export type { interfaces };
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.interfaces = void 0;
|
|
4
|
-
var interfaces;
|
|
5
|
-
(function (interfaces) {
|
|
6
|
-
;
|
|
7
|
-
})(interfaces || (interfaces = {}));
|
|
8
|
-
exports.interfaces = interfaces;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|