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