@tsed/di 6.95.9 → 6.96.2

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.
Files changed (66) hide show
  1. package/lib/cjs/services/DITest.js +11 -3
  2. package/lib/cjs/services/DITest.js.map +1 -1
  3. package/lib/cjs/services/InjectorService.js +1 -1
  4. package/lib/cjs/services/InjectorService.js.map +1 -1
  5. package/lib/esm/services/DITest.js +11 -3
  6. package/lib/esm/services/DITest.js.map +1 -1
  7. package/lib/esm/services/InjectorService.js +2 -2
  8. package/lib/esm/services/InjectorService.js.map +1 -1
  9. package/lib/types/services/DITest.d.ts +5 -1
  10. package/lib/types/services/InjectorService.d.ts +1 -1
  11. package/package.json +3 -3
  12. package/lib/cjs/constants/index.d.ts +0 -3
  13. package/lib/cjs/decorators/configuration.d.ts +0 -8
  14. package/lib/cjs/decorators/constant.d.ts +0 -36
  15. package/lib/cjs/decorators/controller.d.ts +0 -43
  16. package/lib/cjs/decorators/index.d.ts +0 -15
  17. package/lib/cjs/decorators/inject.d.ts +0 -21
  18. package/lib/cjs/decorators/injectable.d.ts +0 -21
  19. package/lib/cjs/decorators/intercept.d.ts +0 -10
  20. package/lib/cjs/decorators/interceptor.d.ts +0 -10
  21. package/lib/cjs/decorators/lazyInject.d.ts +0 -43
  22. package/lib/cjs/decorators/module.d.ts +0 -36
  23. package/lib/cjs/decorators/opts.d.ts +0 -41
  24. package/lib/cjs/decorators/overrideProvider.d.ts +0 -8
  25. package/lib/cjs/decorators/scope.d.ts +0 -8
  26. package/lib/cjs/decorators/service.d.ts +0 -10
  27. package/lib/cjs/decorators/useOpts.d.ts +0 -42
  28. package/lib/cjs/decorators/value.d.ts +0 -36
  29. package/lib/cjs/domain/Container.d.ts +0 -43
  30. package/lib/cjs/domain/ContextLogger.d.ts +0 -41
  31. package/lib/cjs/domain/DIContext.d.ts +0 -72
  32. package/lib/cjs/domain/InjectablePropertyType.d.ts +0 -7
  33. package/lib/cjs/domain/LocalsContainer.d.ts +0 -25
  34. package/lib/cjs/domain/Provider.d.ts +0 -68
  35. package/lib/cjs/domain/ProviderScope.d.ts +0 -5
  36. package/lib/cjs/domain/ProviderType.d.ts +0 -10
  37. package/lib/cjs/domain/index.d.ts +0 -8
  38. package/lib/cjs/errors/InjectionError.d.ts +0 -8
  39. package/lib/cjs/errors/UndefinedTokenError.d.ts +0 -4
  40. package/lib/cjs/index.d.ts +0 -17
  41. package/lib/cjs/interfaces/DIConfigurationOptions.d.ts +0 -25
  42. package/lib/cjs/interfaces/DILogger.d.ts +0 -8
  43. package/lib/cjs/interfaces/DIResolver.d.ts +0 -5
  44. package/lib/cjs/interfaces/IProvider.d.ts +0 -54
  45. package/lib/cjs/interfaces/InjectableProperties.d.ts +0 -24
  46. package/lib/cjs/interfaces/InterceptorContext.d.ts +0 -11
  47. package/lib/cjs/interfaces/InterceptorMethods.d.ts +0 -4
  48. package/lib/cjs/interfaces/InvokeOptions.d.ts +0 -10
  49. package/lib/cjs/interfaces/OnDestroy.d.ts +0 -3
  50. package/lib/cjs/interfaces/OnInit.d.ts +0 -3
  51. package/lib/cjs/interfaces/RegistrySettings.d.ts +0 -20
  52. package/lib/cjs/interfaces/ResolvedInvokeOptions.d.ts +0 -12
  53. package/lib/cjs/interfaces/TokenProvider.d.ts +0 -2
  54. package/lib/cjs/interfaces/index.d.ts +0 -14
  55. package/lib/cjs/registries/GlobalProviders.d.ts +0 -55
  56. package/lib/cjs/registries/ProviderRegistry.d.ts +0 -121
  57. package/lib/cjs/services/DIConfiguration.d.ts +0 -47
  58. package/lib/cjs/services/DILogger.d.ts +0 -1
  59. package/lib/cjs/services/DITest.d.ts +0 -37
  60. package/lib/cjs/services/InjectorService.d.ts +0 -229
  61. package/lib/cjs/utils/colors.d.ts +0 -5
  62. package/lib/cjs/utils/createContainer.d.ts +0 -3
  63. package/lib/cjs/utils/data/Test1.d.ts +0 -3
  64. package/lib/cjs/utils/data/Test2.d.ts +0 -3
  65. package/lib/cjs/utils/getConfiguration.d.ts +0 -2
  66. 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
- }
@@ -1,5 +0,0 @@
1
- export declare const colors: {
2
- red: (text: string) => string;
3
- yellow: (text: string) => string;
4
- green: (text: string) => string;
5
- };
@@ -1,3 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- import { Container } from "../domain/Container";
3
- export declare function createContainer(rootModule?: Type<any>): Container;
@@ -1,3 +0,0 @@
1
- export declare const value1 = "value";
2
- export declare class Test1 {
3
- }
@@ -1,3 +0,0 @@
1
- export declare const value2 = "value";
2
- export declare class Test2 {
3
- }
@@ -1,2 +0,0 @@
1
- import { Type } from "@tsed/core";
2
- export declare function getConfiguration(module: Type<any>, configuration?: any): any;
@@ -1,6 +0,0 @@
1
- import { InjectorService } from "../services/InjectorService";
2
- /**
3
- * @ignore
4
- * @param injector
5
- */
6
- export declare function setLoggerLevel(injector: InjectorService): void;