@tsed/di 6.88.0 → 6.91.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/lib/{constants → cjs/constants}/index.d.ts +0 -0
- package/lib/cjs/constants/index.js +7 -0
- package/lib/cjs/constants/index.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/configuration.d.ts +0 -0
- package/lib/cjs/decorators/configuration.js +24 -0
- package/lib/cjs/decorators/configuration.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/constant.d.ts +0 -0
- package/lib/cjs/decorators/constant.js +55 -0
- package/lib/cjs/decorators/constant.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/controller.d.ts +0 -0
- package/lib/cjs/decorators/controller.js +53 -0
- package/lib/cjs/decorators/controller.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/index.d.ts +0 -0
- package/lib/cjs/decorators/index.js +19 -0
- package/lib/cjs/decorators/index.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/inject.d.ts +0 -0
- package/lib/cjs/decorators/inject.js +79 -0
- package/lib/cjs/decorators/inject.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/injectable.d.ts +0 -0
- package/lib/cjs/decorators/injectable.js +33 -0
- package/lib/cjs/decorators/injectable.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/intercept.d.ts +0 -0
- package/lib/cjs/decorators/intercept.js +28 -0
- package/lib/cjs/decorators/intercept.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/interceptor.d.ts +0 -0
- package/lib/cjs/decorators/interceptor.js +21 -0
- package/lib/cjs/decorators/interceptor.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/lazyInject.d.ts +0 -0
- package/lib/cjs/decorators/lazyInject.js +71 -0
- package/lib/cjs/decorators/lazyInject.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/module.d.ts +0 -0
- package/lib/cjs/decorators/module.js +31 -0
- package/lib/cjs/decorators/module.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/opts.d.ts +0 -0
- package/lib/cjs/decorators/opts.js +54 -0
- package/lib/cjs/decorators/opts.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/overrideProvider.d.ts +0 -0
- package/lib/cjs/decorators/overrideProvider.js +17 -0
- package/lib/cjs/decorators/overrideProvider.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/scope.d.ts +0 -0
- package/lib/cjs/decorators/scope.js +16 -0
- package/lib/cjs/decorators/scope.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/service.d.ts +0 -0
- package/lib/cjs/decorators/service.js +18 -0
- package/lib/cjs/decorators/service.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useOpts.d.ts +0 -0
- package/lib/cjs/decorators/useOpts.js +65 -0
- package/lib/cjs/decorators/useOpts.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/value.d.ts +0 -0
- package/lib/cjs/decorators/value.js +55 -0
- package/lib/cjs/decorators/value.js.map +1 -0
- package/lib/{domain → cjs/domain}/Container.d.ts +0 -0
- package/lib/cjs/domain/Container.js +72 -0
- package/lib/cjs/domain/Container.js.map +1 -0
- package/lib/{domain → cjs/domain}/ContextLogger.d.ts +0 -0
- package/lib/cjs/domain/ContextLogger.js +85 -0
- package/lib/cjs/domain/ContextLogger.js.map +1 -0
- package/lib/{domain → cjs/domain}/DIContext.d.ts +0 -0
- package/lib/cjs/domain/DIContext.js +45 -0
- package/lib/cjs/domain/DIContext.js.map +1 -0
- package/lib/{domain → cjs/domain}/InjectablePropertyType.d.ts +0 -0
- package/lib/cjs/domain/InjectablePropertyType.js +12 -0
- package/lib/cjs/domain/InjectablePropertyType.js.map +1 -0
- package/lib/{domain → cjs/domain}/LocalsContainer.d.ts +0 -0
- package/lib/cjs/domain/LocalsContainer.js +55 -0
- package/lib/cjs/domain/LocalsContainer.js.map +1 -0
- package/lib/{domain → cjs/domain}/Provider.d.ts +0 -0
- package/lib/cjs/domain/Provider.js +122 -0
- package/lib/cjs/domain/Provider.js.map +1 -0
- package/lib/{domain → cjs/domain}/ProviderScope.d.ts +0 -0
- package/lib/cjs/domain/ProviderScope.js +10 -0
- package/lib/cjs/domain/ProviderScope.js.map +1 -0
- package/lib/{domain → cjs/domain}/ProviderType.d.ts +0 -0
- package/lib/cjs/domain/ProviderType.js +15 -0
- package/lib/cjs/domain/ProviderType.js.map +1 -0
- package/lib/{domain → cjs/domain}/index.d.ts +0 -0
- package/lib/cjs/domain/index.js +12 -0
- package/lib/cjs/domain/index.js.map +1 -0
- package/lib/{errors → cjs/errors}/InjectionError.d.ts +0 -0
- package/lib/cjs/errors/InjectionError.js +58 -0
- package/lib/cjs/errors/InjectionError.js.map +1 -0
- package/lib/{errors → cjs/errors}/UndefinedTokenError.d.ts +0 -0
- package/lib/cjs/errors/UndefinedTokenError.js +11 -0
- package/lib/cjs/errors/UndefinedTokenError.js.map +1 -0
- package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
- package/lib/cjs/index.js +21 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/DIConfigurationOptions.d.ts +0 -0
- package/lib/cjs/interfaces/DIConfigurationOptions.js +3 -0
- package/lib/cjs/interfaces/DIConfigurationOptions.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/DILogger.d.ts +0 -0
- package/lib/cjs/interfaces/DILogger.js +3 -0
- package/lib/cjs/interfaces/DILogger.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/DIResolver.d.ts +0 -0
- package/lib/cjs/interfaces/DIResolver.js +3 -0
- package/lib/cjs/interfaces/DIResolver.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/IProvider.d.ts +0 -0
- package/lib/cjs/interfaces/IProvider.js +3 -0
- package/lib/cjs/interfaces/IProvider.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/InjectableProperties.d.ts +0 -0
- package/lib/cjs/interfaces/InjectableProperties.js +3 -0
- package/lib/cjs/interfaces/InjectableProperties.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/InterceptorContext.d.ts +0 -0
- package/lib/cjs/interfaces/InterceptorContext.js +3 -0
- package/lib/cjs/interfaces/InterceptorContext.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/InterceptorMethods.d.ts +0 -0
- package/lib/cjs/interfaces/InterceptorMethods.js +3 -0
- package/lib/cjs/interfaces/InterceptorMethods.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/InvokeOptions.d.ts +0 -0
- package/lib/cjs/interfaces/InvokeOptions.js +3 -0
- package/lib/cjs/interfaces/InvokeOptions.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnDestroy.d.ts +0 -0
- package/lib/cjs/interfaces/OnDestroy.js +3 -0
- package/lib/cjs/interfaces/OnDestroy.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnInit.d.ts +0 -0
- package/lib/cjs/interfaces/OnInit.js +3 -0
- package/lib/cjs/interfaces/OnInit.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/RegistrySettings.d.ts +0 -0
- package/lib/cjs/interfaces/RegistrySettings.js +3 -0
- package/lib/cjs/interfaces/RegistrySettings.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/ResolvedInvokeOptions.d.ts +0 -0
- package/lib/cjs/interfaces/ResolvedInvokeOptions.js +3 -0
- package/lib/cjs/interfaces/ResolvedInvokeOptions.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/TokenProvider.d.ts +0 -0
- package/lib/cjs/interfaces/TokenProvider.js +3 -0
- package/lib/cjs/interfaces/TokenProvider.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/index.d.ts +0 -0
- package/lib/cjs/interfaces/index.js +18 -0
- package/lib/cjs/interfaces/index.js.map +1 -0
- package/lib/{registries → cjs/registries}/GlobalProviders.d.ts +0 -0
- package/lib/cjs/registries/GlobalProviders.js +124 -0
- package/lib/cjs/registries/GlobalProviders.js.map +1 -0
- package/lib/{registries → cjs/registries}/ProviderRegistry.d.ts +0 -0
- package/lib/cjs/registries/ProviderRegistry.js +149 -0
- package/lib/cjs/registries/ProviderRegistry.js.map +1 -0
- package/lib/{services → cjs/services}/DIConfiguration.d.ts +0 -0
- package/lib/cjs/services/DIConfiguration.js +129 -0
- package/lib/cjs/services/DIConfiguration.js.map +1 -0
- package/lib/{services → cjs/services}/DILogger.d.ts +0 -0
- package/lib/cjs/services/DILogger.js +13 -0
- package/lib/cjs/services/DILogger.js.map +1 -0
- package/lib/{services → cjs/services}/DITest.d.ts +0 -0
- package/lib/cjs/services/DITest.js +100 -0
- package/lib/cjs/services/DITest.js.map +1 -0
- package/lib/{services → cjs/services}/InjectorService.d.ts +0 -0
- package/lib/cjs/services/InjectorService.js +581 -0
- package/lib/cjs/services/InjectorService.js.map +1 -0
- package/lib/{utils → cjs/utils}/colors.d.ts +0 -0
- package/lib/cjs/utils/colors.js +10 -0
- package/lib/cjs/utils/colors.js.map +1 -0
- package/lib/{utils → cjs/utils}/createContainer.d.ts +0 -0
- package/lib/cjs/utils/createContainer.js +14 -0
- package/lib/cjs/utils/createContainer.js.map +1 -0
- package/lib/cjs/utils/data/Test1.d.ts +3 -0
- package/lib/cjs/utils/data/Test1.js +8 -0
- package/lib/cjs/utils/data/Test1.js.map +1 -0
- package/lib/cjs/utils/data/Test2.d.ts +3 -0
- package/lib/cjs/utils/data/Test2.js +8 -0
- package/lib/cjs/utils/data/Test2.js.map +1 -0
- package/lib/{utils → cjs/utils}/getConfiguration.d.ts +0 -0
- package/lib/cjs/utils/getConfiguration.js +20 -0
- package/lib/cjs/utils/getConfiguration.js.map +1 -0
- package/lib/{utils → cjs/utils}/setLoggerLevel.d.ts +0 -0
- package/lib/cjs/utils/setLoggerLevel.js +16 -0
- package/lib/cjs/utils/setLoggerLevel.js.map +1 -0
- package/lib/esm/constants/index.js +4 -0
- package/lib/esm/constants/index.js.map +1 -0
- package/lib/esm/decorators/configuration.js +20 -0
- package/lib/esm/decorators/configuration.js.map +1 -0
- package/lib/esm/decorators/constant.js +51 -0
- package/lib/esm/decorators/constant.js.map +1 -0
- package/lib/esm/decorators/controller.js +49 -0
- package/lib/esm/decorators/controller.js.map +1 -0
- package/lib/esm/decorators/index.js +16 -0
- package/lib/esm/decorators/index.js.map +1 -0
- package/lib/esm/decorators/inject.js +74 -0
- package/lib/esm/decorators/inject.js.map +1 -0
- package/lib/esm/decorators/injectable.js +29 -0
- package/lib/esm/decorators/injectable.js.map +1 -0
- package/lib/esm/decorators/intercept.js +24 -0
- package/lib/esm/decorators/intercept.js.map +1 -0
- package/lib/esm/decorators/interceptor.js +17 -0
- package/lib/esm/decorators/interceptor.js.map +1 -0
- package/lib/esm/decorators/lazyInject.js +66 -0
- package/lib/esm/decorators/lazyInject.js.map +1 -0
- package/lib/esm/decorators/module.js +27 -0
- package/lib/esm/decorators/module.js.map +1 -0
- package/lib/esm/decorators/opts.js +50 -0
- package/lib/esm/decorators/opts.js.map +1 -0
- package/lib/esm/decorators/overrideProvider.js +13 -0
- package/lib/esm/decorators/overrideProvider.js.map +1 -0
- package/lib/esm/decorators/scope.js +12 -0
- package/lib/esm/decorators/scope.js.map +1 -0
- package/lib/esm/decorators/service.js +14 -0
- package/lib/esm/decorators/service.js.map +1 -0
- package/lib/esm/decorators/useOpts.js +61 -0
- package/lib/esm/decorators/useOpts.js.map +1 -0
- package/lib/esm/decorators/value.js +51 -0
- package/lib/esm/decorators/value.js.map +1 -0
- package/lib/esm/domain/Container.js +68 -0
- package/lib/esm/domain/Container.js.map +1 -0
- package/lib/esm/domain/ContextLogger.js +81 -0
- package/lib/esm/domain/ContextLogger.js.map +1 -0
- package/lib/esm/domain/DIContext.js +41 -0
- package/lib/esm/domain/DIContext.js.map +1 -0
- package/lib/esm/domain/InjectablePropertyType.js +9 -0
- package/lib/esm/domain/InjectablePropertyType.js.map +1 -0
- package/lib/esm/domain/LocalsContainer.js +51 -0
- package/lib/esm/domain/LocalsContainer.js.map +1 -0
- package/lib/esm/domain/Provider.js +118 -0
- package/lib/esm/domain/Provider.js.map +1 -0
- package/lib/esm/domain/ProviderScope.js +7 -0
- package/lib/esm/domain/ProviderScope.js.map +1 -0
- package/lib/esm/domain/ProviderType.js +12 -0
- package/lib/esm/domain/ProviderType.js.map +1 -0
- package/lib/esm/domain/index.js +9 -0
- package/lib/esm/domain/index.js.map +1 -0
- package/lib/esm/errors/InjectionError.js +54 -0
- package/lib/esm/errors/InjectionError.js.map +1 -0
- package/lib/esm/errors/UndefinedTokenError.js +7 -0
- package/lib/esm/errors/UndefinedTokenError.js.map +1 -0
- package/lib/esm/index.js +18 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/DIConfigurationOptions.js +2 -0
- package/lib/esm/interfaces/DIConfigurationOptions.js.map +1 -0
- package/lib/esm/interfaces/DILogger.js +2 -0
- package/lib/esm/interfaces/DILogger.js.map +1 -0
- package/lib/esm/interfaces/DIResolver.js +2 -0
- package/lib/esm/interfaces/DIResolver.js.map +1 -0
- package/lib/esm/interfaces/IProvider.js +2 -0
- package/lib/esm/interfaces/IProvider.js.map +1 -0
- package/lib/esm/interfaces/InjectableProperties.js +2 -0
- package/lib/esm/interfaces/InjectableProperties.js.map +1 -0
- package/lib/esm/interfaces/InterceptorContext.js +2 -0
- package/lib/esm/interfaces/InterceptorContext.js.map +1 -0
- package/lib/esm/interfaces/InterceptorMethods.js +2 -0
- package/lib/esm/interfaces/InterceptorMethods.js.map +1 -0
- package/lib/esm/interfaces/InvokeOptions.js +2 -0
- package/lib/esm/interfaces/InvokeOptions.js.map +1 -0
- package/lib/esm/interfaces/OnDestroy.js +2 -0
- package/lib/esm/interfaces/OnDestroy.js.map +1 -0
- package/lib/esm/interfaces/OnInit.js +2 -0
- package/lib/esm/interfaces/OnInit.js.map +1 -0
- package/lib/esm/interfaces/RegistrySettings.js +2 -0
- package/lib/esm/interfaces/RegistrySettings.js.map +1 -0
- package/lib/esm/interfaces/ResolvedInvokeOptions.js +2 -0
- package/lib/esm/interfaces/ResolvedInvokeOptions.js.map +1 -0
- package/lib/esm/interfaces/TokenProvider.js +2 -0
- package/lib/esm/interfaces/TokenProvider.js.map +1 -0
- package/lib/esm/interfaces/index.js +15 -0
- package/lib/esm/interfaces/index.js.map +1 -0
- package/lib/esm/registries/GlobalProviders.js +120 -0
- package/lib/esm/registries/GlobalProviders.js.map +1 -0
- package/lib/esm/registries/ProviderRegistry.js +144 -0
- package/lib/esm/registries/ProviderRegistry.js.map +1 -0
- package/lib/esm/services/DIConfiguration.js +125 -0
- package/lib/esm/services/DIConfiguration.js.map +1 -0
- package/lib/esm/services/DILogger.js +11 -0
- package/lib/esm/services/DILogger.js.map +1 -0
- package/lib/esm/services/DITest.js +96 -0
- package/lib/esm/services/DITest.js.map +1 -0
- package/lib/esm/services/InjectorService.js +578 -0
- package/lib/esm/services/InjectorService.js.map +1 -0
- package/lib/esm/utils/colors.js +7 -0
- package/lib/esm/utils/colors.js.map +1 -0
- package/lib/esm/utils/createContainer.js +10 -0
- package/lib/esm/utils/createContainer.js.map +1 -0
- package/lib/esm/utils/data/Test1.js +4 -0
- package/lib/esm/utils/data/Test1.js.map +1 -0
- package/lib/esm/utils/data/Test2.js +4 -0
- package/lib/esm/utils/data/Test2.js.map +1 -0
- package/lib/esm/utils/getConfiguration.js +16 -0
- package/lib/esm/utils/getConfiguration.js.map +1 -0
- package/lib/esm/utils/setLoggerLevel.js +12 -0
- package/lib/esm/utils/setLoggerLevel.js.map +1 -0
- package/lib/types/constants/index.d.ts +3 -0
- package/lib/types/decorators/configuration.d.ts +8 -0
- package/lib/types/decorators/constant.d.ts +36 -0
- package/lib/types/decorators/controller.d.ts +43 -0
- package/lib/types/decorators/index.d.ts +15 -0
- package/lib/types/decorators/inject.d.ts +21 -0
- package/lib/types/decorators/injectable.d.ts +21 -0
- package/lib/types/decorators/intercept.d.ts +10 -0
- package/lib/types/decorators/interceptor.d.ts +10 -0
- package/lib/types/decorators/lazyInject.d.ts +43 -0
- package/lib/types/decorators/module.d.ts +36 -0
- package/lib/types/decorators/opts.d.ts +41 -0
- package/lib/types/decorators/overrideProvider.d.ts +8 -0
- package/lib/types/decorators/scope.d.ts +8 -0
- package/lib/types/decorators/service.d.ts +10 -0
- package/lib/types/decorators/useOpts.d.ts +42 -0
- package/lib/types/decorators/value.d.ts +36 -0
- package/lib/types/domain/Container.d.ts +43 -0
- package/lib/types/domain/ContextLogger.d.ts +41 -0
- package/lib/types/domain/DIContext.d.ts +72 -0
- package/lib/types/domain/InjectablePropertyType.d.ts +7 -0
- package/lib/types/domain/LocalsContainer.d.ts +25 -0
- package/lib/types/domain/Provider.d.ts +68 -0
- package/lib/types/domain/ProviderScope.d.ts +5 -0
- package/lib/types/domain/ProviderType.d.ts +10 -0
- package/lib/types/domain/index.d.ts +8 -0
- package/lib/types/errors/InjectionError.d.ts +8 -0
- package/lib/types/errors/UndefinedTokenError.d.ts +4 -0
- package/lib/types/index.d.ts +17 -0
- package/lib/types/interfaces/DIConfigurationOptions.d.ts +25 -0
- package/lib/types/interfaces/DILogger.d.ts +8 -0
- package/lib/types/interfaces/DIResolver.d.ts +5 -0
- package/lib/types/interfaces/IProvider.d.ts +54 -0
- package/lib/types/interfaces/InjectableProperties.d.ts +24 -0
- package/lib/types/interfaces/InterceptorContext.d.ts +11 -0
- package/lib/types/interfaces/InterceptorMethods.d.ts +4 -0
- package/lib/types/interfaces/InvokeOptions.d.ts +10 -0
- package/lib/types/interfaces/OnDestroy.d.ts +3 -0
- package/lib/types/interfaces/OnInit.d.ts +3 -0
- package/lib/types/interfaces/RegistrySettings.d.ts +20 -0
- package/lib/types/interfaces/ResolvedInvokeOptions.d.ts +12 -0
- package/lib/types/interfaces/TokenProvider.d.ts +2 -0
- package/lib/types/interfaces/index.d.ts +14 -0
- package/lib/types/registries/GlobalProviders.d.ts +55 -0
- package/lib/types/registries/ProviderRegistry.d.ts +121 -0
- package/lib/types/services/DIConfiguration.d.ts +47 -0
- package/lib/types/services/DILogger.d.ts +1 -0
- package/lib/types/services/DITest.d.ts +37 -0
- package/lib/types/services/InjectorService.d.ts +229 -0
- package/lib/types/utils/colors.d.ts +5 -0
- package/lib/types/utils/createContainer.d.ts +3 -0
- package/lib/types/utils/data/Test1.d.ts +3 -0
- package/lib/types/utils/data/Test2.d.ts +3 -0
- package/lib/types/utils/getConfiguration.d.ts +2 -0
- package/lib/types/utils/setLoggerLevel.d.ts +6 -0
- package/package.json +12 -8
- package/tsconfig.compile.esm.json +24 -0
- package/lib/index.js +0 -2546
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -2508
- package/lib/index.modern.js.map +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TokenProvider } from "../interfaces/TokenProvider";
|
|
2
|
+
export declare class LocalsContainer<V = any> extends Map<TokenProvider, V> {
|
|
3
|
+
/**
|
|
4
|
+
* Emit an event to all service. See service [lifecycle hooks](/docs/services.md#lifecycle-hooks).
|
|
5
|
+
* @param eventName The event name to emit at all services.
|
|
6
|
+
* @param args List of the parameters to give to each services.
|
|
7
|
+
* @returns {Promise<any[]>} A list of promises.
|
|
8
|
+
*/
|
|
9
|
+
emit(eventName: string, ...args: any[]): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* @param eventName
|
|
12
|
+
* @param value
|
|
13
|
+
* @param args
|
|
14
|
+
*/
|
|
15
|
+
alter<T = any>(eventName: string, value: any, ...args: any[]): T;
|
|
16
|
+
/**
|
|
17
|
+
* @param eventName
|
|
18
|
+
* @param value
|
|
19
|
+
* @param args
|
|
20
|
+
*/
|
|
21
|
+
alterAsync<T = any>(eventName: string, value: any, ...args: any[]): Promise<T>;
|
|
22
|
+
toArray(): V[];
|
|
23
|
+
destroy(): Promise<void>;
|
|
24
|
+
protected getListeners(event: string): any[];
|
|
25
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Store, Type } from "@tsed/core";
|
|
2
|
+
import { IProvider, TokenProvider } from "../interfaces";
|
|
3
|
+
import { ProviderScope } from "./ProviderScope";
|
|
4
|
+
import { ProviderType } from "./ProviderType";
|
|
5
|
+
export declare class Provider<T = any> implements IProvider<T> {
|
|
6
|
+
type: ProviderType | any;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use injector.get(provider.token) instead.
|
|
9
|
+
*/
|
|
10
|
+
instance: T;
|
|
11
|
+
deps: TokenProvider[];
|
|
12
|
+
imports: any[];
|
|
13
|
+
useFactory: Function;
|
|
14
|
+
useAsyncFactory: Function;
|
|
15
|
+
useValue: any;
|
|
16
|
+
private _useClass;
|
|
17
|
+
private _provide;
|
|
18
|
+
private _store;
|
|
19
|
+
private _tokenStore;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
constructor(token: TokenProvider, options?: Partial<Provider>);
|
|
22
|
+
get token(): any;
|
|
23
|
+
get provide(): TokenProvider;
|
|
24
|
+
set provide(value: TokenProvider);
|
|
25
|
+
get useClass(): Type<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new store if the given value is a class. Otherwise the value is ignored.
|
|
28
|
+
* @param value
|
|
29
|
+
*/
|
|
30
|
+
set useClass(value: Type<T>);
|
|
31
|
+
get className(): string;
|
|
32
|
+
get name(): string;
|
|
33
|
+
get store(): Store;
|
|
34
|
+
get path(): string;
|
|
35
|
+
set path(path: string);
|
|
36
|
+
/**
|
|
37
|
+
* Get the scope of the provider.
|
|
38
|
+
*
|
|
39
|
+
* ::: tip Note
|
|
40
|
+
* Async provider is always a SINGLETON
|
|
41
|
+
* :::
|
|
42
|
+
*
|
|
43
|
+
* @returns {boolean}
|
|
44
|
+
*/
|
|
45
|
+
get scope(): ProviderScope;
|
|
46
|
+
/**
|
|
47
|
+
* Change the scope value of the provider.
|
|
48
|
+
* @param scope
|
|
49
|
+
*/
|
|
50
|
+
set scope(scope: ProviderScope);
|
|
51
|
+
get configuration(): Partial<TsED.Configuration>;
|
|
52
|
+
set configuration(configuration: Partial<TsED.Configuration>);
|
|
53
|
+
get children(): TokenProvider[];
|
|
54
|
+
get(key: string): any;
|
|
55
|
+
isAsync(): boolean;
|
|
56
|
+
clone(): Provider;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @returns {boolean}
|
|
60
|
+
*/
|
|
61
|
+
hasChildren(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @returns {boolean}
|
|
65
|
+
*/
|
|
66
|
+
hasParent(): boolean;
|
|
67
|
+
toString(): string;
|
|
68
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./Container";
|
|
2
|
+
export * from "./InjectablePropertyType";
|
|
3
|
+
export * from "./LocalsContainer";
|
|
4
|
+
export * from "./Provider";
|
|
5
|
+
export * from "./ProviderScope";
|
|
6
|
+
export * from "./ProviderType";
|
|
7
|
+
export * from "./ContextLogger";
|
|
8
|
+
export * from "./DIContext";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TokenProvider } from "../interfaces";
|
|
2
|
+
export declare class InjectionError extends Error {
|
|
3
|
+
name: string;
|
|
4
|
+
tokens: TokenProvider[];
|
|
5
|
+
origin: any;
|
|
6
|
+
constructor(token: TokenProvider, origin?: any);
|
|
7
|
+
static throwInjectorError(token: any, currentDependency: any, error: any): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from "./constants/index";
|
|
2
|
+
export * from "./domain";
|
|
3
|
+
export * from "./interfaces";
|
|
4
|
+
export * from "./decorators";
|
|
5
|
+
export * from "./registries/ProviderRegistry";
|
|
6
|
+
export * from "./registries/GlobalProviders";
|
|
7
|
+
export * from "./services/InjectorService";
|
|
8
|
+
export * from "./services/DILogger";
|
|
9
|
+
export * from "./services/DIConfiguration";
|
|
10
|
+
export * from "./services/DITest";
|
|
11
|
+
export * from "./errors/InjectionError";
|
|
12
|
+
export * from "./errors/UndefinedTokenError";
|
|
13
|
+
export * from "./utils/createContainer";
|
|
14
|
+
export * from "./utils/getConfiguration";
|
|
15
|
+
export * from "./utils/getConfiguration";
|
|
16
|
+
export * from "./utils/setLoggerLevel";
|
|
17
|
+
export * from "./utils/colors";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DIResolver } from "./DIResolver";
|
|
2
|
+
import type { ProviderScope } from "../domain/ProviderScope";
|
|
3
|
+
import type { TokenProvider } from "./TokenProvider";
|
|
4
|
+
declare global {
|
|
5
|
+
namespace TsED {
|
|
6
|
+
interface Context {
|
|
7
|
+
}
|
|
8
|
+
interface Configuration {
|
|
9
|
+
scopes: {
|
|
10
|
+
[key: string]: ProviderScope;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Define a list of resolvers (it can be an external DI).
|
|
14
|
+
*/
|
|
15
|
+
resolvers: DIResolver[];
|
|
16
|
+
/**
|
|
17
|
+
* Define dependencies to build the provider
|
|
18
|
+
*/
|
|
19
|
+
imports: TokenProvider[];
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export interface DIConfigurationOptions extends TsED.Configuration {
|
|
25
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Type } from "@tsed/core";
|
|
2
|
+
import type { DIResolver } from "./DIResolver";
|
|
3
|
+
import type { ProviderScope } from "../domain/ProviderScope";
|
|
4
|
+
import type { ProviderType } from "../domain/ProviderType";
|
|
5
|
+
import type { TokenProvider } from "./TokenProvider";
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export interface IProvider<T = any> {
|
|
10
|
+
/**
|
|
11
|
+
* An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).
|
|
12
|
+
*/
|
|
13
|
+
provide: TokenProvider;
|
|
14
|
+
/**
|
|
15
|
+
* Provider type
|
|
16
|
+
*/
|
|
17
|
+
type?: ProviderType | string;
|
|
18
|
+
/**
|
|
19
|
+
* Instance build by the injector
|
|
20
|
+
*/
|
|
21
|
+
instance?: T;
|
|
22
|
+
/**
|
|
23
|
+
* Define dependencies to build the provider
|
|
24
|
+
*/
|
|
25
|
+
deps?: TokenProvider[];
|
|
26
|
+
/**
|
|
27
|
+
* Class to instantiate for the `token`.
|
|
28
|
+
*/
|
|
29
|
+
useClass?: Type<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Provide a function to build the provider
|
|
32
|
+
*/
|
|
33
|
+
useFactory?: Function;
|
|
34
|
+
/**
|
|
35
|
+
* Provide an async function to build the provider
|
|
36
|
+
*/
|
|
37
|
+
useAsyncFactory?: Function;
|
|
38
|
+
/**
|
|
39
|
+
* Provide predefined value
|
|
40
|
+
*/
|
|
41
|
+
useValue?: any;
|
|
42
|
+
/**
|
|
43
|
+
* Scope used by the injector to build the provider.
|
|
44
|
+
*/
|
|
45
|
+
scope?: ProviderScope;
|
|
46
|
+
/**
|
|
47
|
+
* A list of resolvers which will be used to resolve missing Symbol/Class when injector invoke a Class. This property allow external DI usage.
|
|
48
|
+
*/
|
|
49
|
+
resolvers?: DIResolver[];
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
[key: string]: any;
|
|
54
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { InjectablePropertyType } from "../domain/InjectablePropertyType";
|
|
2
|
+
import type { TokenProvider } from "./TokenProvider";
|
|
3
|
+
import type { InjectorService } from "../services/InjectorService";
|
|
4
|
+
import type { InvokeOptions } from "./InvokeOptions";
|
|
5
|
+
export interface InjectableProperty {
|
|
6
|
+
propertyKey: string;
|
|
7
|
+
}
|
|
8
|
+
export interface InjectablePropertyOptions extends InjectableProperty {
|
|
9
|
+
bindingType: InjectablePropertyType.METHOD | InjectablePropertyType.PROPERTY | InjectablePropertyType.INTERCEPTOR;
|
|
10
|
+
propertyType: string;
|
|
11
|
+
useType?: TokenProvider;
|
|
12
|
+
resolver: (injector: InjectorService, locals: Map<TokenProvider, any>, options: Partial<InvokeOptions> & {
|
|
13
|
+
options: any;
|
|
14
|
+
}) => () => any;
|
|
15
|
+
options?: any;
|
|
16
|
+
}
|
|
17
|
+
export interface InjectablePropertyValue extends InjectableProperty {
|
|
18
|
+
bindingType: InjectablePropertyType.CONSTANT | InjectablePropertyType.VALUE;
|
|
19
|
+
expression: string;
|
|
20
|
+
defaultValue?: any;
|
|
21
|
+
}
|
|
22
|
+
export interface InjectableProperties {
|
|
23
|
+
[key: string]: InjectablePropertyOptions | InjectablePropertyValue;
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Type } from "@tsed/core";
|
|
2
|
+
export interface InterceptorNext {
|
|
3
|
+
<T>(err?: Error): T;
|
|
4
|
+
}
|
|
5
|
+
export interface InterceptorContext<Klass = Type, Opts = any> {
|
|
6
|
+
target: Klass;
|
|
7
|
+
propertyKey: string;
|
|
8
|
+
args: any[];
|
|
9
|
+
next: InterceptorNext;
|
|
10
|
+
options?: Opts;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ProviderScope } from "../domain/ProviderScope";
|
|
2
|
+
import { TokenProvider } from "./TokenProvider";
|
|
3
|
+
export interface InvokeOptions<T = any> {
|
|
4
|
+
deps: any[];
|
|
5
|
+
imports: any[];
|
|
6
|
+
parent?: TokenProvider;
|
|
7
|
+
scope: ProviderScope;
|
|
8
|
+
useScope: boolean;
|
|
9
|
+
rebuild?: boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import type { Provider } from "../domain";
|
|
3
|
+
import type { InjectorService } from "../services/InjectorService";
|
|
4
|
+
import type { ResolvedInvokeOptions } from "./ResolvedInvokeOptions";
|
|
5
|
+
/**
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
export interface RegistrySettings {
|
|
9
|
+
injectable?: boolean;
|
|
10
|
+
model?: Type<Provider>;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param provider
|
|
14
|
+
* @param {Map<string | Function, any>} locals
|
|
15
|
+
* @param options
|
|
16
|
+
*/
|
|
17
|
+
onInvoke?(provider: Provider, locals: Map<string | Function, any>, options: ResolvedInvokeOptions & {
|
|
18
|
+
injector: InjectorService;
|
|
19
|
+
}): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Provider } from "../domain/Provider";
|
|
2
|
+
import type { ProviderScope } from "../domain/ProviderScope";
|
|
3
|
+
import type { TokenProvider } from "./TokenProvider";
|
|
4
|
+
export interface ResolvedInvokeOptions {
|
|
5
|
+
token: TokenProvider;
|
|
6
|
+
parent?: TokenProvider;
|
|
7
|
+
scope: ProviderScope;
|
|
8
|
+
deps: TokenProvider[];
|
|
9
|
+
imports: TokenProvider[];
|
|
10
|
+
provider: Provider;
|
|
11
|
+
construct(deps: TokenProvider[]): any;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./DILogger";
|
|
2
|
+
export * from "./DIConfigurationOptions";
|
|
3
|
+
export * from "./DIResolver";
|
|
4
|
+
export * from "./InjectableProperties";
|
|
5
|
+
export * from "./InterceptorMethods";
|
|
6
|
+
export * from "./InterceptorContext";
|
|
7
|
+
export * from "./InvokeOptions";
|
|
8
|
+
export * from "./IProvider";
|
|
9
|
+
export * from "./OnInit";
|
|
10
|
+
export * from "./OnDestroy";
|
|
11
|
+
export * from "./OnInit";
|
|
12
|
+
export * from "./RegistrySettings";
|
|
13
|
+
export * from "./TokenProvider";
|
|
14
|
+
export * from "./ResolvedInvokeOptions";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { Provider } from "../domain/Provider";
|
|
3
|
+
import type { IProvider, RegistrySettings, TokenProvider } from "../interfaces";
|
|
4
|
+
import type { InjectorService } from "../services/InjectorService";
|
|
5
|
+
import { ResolvedInvokeOptions } from "../interfaces/ResolvedInvokeOptions";
|
|
6
|
+
export declare class GlobalProviderRegistry extends Map<TokenProvider, Provider> {
|
|
7
|
+
#private;
|
|
8
|
+
/**
|
|
9
|
+
* The get() method returns a specified element from a Map object.
|
|
10
|
+
* @param key Required. The key of the element to return from the Map object.
|
|
11
|
+
* @returns {T} Returns the element associated with the specified key or undefined if the key can't be found in the Map object.
|
|
12
|
+
*/
|
|
13
|
+
get(key: TokenProvider): Provider | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The has() method returns a boolean indicating whether an element with the specified key exists or not.
|
|
16
|
+
* @param key
|
|
17
|
+
* @returns {boolean}
|
|
18
|
+
*/
|
|
19
|
+
has(key: TokenProvider): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The set() method adds or updates an element with a specified key and value to a Map object.
|
|
22
|
+
* @param key Required. The key of the element to add to the Map object.
|
|
23
|
+
* @param metadata Required. The value of the element to add to the Map object.
|
|
24
|
+
*/
|
|
25
|
+
set(key: TokenProvider, metadata: Provider): this;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param target
|
|
29
|
+
* @param options
|
|
30
|
+
*/
|
|
31
|
+
merge(target: TokenProvider, options: Partial<IProvider>): void;
|
|
32
|
+
/**
|
|
33
|
+
* The delete() method removes the specified element from a Map object.
|
|
34
|
+
* @param key Required. The key of the element to remove from the Map object.
|
|
35
|
+
* @returns {boolean} Returns true if an element in the Map object existed and has been removed, or false if the element does not exist.
|
|
36
|
+
*/
|
|
37
|
+
delete(key: TokenProvider): boolean;
|
|
38
|
+
createRegistry(type: string, model: Type<Provider>, options?: Partial<RegistrySettings>): this;
|
|
39
|
+
onInvoke(provider: Provider, locals: Map<TokenProvider, any>, options: ResolvedInvokeOptions & {
|
|
40
|
+
injector: InjectorService;
|
|
41
|
+
}): void;
|
|
42
|
+
getRegistrySettings(target: string | TokenProvider): RegistrySettings;
|
|
43
|
+
createRegisterFn(type: string): (provider: any | IProvider, instance?: any) => void;
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @param key
|
|
47
|
+
* @param options
|
|
48
|
+
*/
|
|
49
|
+
protected createIfNotExists(key: TokenProvider, options: Partial<IProvider>): Provider;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @type {GlobalProviders}
|
|
54
|
+
*/
|
|
55
|
+
export declare const GlobalProviders: GlobalProviderRegistry;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { IProvider } from "../interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Register a provider configuration.
|
|
4
|
+
* @param {IProvider<any>} provider
|
|
5
|
+
*/
|
|
6
|
+
export declare function registerProvider(provider: Partial<IProvider>): void;
|
|
7
|
+
/**
|
|
8
|
+
* Add a new factory in the `ProviderRegistry`.
|
|
9
|
+
*
|
|
10
|
+
* #### Example with symbol definition
|
|
11
|
+
*
|
|
12
|
+
*
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import {registerFactory, InjectorService} from "@tsed/di";
|
|
15
|
+
*
|
|
16
|
+
* export interface IMyFooFactory {
|
|
17
|
+
* getFoo(): string;
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* export type MyFooFactory = IMyFooFactory;
|
|
21
|
+
* export const MyFooFactory = Symbol("MyFooFactory");
|
|
22
|
+
*
|
|
23
|
+
* registerFactory(MyFooFactory, {
|
|
24
|
+
* getFoo: () => "test"
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // or
|
|
28
|
+
*
|
|
29
|
+
* registerFactory({provide: MyFooFactory, instance: {
|
|
30
|
+
* getFoo: () => "test"
|
|
31
|
+
* }});
|
|
32
|
+
*
|
|
33
|
+
* @Service()
|
|
34
|
+
* export class OtherService {
|
|
35
|
+
* constructor(@Inject(MyFooFactory) myFooFactory: MyFooFactory){
|
|
36
|
+
* console.log(myFooFactory.getFoo()); /// "test"
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* > Note: When you use the factory method with Symbol definition, you must use the `@Inject()`
|
|
42
|
+
* decorator to retrieve your factory in another Service. Advice: By convention all factory class name will be prefixed by
|
|
43
|
+
* `Factory`.
|
|
44
|
+
*
|
|
45
|
+
* #### Example with class
|
|
46
|
+
*
|
|
47
|
+
* ```typescript
|
|
48
|
+
* import {InjectorService, registerFactory} from "@tsed/di";
|
|
49
|
+
*
|
|
50
|
+
* export class MyFooService {
|
|
51
|
+
* constructor(){}
|
|
52
|
+
* getFoo() {
|
|
53
|
+
* return "test";
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* registerFactory(MyFooService, new MyFooService());
|
|
58
|
+
* // or
|
|
59
|
+
* registerFactory({provider: MyFooService, instance: new MyFooService()});
|
|
60
|
+
*
|
|
61
|
+
* @Service()
|
|
62
|
+
* export class OtherService {
|
|
63
|
+
* constructor(myFooService: MyFooService){
|
|
64
|
+
* console.log(myFooFactory.getFoo()); /// "test"
|
|
65
|
+
* }
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
* @deprecated Since 2021-05-15. Use registerProvider instead.
|
|
69
|
+
*/
|
|
70
|
+
export declare const registerFactory: typeof registerProvider;
|
|
71
|
+
/**
|
|
72
|
+
* Add a new value in the `ProviderRegistry`.
|
|
73
|
+
*
|
|
74
|
+
* #### Example with symbol definition
|
|
75
|
+
*
|
|
76
|
+
*
|
|
77
|
+
* ```typescript
|
|
78
|
+
* import {registerValue, InjectorService} from "@tsed/di";
|
|
79
|
+
*
|
|
80
|
+
* const MyValue = Symbol.from("MyValue")
|
|
81
|
+
*
|
|
82
|
+
* registerValue({token: MyValue, useValue: "myValue"});
|
|
83
|
+
*
|
|
84
|
+
* @Service()
|
|
85
|
+
* export class OtherService {
|
|
86
|
+
* constructor(@Inject(MyValue) myValue: string){
|
|
87
|
+
* console.log(myValue); /// "myValue"
|
|
88
|
+
* }
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare const registerValue: (provider: any | IProvider<any>, value?: any) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Add a new controller in the `ProviderRegistry`. This controller will be built when `InjectorService` will be loaded.
|
|
95
|
+
*
|
|
96
|
+
* #### Example
|
|
97
|
+
*
|
|
98
|
+
* ```typescript
|
|
99
|
+
* import {registerController, InjectorService} from "@tsed/di";
|
|
100
|
+
*
|
|
101
|
+
* export default class MyController {
|
|
102
|
+
* constructor(){}
|
|
103
|
+
* transform() {
|
|
104
|
+
* return "test";
|
|
105
|
+
* }
|
|
106
|
+
* }
|
|
107
|
+
*
|
|
108
|
+
* registerController({provide: MyController});
|
|
109
|
+
* // or
|
|
110
|
+
* registerController(MyController);
|
|
111
|
+
*
|
|
112
|
+
* const injector = new InjectorService();
|
|
113
|
+
* injector.load();
|
|
114
|
+
*
|
|
115
|
+
* const myController = injector.get<MyController>(MyController);
|
|
116
|
+
* myController.getFoo(); // test
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @param provider Provider configuration.
|
|
120
|
+
*/
|
|
121
|
+
export declare const registerController: (provider: any, instance?: any) => void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ProviderScope } from "../domain";
|
|
2
|
+
import type { DIResolver, TokenProvider } from "../interfaces";
|
|
3
|
+
export declare class DIConfiguration {
|
|
4
|
+
readonly default: Map<string, any>;
|
|
5
|
+
protected map: Map<string, any>;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
constructor(initialProps?: {});
|
|
8
|
+
get scopes(): {
|
|
9
|
+
[key: string]: ProviderScope;
|
|
10
|
+
};
|
|
11
|
+
set scopes(value: {
|
|
12
|
+
[key: string]: ProviderScope;
|
|
13
|
+
});
|
|
14
|
+
get resolvers(): DIResolver[];
|
|
15
|
+
set resolvers(resolvers: DIResolver[]);
|
|
16
|
+
get imports(): TokenProvider[];
|
|
17
|
+
set imports(imports: TokenProvider[]);
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param callbackfn
|
|
21
|
+
* @param thisArg
|
|
22
|
+
*/
|
|
23
|
+
forEach(callbackfn: (value: any, index: string, map: Map<string, any>) => void, thisArg?: any): void;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param propertyKey
|
|
27
|
+
* @param value
|
|
28
|
+
*/
|
|
29
|
+
set(propertyKey: string | Partial<TsED.Configuration>, value?: any): this;
|
|
30
|
+
setRaw(propertyKey: string, value: any): this;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param propertyKey
|
|
34
|
+
* @param defaultValue
|
|
35
|
+
* @returns {undefined|any}
|
|
36
|
+
*/
|
|
37
|
+
get<T = any>(propertyKey: string, defaultValue?: T): T;
|
|
38
|
+
getRaw(propertyKey: string, defaultValue?: any): any;
|
|
39
|
+
merge(obj: Partial<TsED.Configuration>): void;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param value
|
|
43
|
+
* @returns {any}
|
|
44
|
+
*/
|
|
45
|
+
resolve(value: any): any;
|
|
46
|
+
build(): void;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TokenProvider } from "../interfaces/TokenProvider";
|
|
2
|
+
import { InjectorService } from "./InjectorService";
|
|
3
|
+
export interface DITestInvokeOptions {
|
|
4
|
+
token?: TokenProvider;
|
|
5
|
+
use: any;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Tool to run test with lightweight DI sandbox.
|
|
9
|
+
*/
|
|
10
|
+
export declare class DITest {
|
|
11
|
+
protected static _injector: InjectorService | null;
|
|
12
|
+
static get injector(): InjectorService;
|
|
13
|
+
static set injector(injector: InjectorService);
|
|
14
|
+
static hasInjector(): boolean;
|
|
15
|
+
static create(settings?: Partial<TsED.Configuration>): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new injector with the right default services
|
|
18
|
+
*/
|
|
19
|
+
static createInjector(settings?: any): InjectorService;
|
|
20
|
+
/**
|
|
21
|
+
* Resets the test injector of the test context, so it won't pollute your next test. Call this in your `tearDown` logic.
|
|
22
|
+
*/
|
|
23
|
+
static reset(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Invoke a provider and return a fresh instance
|
|
26
|
+
* @param target
|
|
27
|
+
* @param providers
|
|
28
|
+
*/
|
|
29
|
+
static invoke<T = any>(target: TokenProvider, providers?: DITestInvokeOptions[]): T | Promise<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Return the instance from injector registry
|
|
32
|
+
* @param target
|
|
33
|
+
* @param options
|
|
34
|
+
*/
|
|
35
|
+
static get<T = any>(target: TokenProvider, options?: any): T;
|
|
36
|
+
protected static configure(settings?: Partial<TsED.Configuration>): Partial<TsED.Configuration>;
|
|
37
|
+
}
|