@tsed/di 7.0.0-alpha.2 → 7.0.0-beta.11
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/constants/constants.js +7 -0
- package/lib/cjs/constants/constants.js.map +1 -0
- package/lib/cjs/decorators/configuration.js +24 -0
- package/lib/cjs/decorators/configuration.js.map +1 -0
- package/lib/cjs/decorators/constant.js +55 -0
- package/lib/cjs/decorators/constant.js.map +1 -0
- package/lib/cjs/decorators/controller.js +53 -0
- package/lib/cjs/decorators/controller.js.map +1 -0
- package/lib/cjs/decorators/inject.js +104 -0
- package/lib/cjs/decorators/inject.js.map +1 -0
- package/lib/cjs/decorators/injectable.js +32 -0
- package/lib/cjs/decorators/injectable.js.map +1 -0
- package/lib/cjs/decorators/intercept.js +36 -0
- package/lib/cjs/decorators/intercept.js.map +1 -0
- package/lib/cjs/decorators/interceptor.js +21 -0
- package/lib/cjs/decorators/interceptor.js.map +1 -0
- package/lib/cjs/decorators/lazyInject.js +71 -0
- package/lib/cjs/decorators/lazyInject.js.map +1 -0
- package/lib/cjs/decorators/module.js +32 -0
- package/lib/cjs/decorators/module.js.map +1 -0
- package/lib/cjs/decorators/opts.js +54 -0
- package/lib/cjs/decorators/opts.js.map +1 -0
- package/lib/cjs/decorators/overrideProvider.js +17 -0
- package/lib/cjs/decorators/overrideProvider.js.map +1 -0
- package/lib/cjs/decorators/scope.js +16 -0
- package/lib/cjs/decorators/scope.js.map +1 -0
- package/lib/cjs/decorators/service.js +18 -0
- package/lib/cjs/decorators/service.js.map +1 -0
- package/lib/cjs/decorators/useOpts.js +65 -0
- package/lib/cjs/decorators/useOpts.js.map +1 -0
- package/lib/cjs/decorators/value.js +55 -0
- package/lib/cjs/decorators/value.js.map +1 -0
- package/lib/cjs/domain/Container.js +72 -0
- package/lib/cjs/domain/Container.js.map +1 -0
- package/lib/cjs/domain/ContextLogger.js +85 -0
- package/lib/cjs/domain/ContextLogger.js.map +1 -0
- package/lib/cjs/domain/DIContext.js +45 -0
- package/lib/cjs/domain/DIContext.js.map +1 -0
- package/lib/cjs/domain/InjectablePropertyType.js +12 -0
- package/lib/cjs/domain/InjectablePropertyType.js.map +1 -0
- package/lib/cjs/domain/LocalsContainer.js +55 -0
- package/lib/cjs/domain/LocalsContainer.js.map +1 -0
- package/lib/cjs/domain/Provider.js +122 -0
- package/lib/cjs/domain/Provider.js.map +1 -0
- package/lib/cjs/domain/ProviderScope.js +10 -0
- package/lib/cjs/domain/ProviderScope.js.map +1 -0
- package/lib/cjs/domain/ProviderType.js +15 -0
- package/lib/cjs/domain/ProviderType.js.map +1 -0
- package/lib/cjs/errors/InjectionError.js +58 -0
- package/lib/cjs/errors/InjectionError.js.map +1 -0
- package/lib/cjs/errors/UndefinedTokenError.js +11 -0
- package/lib/cjs/errors/UndefinedTokenError.js.map +1 -0
- package/lib/cjs/index.js +59 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/interfaces/DIConfigurationOptions.js +3 -0
- package/lib/cjs/interfaces/DIConfigurationOptions.js.map +1 -0
- package/lib/cjs/interfaces/DILogger.js +3 -0
- package/lib/cjs/interfaces/DILogger.js.map +1 -0
- package/lib/cjs/interfaces/DIResolver.js +3 -0
- package/lib/cjs/interfaces/DIResolver.js.map +1 -0
- package/lib/cjs/interfaces/InjectableProperties.js +3 -0
- package/lib/cjs/interfaces/InjectableProperties.js.map +1 -0
- package/lib/cjs/interfaces/InterceptorContext.js +3 -0
- package/lib/cjs/interfaces/InterceptorContext.js.map +1 -0
- package/lib/cjs/interfaces/InterceptorMethods.js +3 -0
- package/lib/cjs/interfaces/InterceptorMethods.js.map +1 -0
- package/lib/cjs/interfaces/InvokeOptions.js +3 -0
- package/lib/cjs/interfaces/InvokeOptions.js.map +1 -0
- package/lib/cjs/interfaces/OnDestroy.js +3 -0
- package/lib/cjs/interfaces/OnDestroy.js.map +1 -0
- package/lib/cjs/interfaces/OnInit.js +3 -0
- package/lib/cjs/interfaces/OnInit.js.map +1 -0
- package/lib/cjs/interfaces/ProviderOpts.js +3 -0
- package/lib/cjs/interfaces/ProviderOpts.js.map +1 -0
- package/lib/cjs/interfaces/RegistrySettings.js +3 -0
- package/lib/cjs/interfaces/RegistrySettings.js.map +1 -0
- package/lib/cjs/interfaces/ResolvedInvokeOptions.js +3 -0
- package/lib/cjs/interfaces/ResolvedInvokeOptions.js.map +1 -0
- package/lib/cjs/interfaces/TokenProvider.js +3 -0
- package/lib/cjs/interfaces/TokenProvider.js.map +1 -0
- package/lib/cjs/interfaces/TokenRoute.js +3 -0
- package/lib/cjs/interfaces/TokenRoute.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/registries/GlobalProviders.js +124 -0
- package/lib/cjs/registries/GlobalProviders.js.map +1 -0
- package/lib/cjs/registries/ProviderRegistry.js +86 -0
- package/lib/cjs/registries/ProviderRegistry.js.map +1 -0
- package/lib/cjs/services/DIConfiguration.js +136 -0
- package/lib/cjs/services/DIConfiguration.js.map +1 -0
- package/lib/cjs/services/DILogger.js +13 -0
- package/lib/cjs/services/DILogger.js.map +1 -0
- package/lib/cjs/services/DITest.js +116 -0
- package/lib/cjs/services/DITest.js.map +1 -0
- package/lib/cjs/services/InjectorService.js +589 -0
- package/lib/cjs/services/InjectorService.js.map +1 -0
- package/lib/cjs/utils/colors.js +10 -0
- package/lib/cjs/utils/colors.js.map +1 -0
- package/lib/cjs/utils/createContainer.js +14 -0
- package/lib/cjs/utils/createContainer.js.map +1 -0
- package/lib/cjs/utils/getConfiguration.js +29 -0
- package/lib/cjs/utils/getConfiguration.js.map +1 -0
- package/lib/cjs/utils/resolveControllers.js +47 -0
- package/lib/cjs/utils/resolveControllers.js.map +1 -0
- package/lib/cjs/utils/runInContext.js +19 -0
- package/lib/cjs/utils/runInContext.js.map +1 -0
- package/lib/cjs/utils/setLoggerLevel.js +16 -0
- package/lib/cjs/utils/setLoggerLevel.js.map +1 -0
- package/lib/esm/constants/constants.js +4 -0
- package/lib/esm/constants/constants.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/inject.js +98 -0
- package/lib/esm/decorators/inject.js.map +1 -0
- package/lib/esm/decorators/injectable.js +28 -0
- package/lib/esm/decorators/injectable.js.map +1 -0
- package/lib/esm/decorators/intercept.js +32 -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 +28 -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/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 +56 -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/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/ProviderOpts.js +2 -0
- package/lib/esm/interfaces/ProviderOpts.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/TokenRoute.js +2 -0
- package/lib/esm/interfaces/TokenRoute.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/registries/GlobalProviders.js +120 -0
- package/lib/esm/registries/GlobalProviders.js.map +1 -0
- package/lib/esm/registries/ProviderRegistry.js +81 -0
- package/lib/esm/registries/ProviderRegistry.js.map +1 -0
- package/lib/esm/services/DIConfiguration.js +132 -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 +112 -0
- package/lib/esm/services/DITest.js.map +1 -0
- package/lib/esm/services/InjectorService.js +586 -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/getConfiguration.js +24 -0
- package/lib/esm/utils/getConfiguration.js.map +1 -0
- package/lib/esm/utils/resolveControllers.js +42 -0
- package/lib/esm/utils/resolveControllers.js.map +1 -0
- package/lib/esm/utils/runInContext.js +13 -0
- package/lib/esm/utils/runInContext.js.map +1 -0
- package/lib/esm/utils/setLoggerLevel.js +12 -0
- package/lib/esm/utils/setLoggerLevel.js.map +1 -0
- package/lib/{constants/index.d.ts → types/constants/constants.d.ts} +0 -0
- package/lib/{decorators → types/decorators}/configuration.d.ts +0 -0
- package/lib/{decorators → types/decorators}/constant.d.ts +0 -0
- package/lib/{decorators → types/decorators}/controller.d.ts +2 -2
- package/lib/types/decorators/inject.d.ts +36 -0
- package/lib/{decorators → types/decorators}/injectable.d.ts +4 -5
- package/lib/{decorators → types/decorators}/intercept.d.ts +2 -2
- package/lib/{decorators → types/decorators}/interceptor.d.ts +0 -0
- package/lib/types/decorators/lazyInject.d.ts +43 -0
- package/lib/{decorators → types/decorators}/module.d.ts +3 -2
- package/lib/{decorators → types/decorators}/opts.d.ts +0 -0
- package/lib/{decorators → types/decorators}/overrideProvider.d.ts +0 -0
- package/lib/{decorators → types/decorators}/scope.d.ts +0 -0
- package/lib/{decorators → types/decorators}/service.d.ts +0 -0
- package/lib/{decorators → types/decorators}/useOpts.d.ts +0 -0
- package/lib/{decorators → types/decorators}/value.d.ts +0 -0
- package/lib/{domain → types/domain}/Container.d.ts +5 -6
- package/lib/{domain → types/domain}/ContextLogger.d.ts +0 -0
- package/lib/{domain → types/domain}/DIContext.d.ts +0 -6
- package/lib/{domain → types/domain}/InjectablePropertyType.d.ts +0 -0
- package/lib/{domain → types/domain}/LocalsContainer.d.ts +0 -0
- package/lib/{domain → types/domain}/Provider.d.ts +17 -3
- package/lib/{domain → types/domain}/ProviderScope.d.ts +0 -0
- package/lib/{domain → types/domain}/ProviderType.d.ts +0 -0
- package/lib/{errors → types/errors}/InjectionError.d.ts +1 -1
- package/lib/{errors → types/errors}/UndefinedTokenError.d.ts +0 -0
- package/lib/types/index.d.ts +55 -0
- package/lib/{interfaces → types/interfaces}/DIConfigurationOptions.d.ts +4 -0
- package/lib/{interfaces → types/interfaces}/DILogger.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/DIResolver.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/InjectableProperties.d.ts +8 -4
- package/lib/{interfaces → types/interfaces}/InterceptorContext.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/InterceptorMethods.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/InvokeOptions.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnDestroy.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnInit.d.ts +0 -0
- package/lib/{interfaces/IProvider.d.ts → types/interfaces/ProviderOpts.d.ts} +5 -4
- package/lib/{interfaces → types/interfaces}/RegistrySettings.d.ts +7 -3
- package/lib/types/interfaces/ResolvedInvokeOptions.d.ts +12 -0
- package/lib/{interfaces → types/interfaces}/TokenProvider.d.ts +0 -0
- package/lib/types/interfaces/TokenRoute.d.ts +5 -0
- package/lib/{registries → types/registries}/GlobalProviders.d.ts +11 -5
- package/lib/{registries → types/registries}/ProviderRegistry.d.ts +4 -4
- package/lib/{services → types/services}/DIConfiguration.d.ts +6 -2
- package/lib/{services → types/services}/DILogger.d.ts +0 -0
- package/lib/{services → types/services}/DITest.d.ts +7 -1
- package/lib/{services → types/services}/InjectorService.d.ts +45 -22
- package/lib/types/utils/colors.d.ts +5 -0
- package/lib/{utils → types/utils}/createContainer.d.ts +0 -0
- package/lib/{utils → types/utils}/getConfiguration.d.ts +1 -0
- package/lib/types/utils/resolveControllers.d.ts +12 -0
- package/lib/types/utils/runInContext.d.ts +6 -0
- package/lib/{utils → types/utils}/setLoggerLevel.d.ts +0 -0
- package/package.json +32 -16
- package/readme.md +37 -41
- package/tsconfig.compile.esm.json +25 -0
- package/lib/decorators/index.d.ts +0 -14
- package/lib/decorators/inject.d.ts +0 -19
- package/lib/domain/index.d.ts +0 -8
- package/lib/index.d.ts +0 -16
- package/lib/index.js +0 -2269
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -2232
- package/lib/index.modern.js.map +0 -1
- package/lib/interfaces/index.d.ts +0 -13
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
var _InjectorService_cache;
|
|
2
|
+
var InjectorService_1;
|
|
3
|
+
import { __classPrivateFieldGet, __decorate, __metadata } from "tslib";
|
|
4
|
+
import { ancestorsOf, catchError, classOf, deepClone, deepMerge, isClass, isFunction, isInheritedFrom, Metadata, nameOf, prototypeOf, Store } from "@tsed/core";
|
|
5
|
+
import { DI_PARAM_OPTIONS, INJECTABLE_PROP } from "../constants/constants.js";
|
|
6
|
+
import { Configuration } from "../decorators/configuration.js";
|
|
7
|
+
import { Injectable } from "../decorators/injectable.js";
|
|
8
|
+
import { Container } from "../domain/Container.js";
|
|
9
|
+
import { LocalsContainer } from "../domain/LocalsContainer.js";
|
|
10
|
+
import { Provider } from "../domain/Provider.js";
|
|
11
|
+
import { InjectionError } from "../errors/InjectionError.js";
|
|
12
|
+
import { UndefinedTokenError } from "../errors/UndefinedTokenError.js";
|
|
13
|
+
import { GlobalProviders } from "../registries/GlobalProviders.js";
|
|
14
|
+
import { createContainer } from "../utils/createContainer.js";
|
|
15
|
+
import { resolveControllers } from "../utils/resolveControllers.js";
|
|
16
|
+
import { DIConfiguration } from "./DIConfiguration.js";
|
|
17
|
+
import { ProviderScope } from "../domain/ProviderScope.js";
|
|
18
|
+
import { InjectablePropertyType } from "../domain/InjectablePropertyType.js";
|
|
19
|
+
/**
|
|
20
|
+
* This service contain all services collected by `@Service` or services declared manually with `InjectorService.factory()` or `InjectorService.service()`.
|
|
21
|
+
*
|
|
22
|
+
* ### Example:
|
|
23
|
+
*
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import {InjectorService} from "@tsed/di";
|
|
26
|
+
*
|
|
27
|
+
* // Import the services (all services are decorated with @Service()";
|
|
28
|
+
* import MyService1 from "./services/service1";
|
|
29
|
+
* import MyService2 from "./services/service2";
|
|
30
|
+
* import MyService3 from "./services/service3";
|
|
31
|
+
*
|
|
32
|
+
* // When all services are imported, you can load InjectorService.
|
|
33
|
+
* const injector = new InjectorService()
|
|
34
|
+
*
|
|
35
|
+
* await injector.load();
|
|
36
|
+
*
|
|
37
|
+
* const myService1 = injector.get<MyService1>(MyServcice1);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
let InjectorService = InjectorService_1 = class InjectorService extends Container {
|
|
41
|
+
constructor() {
|
|
42
|
+
super();
|
|
43
|
+
this.settings = new DIConfiguration();
|
|
44
|
+
this.logger = console;
|
|
45
|
+
this.resolvedConfiguration = false;
|
|
46
|
+
_InjectorService_cache.set(this, new LocalsContainer());
|
|
47
|
+
__classPrivateFieldGet(this, _InjectorService_cache, "f").set(InjectorService_1, this);
|
|
48
|
+
}
|
|
49
|
+
get resolvers() {
|
|
50
|
+
return this.settings.resolvers;
|
|
51
|
+
}
|
|
52
|
+
get scopes() {
|
|
53
|
+
return this.settings.scopes || {};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Retrieve default scope for a given provider.
|
|
57
|
+
* @param provider
|
|
58
|
+
*/
|
|
59
|
+
scopeOf(provider) {
|
|
60
|
+
return provider.scope || this.scopes[provider.type] || ProviderScope.SINGLETON;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Return a list of instance build by the injector.
|
|
64
|
+
*/
|
|
65
|
+
toArray() {
|
|
66
|
+
return __classPrivateFieldGet(this, _InjectorService_cache, "f").toArray();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get a service or factory already constructed from his symbol or class.
|
|
70
|
+
*
|
|
71
|
+
* #### Example
|
|
72
|
+
*
|
|
73
|
+
* ```typescript
|
|
74
|
+
* import {InjectorService} from "@tsed/di";
|
|
75
|
+
* import MyService from "./services";
|
|
76
|
+
*
|
|
77
|
+
* class OtherService {
|
|
78
|
+
* constructor(injectorService: InjectorService) {
|
|
79
|
+
* const myService = injectorService.get<MyService>(MyService);
|
|
80
|
+
* }
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @param token The class or symbol registered in InjectorService.
|
|
85
|
+
* @param options
|
|
86
|
+
* @returns {boolean}
|
|
87
|
+
*/
|
|
88
|
+
get(token, options = {}) {
|
|
89
|
+
const instance = this.getInstance(token);
|
|
90
|
+
if (instance !== undefined) {
|
|
91
|
+
return instance;
|
|
92
|
+
}
|
|
93
|
+
if (!this.hasProvider(token)) {
|
|
94
|
+
for (const resolver of this.resolvers) {
|
|
95
|
+
const result = resolver.get(token, options);
|
|
96
|
+
if (result !== undefined) {
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Return all instance of the same provider type
|
|
104
|
+
* @param type
|
|
105
|
+
*/
|
|
106
|
+
getAll(type) {
|
|
107
|
+
return this.getProviders(type).map((provider) => {
|
|
108
|
+
return this.get(provider.token);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The has() method returns a boolean indicating whether an element with the specified key exists or not.
|
|
113
|
+
* @returns {boolean}
|
|
114
|
+
* @param token
|
|
115
|
+
*/
|
|
116
|
+
has(token) {
|
|
117
|
+
return __classPrivateFieldGet(this, _InjectorService_cache, "f").get(token) !== undefined;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Invoke the class and inject all services that required by the class constructor.
|
|
121
|
+
*
|
|
122
|
+
* #### Example
|
|
123
|
+
*
|
|
124
|
+
* ```typescript
|
|
125
|
+
* import {InjectorService} from "@tsed/di";
|
|
126
|
+
* import MyService from "./services";
|
|
127
|
+
*
|
|
128
|
+
* class OtherService {
|
|
129
|
+
* constructor(injectorService: InjectorService) {
|
|
130
|
+
* const myService = injectorService.invoke<MyService>(MyService);
|
|
131
|
+
* }
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @param token The injectable class to invoke. Class parameters are injected according constructor signature.
|
|
136
|
+
* @param locals Optional object. If preset then any argument Class are read from this object first, before the `InjectorService` is consulted.
|
|
137
|
+
* @param options
|
|
138
|
+
* @returns {T} The class constructed.
|
|
139
|
+
*/
|
|
140
|
+
invoke(token, locals = new LocalsContainer(), options = {}) {
|
|
141
|
+
const provider = this.ensureProvider(token);
|
|
142
|
+
let instance;
|
|
143
|
+
!locals.has(Configuration) && locals.set(Configuration, this.settings);
|
|
144
|
+
if (locals.has(token)) {
|
|
145
|
+
return locals.get(token);
|
|
146
|
+
}
|
|
147
|
+
if (token === DI_PARAM_OPTIONS) {
|
|
148
|
+
return {};
|
|
149
|
+
}
|
|
150
|
+
if (!provider || options.rebuild) {
|
|
151
|
+
instance = this.resolve(token, locals, options);
|
|
152
|
+
if (this.hasProvider(token)) {
|
|
153
|
+
__classPrivateFieldGet(this, _InjectorService_cache, "f").set(token, instance);
|
|
154
|
+
}
|
|
155
|
+
return instance;
|
|
156
|
+
}
|
|
157
|
+
switch (this.scopeOf(provider)) {
|
|
158
|
+
case ProviderScope.SINGLETON:
|
|
159
|
+
if (!this.has(token)) {
|
|
160
|
+
__classPrivateFieldGet(this, _InjectorService_cache, "f").set(token, this.resolve(token, locals, options));
|
|
161
|
+
if (provider.isAsync()) {
|
|
162
|
+
__classPrivateFieldGet(this, _InjectorService_cache, "f").get(token).then((instance) => {
|
|
163
|
+
__classPrivateFieldGet(this, _InjectorService_cache, "f").set(token, instance);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
instance = this.get(token);
|
|
168
|
+
break;
|
|
169
|
+
case ProviderScope.REQUEST:
|
|
170
|
+
instance = this.resolve(token, locals, options);
|
|
171
|
+
locals.set(token, instance);
|
|
172
|
+
break;
|
|
173
|
+
case ProviderScope.INSTANCE:
|
|
174
|
+
instance = this.resolve(provider.provide, locals, options);
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
return instance;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Build only providers which are asynchronous.
|
|
181
|
+
*/
|
|
182
|
+
async loadAsync(locals = new LocalsContainer()) {
|
|
183
|
+
for (const [, provider] of this) {
|
|
184
|
+
if (!locals.has(provider.token)) {
|
|
185
|
+
if (provider.isAsync()) {
|
|
186
|
+
await this.invoke(provider.token, locals);
|
|
187
|
+
}
|
|
188
|
+
const instance = __classPrivateFieldGet(this, _InjectorService_cache, "f").get(provider.token);
|
|
189
|
+
if (instance !== undefined) {
|
|
190
|
+
locals.set(provider.token, instance);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return locals;
|
|
195
|
+
}
|
|
196
|
+
loadSync(locals = new LocalsContainer()) {
|
|
197
|
+
for (const [, provider] of this) {
|
|
198
|
+
if (!locals.has(provider.token) && this.scopeOf(provider) === ProviderScope.SINGLETON) {
|
|
199
|
+
this.invoke(provider.token, locals);
|
|
200
|
+
}
|
|
201
|
+
const instance = __classPrivateFieldGet(this, _InjectorService_cache, "f").get(provider.token);
|
|
202
|
+
if (instance !== undefined) {
|
|
203
|
+
locals.set(provider.token, instance);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return locals;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Boostrap injector from container and resolve configuration.
|
|
210
|
+
*
|
|
211
|
+
* @param container
|
|
212
|
+
*/
|
|
213
|
+
bootstrap(container = createContainer()) {
|
|
214
|
+
// Clone all providers in the container
|
|
215
|
+
this.addProviders(container);
|
|
216
|
+
// Resolve all configuration
|
|
217
|
+
this.resolveConfiguration();
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Load injector from a given module
|
|
222
|
+
* @param rootModule
|
|
223
|
+
*/
|
|
224
|
+
loadModule(rootModule) {
|
|
225
|
+
this.settings.routes = this.settings.routes.concat(resolveControllers(this.settings));
|
|
226
|
+
const container = createContainer();
|
|
227
|
+
container.delete(rootModule);
|
|
228
|
+
container.addProvider(rootModule, {
|
|
229
|
+
type: "server:module",
|
|
230
|
+
scope: ProviderScope.SINGLETON
|
|
231
|
+
});
|
|
232
|
+
return this.load(container);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Build all providers from given container (or GlobalProviders) and emit `$onInit` event.
|
|
236
|
+
*
|
|
237
|
+
* @param container
|
|
238
|
+
* @param rootModule
|
|
239
|
+
*/
|
|
240
|
+
async load(container = createContainer(), rootModule) {
|
|
241
|
+
this.bootstrap(container);
|
|
242
|
+
// build async and sync provider
|
|
243
|
+
let locals = await this.loadAsync();
|
|
244
|
+
if (rootModule) {
|
|
245
|
+
await this.invoke(rootModule);
|
|
246
|
+
}
|
|
247
|
+
// load sync provider
|
|
248
|
+
locals = this.loadSync(locals);
|
|
249
|
+
await locals.emit("$beforeInit");
|
|
250
|
+
await locals.emit("$onInit");
|
|
251
|
+
return locals;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Load all configurations registered on providers
|
|
255
|
+
*/
|
|
256
|
+
resolveConfiguration() {
|
|
257
|
+
if (this.resolvedConfiguration) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const mergedConfiguration = new Map();
|
|
261
|
+
super.forEach((provider) => {
|
|
262
|
+
if (provider.configuration && provider.type !== "server:module") {
|
|
263
|
+
Object.entries(provider.configuration).forEach(([key, value]) => {
|
|
264
|
+
if (!["resolvers", "mount", "imports"].includes(key)) {
|
|
265
|
+
value = mergedConfiguration.has(key) ? deepMerge(mergedConfiguration.get(key), value) : deepClone(value);
|
|
266
|
+
mergedConfiguration.set(key, value);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
if (provider.resolvers) {
|
|
271
|
+
this.resolvers.push(...provider.resolvers);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
mergedConfiguration.forEach((value, key) => {
|
|
275
|
+
this.settings[key] = deepMerge(value, this.settings[key]);
|
|
276
|
+
});
|
|
277
|
+
this.settings.build();
|
|
278
|
+
this.resolvedConfiguration = true;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
*
|
|
282
|
+
* @param instance
|
|
283
|
+
* @param locals
|
|
284
|
+
* @param options
|
|
285
|
+
*/
|
|
286
|
+
bindInjectableProperties(instance, locals, options) {
|
|
287
|
+
const properties = ancestorsOf(classOf(instance)).reduce((properties, target) => {
|
|
288
|
+
const store = Store.from(target);
|
|
289
|
+
return {
|
|
290
|
+
...properties,
|
|
291
|
+
...(store.get(INJECTABLE_PROP) || {})
|
|
292
|
+
};
|
|
293
|
+
}, {});
|
|
294
|
+
Object.values(properties).forEach((definition) => {
|
|
295
|
+
switch (definition.bindingType) {
|
|
296
|
+
case InjectablePropertyType.METHOD:
|
|
297
|
+
this.bindMethod(instance, definition);
|
|
298
|
+
break;
|
|
299
|
+
case InjectablePropertyType.PROPERTY:
|
|
300
|
+
this.bindProperty(instance, definition, locals, options);
|
|
301
|
+
break;
|
|
302
|
+
case InjectablePropertyType.CONSTANT:
|
|
303
|
+
this.bindConstant(instance, definition);
|
|
304
|
+
break;
|
|
305
|
+
case InjectablePropertyType.VALUE:
|
|
306
|
+
this.bindValue(instance, definition);
|
|
307
|
+
break;
|
|
308
|
+
case InjectablePropertyType.INTERCEPTOR:
|
|
309
|
+
this.bindInterceptor(instance, definition);
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
*
|
|
316
|
+
* @param instance
|
|
317
|
+
* @param {string} propertyKey
|
|
318
|
+
*/
|
|
319
|
+
bindMethod(instance, { propertyKey }) {
|
|
320
|
+
const target = classOf(instance);
|
|
321
|
+
const originalMethod = instance[propertyKey];
|
|
322
|
+
const deps = Metadata.getParamTypes(prototypeOf(target), propertyKey);
|
|
323
|
+
instance[propertyKey] = () => {
|
|
324
|
+
const services = deps.map((dependency) => this.get(dependency));
|
|
325
|
+
return originalMethod.call(instance, ...services);
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Create an injectable property.
|
|
330
|
+
*
|
|
331
|
+
* @param instance
|
|
332
|
+
* @param {string} propertyKey
|
|
333
|
+
* @param {any} useType
|
|
334
|
+
* @param resolver
|
|
335
|
+
* @param options
|
|
336
|
+
* @param locals
|
|
337
|
+
* @param invokeOptions
|
|
338
|
+
*/
|
|
339
|
+
bindProperty(instance, { propertyKey, resolver, options = {} }, locals, invokeOptions) {
|
|
340
|
+
let get;
|
|
341
|
+
get = resolver(this, locals, { ...invokeOptions, options });
|
|
342
|
+
catchError(() => Object.defineProperty(instance, propertyKey, {
|
|
343
|
+
get
|
|
344
|
+
}));
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
*
|
|
348
|
+
* @param instance
|
|
349
|
+
* @param {string} propertyKey
|
|
350
|
+
* @param {any} useType
|
|
351
|
+
*/
|
|
352
|
+
bindValue(instance, { propertyKey, expression, defaultValue }) {
|
|
353
|
+
const descriptor = {
|
|
354
|
+
get: () => this.settings.get(expression) || defaultValue,
|
|
355
|
+
set: (value) => this.settings.set(expression, value),
|
|
356
|
+
enumerable: true,
|
|
357
|
+
configurable: true
|
|
358
|
+
};
|
|
359
|
+
catchError(() => Object.defineProperty(instance, propertyKey, descriptor));
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
*
|
|
363
|
+
* @param instance
|
|
364
|
+
* @param {string} propertyKey
|
|
365
|
+
* @param {any} useType
|
|
366
|
+
*/
|
|
367
|
+
bindConstant(instance, { propertyKey, expression, defaultValue }) {
|
|
368
|
+
let bean;
|
|
369
|
+
const get = () => {
|
|
370
|
+
if (bean !== undefined) {
|
|
371
|
+
return bean;
|
|
372
|
+
}
|
|
373
|
+
const value = this.settings.get(expression, defaultValue);
|
|
374
|
+
bean = Object.freeze(deepClone(value));
|
|
375
|
+
return bean;
|
|
376
|
+
};
|
|
377
|
+
const descriptor = {
|
|
378
|
+
get,
|
|
379
|
+
enumerable: true,
|
|
380
|
+
configurable: true
|
|
381
|
+
};
|
|
382
|
+
catchError(() => Object.defineProperty(instance, propertyKey, descriptor));
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
*
|
|
386
|
+
* @param instance
|
|
387
|
+
* @param propertyKey
|
|
388
|
+
* @param useType
|
|
389
|
+
* @param options
|
|
390
|
+
*/
|
|
391
|
+
bindInterceptor(instance, { propertyKey, useType, options }) {
|
|
392
|
+
const target = classOf(instance);
|
|
393
|
+
const originalMethod = instance[propertyKey];
|
|
394
|
+
instance[propertyKey] = (...args) => {
|
|
395
|
+
const next = (err) => {
|
|
396
|
+
if (!err) {
|
|
397
|
+
return originalMethod.apply(instance, args);
|
|
398
|
+
}
|
|
399
|
+
throw err;
|
|
400
|
+
};
|
|
401
|
+
const context = {
|
|
402
|
+
target,
|
|
403
|
+
propertyKey,
|
|
404
|
+
args,
|
|
405
|
+
options,
|
|
406
|
+
next
|
|
407
|
+
};
|
|
408
|
+
const interceptor = this.get(useType);
|
|
409
|
+
return interceptor.intercept({
|
|
410
|
+
...context,
|
|
411
|
+
options
|
|
412
|
+
}, next);
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
async lazyInvoke(token) {
|
|
416
|
+
let instance = this.getInstance(token);
|
|
417
|
+
if (!instance) {
|
|
418
|
+
instance = await this.invoke(token);
|
|
419
|
+
if (isFunction(instance === null || instance === void 0 ? void 0 : instance.$onInit)) {
|
|
420
|
+
await instance.$onInit();
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return instance;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Emit an event to all service. See service [lifecycle hooks](/docs/services.md#lifecycle-hooks).
|
|
427
|
+
* @param eventName The event name to emit at all services.
|
|
428
|
+
* @param args List of the parameters to give to each services.
|
|
429
|
+
* @returns {Promise<any[]>} A list of promises.
|
|
430
|
+
*/
|
|
431
|
+
async emit(eventName, ...args) {
|
|
432
|
+
return __classPrivateFieldGet(this, _InjectorService_cache, "f").emit(eventName, ...args);
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* @param eventName
|
|
436
|
+
* @param value
|
|
437
|
+
* @param args
|
|
438
|
+
*/
|
|
439
|
+
alter(eventName, value, ...args) {
|
|
440
|
+
return __classPrivateFieldGet(this, _InjectorService_cache, "f").alter(eventName, value, ...args);
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* @param eventName
|
|
444
|
+
* @param value
|
|
445
|
+
* @param args
|
|
446
|
+
*/
|
|
447
|
+
async alterAsync(eventName, value, ...args) {
|
|
448
|
+
return __classPrivateFieldGet(this, _InjectorService_cache, "f").alterAsync(eventName, value, ...args);
|
|
449
|
+
}
|
|
450
|
+
async destroy() {
|
|
451
|
+
await __classPrivateFieldGet(this, _InjectorService_cache, "f").destroy();
|
|
452
|
+
}
|
|
453
|
+
ensureProvider(token) {
|
|
454
|
+
if (!this.hasProvider(token) && GlobalProviders.has(token)) {
|
|
455
|
+
this.addProvider(token);
|
|
456
|
+
}
|
|
457
|
+
return this.getProvider(token);
|
|
458
|
+
}
|
|
459
|
+
getInstance(token) {
|
|
460
|
+
return __classPrivateFieldGet(this, _InjectorService_cache, "f").get(token);
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Invoke a class method and inject service.
|
|
464
|
+
*
|
|
465
|
+
* #### IInjectableMethod options
|
|
466
|
+
*
|
|
467
|
+
* * **target**: Optional. The class instance.
|
|
468
|
+
* * **methodName**: `string` Optional. The method name.
|
|
469
|
+
* * **designParamTypes**: `any[]` Optional. List of injectable types.
|
|
470
|
+
* * **locals**: `Map<Function, any>` Optional. If preset then any argument Class are read from this object first, before the `InjectorService` is consulted.
|
|
471
|
+
*
|
|
472
|
+
* #### Example
|
|
473
|
+
*
|
|
474
|
+
* @param target
|
|
475
|
+
* @param locals
|
|
476
|
+
* @param options
|
|
477
|
+
* @private
|
|
478
|
+
*/
|
|
479
|
+
resolve(target, locals, options = {}) {
|
|
480
|
+
const resolvedOpts = this.mapInvokeOptions(target, locals, options);
|
|
481
|
+
const { token, deps, construct, imports, provider } = resolvedOpts;
|
|
482
|
+
if (provider) {
|
|
483
|
+
GlobalProviders.onInvoke(provider, locals, { ...resolvedOpts, injector: this });
|
|
484
|
+
}
|
|
485
|
+
let instance;
|
|
486
|
+
let currentDependency = false;
|
|
487
|
+
try {
|
|
488
|
+
const invokeDependency = (parent) => (token, index) => {
|
|
489
|
+
var _a;
|
|
490
|
+
currentDependency = { token, index, deps };
|
|
491
|
+
if (token !== DI_PARAM_OPTIONS) {
|
|
492
|
+
const options = (_a = provider === null || provider === void 0 ? void 0 : provider.store) === null || _a === void 0 ? void 0 : _a.get(`${DI_PARAM_OPTIONS}:${index}`);
|
|
493
|
+
locals.set(DI_PARAM_OPTIONS, options || {});
|
|
494
|
+
}
|
|
495
|
+
return isInheritedFrom(token, Provider, 1) ? provider : this.invoke(token, locals, { parent });
|
|
496
|
+
};
|
|
497
|
+
// Invoke manually imported providers
|
|
498
|
+
imports.forEach(invokeDependency());
|
|
499
|
+
// Inject dependencies
|
|
500
|
+
const services = deps.map(invokeDependency(token));
|
|
501
|
+
currentDependency = false;
|
|
502
|
+
instance = construct(services);
|
|
503
|
+
}
|
|
504
|
+
catch (error) {
|
|
505
|
+
InjectionError.throwInjectorError(token, currentDependency, error);
|
|
506
|
+
}
|
|
507
|
+
if (instance === undefined) {
|
|
508
|
+
throw new InjectionError(token, `Unable to create new instance from undefined value. Check your provider declaration for ${nameOf(token)}`);
|
|
509
|
+
}
|
|
510
|
+
if (instance && isClass(classOf(instance))) {
|
|
511
|
+
this.bindInjectableProperties(instance, locals, options);
|
|
512
|
+
}
|
|
513
|
+
if (instance && provider.hooks) {
|
|
514
|
+
Object.entries(provider.hooks).forEach(([key, cb]) => {
|
|
515
|
+
instance[key] = (...args) => cb(instance, ...args);
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
return instance;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Create options to invoke a provider or class.
|
|
522
|
+
* @param token
|
|
523
|
+
* @param locals
|
|
524
|
+
* @param options
|
|
525
|
+
*/
|
|
526
|
+
mapInvokeOptions(token, locals, options) {
|
|
527
|
+
let imports = options.imports;
|
|
528
|
+
let deps = options.deps;
|
|
529
|
+
let scope = options.scope;
|
|
530
|
+
let construct;
|
|
531
|
+
if (!token) {
|
|
532
|
+
throw new UndefinedTokenError();
|
|
533
|
+
}
|
|
534
|
+
let provider;
|
|
535
|
+
if (!this.hasProvider(token)) {
|
|
536
|
+
provider = new Provider(token);
|
|
537
|
+
this.resolvers.forEach((resolver) => {
|
|
538
|
+
const result = resolver.get(token, locals.get(DI_PARAM_OPTIONS));
|
|
539
|
+
if (result !== undefined) {
|
|
540
|
+
provider.useFactory = () => result;
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
else {
|
|
545
|
+
provider = this.getProvider(token);
|
|
546
|
+
}
|
|
547
|
+
scope = scope || this.scopeOf(provider);
|
|
548
|
+
deps = deps || provider.deps;
|
|
549
|
+
imports = imports || provider.imports;
|
|
550
|
+
if (provider.useValue !== undefined) {
|
|
551
|
+
construct = () => (isFunction(provider.useValue) ? provider.useValue() : provider.useValue);
|
|
552
|
+
}
|
|
553
|
+
else if (provider.useFactory) {
|
|
554
|
+
construct = (deps) => provider.useFactory(...deps);
|
|
555
|
+
}
|
|
556
|
+
else if (provider.useAsyncFactory) {
|
|
557
|
+
construct = async (deps) => {
|
|
558
|
+
deps = await Promise.all(deps);
|
|
559
|
+
return provider.useAsyncFactory(...deps);
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
// useClass
|
|
564
|
+
deps = deps || Metadata.getParamTypes(provider.useClass);
|
|
565
|
+
construct = (deps) => new provider.useClass(...deps);
|
|
566
|
+
}
|
|
567
|
+
return {
|
|
568
|
+
token,
|
|
569
|
+
scope: scope || Store.from(token).get("scope") || ProviderScope.SINGLETON,
|
|
570
|
+
deps: deps || [],
|
|
571
|
+
imports: imports || [],
|
|
572
|
+
construct,
|
|
573
|
+
provider
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
_InjectorService_cache = new WeakMap();
|
|
578
|
+
InjectorService = InjectorService_1 = __decorate([
|
|
579
|
+
Injectable({
|
|
580
|
+
scope: ProviderScope.SINGLETON,
|
|
581
|
+
global: true
|
|
582
|
+
}),
|
|
583
|
+
__metadata("design:paramtypes", [])
|
|
584
|
+
], InjectorService);
|
|
585
|
+
export { InjectorService };
|
|
586
|
+
//# sourceMappingURL=InjectorService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InjectorService.js","sourceRoot":"","sources":["../../../src/services/InjectorService.ts"],"names":[],"mappings":";;;A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,CAAC,CAAC;YACzD,SAAS,GAAG,CAAC,IAAqB,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;SACvE;QAED,OAAO;YACL,KAAK;YACL,KAAK,EAAE,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,aAAa,CAAC,SAAS;YACzE,IAAI,EAAE,IAAK,IAAI,EAAE;YACjB,OAAO,EAAE,OAAO,IAAI,EAAE;YACtB,SAAS;YACT,QAAQ;SACT,CAAC;IACJ,CAAC;CACF,CAAA;;AAhpBY,eAAe;IAJ3B,UAAU,CAAC;QACV,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,MAAM,EAAE,IAAI;KACb,CAAC;;GACW,eAAe,CAgpB3B;SAhpBY,eAAe","sourcesContent":["import {\n ancestorsOf,\n catchError,\n classOf,\n deepClone,\n deepMerge,\n isClass,\n isFunction,\n isInheritedFrom,\n Metadata,\n nameOf,\n prototypeOf,\n Store\n} from \"@tsed/core\";\nimport {DI_PARAM_OPTIONS, INJECTABLE_PROP} from \"../constants/constants\";\nimport {Configuration} from \"../decorators/configuration\";\nimport {Injectable} from \"../decorators/injectable\";\nimport {Container} from \"../domain/Container\";\nimport {LocalsContainer} from \"../domain/LocalsContainer\";\nimport {Provider} from \"../domain/Provider\";\nimport {InjectionError} from \"../errors/InjectionError\";\nimport {UndefinedTokenError} from \"../errors/UndefinedTokenError\";\nimport {GlobalProviders} from \"../registries/GlobalProviders\";\nimport {createContainer} from \"../utils/createContainer\";\nimport {resolveControllers} from \"../utils/resolveControllers\";\nimport {DIConfiguration} from \"./DIConfiguration\";\nimport {ResolvedInvokeOptions} from \"../interfaces/ResolvedInvokeOptions\";\nimport {ProviderScope} from \"../domain/ProviderScope\";\nimport {DILogger} from \"../interfaces/DILogger\";\nimport {TokenProvider} from \"../interfaces/TokenProvider\";\nimport {InvokeOptions} from \"../interfaces/InvokeOptions\";\nimport {InjectableProperties, InjectablePropertyOptions, InjectablePropertyValue} from \"../interfaces/InjectableProperties\";\nimport {InjectablePropertyType} from \"../domain/InjectablePropertyType\";\nimport {InterceptorContext} from \"../interfaces/InterceptorContext\";\nimport {InterceptorMethods} from \"../interfaces/InterceptorMethods\";\n\n/**\n * This service contain all services collected by `@Service` or services declared manually with `InjectorService.factory()` or `InjectorService.service()`.\n *\n * ### Example:\n *\n * ```typescript\n * import {InjectorService} from \"@tsed/di\";\n *\n * // Import the services (all services are decorated with @Service()\";\n * import MyService1 from \"./services/service1\";\n * import MyService2 from \"./services/service2\";\n * import MyService3 from \"./services/service3\";\n *\n * // When all services are imported, you can load InjectorService.\n * const injector = new InjectorService()\n *\n * await injector.load();\n *\n * const myService1 = injector.get<MyService1>(MyServcice1);\n * ```\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n global: true\n})\nexport class InjectorService extends Container {\n public settings: TsED.Configuration & DIConfiguration = new DIConfiguration() as any;\n public logger: DILogger = console;\n private resolvedConfiguration: boolean = false;\n #cache = new LocalsContainer();\n\n constructor() {\n super();\n this.#cache.set(InjectorService, this);\n }\n\n get resolvers() {\n return this.settings.resolvers!;\n }\n\n get scopes() {\n return this.settings.scopes || {};\n }\n\n /**\n * Retrieve default scope for a given provider.\n * @param provider\n */\n public scopeOf(provider: Provider) {\n return provider.scope || this.scopes[provider.type] || ProviderScope.SINGLETON;\n }\n\n /**\n * Return a list of instance build by the injector.\n */\n public toArray(): any[] {\n return this.#cache.toArray();\n }\n\n /**\n * Get a service or factory already constructed from his symbol or class.\n *\n * #### Example\n *\n * ```typescript\n * import {InjectorService} from \"@tsed/di\";\n * import MyService from \"./services\";\n *\n * class OtherService {\n * constructor(injectorService: InjectorService) {\n * const myService = injectorService.get<MyService>(MyService);\n * }\n * }\n * ```\n *\n * @param token The class or symbol registered in InjectorService.\n * @param options\n * @returns {boolean}\n */\n get<T = any>(token: TokenProvider, options: any = {}): T | undefined {\n const instance = this.getInstance(token);\n\n if (instance !== undefined) {\n return instance;\n }\n\n if (!this.hasProvider(token)) {\n for (const resolver of this.resolvers) {\n const result = resolver.get(token, options);\n\n if (result !== undefined) {\n return result;\n }\n }\n }\n }\n\n /**\n * Return all instance of the same provider type\n * @param type\n */\n getAll(type: string) {\n return this.getProviders(type).map((provider) => {\n return this.get(provider.token);\n });\n }\n\n /**\n * The has() method returns a boolean indicating whether an element with the specified key exists or not.\n * @returns {boolean}\n * @param token\n */\n has(token: TokenProvider): boolean {\n return this.#cache.get(token) !== undefined;\n }\n\n /**\n * Invoke the class and inject all services that required by the class constructor.\n *\n * #### Example\n *\n * ```typescript\n * import {InjectorService} from \"@tsed/di\";\n * import MyService from \"./services\";\n *\n * class OtherService {\n * constructor(injectorService: InjectorService) {\n * const myService = injectorService.invoke<MyService>(MyService);\n * }\n * }\n * ```\n *\n * @param token The injectable class to invoke. Class parameters are injected according constructor signature.\n * @param locals Optional object. If preset then any argument Class are read from this object first, before the `InjectorService` is consulted.\n * @param options\n * @returns {T} The class constructed.\n */\n public invoke<T>(\n token: TokenProvider,\n locals: Map<TokenProvider, any> = new LocalsContainer(),\n options: Partial<InvokeOptions<T>> = {}\n ): T {\n const provider = this.ensureProvider(token);\n let instance: any;\n\n !locals.has(Configuration) && locals.set(Configuration, this.settings);\n\n if (locals.has(token)) {\n return locals.get(token);\n }\n\n if (token === DI_PARAM_OPTIONS) {\n return {} as T;\n }\n\n if (!provider || options.rebuild) {\n instance = this.resolve(token, locals, options);\n\n if (this.hasProvider(token)) {\n this.#cache.set(token, instance);\n }\n\n return instance;\n }\n\n switch (this.scopeOf(provider)) {\n case ProviderScope.SINGLETON:\n if (!this.has(token)) {\n this.#cache.set(token, this.resolve(token, locals, options));\n\n if (provider.isAsync()) {\n this.#cache.get(token).then((instance: any) => {\n this.#cache.set(token, instance);\n });\n }\n }\n\n instance = this.get<T>(token)!;\n break;\n\n case ProviderScope.REQUEST:\n instance = this.resolve(token, locals, options);\n locals.set(token, instance);\n break;\n\n case ProviderScope.INSTANCE:\n instance = this.resolve(provider.provide, locals, options);\n break;\n }\n\n return instance;\n }\n\n /**\n * Build only providers which are asynchronous.\n */\n async loadAsync(locals: LocalsContainer = new LocalsContainer()) {\n for (const [, provider] of this) {\n if (!locals.has(provider.token)) {\n if (provider.isAsync()) {\n await this.invoke(provider.token, locals);\n }\n\n const instance = this.#cache.get(provider.token);\n if (instance !== undefined) {\n locals.set(provider.token, instance);\n }\n }\n }\n\n return locals;\n }\n\n loadSync(locals: LocalsContainer = new LocalsContainer()) {\n for (const [, provider] of this) {\n if (!locals.has(provider.token) && this.scopeOf(provider) === ProviderScope.SINGLETON) {\n this.invoke(provider.token, locals);\n }\n\n const instance = this.#cache.get(provider.token);\n if (instance !== undefined) {\n locals.set(provider.token, instance);\n }\n }\n\n return locals;\n }\n\n /**\n * Boostrap injector from container and resolve configuration.\n *\n * @param container\n */\n bootstrap(container: Container = createContainer()) {\n // Clone all providers in the container\n this.addProviders(container);\n\n // Resolve all configuration\n this.resolveConfiguration();\n\n return this;\n }\n\n /**\n * Load injector from a given module\n * @param rootModule\n */\n loadModule(rootModule: TokenProvider) {\n this.settings.routes = this.settings.routes.concat(resolveControllers(this.settings));\n\n const container = createContainer();\n container.delete(rootModule);\n\n container.addProvider(rootModule, {\n type: \"server:module\",\n scope: ProviderScope.SINGLETON\n });\n\n return this.load(container);\n }\n\n /**\n * Build all providers from given container (or GlobalProviders) and emit `$onInit` event.\n *\n * @param container\n * @param rootModule\n */\n async load(container: Container = createContainer(), rootModule?: TokenProvider): Promise<LocalsContainer<any>> {\n this.bootstrap(container);\n\n // build async and sync provider\n let locals = await this.loadAsync();\n\n if (rootModule) {\n await this.invoke(rootModule);\n }\n\n // load sync provider\n locals = this.loadSync(locals);\n\n await locals.emit(\"$beforeInit\");\n await locals.emit(\"$onInit\");\n\n return locals;\n }\n\n /**\n * Load all configurations registered on providers\n */\n resolveConfiguration() {\n if (this.resolvedConfiguration) {\n return;\n }\n const mergedConfiguration = new Map();\n\n super.forEach((provider) => {\n if (provider.configuration && provider.type !== \"server:module\") {\n Object.entries(provider.configuration).forEach(([key, value]) => {\n if (![\"resolvers\", \"mount\", \"imports\"].includes(key)) {\n value = mergedConfiguration.has(key) ? deepMerge(mergedConfiguration.get(key), value) : deepClone(value);\n mergedConfiguration.set(key, value);\n }\n });\n }\n\n if (provider.resolvers) {\n this.resolvers.push(...provider.resolvers);\n }\n });\n\n mergedConfiguration.forEach((value, key) => {\n this.settings[key] = deepMerge(value, this.settings[key]);\n });\n\n this.settings.build();\n\n this.resolvedConfiguration = true;\n }\n\n /**\n *\n * @param instance\n * @param locals\n * @param options\n */\n public bindInjectableProperties(instance: any, locals: Map<TokenProvider, any>, options: Partial<InvokeOptions>) {\n const properties: InjectableProperties = ancestorsOf(classOf(instance)).reduce((properties: any, target: any) => {\n const store = Store.from(target);\n\n return {\n ...properties,\n ...(store.get(INJECTABLE_PROP) || {})\n };\n }, {});\n\n Object.values(properties).forEach((definition) => {\n switch (definition.bindingType) {\n case InjectablePropertyType.METHOD:\n this.bindMethod(instance, definition);\n break;\n case InjectablePropertyType.PROPERTY:\n this.bindProperty(instance, definition, locals, options);\n break;\n case InjectablePropertyType.CONSTANT:\n this.bindConstant(instance, definition);\n break;\n case InjectablePropertyType.VALUE:\n this.bindValue(instance, definition);\n break;\n case InjectablePropertyType.INTERCEPTOR:\n this.bindInterceptor(instance, definition);\n break;\n }\n });\n }\n\n /**\n *\n * @param instance\n * @param {string} propertyKey\n */\n public bindMethod(instance: any, {propertyKey}: InjectablePropertyOptions) {\n const target = classOf(instance);\n const originalMethod = instance[propertyKey];\n const deps = Metadata.getParamTypes(prototypeOf(target), propertyKey);\n\n instance[propertyKey] = () => {\n const services = deps.map((dependency: any) => this.get(dependency));\n\n return originalMethod.call(instance, ...services);\n };\n }\n\n /**\n * Create an injectable property.\n *\n * @param instance\n * @param {string} propertyKey\n * @param {any} useType\n * @param resolver\n * @param options\n * @param locals\n * @param invokeOptions\n */\n public bindProperty(\n instance: any,\n {propertyKey, resolver, options = {}}: InjectablePropertyOptions,\n locals: Map<TokenProvider, any>,\n invokeOptions: Partial<InvokeOptions>\n ) {\n let get: () => any;\n\n get = resolver(this, locals, {...invokeOptions, options});\n\n catchError(() =>\n Object.defineProperty(instance, propertyKey, {\n get\n })\n );\n }\n\n /**\n *\n * @param instance\n * @param {string} propertyKey\n * @param {any} useType\n */\n public bindValue(instance: any, {propertyKey, expression, defaultValue}: InjectablePropertyValue) {\n const descriptor = {\n get: () => this.settings.get(expression) || defaultValue,\n set: (value: any) => this.settings.set(expression, value),\n enumerable: true,\n configurable: true\n };\n\n catchError(() => Object.defineProperty(instance, propertyKey, descriptor));\n }\n\n /**\n *\n * @param instance\n * @param {string} propertyKey\n * @param {any} useType\n */\n public bindConstant(instance: any, {propertyKey, expression, defaultValue}: InjectablePropertyValue) {\n let bean: any;\n\n const get = () => {\n if (bean !== undefined) {\n return bean;\n }\n\n const value = this.settings.get(expression, defaultValue);\n bean = Object.freeze(deepClone(value));\n\n return bean;\n };\n\n const descriptor = {\n get,\n enumerable: true,\n configurable: true\n };\n\n catchError(() => Object.defineProperty(instance, propertyKey, descriptor));\n }\n\n /**\n *\n * @param instance\n * @param propertyKey\n * @param useType\n * @param options\n */\n public bindInterceptor(instance: any, {propertyKey, useType, options}: InjectablePropertyOptions) {\n const target = classOf(instance);\n const originalMethod = instance[propertyKey];\n\n instance[propertyKey] = (...args: any[]) => {\n const next = (err?: Error) => {\n if (!err) {\n return originalMethod.apply(instance, args);\n }\n\n throw err;\n };\n\n const context: InterceptorContext<any> = {\n target,\n propertyKey,\n args,\n options,\n next\n };\n\n const interceptor = this.get<InterceptorMethods>(useType)!;\n\n return interceptor.intercept!(\n {\n ...context,\n options\n },\n next\n );\n };\n }\n\n async lazyInvoke<T = any>(token: TokenProvider) {\n let instance = this.getInstance(token);\n\n if (!instance) {\n instance = await this.invoke<T>(token);\n\n if (isFunction(instance?.$onInit)) {\n await instance.$onInit();\n }\n }\n\n return instance;\n }\n\n /**\n * Emit an event to all service. See service [lifecycle hooks](/docs/services.md#lifecycle-hooks).\n * @param eventName The event name to emit at all services.\n * @param args List of the parameters to give to each services.\n * @returns {Promise<any[]>} A list of promises.\n */\n public async emit(eventName: string, ...args: any[]) {\n return this.#cache.emit(eventName, ...args);\n }\n\n /**\n * @param eventName\n * @param value\n * @param args\n */\n public alter<T = any>(eventName: string, value: any, ...args: any[]): T {\n return this.#cache.alter(eventName, value, ...args);\n }\n\n /**\n * @param eventName\n * @param value\n * @param args\n */\n public async alterAsync<T = any>(eventName: string, value: any, ...args: any[]): Promise<T> {\n return this.#cache.alterAsync(eventName, value, ...args);\n }\n\n async destroy() {\n await this.#cache.destroy();\n }\n\n protected ensureProvider(token: TokenProvider): Provider | undefined {\n if (!this.hasProvider(token) && GlobalProviders.has(token)) {\n this.addProvider(token);\n }\n\n return this.getProvider(token)!;\n }\n\n protected getInstance(token: any) {\n return this.#cache.get(token);\n }\n\n /**\n * Invoke a class method and inject service.\n *\n * #### IInjectableMethod options\n *\n * * **target**: Optional. The class instance.\n * * **methodName**: `string` Optional. The method name.\n * * **designParamTypes**: `any[]` Optional. List of injectable types.\n * * **locals**: `Map<Function, any>` Optional. If preset then any argument Class are read from this object first, before the `InjectorService` is consulted.\n *\n * #### Example\n *\n * @param target\n * @param locals\n * @param options\n * @private\n */\n private resolve<T>(target: TokenProvider, locals: Map<TokenProvider, any>, options: Partial<InvokeOptions<T>> = {}): Promise<T> {\n const resolvedOpts = this.mapInvokeOptions(target, locals, options);\n const {token, deps, construct, imports, provider} = resolvedOpts;\n\n if (provider) {\n GlobalProviders.onInvoke(provider, locals, {...resolvedOpts, injector: this});\n }\n\n let instance: any;\n let currentDependency: any = false;\n\n try {\n const invokeDependency =\n (parent?: any) =>\n (token: any, index: number): any => {\n currentDependency = {token, index, deps};\n\n if (token !== DI_PARAM_OPTIONS) {\n const options = provider?.store?.get(`${DI_PARAM_OPTIONS}:${index}`);\n\n locals.set(DI_PARAM_OPTIONS, options || {});\n }\n\n return isInheritedFrom(token, Provider, 1) ? provider : this.invoke(token, locals, {parent});\n };\n\n // Invoke manually imported providers\n imports.forEach(invokeDependency());\n\n // Inject dependencies\n const services = deps.map(invokeDependency(token));\n\n currentDependency = false;\n\n instance = construct(services);\n } catch (error) {\n InjectionError.throwInjectorError(token, currentDependency, error);\n }\n\n if (instance === undefined) {\n throw new InjectionError(\n token,\n `Unable to create new instance from undefined value. Check your provider declaration for ${nameOf(token)}`\n );\n }\n\n if (instance && isClass(classOf(instance))) {\n this.bindInjectableProperties(instance, locals, options);\n }\n\n if (instance && provider.hooks) {\n Object.entries(provider.hooks).forEach(([key, cb]) => {\n instance[key] = (...args: any[]) => cb(instance, ...args);\n });\n }\n\n return instance;\n }\n\n /**\n * Create options to invoke a provider or class.\n * @param token\n * @param locals\n * @param options\n */\n private mapInvokeOptions(token: TokenProvider, locals: Map<TokenProvider, any>, options: Partial<InvokeOptions>): ResolvedInvokeOptions {\n let imports: TokenProvider[] | undefined = options.imports;\n let deps: TokenProvider[] | undefined = options.deps;\n let scope = options.scope;\n let construct;\n\n if (!token) {\n throw new UndefinedTokenError();\n }\n\n let provider: Provider;\n\n if (!this.hasProvider(token)) {\n provider = new Provider(token);\n\n this.resolvers.forEach((resolver) => {\n const result = resolver.get(token, locals.get(DI_PARAM_OPTIONS));\n\n if (result !== undefined) {\n provider.useFactory = () => result;\n }\n });\n } else {\n provider = this.getProvider(token)!;\n }\n\n scope = scope || this.scopeOf(provider);\n deps = deps || provider.deps;\n imports = imports || provider.imports;\n\n if (provider.useValue !== undefined) {\n construct = () => (isFunction(provider.useValue) ? provider.useValue() : provider.useValue);\n } else if (provider.useFactory) {\n construct = (deps: TokenProvider[]) => provider.useFactory(...deps);\n } else if (provider.useAsyncFactory) {\n construct = async (deps: TokenProvider[]) => {\n deps = await Promise.all(deps);\n return provider.useAsyncFactory(...deps);\n };\n } else {\n // useClass\n deps = deps || Metadata.getParamTypes(provider.useClass);\n construct = (deps: TokenProvider[]) => new provider.useClass(...deps);\n }\n\n return {\n token,\n scope: scope || Store.from(token).get(\"scope\") || ProviderScope.SINGLETON,\n deps: deps! || [],\n imports: imports || [],\n construct,\n provider\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// istanbul ignore next
|
|
2
|
+
const colorIfAllowed = (colorFn) => (text) => !process.env.NO_COLOR && process.env.NODE_ENV !== "production" ? colorFn(text) : text;
|
|
3
|
+
const red = colorIfAllowed((text) => `\x1B[31m${text}\x1B[39m`);
|
|
4
|
+
const yellow = colorIfAllowed((text) => `\x1B[33m${text}\x1B[39m`);
|
|
5
|
+
const green = colorIfAllowed((text) => `\x1B[32m${text}\x1B[39m`);
|
|
6
|
+
export const colors = { red, yellow, green };
|
|
7
|
+
//# sourceMappingURL=colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../../src/utils/colors.ts"],"names":[],"mappings":"AAEA,uBAAuB;AACvB,MAAM,cAAc,GAAG,CAAC,OAAoB,EAAE,EAAE,CAAC,CAAC,IAAY,EAAE,EAAE,CAChE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAExF,MAAM,GAAG,GAAG,cAAc,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,WAAW,IAAI,UAAU,CAAC,CAAC;AACxE,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,WAAW,IAAI,UAAU,CAAC,CAAC;AAC3E,MAAM,KAAK,GAAG,cAAc,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,WAAW,IAAI,UAAU,CAAC,CAAC;AAE1E,MAAM,CAAC,MAAM,MAAM,GAAG,EAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAC,CAAC","sourcesContent":["type ColorTextFn = (text: string) => string;\n\n// istanbul ignore next\nconst colorIfAllowed = (colorFn: ColorTextFn) => (text: string) =>\n !process.env.NO_COLOR && process.env.NODE_ENV !== \"production\" ? colorFn(text) : text;\n\nconst red = colorIfAllowed((text: string) => `\\x1B[31m${text}\\x1B[39m`);\nconst yellow = colorIfAllowed((text: string) => `\\x1B[33m${text}\\x1B[39m`);\nconst green = colorIfAllowed((text: string) => `\\x1B[32m${text}\\x1B[39m`);\n\nexport const colors = {red, yellow, green};\n"]}
|