@tsed/di 8.0.0-alpha.1 → 8.0.0-alpha.10
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/browser/di.umd.min.js +1 -1
- package/lib/browser/di.umd.min.js.map +1 -1
- package/lib/esm/common/decorators/autoInjectable.js.map +1 -1
- package/lib/esm/common/decorators/configuration.js.map +1 -1
- package/lib/esm/common/decorators/constant.js.map +1 -1
- package/lib/esm/common/decorators/controller.js.map +1 -1
- package/lib/esm/common/decorators/inject.js +1 -1
- package/lib/esm/common/decorators/inject.js.map +1 -1
- package/lib/esm/common/decorators/intercept.js.map +1 -1
- package/lib/esm/common/decorators/lazyInject.js.map +1 -1
- package/lib/esm/common/decorators/module.js +1 -1
- package/lib/esm/common/decorators/module.js.map +1 -1
- package/lib/esm/common/decorators/opts.js.map +1 -1
- package/lib/esm/common/decorators/overrideProvider.js.map +1 -1
- package/lib/esm/common/decorators/scope.js.map +1 -1
- package/lib/esm/common/decorators/useOpts.js +1 -1
- package/lib/esm/common/decorators/useOpts.js.map +1 -1
- package/lib/esm/common/decorators/value.js.map +1 -1
- package/lib/esm/common/domain/Container.js.map +1 -1
- package/lib/esm/common/domain/LocalsContainer.js.map +1 -1
- package/lib/esm/common/domain/Provider.js.map +1 -1
- package/lib/esm/common/errors/InjectionError.js.map +1 -1
- package/lib/esm/common/registries/GlobalProviders.js +1 -5
- package/lib/esm/common/registries/GlobalProviders.js.map +1 -1
- package/lib/esm/common/registries/ProviderRegistry.js.map +1 -1
- package/lib/esm/common/services/DIConfiguration.js.map +1 -1
- package/lib/esm/common/services/InjectorService.js.map +1 -1
- package/lib/esm/common/utils/createContainer.js.map +1 -1
- package/lib/esm/common/utils/resolveControllers.js +1 -1
- package/lib/esm/common/utils/resolveControllers.js.map +1 -1
- package/lib/esm/node/decorators/injectContext.js +2 -2
- package/lib/esm/node/decorators/injectContext.js.map +1 -1
- package/lib/esm/node/domain/ContextLogger.js +2 -2
- package/lib/esm/node/domain/ContextLogger.js.map +1 -1
- package/lib/esm/node/domain/DIContext.js.map +1 -1
- package/lib/esm/node/services/DILogger.js.map +1 -1
- package/lib/esm/node/services/DITest.js +1 -1
- package/lib/esm/node/services/DITest.js.map +1 -1
- package/lib/esm/node/utils/asyncHookContext.js +3 -2
- package/lib/esm/node/utils/asyncHookContext.js.map +1 -1
- package/lib/esm/node/utils/setLoggerFormat.js.map +1 -1
- package/lib/esm/node/utils/setLoggerLevel.js.map +1 -1
- package/lib/types/common/decorators/module.d.ts +1 -1
- package/lib/types/common/domain/Container.d.ts +1 -1
- package/lib/types/common/domain/Provider.d.ts +1 -1
- package/lib/types/common/interfaces/ProviderOpts.d.ts +1 -1
- package/lib/types/common/interfaces/TokenProvider.d.ts +1 -1
- package/lib/types/node/decorators/injectContext.d.ts +2 -1
- package/lib/types/node/domain/ContextLogger.d.ts +3 -3
- package/lib/types/node/domain/DIContext.d.ts +1 -1
- package/lib/types/node/utils/asyncHookContext.d.ts +4 -3
- package/package.json +17 -18
- package/vitest.config.mts +4 -4
- package/lib/cjs/common/constants/constants.js +0 -9
- package/lib/cjs/common/constants/constants.js.map +0 -1
- package/lib/cjs/common/decorators/autoInjectable.js +0 -38
- package/lib/cjs/common/decorators/autoInjectable.js.map +0 -1
- package/lib/cjs/common/decorators/configuration.js +0 -24
- package/lib/cjs/common/decorators/configuration.js.map +0 -1
- package/lib/cjs/common/decorators/constant.js +0 -74
- package/lib/cjs/common/decorators/constant.js.map +0 -1
- package/lib/cjs/common/decorators/controller.js +0 -53
- package/lib/cjs/common/decorators/controller.js.map +0 -1
- package/lib/cjs/common/decorators/inject.js +0 -84
- package/lib/cjs/common/decorators/inject.js.map +0 -1
- package/lib/cjs/common/decorators/injectable.js +0 -32
- package/lib/cjs/common/decorators/injectable.js.map +0 -1
- package/lib/cjs/common/decorators/intercept.js +0 -65
- package/lib/cjs/common/decorators/intercept.js.map +0 -1
- package/lib/cjs/common/decorators/interceptor.js +0 -21
- package/lib/cjs/common/decorators/interceptor.js.map +0 -1
- package/lib/cjs/common/decorators/lazyInject.js +0 -71
- package/lib/cjs/common/decorators/lazyInject.js.map +0 -1
- package/lib/cjs/common/decorators/module.js +0 -32
- package/lib/cjs/common/decorators/module.js.map +0 -1
- package/lib/cjs/common/decorators/opts.js +0 -54
- package/lib/cjs/common/decorators/opts.js.map +0 -1
- package/lib/cjs/common/decorators/overrideProvider.js +0 -17
- package/lib/cjs/common/decorators/overrideProvider.js.map +0 -1
- package/lib/cjs/common/decorators/scope.js +0 -16
- package/lib/cjs/common/decorators/scope.js.map +0 -1
- package/lib/cjs/common/decorators/service.js +0 -18
- package/lib/cjs/common/decorators/service.js.map +0 -1
- package/lib/cjs/common/decorators/useOpts.js +0 -61
- package/lib/cjs/common/decorators/useOpts.js.map +0 -1
- package/lib/cjs/common/decorators/value.js +0 -62
- package/lib/cjs/common/decorators/value.js.map +0 -1
- package/lib/cjs/common/domain/Container.js +0 -72
- package/lib/cjs/common/domain/Container.js.map +0 -1
- package/lib/cjs/common/domain/ControllerProvider.js +0 -36
- package/lib/cjs/common/domain/ControllerProvider.js.map +0 -1
- package/lib/cjs/common/domain/InjectablePropertyType.js +0 -12
- package/lib/cjs/common/domain/InjectablePropertyType.js.map +0 -1
- package/lib/cjs/common/domain/LocalsContainer.js +0 -15
- package/lib/cjs/common/domain/LocalsContainer.js.map +0 -1
- package/lib/cjs/common/domain/Provider.js +0 -134
- package/lib/cjs/common/domain/Provider.js.map +0 -1
- package/lib/cjs/common/domain/ProviderScope.js +0 -10
- package/lib/cjs/common/domain/ProviderScope.js.map +0 -1
- package/lib/cjs/common/domain/ProviderType.js +0 -15
- package/lib/cjs/common/domain/ProviderType.js.map +0 -1
- package/lib/cjs/common/errors/InjectionError.js +0 -58
- package/lib/cjs/common/errors/InjectionError.js.map +0 -1
- package/lib/cjs/common/errors/InvalidPropertyTokenError.js +0 -12
- package/lib/cjs/common/errors/InvalidPropertyTokenError.js.map +0 -1
- package/lib/cjs/common/index.js +0 -58
- package/lib/cjs/common/index.js.map +0 -1
- package/lib/cjs/common/interfaces/DIConfigurationOptions.js +0 -3
- package/lib/cjs/common/interfaces/DIConfigurationOptions.js.map +0 -1
- package/lib/cjs/common/interfaces/DILogger.js +0 -3
- package/lib/cjs/common/interfaces/DILogger.js.map +0 -1
- package/lib/cjs/common/interfaces/DILoggerOptions.js +0 -3
- package/lib/cjs/common/interfaces/DILoggerOptions.js.map +0 -1
- package/lib/cjs/common/interfaces/DIResolver.js +0 -3
- package/lib/cjs/common/interfaces/DIResolver.js.map +0 -1
- package/lib/cjs/common/interfaces/ImportTokenProviderOpts.js +0 -3
- package/lib/cjs/common/interfaces/ImportTokenProviderOpts.js.map +0 -1
- package/lib/cjs/common/interfaces/InterceptorContext.js +0 -3
- package/lib/cjs/common/interfaces/InterceptorContext.js.map +0 -1
- package/lib/cjs/common/interfaces/InterceptorMethods.js +0 -3
- package/lib/cjs/common/interfaces/InterceptorMethods.js.map +0 -1
- package/lib/cjs/common/interfaces/InvokeOptions.js +0 -3
- package/lib/cjs/common/interfaces/InvokeOptions.js.map +0 -1
- package/lib/cjs/common/interfaces/OnDestroy.js +0 -3
- package/lib/cjs/common/interfaces/OnDestroy.js.map +0 -1
- package/lib/cjs/common/interfaces/OnInit.js +0 -3
- package/lib/cjs/common/interfaces/OnInit.js.map +0 -1
- package/lib/cjs/common/interfaces/ProviderOpts.js +0 -3
- package/lib/cjs/common/interfaces/ProviderOpts.js.map +0 -1
- package/lib/cjs/common/interfaces/RegistrySettings.js +0 -3
- package/lib/cjs/common/interfaces/RegistrySettings.js.map +0 -1
- package/lib/cjs/common/interfaces/ResolvedInvokeOptions.js +0 -3
- package/lib/cjs/common/interfaces/ResolvedInvokeOptions.js.map +0 -1
- package/lib/cjs/common/interfaces/TokenProvider.js +0 -3
- package/lib/cjs/common/interfaces/TokenProvider.js.map +0 -1
- package/lib/cjs/common/interfaces/TokenRoute.js +0 -3
- package/lib/cjs/common/interfaces/TokenRoute.js.map +0 -1
- package/lib/cjs/common/registries/GlobalProviders.js +0 -121
- package/lib/cjs/common/registries/GlobalProviders.js.map +0 -1
- package/lib/cjs/common/registries/ProviderRegistry.js +0 -86
- package/lib/cjs/common/registries/ProviderRegistry.js.map +0 -1
- package/lib/cjs/common/services/DIConfiguration.js +0 -142
- package/lib/cjs/common/services/DIConfiguration.js.map +0 -1
- package/lib/cjs/common/services/DILogger.js +0 -14
- package/lib/cjs/common/services/DILogger.js.map +0 -1
- package/lib/cjs/common/services/InjectorService.js +0 -536
- package/lib/cjs/common/services/InjectorService.js.map +0 -1
- package/lib/cjs/common/utils/colors.js +0 -10
- package/lib/cjs/common/utils/colors.js.map +0 -1
- package/lib/cjs/common/utils/createContainer.js +0 -14
- package/lib/cjs/common/utils/createContainer.js.map +0 -1
- package/lib/cjs/common/utils/getConfiguration.js +0 -23
- package/lib/cjs/common/utils/getConfiguration.js.map +0 -1
- package/lib/cjs/common/utils/getConstructorDependencies.js +0 -13
- package/lib/cjs/common/utils/getConstructorDependencies.js.map +0 -1
- package/lib/cjs/common/utils/resolveControllers.js +0 -47
- package/lib/cjs/common/utils/resolveControllers.js.map +0 -1
- package/lib/cjs/index.js +0 -6
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/node/decorators/injectContext.js +0 -39
- package/lib/cjs/node/decorators/injectContext.js.map +0 -1
- package/lib/cjs/node/domain/ContextLogger.js +0 -99
- package/lib/cjs/node/domain/ContextLogger.js.map +0 -1
- package/lib/cjs/node/domain/DIContext.js +0 -102
- package/lib/cjs/node/domain/DIContext.js.map +0 -1
- package/lib/cjs/node/index.js +0 -18
- package/lib/cjs/node/index.js.map +0 -1
- package/lib/cjs/node/interfaces/AlterRunInContext.js +0 -3
- package/lib/cjs/node/interfaces/AlterRunInContext.js.map +0 -1
- package/lib/cjs/node/services/DILogger.js +0 -12
- package/lib/cjs/node/services/DILogger.js.map +0 -1
- package/lib/cjs/node/services/DITest.js +0 -126
- package/lib/cjs/node/services/DITest.js.map +0 -1
- package/lib/cjs/node/utils/asyncHookContext.js +0 -42
- package/lib/cjs/node/utils/asyncHookContext.js.map +0 -1
- package/lib/cjs/node/utils/attachLogger.js +0 -10
- package/lib/cjs/node/utils/attachLogger.js.map +0 -1
- package/lib/cjs/node/utils/setLoggerConfiguration.js +0 -11
- package/lib/cjs/node/utils/setLoggerConfiguration.js.map +0 -1
- package/lib/cjs/node/utils/setLoggerFormat.js +0 -33
- package/lib/cjs/node/utils/setLoggerFormat.js.map +0 -1
- package/lib/cjs/node/utils/setLoggerLevel.js +0 -15
- package/lib/cjs/node/utils/setLoggerLevel.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/esm/package.json +0 -3
- package/lib/types-esm/common/constants/constants.d.ts +0 -5
- package/lib/types-esm/common/decorators/autoInjectable.d.ts +0 -1
- package/lib/types-esm/common/decorators/configuration.d.ts +0 -8
- package/lib/types-esm/common/decorators/constant.d.ts +0 -39
- package/lib/types-esm/common/decorators/controller.d.ts +0 -42
- package/lib/types-esm/common/decorators/inject.d.ts +0 -35
- package/lib/types-esm/common/decorators/injectable.d.ts +0 -20
- package/lib/types-esm/common/decorators/intercept.d.ts +0 -13
- package/lib/types-esm/common/decorators/interceptor.d.ts +0 -10
- package/lib/types-esm/common/decorators/lazyInject.d.ts +0 -43
- package/lib/types-esm/common/decorators/module.d.ts +0 -37
- package/lib/types-esm/common/decorators/opts.d.ts +0 -41
- package/lib/types-esm/common/decorators/overrideProvider.d.ts +0 -8
- package/lib/types-esm/common/decorators/scope.d.ts +0 -8
- package/lib/types-esm/common/decorators/service.d.ts +0 -10
- package/lib/types-esm/common/decorators/useOpts.d.ts +0 -42
- package/lib/types-esm/common/decorators/value.d.ts +0 -37
- package/lib/types-esm/common/domain/Container.d.ts +0 -43
- package/lib/types-esm/common/domain/ControllerProvider.d.ts +0 -17
- package/lib/types-esm/common/domain/InjectablePropertyType.d.ts +0 -7
- package/lib/types-esm/common/domain/LocalsContainer.d.ts +0 -6
- package/lib/types-esm/common/domain/Provider.d.ts +0 -71
- package/lib/types-esm/common/domain/ProviderScope.d.ts +0 -5
- package/lib/types-esm/common/domain/ProviderType.d.ts +0 -10
- package/lib/types-esm/common/errors/InjectionError.d.ts +0 -8
- package/lib/types-esm/common/errors/InvalidPropertyTokenError.d.ts +0 -4
- package/lib/types-esm/common/index.d.ts +0 -54
- package/lib/types-esm/common/interfaces/DIConfigurationOptions.d.ts +0 -29
- package/lib/types-esm/common/interfaces/DILogger.d.ts +0 -8
- package/lib/types-esm/common/interfaces/DILoggerOptions.d.ts +0 -53
- package/lib/types-esm/common/interfaces/DIResolver.d.ts +0 -5
- package/lib/types-esm/common/interfaces/ImportTokenProviderOpts.d.ts +0 -19
- package/lib/types-esm/common/interfaces/InterceptorContext.d.ts +0 -11
- package/lib/types-esm/common/interfaces/InterceptorMethods.d.ts +0 -4
- package/lib/types-esm/common/interfaces/InvokeOptions.d.ts +0 -30
- package/lib/types-esm/common/interfaces/OnDestroy.d.ts +0 -3
- package/lib/types-esm/common/interfaces/OnInit.d.ts +0 -3
- package/lib/types-esm/common/interfaces/ProviderOpts.d.ts +0 -59
- package/lib/types-esm/common/interfaces/RegistrySettings.d.ts +0 -21
- package/lib/types-esm/common/interfaces/ResolvedInvokeOptions.d.ts +0 -12
- package/lib/types-esm/common/interfaces/TokenProvider.d.ts +0 -2
- package/lib/types-esm/common/interfaces/TokenRoute.d.ts +0 -5
- package/lib/types-esm/common/registries/GlobalProviders.d.ts +0 -58
- package/lib/types-esm/common/registries/ProviderRegistry.d.ts +0 -58
- package/lib/types-esm/common/services/DIConfiguration.d.ts +0 -57
- package/lib/types-esm/common/services/DILogger.d.ts +0 -3
- package/lib/types-esm/common/services/InjectorService.d.ts +0 -203
- package/lib/types-esm/common/utils/colors.d.ts +0 -5
- package/lib/types-esm/common/utils/createContainer.d.ts +0 -3
- package/lib/types-esm/common/utils/getConfiguration.d.ts +0 -3
- package/lib/types-esm/common/utils/getConstructorDependencies.d.ts +0 -2
- package/lib/types-esm/common/utils/resolveControllers.d.ts +0 -12
- package/lib/types-esm/index.d.ts +0 -2
- package/lib/types-esm/node/decorators/injectContext.d.ts +0 -15
- package/lib/types-esm/node/domain/ContextLogger.d.ts +0 -37
- package/lib/types-esm/node/domain/DIContext.d.ts +0 -61
- package/lib/types-esm/node/index.d.ts +0 -14
- package/lib/types-esm/node/interfaces/AlterRunInContext.d.ts +0 -3
- package/lib/types-esm/node/services/DILogger.d.ts +0 -1
- package/lib/types-esm/node/services/DITest.d.ts +0 -37
- package/lib/types-esm/node/utils/asyncHookContext.d.ts +0 -14
- package/lib/types-esm/node/utils/attachLogger.d.ts +0 -2
- package/lib/types-esm/node/utils/setLoggerConfiguration.d.ts +0 -2
- package/lib/types-esm/node/utils/setLoggerFormat.d.ts +0 -6
- package/lib/types-esm/node/utils/setLoggerLevel.d.ts +0 -6
- /package/{webpack.config.js → webpack.config.cjs} +0 -0
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OptionalLazyInject = exports.LazyInject = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const InjectorService_js_1 = require("../services/InjectorService.js");
|
|
6
|
-
/**
|
|
7
|
-
* Lazy load a provider from his package and invoke only when the provider is used
|
|
8
|
-
*
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import type {PlatformException} from "@tsed/platform-exceptions";
|
|
11
|
-
*
|
|
12
|
-
* @Injectable()
|
|
13
|
-
* export class MyService {
|
|
14
|
-
* @LazyInject("PlatformException", () => import("@tsed/platform-exceptions"))
|
|
15
|
-
* exceptions: Promise<PlatformException>;
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @param key
|
|
20
|
-
* @param packageName
|
|
21
|
-
* @param resolver
|
|
22
|
-
* @param optional
|
|
23
|
-
* @returns {Function}
|
|
24
|
-
* @decorator
|
|
25
|
-
*/
|
|
26
|
-
function LazyInject(key, resolver, { optional = false, packageName = resolver.toString() } = {}) {
|
|
27
|
-
return (target, propertyKey) => {
|
|
28
|
-
let bean, token;
|
|
29
|
-
(0, core_1.catchError)(() => Reflect.deleteProperty(target, propertyKey));
|
|
30
|
-
Reflect.defineProperty(target, propertyKey, {
|
|
31
|
-
async get() {
|
|
32
|
-
if (!token) {
|
|
33
|
-
const injector = InjectorService_js_1.InjectorService.getInstance();
|
|
34
|
-
const exports = await (0, core_1.importPackage)(packageName, resolver, optional);
|
|
35
|
-
token = exports[key];
|
|
36
|
-
if (!token) {
|
|
37
|
-
if (!optional) {
|
|
38
|
-
throw new Error(`Unable to lazy load the "${key}". The token isn\'t a valid token provider.`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
bean = token ? await injector.lazyInvoke(token) : {};
|
|
42
|
-
}
|
|
43
|
-
return bean;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
exports.LazyInject = LazyInject;
|
|
49
|
-
/**
|
|
50
|
-
* Optionally Lazy load a provider from his package and invoke only when the provider is used
|
|
51
|
-
*
|
|
52
|
-
* ```typescript
|
|
53
|
-
* import type {PlatformException} from "@tsed/platform-exceptions";
|
|
54
|
-
*
|
|
55
|
-
* @Injectable()
|
|
56
|
-
* export class MyService {
|
|
57
|
-
* @OptionalLazyInject("@tsed/platform-exceptions")
|
|
58
|
-
* exceptions: Promise<PlatformException>;
|
|
59
|
-
* }
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @param key
|
|
63
|
-
* @param resolver
|
|
64
|
-
* @returns {Function}
|
|
65
|
-
* @decorator
|
|
66
|
-
*/
|
|
67
|
-
function OptionalLazyInject(key, resolver) {
|
|
68
|
-
return LazyInject(key, resolver, { optional: true });
|
|
69
|
-
}
|
|
70
|
-
exports.OptionalLazyInject = OptionalLazyInject;
|
|
71
|
-
//# sourceMappingURL=lazyInject.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lazyInject.js","sourceRoot":"","sources":["../../../../src/common/decorators/lazyInject.ts"],"names":[],"mappings":";;;AAAA,qCAAqD;AACrD,uEAA+D;AAE/D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,UAAU,CACxB,GAAW,EACX,QAAmB,EACnB,EAAC,QAAQ,GAAG,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAC,QAAQ,EAAE,KAAgD,EAAE;IAEtG,OAAO,CAAC,MAAW,EAAE,WAA4B,EAAc,EAAE;QAC/D,IAAI,IAAS,EAAE,KAAU,CAAC;QAE1B,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;QAC9D,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE;YAC1C,KAAK,CAAC,GAAG;gBACP,IAAI,CAAC,KAAK,EAAE;oBACV,MAAM,QAAQ,GAAG,oCAAe,CAAC,WAAW,EAAE,CAAC;oBAC/C,MAAM,OAAO,GAAG,MAAM,IAAA,oBAAa,EAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;oBACrE,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;oBACrB,IAAI,CAAC,KAAK,EAAE;wBACV,IAAI,CAAC,QAAQ,EAAE;4BACb,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,6CAA6C,CAAC,CAAC;yBAC/F;qBACF;oBAED,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;iBACtD;gBAED,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AA5BD,gCA4BC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,kBAAkB,CAAC,GAAW,EAAE,QAAmB;IACjE,OAAQ,UAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;AAC9D,CAAC;AAFD,gDAEC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Module = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const ProviderScope_js_1 = require("../domain/ProviderScope.js");
|
|
6
|
-
const configuration_js_1 = require("./configuration.js");
|
|
7
|
-
const injectable_js_1 = require("./injectable.js");
|
|
8
|
-
const ProviderType_js_1 = require("../domain/ProviderType.js");
|
|
9
|
-
/**
|
|
10
|
-
* Declare a new Ts.ED module
|
|
11
|
-
*
|
|
12
|
-
* ## Options
|
|
13
|
-
* - imports: List of Provider which must be built by injector before invoking the module
|
|
14
|
-
* - resolvers: List of external DI must be used to resolve unknown provider
|
|
15
|
-
* - deps: List of provider must be injected to the module constructor (explicit declaration)
|
|
16
|
-
*
|
|
17
|
-
* @param options
|
|
18
|
-
* @decorator
|
|
19
|
-
*/
|
|
20
|
-
function Module(options = {}) {
|
|
21
|
-
const { scopes, imports, resolvers, deps, scope, ...configuration } = options;
|
|
22
|
-
return (0, core_1.useDecorators)((0, configuration_js_1.Configuration)(configuration), (0, injectable_js_1.Injectable)({
|
|
23
|
-
type: ProviderType_js_1.ProviderType.MODULE,
|
|
24
|
-
scope: ProviderScope_js_1.ProviderScope.SINGLETON,
|
|
25
|
-
imports,
|
|
26
|
-
deps,
|
|
27
|
-
injectable: false,
|
|
28
|
-
resolvers
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
exports.Module = Module;
|
|
32
|
-
//# sourceMappingURL=module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../../src/common/decorators/module.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AACzC,iEAAyD;AAEzD,yDAAiD;AACjD,mDAA2C;AAC3C,+DAAuD;AA2BvD;;;;;;;;;;GAUG;AACH,SAAgB,MAAM,CAAC,UAAkC,EAAE;IACzD,MAAM,EAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,aAAa,EAAC,GAAG,OAAO,CAAC;IAE5E,OAAO,IAAA,oBAAa,EAClB,IAAA,gCAAa,EAAC,aAAa,CAAC,EAC5B,IAAA,0BAAU,EAAC;QACT,IAAI,EAAE,8BAAY,CAAC,MAAM;QACzB,KAAK,EAAE,gCAAa,CAAC,SAAS;QAC9B,OAAO;QACP,IAAI;QACJ,UAAU,EAAE,KAAK;QACjB,SAAS;KACV,CAAC,CACH,CAAC;AACJ,CAAC;AAdD,wBAcC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Opts = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const constants_js_1 = require("../constants/constants.js");
|
|
6
|
-
const ProviderScope_js_1 = require("../domain/ProviderScope.js");
|
|
7
|
-
const inject_js_1 = require("./inject.js");
|
|
8
|
-
const scope_js_1 = require("./scope.js");
|
|
9
|
-
/**
|
|
10
|
-
* Get instance options. This options depending on his invocation context.
|
|
11
|
-
*
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import {Injectable, Opts, UseOpts} from "@tsed/di";
|
|
14
|
-
*
|
|
15
|
-
* @Injectable()
|
|
16
|
-
* class MyConfigurableService {
|
|
17
|
-
* source: string;
|
|
18
|
-
* constructor(@Opts options: any = {}) {
|
|
19
|
-
* console.log("Hello ", options.source); // log: Hello Service1 then Hello Service2
|
|
20
|
-
*
|
|
21
|
-
* this.source = options.source;
|
|
22
|
-
* }
|
|
23
|
-
* }
|
|
24
|
-
*
|
|
25
|
-
* @Injectable()
|
|
26
|
-
* class MyService1 {
|
|
27
|
-
* constructor(@UseOpts({source: 'Service1'}) service: MyConfigurableService) {
|
|
28
|
-
* console.log(service.source) // log: Service1
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
*
|
|
32
|
-
* @Injectable()
|
|
33
|
-
* class MyService2 {
|
|
34
|
-
* constructor(@UseOpts({source: 'Service2'}) service: MyConfigurableService) {
|
|
35
|
-
* console.log(service.source) // log: Service2
|
|
36
|
-
* }
|
|
37
|
-
* }
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* ::: warning
|
|
41
|
-
* Using @@Opts@@ decorator on a constructor parameter change the Scope of the provider to `ProviderScope.INSTANCE`.
|
|
42
|
-
* :::
|
|
43
|
-
*
|
|
44
|
-
* @param target
|
|
45
|
-
* @param propertyKey
|
|
46
|
-
* @param index
|
|
47
|
-
* @decorator
|
|
48
|
-
*/
|
|
49
|
-
function Opts(target, propertyKey, index) {
|
|
50
|
-
(0, scope_js_1.Scope)(ProviderScope_js_1.ProviderScope.INSTANCE)((0, core_1.classOf)(target));
|
|
51
|
-
(0, inject_js_1.Inject)(constants_js_1.DI_USE_PARAM_OPTIONS)(target, propertyKey, index);
|
|
52
|
-
}
|
|
53
|
-
exports.Opts = Opts;
|
|
54
|
-
//# sourceMappingURL=opts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"opts.js","sourceRoot":"","sources":["../../../../src/common/decorators/opts.ts"],"names":[],"mappings":";;;AAAA,qCAAmC;AACnC,4DAA+D;AAC/D,iEAAyD;AACzD,2CAAmC;AACnC,yCAAiC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,SAAgB,IAAI,CAAC,MAAW,EAAE,WAAwC,EAAE,KAAa;IACvF,IAAA,gBAAK,EAAC,gCAAa,CAAC,QAAQ,CAAC,CAAC,IAAA,cAAO,EAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,IAAA,kBAAM,EAAC,mCAAoB,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;AAC3D,CAAC;AAHD,oBAGC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OverrideProvider = void 0;
|
|
4
|
-
const GlobalProviders_js_1 = require("../registries/GlobalProviders.js");
|
|
5
|
-
/**
|
|
6
|
-
* Override a provider which is already registered in ProviderRegistry.
|
|
7
|
-
* @returns {Function}
|
|
8
|
-
* @decorators
|
|
9
|
-
* @param originalProvider
|
|
10
|
-
*/
|
|
11
|
-
function OverrideProvider(originalProvider) {
|
|
12
|
-
return (target) => {
|
|
13
|
-
GlobalProviders_js_1.GlobalProviders.get(originalProvider).useClass = target;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
exports.OverrideProvider = OverrideProvider;
|
|
17
|
-
//# sourceMappingURL=overrideProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"overrideProvider.js","sourceRoot":"","sources":["../../../../src/common/decorators/overrideProvider.ts"],"names":[],"mappings":";;;AACA,yEAAiE;AAEjE;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,gBAA2B;IAC1D,OAAO,CAAC,MAAiB,EAAQ,EAAE;QACjC,oCAAe,CAAC,GAAG,CAAC,gBAAgB,CAAE,CAAC,QAAQ,GAAG,MAAM,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC;AAJD,4CAIC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Scope = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const ProviderScope_js_1 = require("../domain/ProviderScope.js");
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {"request" | "singleton" | ProviderScope} scope
|
|
9
|
-
* @returns {Function}
|
|
10
|
-
* @constructor
|
|
11
|
-
*/
|
|
12
|
-
function Scope(scope = ProviderScope_js_1.ProviderScope.REQUEST) {
|
|
13
|
-
return (0, core_1.StoreSet)("scope", scope);
|
|
14
|
-
}
|
|
15
|
-
exports.Scope = Scope;
|
|
16
|
-
//# sourceMappingURL=scope.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../../src/common/decorators/scope.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AACpC,iEAAyD;AAEzD;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,QAAiD,gCAAa,CAAC,OAAO;IAC1F,OAAO,IAAA,eAAQ,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAClC,CAAC;AAFD,sBAEC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Service = void 0;
|
|
4
|
-
const injectable_js_1 = require("./injectable.js");
|
|
5
|
-
/**
|
|
6
|
-
* The decorators `@Service()` declare a new service can be injected in other service or controller on there `constructor`.
|
|
7
|
-
* All services annotated with `@Service()` are constructed one time.
|
|
8
|
-
*
|
|
9
|
-
* > `@Service()` use the `reflect-metadata` to collect and inject service on controllers or other services.
|
|
10
|
-
*
|
|
11
|
-
* @returns {Function}
|
|
12
|
-
* @decorator
|
|
13
|
-
*/
|
|
14
|
-
function Service() {
|
|
15
|
-
return (0, injectable_js_1.Injectable)();
|
|
16
|
-
}
|
|
17
|
-
exports.Service = Service;
|
|
18
|
-
//# sourceMappingURL=service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../src/common/decorators/service.ts"],"names":[],"mappings":";;;AAAA,mDAA2C;AAE3C;;;;;;;;GAQG;AACH,SAAgB,OAAO;IACrB,OAAO,IAAA,0BAAU,GAAE,CAAC;AACtB,CAAC;AAFD,0BAEC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UseOpts = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const constants_js_1 = require("../constants/constants.js");
|
|
6
|
-
/**
|
|
7
|
-
* Add options to invoke the Service.
|
|
8
|
-
*
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import {Injectable, Opts, UseOpts} from "@tsed/di";
|
|
11
|
-
*
|
|
12
|
-
* @Injectable()
|
|
13
|
-
* class MyConfigurableService {
|
|
14
|
-
* source: string;
|
|
15
|
-
* constructor(@Opts options: any = {}) {
|
|
16
|
-
* console.log("Hello ", options.source); // log: Hello Service1 then Hello Service2
|
|
17
|
-
*
|
|
18
|
-
* this.source = options.source;
|
|
19
|
-
* }
|
|
20
|
-
* }
|
|
21
|
-
*
|
|
22
|
-
* @Injectable()
|
|
23
|
-
* class MyService1 {
|
|
24
|
-
* constructor(@UseOpts({source: 'Service1'}) service: MyConfigurableService) {
|
|
25
|
-
* console.log(service.source) // log: Service1
|
|
26
|
-
* }
|
|
27
|
-
* }
|
|
28
|
-
*
|
|
29
|
-
* @Injectable()
|
|
30
|
-
* class MyService2 {
|
|
31
|
-
* constructor(@UseOpts({source: 'Service2'}) service: MyConfigurableService) {
|
|
32
|
-
* console.log(service.source) // log: Service2
|
|
33
|
-
* }
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* ::: warning
|
|
38
|
-
* Using @@Opts@@ decorator on a constructor parameter change the Scope of the provider to `ProviderScope.INSTANCE`.
|
|
39
|
-
* :::
|
|
40
|
-
*
|
|
41
|
-
* @returns {Function}
|
|
42
|
-
* @decorator
|
|
43
|
-
* @param options
|
|
44
|
-
*/
|
|
45
|
-
function UseOpts(options) {
|
|
46
|
-
return (target, propertyKey, index) => {
|
|
47
|
-
const bindingType = (0, core_1.decoratorTypeOf)([target, propertyKey, index]);
|
|
48
|
-
switch (bindingType) {
|
|
49
|
-
case core_1.DecoratorTypes.PARAM_CTOR:
|
|
50
|
-
core_1.Store.from(target).merge(`${constants_js_1.DI_USE_PARAM_OPTIONS}:${index}`, options);
|
|
51
|
-
break;
|
|
52
|
-
case core_1.DecoratorTypes.PROP:
|
|
53
|
-
core_1.Store.from(target, propertyKey).set(constants_js_1.DI_USE_OPTIONS, options);
|
|
54
|
-
break;
|
|
55
|
-
default:
|
|
56
|
-
throw new core_1.UnsupportedDecoratorType(UseOpts, [target, propertyKey, index]);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
exports.UseOpts = UseOpts;
|
|
61
|
-
//# sourceMappingURL=useOpts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useOpts.js","sourceRoot":"","sources":["../../../../src/common/decorators/useOpts.ts"],"names":[],"mappings":";;;AAAA,qCAA4F;AAC5F,4DAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,SAAgB,OAAO,CAAC,OAA6B;IACnD,OAAO,CAAC,MAAc,EAAE,WAA4B,EAAE,KAAc,EAAO,EAAE;QAC3E,MAAM,WAAW,GAAG,IAAA,sBAAe,EAAC,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;QAElE,QAAQ,WAAW,EAAE;YACnB,KAAK,qBAAc,CAAC,UAAU;gBAC5B,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,mCAAoB,IAAI,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;gBACtE,MAAM;YAER,KAAK,qBAAc,CAAC,IAAI;gBACtB,YAAK,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,GAAG,CAAC,6BAAc,EAAE,OAAO,CAAC,CAAC;gBAC7D,MAAM;YAER;gBACE,MAAM,IAAI,+BAAwB,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;SAC7E;IACH,CAAC,CAAC;AACJ,CAAC;AAjBD,0BAiBC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Value = exports.bindValue = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const InjectorService_js_1 = require("../services/InjectorService.js");
|
|
6
|
-
function bindValue(target, propertyKey, expression, defaultValue) {
|
|
7
|
-
const descriptor = {
|
|
8
|
-
get() {
|
|
9
|
-
return InjectorService_js_1.InjectorService.getInstance().settings.get(expression, defaultValue);
|
|
10
|
-
},
|
|
11
|
-
set(value) {
|
|
12
|
-
InjectorService_js_1.InjectorService.getInstance().settings.set(expression, value);
|
|
13
|
-
},
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true
|
|
16
|
-
};
|
|
17
|
-
(0, core_1.catchError)(() => Reflect.deleteProperty(target, propertyKey));
|
|
18
|
-
(0, core_1.catchError)(() => Reflect.defineProperty(target, propertyKey, descriptor));
|
|
19
|
-
}
|
|
20
|
-
exports.bindValue = bindValue;
|
|
21
|
-
/**
|
|
22
|
-
* Return value from Configuration.
|
|
23
|
-
*
|
|
24
|
-
* ## Example
|
|
25
|
-
*
|
|
26
|
-
* ```typescript
|
|
27
|
-
* import {Env} from "@tsed/core";
|
|
28
|
-
* import {Constant, Value} from "@tsed/di";
|
|
29
|
-
*
|
|
30
|
-
* export class MyClass {
|
|
31
|
-
*
|
|
32
|
-
* @Constant("env")
|
|
33
|
-
* env: Env;
|
|
34
|
-
*
|
|
35
|
-
* @Value("swagger.path")
|
|
36
|
-
* swaggerPath: string;
|
|
37
|
-
*
|
|
38
|
-
* @Value("swagger.path", "defaultValue")
|
|
39
|
-
* swaggerPath: string;
|
|
40
|
-
*
|
|
41
|
-
* constructor() {
|
|
42
|
-
* console.log(this.swaggerPath) // undefined. Not available on constructor
|
|
43
|
-
* }
|
|
44
|
-
*
|
|
45
|
-
* $onInit() {
|
|
46
|
-
* console.log(this.swaggerPath) // something
|
|
47
|
-
* }
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @param expression
|
|
52
|
-
* @param defaultValue
|
|
53
|
-
* @returns {(targetClass: any, attributeName: string) => any}
|
|
54
|
-
* @decorator
|
|
55
|
-
*/
|
|
56
|
-
function Value(expression, defaultValue) {
|
|
57
|
-
return (target, propertyKey) => {
|
|
58
|
-
return bindValue(target, propertyKey, expression, defaultValue);
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
exports.Value = Value;
|
|
62
|
-
//# sourceMappingURL=value.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"value.js","sourceRoot":"","sources":["../../../../src/common/decorators/value.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AACtC,uEAA+D;AAE/D,SAAgB,SAAS,CAAC,MAAW,EAAE,WAA4B,EAAE,UAAkB,EAAE,YAAkB;IACzG,MAAM,UAAU,GAAG;QACjB,GAAG;YACD,OAAO,oCAAe,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAC9E,CAAC;QACD,GAAG,CAAC,KAAc;YAChB,oCAAe,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAChE,CAAC;QACD,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,IAAI;KACnB,CAAC;IAEF,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IAC9D,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;AAC5E,CAAC;AAdD,8BAcC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,SAAgB,KAAK,CAAC,UAAkB,EAAE,YAAsB;IAC9D,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;QAC7B,OAAO,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC;AAJD,sBAIC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Container = void 0;
|
|
4
|
-
const GlobalProviders_js_1 = require("../registries/GlobalProviders.js");
|
|
5
|
-
const Provider_js_1 = require("./Provider.js");
|
|
6
|
-
class Container extends Map {
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param token
|
|
10
|
-
* @param settings
|
|
11
|
-
*/
|
|
12
|
-
add(token, settings = {}) {
|
|
13
|
-
const provider = GlobalProviders_js_1.GlobalProviders.get(token)?.clone() || new Provider_js_1.Provider(token);
|
|
14
|
-
Object.assign(provider, settings);
|
|
15
|
-
return super.set(token, provider);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Add a provider to the
|
|
19
|
-
* @param token
|
|
20
|
-
* @param settings
|
|
21
|
-
*/
|
|
22
|
-
addProvider(token, settings = {}) {
|
|
23
|
-
return this.add(token, settings);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @param token
|
|
28
|
-
*/
|
|
29
|
-
hasProvider(token) {
|
|
30
|
-
return super.has(token);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Add a provider to the
|
|
34
|
-
* @param token
|
|
35
|
-
* @param provider
|
|
36
|
-
*/
|
|
37
|
-
setProvider(token, provider) {
|
|
38
|
-
return super.set(token, provider);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* The getProvider() method returns a specified element from a Map object.
|
|
42
|
-
* @returns {T} Returns the element associated with the specified key or undefined if the key can't be found in the Map object.
|
|
43
|
-
* @param token
|
|
44
|
-
*/
|
|
45
|
-
getProvider(token) {
|
|
46
|
-
return super.get(token);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Get all providers registered in the injector container.
|
|
50
|
-
*
|
|
51
|
-
* @param type Filter the list by the given ProviderType.
|
|
52
|
-
* @returns {[TokenProvider , Provider<any>][]}
|
|
53
|
-
*/
|
|
54
|
-
getProviders(type) {
|
|
55
|
-
const types = [].concat(type).map(String);
|
|
56
|
-
return [...this].reduce((providers, [_, provider]) => {
|
|
57
|
-
if (types.includes(String(provider.type)) || !type) {
|
|
58
|
-
return [...providers, provider];
|
|
59
|
-
}
|
|
60
|
-
return providers;
|
|
61
|
-
}, []);
|
|
62
|
-
}
|
|
63
|
-
addProviders(container) {
|
|
64
|
-
container.forEach((provider) => {
|
|
65
|
-
if (!this.hasProvider(provider.provide)) {
|
|
66
|
-
this.setProvider(provider.provide, provider.clone());
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.Container = Container;
|
|
72
|
-
//# sourceMappingURL=Container.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Container.js","sourceRoot":"","sources":["../../../../src/common/domain/Container.ts"],"names":[],"mappings":";;;AAGA,yEAAiE;AACjE,+CAAuC;AAEvC,MAAa,SAAU,SAAQ,GAA4B;IACzD;;;;OAIG;IACI,GAAG,CAAC,KAAoB,EAAE,WAAkC,EAAE;QACnE,MAAM,QAAQ,GAAG,oCAAe,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,IAAI,sBAAQ,CAAC,KAAK,CAAC,CAAC;QAE5E,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAElC,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACI,WAAW,CAAC,KAAoB,EAAE,WAAkC,EAAE;QAC3E,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED;;;OAGG;IACI,WAAW,CAAC,KAAoB;QACrC,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACI,WAAW,CAAC,KAAoB,EAAE,QAAkB;QACzD,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACI,WAAW,CAAgC,KAAgC;QAChF,OAAO,KAAK,CAAC,GAAG,CAAC,KAAM,CAAM,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACI,YAAY,CAAC,IAAuD;QACzE,MAAM,KAAK,GAAI,EAAgC,CAAC,MAAM,CAAC,IAAa,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAElF,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,EAAE;YACnD,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE;gBAClD,OAAO,CAAC,GAAG,SAAS,EAAE,QAAQ,CAAC,CAAC;aACjC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;IAEM,YAAY,CAAC,SAAuC;QACzD,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC7B,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBACvC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;aACtD;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAzED,8BAyEC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ControllerProvider = void 0;
|
|
4
|
-
const Provider_js_1 = require("./Provider.js");
|
|
5
|
-
const ProviderType_js_1 = require("./ProviderType.js");
|
|
6
|
-
class ControllerProvider extends Provider_js_1.Provider {
|
|
7
|
-
constructor(provide, options = {}) {
|
|
8
|
-
super(provide, options);
|
|
9
|
-
this.type = ProviderType_js_1.ProviderType.CONTROLLER;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @returns {any[]}
|
|
14
|
-
*/
|
|
15
|
-
get middlewares() {
|
|
16
|
-
return Object.assign({
|
|
17
|
-
use: [],
|
|
18
|
-
useAfter: [],
|
|
19
|
-
useBefore: []
|
|
20
|
-
}, this.store.get("middlewares", {}));
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param middlewares
|
|
25
|
-
*/
|
|
26
|
-
set middlewares(middlewares) {
|
|
27
|
-
const mdlwrs = this.middlewares;
|
|
28
|
-
const concat = (key, a, b) => (a[key] = a[key].concat(b[key]));
|
|
29
|
-
Object.keys(middlewares).forEach((key) => {
|
|
30
|
-
concat(key, mdlwrs, middlewares);
|
|
31
|
-
});
|
|
32
|
-
this.store.set("middlewares", mdlwrs);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.ControllerProvider = ControllerProvider;
|
|
36
|
-
//# sourceMappingURL=ControllerProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ControllerProvider.js","sourceRoot":"","sources":["../../../../src/common/domain/ControllerProvider.ts"],"names":[],"mappings":";;;AAEA,+CAAuC;AACvC,uDAA+C;AAE/C,MAAa,kBAA4B,SAAQ,sBAAW;IAG1D,YAAY,OAAsB,EAAE,UAA6B,EAAE;QACjE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,8BAAY,CAAC,UAAU,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW;QACb,OAAO,MAAM,CAAC,MAAM,CAClB;YACE,GAAG,EAAE,EAAE;YACP,QAAQ,EAAE,EAAE;YACZ,SAAS,EAAE,EAAE;SACd,EACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,CAAC,CAClC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW,CAAC,WAAkC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;QAChC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEjF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;YAC/C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;CACF;AArCD,gDAqCC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InjectablePropertyType = void 0;
|
|
4
|
-
var InjectablePropertyType;
|
|
5
|
-
(function (InjectablePropertyType) {
|
|
6
|
-
InjectablePropertyType["METHOD"] = "method";
|
|
7
|
-
InjectablePropertyType["PROPERTY"] = "property";
|
|
8
|
-
InjectablePropertyType["CONSTANT"] = "constant";
|
|
9
|
-
InjectablePropertyType["VALUE"] = "value";
|
|
10
|
-
InjectablePropertyType["INTERCEPTOR"] = "interceptor";
|
|
11
|
-
})(InjectablePropertyType = exports.InjectablePropertyType || (exports.InjectablePropertyType = {}));
|
|
12
|
-
//# sourceMappingURL=InjectablePropertyType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InjectablePropertyType.js","sourceRoot":"","sources":["../../../../src/common/domain/InjectablePropertyType.ts"],"names":[],"mappings":";;;AAAA,IAAY,sBAMX;AAND,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,+CAAqB,CAAA;IACrB,+CAAqB,CAAA;IACrB,yCAAe,CAAA;IACf,qDAA2B,CAAA;AAC7B,CAAC,EANW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAMjC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LocalsContainer = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
class LocalsContainer extends Map {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
this.hooks = new core_1.Hooks();
|
|
9
|
-
}
|
|
10
|
-
async destroy() {
|
|
11
|
-
await this.hooks.asyncEmit("$onDestroy");
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.LocalsContainer = LocalsContainer;
|
|
15
|
-
//# sourceMappingURL=LocalsContainer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalsContainer.js","sourceRoot":"","sources":["../../../../src/common/domain/LocalsContainer.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAGjC,MAAa,eAAgB,SAAQ,GAAuB;IAA5D;;QACW,UAAK,GAAG,IAAI,YAAK,EAAE,CAAC;IAK/B,CAAC;IAHC,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAC3C,CAAC;CACF;AAND,0CAMC"}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Provider = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const ProviderScope_js_1 = require("./ProviderScope.js");
|
|
6
|
-
const ProviderType_js_1 = require("./ProviderType.js");
|
|
7
|
-
class Provider {
|
|
8
|
-
constructor(token, options = {}) {
|
|
9
|
-
/**
|
|
10
|
-
* Token group provider to retrieve all provider from the same type
|
|
11
|
-
*/
|
|
12
|
-
this.type = ProviderType_js_1.ProviderType.PROVIDER;
|
|
13
|
-
this.provide = token;
|
|
14
|
-
this.useClass = token;
|
|
15
|
-
Object.assign(this, options);
|
|
16
|
-
}
|
|
17
|
-
get token() {
|
|
18
|
-
return this._provide;
|
|
19
|
-
}
|
|
20
|
-
get provide() {
|
|
21
|
-
return this._provide;
|
|
22
|
-
}
|
|
23
|
-
set provide(value) {
|
|
24
|
-
if (value) {
|
|
25
|
-
this._provide = (0, core_1.getClassOrSymbol)(value);
|
|
26
|
-
this._tokenStore = this._store = core_1.Store.from(value);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
get useClass() {
|
|
30
|
-
return this._useClass;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Create a new store if the given value is a class. Otherwise, the value is ignored.
|
|
34
|
-
* @param value
|
|
35
|
-
*/
|
|
36
|
-
set useClass(value) {
|
|
37
|
-
if ((0, core_1.isClass)(value)) {
|
|
38
|
-
this._useClass = (0, core_1.classOf)(value);
|
|
39
|
-
this._store = core_1.Store.from(value);
|
|
40
|
-
this.hooks = (0, core_1.methodsOf)(this._useClass).reduce((hooks, { propertyKey }) => {
|
|
41
|
-
if (String(propertyKey).startsWith("$")) {
|
|
42
|
-
return {
|
|
43
|
-
...hooks,
|
|
44
|
-
[propertyKey]: (instance, ...args) => instance[propertyKey](...args)
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return hooks;
|
|
48
|
-
}, {});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
get className() {
|
|
52
|
-
return this.name;
|
|
53
|
-
}
|
|
54
|
-
get name() {
|
|
55
|
-
return (0, core_1.nameOf)(this.provide);
|
|
56
|
-
}
|
|
57
|
-
get store() {
|
|
58
|
-
return this._store;
|
|
59
|
-
}
|
|
60
|
-
get path() {
|
|
61
|
-
return this.store.get("path", "/");
|
|
62
|
-
}
|
|
63
|
-
set path(path) {
|
|
64
|
-
this.store.set("path", path);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Get the scope of the provider.
|
|
68
|
-
*
|
|
69
|
-
* ::: tip Note
|
|
70
|
-
* Async provider is always a SINGLETON
|
|
71
|
-
* :::
|
|
72
|
-
*
|
|
73
|
-
* @returns {boolean}
|
|
74
|
-
*/
|
|
75
|
-
get scope() {
|
|
76
|
-
if (this.isAsync()) {
|
|
77
|
-
return ProviderScope_js_1.ProviderScope.SINGLETON;
|
|
78
|
-
}
|
|
79
|
-
return this.get("scope");
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Change the scope value of the provider.
|
|
83
|
-
* @param scope
|
|
84
|
-
*/
|
|
85
|
-
set scope(scope) {
|
|
86
|
-
this.store.set("scope", scope);
|
|
87
|
-
}
|
|
88
|
-
get configuration() {
|
|
89
|
-
return this.get("configuration");
|
|
90
|
-
}
|
|
91
|
-
set configuration(configuration) {
|
|
92
|
-
this.store.set("configuration", configuration);
|
|
93
|
-
}
|
|
94
|
-
get children() {
|
|
95
|
-
return this.store.get("childrenControllers", []);
|
|
96
|
-
}
|
|
97
|
-
get(key) {
|
|
98
|
-
return this.store.get(key) || this._tokenStore.get(key);
|
|
99
|
-
}
|
|
100
|
-
isAsync() {
|
|
101
|
-
return !!this.useAsyncFactory;
|
|
102
|
-
}
|
|
103
|
-
clone() {
|
|
104
|
-
return new ((0, core_1.classOf)(this))(this._provide, this);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
*
|
|
108
|
-
* @returns {boolean}
|
|
109
|
-
*/
|
|
110
|
-
hasChildren() {
|
|
111
|
-
return !!this.children.length;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
*
|
|
115
|
-
* @returns {boolean}
|
|
116
|
-
*/
|
|
117
|
-
hasParent() {
|
|
118
|
-
return !!this.store.get("parentController");
|
|
119
|
-
}
|
|
120
|
-
toString() {
|
|
121
|
-
return [
|
|
122
|
-
"Token",
|
|
123
|
-
this.name,
|
|
124
|
-
this.useClass && (0, core_1.nameOf)(this.useClass),
|
|
125
|
-
this.useFactory && "Factory",
|
|
126
|
-
this.useValue && "Value",
|
|
127
|
-
this.useAsyncFactory && "AsyncFactory"
|
|
128
|
-
]
|
|
129
|
-
.filter(Boolean)
|
|
130
|
-
.join(":");
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
exports.Provider = Provider;
|
|
134
|
-
//# sourceMappingURL=Provider.js.map
|