@tsed/di 6.95.8 → 6.96.1
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/lib/cjs/services/DITest.js +11 -3
- package/lib/cjs/services/DITest.js.map +1 -1
- package/lib/cjs/services/InjectorService.js +1 -1
- package/lib/cjs/services/InjectorService.js.map +1 -1
- package/lib/esm/services/DITest.js +11 -3
- package/lib/esm/services/DITest.js.map +1 -1
- package/lib/esm/services/InjectorService.js +2 -2
- package/lib/esm/services/InjectorService.js.map +1 -1
- package/lib/types/services/DITest.d.ts +5 -1
- package/lib/types/services/InjectorService.d.ts +1 -1
- package/package.json +3 -3
- package/lib/cjs/constants/index.d.ts +0 -3
- package/lib/cjs/decorators/configuration.d.ts +0 -8
- package/lib/cjs/decorators/constant.d.ts +0 -36
- package/lib/cjs/decorators/controller.d.ts +0 -43
- package/lib/cjs/decorators/index.d.ts +0 -15
- package/lib/cjs/decorators/inject.d.ts +0 -21
- package/lib/cjs/decorators/injectable.d.ts +0 -21
- package/lib/cjs/decorators/intercept.d.ts +0 -10
- package/lib/cjs/decorators/interceptor.d.ts +0 -10
- package/lib/cjs/decorators/lazyInject.d.ts +0 -43
- package/lib/cjs/decorators/module.d.ts +0 -36
- package/lib/cjs/decorators/opts.d.ts +0 -41
- package/lib/cjs/decorators/overrideProvider.d.ts +0 -8
- package/lib/cjs/decorators/scope.d.ts +0 -8
- package/lib/cjs/decorators/service.d.ts +0 -10
- package/lib/cjs/decorators/useOpts.d.ts +0 -42
- package/lib/cjs/decorators/value.d.ts +0 -36
- package/lib/cjs/domain/Container.d.ts +0 -43
- package/lib/cjs/domain/ContextLogger.d.ts +0 -41
- package/lib/cjs/domain/DIContext.d.ts +0 -72
- package/lib/cjs/domain/InjectablePropertyType.d.ts +0 -7
- package/lib/cjs/domain/LocalsContainer.d.ts +0 -25
- package/lib/cjs/domain/Provider.d.ts +0 -68
- package/lib/cjs/domain/ProviderScope.d.ts +0 -5
- package/lib/cjs/domain/ProviderType.d.ts +0 -10
- package/lib/cjs/domain/index.d.ts +0 -8
- package/lib/cjs/errors/InjectionError.d.ts +0 -8
- package/lib/cjs/errors/UndefinedTokenError.d.ts +0 -4
- package/lib/cjs/index.d.ts +0 -17
- package/lib/cjs/interfaces/DIConfigurationOptions.d.ts +0 -25
- package/lib/cjs/interfaces/DILogger.d.ts +0 -8
- package/lib/cjs/interfaces/DIResolver.d.ts +0 -5
- package/lib/cjs/interfaces/IProvider.d.ts +0 -54
- package/lib/cjs/interfaces/InjectableProperties.d.ts +0 -24
- package/lib/cjs/interfaces/InterceptorContext.d.ts +0 -11
- package/lib/cjs/interfaces/InterceptorMethods.d.ts +0 -4
- package/lib/cjs/interfaces/InvokeOptions.d.ts +0 -10
- package/lib/cjs/interfaces/OnDestroy.d.ts +0 -3
- package/lib/cjs/interfaces/OnInit.d.ts +0 -3
- package/lib/cjs/interfaces/RegistrySettings.d.ts +0 -20
- package/lib/cjs/interfaces/ResolvedInvokeOptions.d.ts +0 -12
- package/lib/cjs/interfaces/TokenProvider.d.ts +0 -2
- package/lib/cjs/interfaces/index.d.ts +0 -14
- package/lib/cjs/registries/GlobalProviders.d.ts +0 -55
- package/lib/cjs/registries/ProviderRegistry.d.ts +0 -121
- package/lib/cjs/services/DIConfiguration.d.ts +0 -47
- package/lib/cjs/services/DILogger.d.ts +0 -1
- package/lib/cjs/services/DITest.d.ts +0 -37
- package/lib/cjs/services/InjectorService.d.ts +0 -229
- package/lib/cjs/utils/colors.d.ts +0 -5
- package/lib/cjs/utils/createContainer.d.ts +0 -3
- package/lib/cjs/utils/data/Test1.d.ts +0 -3
- package/lib/cjs/utils/data/Test2.d.ts +0 -3
- package/lib/cjs/utils/getConfiguration.d.ts +0 -2
- package/lib/cjs/utils/setLoggerLevel.d.ts +0 -6
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { DIContext, ProviderScope } from "../domain";
|
|
2
|
-
import { Container } from "../domain/Container";
|
|
3
|
-
import { LocalsContainer } from "../domain/LocalsContainer";
|
|
4
|
-
import { Provider } from "../domain/Provider";
|
|
5
|
-
import { DILogger, InjectablePropertyOptions, InjectablePropertyValue, InvokeOptions, IProvider, TokenProvider } from "../interfaces";
|
|
6
|
-
import { DIConfiguration } from "./DIConfiguration";
|
|
7
|
-
/**
|
|
8
|
-
* This service contain all services collected by `@Service` or services declared manually with `InjectorService.factory()` or `InjectorService.service()`.
|
|
9
|
-
*
|
|
10
|
-
* ### Example:
|
|
11
|
-
*
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import {InjectorService} from "@tsed/di";
|
|
14
|
-
*
|
|
15
|
-
* // Import the services (all services are decorated with @Service()";
|
|
16
|
-
* import MyService1 from "./services/service1";
|
|
17
|
-
* import MyService2 from "./services/service2";
|
|
18
|
-
* import MyService3 from "./services/service3";
|
|
19
|
-
*
|
|
20
|
-
* // When all services is imported you can load InjectorService.
|
|
21
|
-
* const injector = new InjectorService()
|
|
22
|
-
*
|
|
23
|
-
* await injector.load();
|
|
24
|
-
*
|
|
25
|
-
* const myService1 = injector.get<MyService1>(MyServcice1);
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare class InjectorService extends Container {
|
|
29
|
-
#private;
|
|
30
|
-
settings: TsED.Configuration & DIConfiguration;
|
|
31
|
-
logger: DILogger;
|
|
32
|
-
private resolvedConfiguration;
|
|
33
|
-
constructor();
|
|
34
|
-
get resolvers(): import("../interfaces").DIResolver[];
|
|
35
|
-
get scopes(): {
|
|
36
|
-
[key: string]: ProviderScope;
|
|
37
|
-
} & {
|
|
38
|
-
[key: string]: ProviderScope;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Retrieve default scope for a given provider.
|
|
42
|
-
* @param provider
|
|
43
|
-
*/
|
|
44
|
-
scopeOf(provider: Provider): ProviderScope;
|
|
45
|
-
/**
|
|
46
|
-
* Clone a provider from GlobalProviders and the given token. forkProvider method build automatically the provider if the instance parameter ins't given.
|
|
47
|
-
* @param token
|
|
48
|
-
* @param settings
|
|
49
|
-
* @deprecated
|
|
50
|
-
*/
|
|
51
|
-
forkProvider(token: TokenProvider, settings?: Partial<IProvider<any>>): Provider;
|
|
52
|
-
/**
|
|
53
|
-
* Return a list of instance build by the injector.
|
|
54
|
-
*/
|
|
55
|
-
toArray(): any[];
|
|
56
|
-
/**
|
|
57
|
-
* Get a service or factory already constructed from his symbol or class.
|
|
58
|
-
*
|
|
59
|
-
* #### Example
|
|
60
|
-
*
|
|
61
|
-
* ```typescript
|
|
62
|
-
* import {InjectorService} from "@tsed/di";
|
|
63
|
-
* import MyService from "./services";
|
|
64
|
-
*
|
|
65
|
-
* class OtherService {
|
|
66
|
-
* constructor(injectorService: InjectorService) {
|
|
67
|
-
* const myService = injectorService.get<MyService>(MyService);
|
|
68
|
-
* }
|
|
69
|
-
* }
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
* @param token The class or symbol registered in InjectorService.
|
|
73
|
-
* @param options
|
|
74
|
-
* @returns {boolean}
|
|
75
|
-
*/
|
|
76
|
-
get<T = any>(token: TokenProvider, options?: any): T | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* The has() method returns a boolean indicating whether an element with the specified key exists or not.
|
|
79
|
-
* @returns {boolean}
|
|
80
|
-
* @param token
|
|
81
|
-
*/
|
|
82
|
-
has(token: TokenProvider): boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Invoke the class and inject all services that required by the class constructor.
|
|
85
|
-
*
|
|
86
|
-
* #### Example
|
|
87
|
-
*
|
|
88
|
-
* ```typescript
|
|
89
|
-
* import {InjectorService} from "@tsed/di";
|
|
90
|
-
* import MyService from "./services";
|
|
91
|
-
*
|
|
92
|
-
* class OtherService {
|
|
93
|
-
* constructor(injectorService: InjectorService) {
|
|
94
|
-
* const myService = injectorService.invoke<MyService>(MyService);
|
|
95
|
-
* }
|
|
96
|
-
* }
|
|
97
|
-
* ```
|
|
98
|
-
*
|
|
99
|
-
* @param token The injectable class to invoke. Class parameters are injected according constructor signature.
|
|
100
|
-
* @param locals Optional object. If preset then any argument Class are read from this object first, before the `InjectorService` is consulted.
|
|
101
|
-
* @param options
|
|
102
|
-
* @returns {T} The class constructed.
|
|
103
|
-
*/
|
|
104
|
-
invoke<T>(token: TokenProvider, locals?: Map<TokenProvider, any>, options?: Partial<InvokeOptions<T>>): T;
|
|
105
|
-
/**
|
|
106
|
-
* Build only providers which are asynchronous.
|
|
107
|
-
*/
|
|
108
|
-
loadAsync(locals?: LocalsContainer): Promise<LocalsContainer<any>>;
|
|
109
|
-
loadSync(locals?: LocalsContainer<any>): LocalsContainer<any>;
|
|
110
|
-
/**
|
|
111
|
-
* Boostrap injector from container and resolve configuration.
|
|
112
|
-
*
|
|
113
|
-
* @param container
|
|
114
|
-
*/
|
|
115
|
-
bootstrap(container?: Container): this;
|
|
116
|
-
/**
|
|
117
|
-
* Build all providers from given container (or GlobalProviders) and emit `$onInit` event.
|
|
118
|
-
*
|
|
119
|
-
* @param container
|
|
120
|
-
* @param rootModule
|
|
121
|
-
*/
|
|
122
|
-
load(container?: Container, rootModule?: TokenProvider): Promise<LocalsContainer<any>>;
|
|
123
|
-
/**
|
|
124
|
-
* Load all configurations registered on providers
|
|
125
|
-
*/
|
|
126
|
-
resolveConfiguration(): void;
|
|
127
|
-
/**
|
|
128
|
-
*
|
|
129
|
-
* @param instance
|
|
130
|
-
* @param locals
|
|
131
|
-
* @param options
|
|
132
|
-
*/
|
|
133
|
-
bindInjectableProperties(instance: any, locals: Map<TokenProvider, any>, options: Partial<InvokeOptions>): void;
|
|
134
|
-
/**
|
|
135
|
-
*
|
|
136
|
-
* @param instance
|
|
137
|
-
* @param {string} propertyKey
|
|
138
|
-
*/
|
|
139
|
-
bindMethod(instance: any, { propertyKey }: InjectablePropertyOptions): void;
|
|
140
|
-
/**
|
|
141
|
-
* Create an injectable property.
|
|
142
|
-
*
|
|
143
|
-
* @param instance
|
|
144
|
-
* @param {string} propertyKey
|
|
145
|
-
* @param {any} useType
|
|
146
|
-
* @param resolver
|
|
147
|
-
* @param options
|
|
148
|
-
* @param locals
|
|
149
|
-
* @param invokeOptions
|
|
150
|
-
*/
|
|
151
|
-
bindProperty(instance: any, { propertyKey, resolver, options }: InjectablePropertyOptions, locals: Map<TokenProvider, any>, invokeOptions: Partial<InvokeOptions>): void;
|
|
152
|
-
/**
|
|
153
|
-
*
|
|
154
|
-
* @param instance
|
|
155
|
-
* @param {string} propertyKey
|
|
156
|
-
* @param {any} useType
|
|
157
|
-
*/
|
|
158
|
-
bindValue(instance: any, { propertyKey, expression, defaultValue }: InjectablePropertyValue): void;
|
|
159
|
-
/**
|
|
160
|
-
*
|
|
161
|
-
* @param instance
|
|
162
|
-
* @param {string} propertyKey
|
|
163
|
-
* @param {any} useType
|
|
164
|
-
*/
|
|
165
|
-
bindConstant(instance: any, { propertyKey, expression, defaultValue }: InjectablePropertyValue): void;
|
|
166
|
-
/**
|
|
167
|
-
*
|
|
168
|
-
* @param instance
|
|
169
|
-
* @param propertyKey
|
|
170
|
-
* @param useType
|
|
171
|
-
* @param options
|
|
172
|
-
*/
|
|
173
|
-
bindInterceptor(instance: any, { propertyKey, useType, options }: InjectablePropertyOptions): void;
|
|
174
|
-
/**
|
|
175
|
-
* Allow handler hack for AsyncHookContext plugin.
|
|
176
|
-
* @param ctx
|
|
177
|
-
* @param cb
|
|
178
|
-
* @protected
|
|
179
|
-
*/
|
|
180
|
-
runInContext(ctx: DIContext, cb: any): any;
|
|
181
|
-
lazyInvoke<T = any>(token: TokenProvider): Promise<any>;
|
|
182
|
-
/**
|
|
183
|
-
* Emit an event to all service. See service [lifecycle hooks](/docs/services.md#lifecycle-hooks).
|
|
184
|
-
* @param eventName The event name to emit at all services.
|
|
185
|
-
* @param args List of the parameters to give to each services.
|
|
186
|
-
* @returns {Promise<any[]>} A list of promises.
|
|
187
|
-
*/
|
|
188
|
-
emit(eventName: string, ...args: any[]): Promise<void>;
|
|
189
|
-
/**
|
|
190
|
-
* @param eventName
|
|
191
|
-
* @param value
|
|
192
|
-
* @param args
|
|
193
|
-
*/
|
|
194
|
-
alter<T = any>(eventName: string, value: any, ...args: any[]): T;
|
|
195
|
-
/**
|
|
196
|
-
* @param eventName
|
|
197
|
-
* @param value
|
|
198
|
-
* @param args
|
|
199
|
-
*/
|
|
200
|
-
alterAsync<T = any>(eventName: string, value: any, ...args: any[]): Promise<T>;
|
|
201
|
-
destroy(): Promise<void>;
|
|
202
|
-
protected ensureProvider(token: TokenProvider): Provider | undefined;
|
|
203
|
-
protected getInstance(token: any): any;
|
|
204
|
-
/**
|
|
205
|
-
* Invoke a class method and inject service.
|
|
206
|
-
*
|
|
207
|
-
* #### IInjectableMethod options
|
|
208
|
-
*
|
|
209
|
-
* * **target**: Optional. The class instance.
|
|
210
|
-
* * **methodName**: `string` Optional. The method name.
|
|
211
|
-
* * **designParamTypes**: `any[]` Optional. List of injectable types.
|
|
212
|
-
* * **locals**: `Map<Function, any>` Optional. If preset then any argument Class are read from this object first, before the `InjectorService` is consulted.
|
|
213
|
-
*
|
|
214
|
-
* #### Example
|
|
215
|
-
*
|
|
216
|
-
* @param target
|
|
217
|
-
* @param locals
|
|
218
|
-
* @param options
|
|
219
|
-
* @private
|
|
220
|
-
*/
|
|
221
|
-
private resolve;
|
|
222
|
-
/**
|
|
223
|
-
* Create options to invoke a provider or class.
|
|
224
|
-
* @param token
|
|
225
|
-
* @param locals
|
|
226
|
-
* @param options
|
|
227
|
-
*/
|
|
228
|
-
private mapInvokeOptions;
|
|
229
|
-
}
|