@tsed/di 8.0.0-alpha.5 → 8.0.0-alpha.7
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.map +1 -1
- 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.map +1 -1
- 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/domain/ContextLogger.d.ts +1 -1
- package/lib/types/node/utils/asyncHookContext.d.ts +1 -1
- package/package.json +13 -14
- 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 -43
- 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 -16
- 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 -15
- 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
package/vitest.config.mts
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DI_INTERCEPTOR_OPTIONS = exports.DI_USE_PARAM_OPTIONS = exports.DI_USE_OPTIONS = exports.DI_INJECTABLE_PROPS = exports.DI_INVOKE_OPTIONS = void 0;
|
|
4
|
-
exports.DI_INVOKE_OPTIONS = Symbol("DI_INVOKE_OPTIONS");
|
|
5
|
-
exports.DI_INJECTABLE_PROPS = Symbol("DI_INJECTABLE_PROPS");
|
|
6
|
-
exports.DI_USE_OPTIONS = "DI_USE_OPTIONS";
|
|
7
|
-
exports.DI_USE_PARAM_OPTIONS = "DI_USE_PARAM_OPTIONS";
|
|
8
|
-
exports.DI_INTERCEPTOR_OPTIONS = "DI_INTERCEPTOR_OPTIONS";
|
|
9
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/common/constants/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAChD,QAAA,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AACpD,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAClC,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,sBAAsB,GAAG,wBAAwB,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AutoInjectable = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const LocalsContainer_js_1 = require("../domain/LocalsContainer.js");
|
|
6
|
-
const InjectorService_js_1 = require("../services/InjectorService.js");
|
|
7
|
-
const getConstructorDependencies_js_1 = require("../utils/getConstructorDependencies.js");
|
|
8
|
-
function resolveAutoInjectableArgs(token, args) {
|
|
9
|
-
const locals = new LocalsContainer_js_1.LocalsContainer();
|
|
10
|
-
const injector = InjectorService_js_1.InjectorService.getInstance();
|
|
11
|
-
const deps = (0, getConstructorDependencies_js_1.getConstructorDependencies)(token);
|
|
12
|
-
const list = [];
|
|
13
|
-
const length = Math.max(deps.length, args.length);
|
|
14
|
-
for (let i = 0; i < length; i++) {
|
|
15
|
-
if (args[i] !== undefined) {
|
|
16
|
-
list.push(args[i]);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
const value = deps[i];
|
|
20
|
-
const instance = (0, core_1.isArray)(value)
|
|
21
|
-
? injector.getMany(value[0], locals, { parent: token })
|
|
22
|
-
: injector.invoke(value, locals, { parent: token });
|
|
23
|
-
list.push(instance);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return list;
|
|
27
|
-
}
|
|
28
|
-
function AutoInjectable() {
|
|
29
|
-
return (constr) => {
|
|
30
|
-
return class AutoInjectable extends constr {
|
|
31
|
-
constructor(...args) {
|
|
32
|
-
super(...resolveAutoInjectableArgs(constr, args));
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
exports.AutoInjectable = AutoInjectable;
|
|
38
|
-
//# sourceMappingURL=autoInjectable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"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AAM;YACxC,YAAY,GAAG,IAAW;gBACxB,KAAK,CAAC,GAAG,yBAAyB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;YACpD,CAAC;SACc,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AARD,wCAQC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Configuration = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const inject_js_1 = require("./inject.js");
|
|
6
|
-
/**
|
|
7
|
-
* Get or set Configuration on a class.
|
|
8
|
-
*
|
|
9
|
-
* @decorator
|
|
10
|
-
*/
|
|
11
|
-
function Configuration(configuration = {}) {
|
|
12
|
-
return (...args) => {
|
|
13
|
-
switch ((0, core_1.decoratorTypeOf)(args)) {
|
|
14
|
-
case core_1.DecoratorTypes.CLASS:
|
|
15
|
-
(0, core_1.StoreSet)("configuration", configuration)(args[0]);
|
|
16
|
-
break;
|
|
17
|
-
default:
|
|
18
|
-
case core_1.DecoratorTypes.PARAM_CTOR:
|
|
19
|
-
return (0, inject_js_1.Inject)(Configuration)(args[0], args[1], args[2]);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
exports.Configuration = Configuration;
|
|
24
|
-
//# sourceMappingURL=configuration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../../src/common/decorators/configuration.ts"],"names":[],"mappings":";;;AAAA,qCAA0F;AAC1F,2CAAmC;AAGnC;;;;GAIG;AACH,SAAgB,aAAa,CAAC,gBAA6C,EAAE;IAC3E,OAAO,CAAC,GAAG,IAAyB,EAAE,EAAE;QACtC,QAAQ,IAAA,sBAAe,EAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,qBAAc,CAAC,KAAK;gBACvB,IAAA,eAAQ,EAAC,eAAe,EAAE,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAElD,MAAM;YACR,QAAQ;YACR,KAAK,qBAAc,CAAC,UAAU;gBAC5B,OAAO,IAAA,kBAAM,EAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAW,CAAC,CAAC;SACrE;IACH,CAAC,CAAC;AACJ,CAAC;AAZD,sCAYC"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Constant = exports.bindConstant = exports.constant = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const InjectorService_js_1 = require("../services/InjectorService.js");
|
|
6
|
-
function constant(expression, defaultValue) {
|
|
7
|
-
return InjectorService_js_1.InjectorService.getInstance().settings.get(expression, defaultValue);
|
|
8
|
-
}
|
|
9
|
-
exports.constant = constant;
|
|
10
|
-
function bindConstant(target, propertyKey, expression, defaultValue) {
|
|
11
|
-
const symbol = Symbol();
|
|
12
|
-
(0, core_1.catchError)(() => Reflect.deleteProperty(target, propertyKey));
|
|
13
|
-
Reflect.defineProperty(target, propertyKey, {
|
|
14
|
-
get() {
|
|
15
|
-
if (this[symbol] !== undefined) {
|
|
16
|
-
return this[symbol];
|
|
17
|
-
}
|
|
18
|
-
const value = constant(expression, defaultValue);
|
|
19
|
-
this[symbol] = Object.freeze((0, core_1.deepClone)(value));
|
|
20
|
-
return this[symbol];
|
|
21
|
-
},
|
|
22
|
-
set(value) {
|
|
23
|
-
const bean = constant(expression, defaultValue) || this[symbol];
|
|
24
|
-
if (bean === undefined && value !== undefined) {
|
|
25
|
-
this[symbol] = value;
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
enumerable: true,
|
|
29
|
-
configurable: true
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
exports.bindConstant = bindConstant;
|
|
33
|
-
/**
|
|
34
|
-
* Return value from Configuration.
|
|
35
|
-
*
|
|
36
|
-
* ## Example
|
|
37
|
-
*
|
|
38
|
-
* ```typescript
|
|
39
|
-
* import {Env} from "@tsed/core";
|
|
40
|
-
* import {Constant, Value} from "@tsed/di";
|
|
41
|
-
*
|
|
42
|
-
* export class MyClass {
|
|
43
|
-
*
|
|
44
|
-
* @Constant("env")
|
|
45
|
-
* env: Env;
|
|
46
|
-
*
|
|
47
|
-
* @Value("swagger.path")
|
|
48
|
-
* swaggerPath: string;
|
|
49
|
-
*
|
|
50
|
-
* @Value("swagger.path", "defaultValue")
|
|
51
|
-
* swaggerPath: string;
|
|
52
|
-
*
|
|
53
|
-
* constructor() {
|
|
54
|
-
* console.log(this.swaggerPath) // undefined. Not available on constructor
|
|
55
|
-
* }
|
|
56
|
-
*
|
|
57
|
-
* $onInit() {
|
|
58
|
-
* console.log(this.swaggerPath) // something
|
|
59
|
-
* }
|
|
60
|
-
* }
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* @param {string} expression
|
|
64
|
-
* @param defaultValue
|
|
65
|
-
* @returns {(targetClass: any, attributeName: string) => any}
|
|
66
|
-
* @decorator
|
|
67
|
-
*/
|
|
68
|
-
function Constant(expression, defaultValue) {
|
|
69
|
-
return (target, propertyKey) => {
|
|
70
|
-
return bindConstant(target, propertyKey, expression, defaultValue);
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
exports.Constant = Constant;
|
|
74
|
-
//# sourceMappingURL=constant.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../../src/common/decorators/constant.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AACjD,uEAA+D;AAI/D,SAAgB,QAAQ,CAAO,UAAkB,EAAE,YAA+B;IAChF,OAAO,oCAAe,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,C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AACJ,CAAC;AAJD,4BAIC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Controller = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const schema_1 = require("@tsed/schema");
|
|
6
|
-
const ProviderRegistry_js_1 = require("../registries/ProviderRegistry.js");
|
|
7
|
-
function mapOptions(options) {
|
|
8
|
-
if (typeof options === "string" || options instanceof RegExp || (0, core_1.isArrayOrArrayClass)(options)) {
|
|
9
|
-
return {
|
|
10
|
-
path: options
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
return options;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Declare a new controller with his Rest path. His methods annotated will be collected to build the routing list.
|
|
17
|
-
* This routing listing will be built with the `express.Router` object.
|
|
18
|
-
*
|
|
19
|
-
* ::: tip
|
|
20
|
-
* See [Controllers](/docs/controllers.md) section for more details
|
|
21
|
-
* :::
|
|
22
|
-
*
|
|
23
|
-
* ```typescript
|
|
24
|
-
* @Controller("/calendars")
|
|
25
|
-
* export provide CalendarCtrl {
|
|
26
|
-
*
|
|
27
|
-
* @Get("/:id")
|
|
28
|
-
* public get(
|
|
29
|
-
* @Req() request: Req,
|
|
30
|
-
* @Res() response: Res,
|
|
31
|
-
* @Next() next: Next
|
|
32
|
-
* ): void {
|
|
33
|
-
*
|
|
34
|
-
* }
|
|
35
|
-
* }
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* @param options
|
|
39
|
-
* @controller
|
|
40
|
-
* @decorator
|
|
41
|
-
* @classDecorator
|
|
42
|
-
*/
|
|
43
|
-
function Controller(options) {
|
|
44
|
-
const { children = [], path, ...opts } = mapOptions(options);
|
|
45
|
-
return (0, core_1.useDecorators)((target) => {
|
|
46
|
-
(0, ProviderRegistry_js_1.registerController)({
|
|
47
|
-
provide: target,
|
|
48
|
-
...opts
|
|
49
|
-
});
|
|
50
|
-
}, path && (0, schema_1.Path)(path), (0, schema_1.Children)(...children));
|
|
51
|
-
}
|
|
52
|
-
exports.Controller = Controller;
|
|
53
|
-
//# sourceMappingURL=controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../src/common/decorators/controller.ts"],"names":[],"mappings":";;;AAAA,qCAAoE;AACpE,yCAA4C;AAE5C,2EAAqE;AAgBrE,SAAS,UAAU,CAAC,OAAY;IAC9B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,YAAY,MAAM,IAAI,IAAA,0BAAmB,EAAC,OAAO,CAAC,EAAE;QAC5F,OAAO;YACL,IAAI,EAAE,OAAO;SACd,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,UAAU,CAAC,OAAqC;IAC9D,MAAM,EAAC,QAAQ,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,IAAI,EAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAE3D,OAAO,IAAA,oBAAa,EAClB,CAAC,MAAY,EAAE,EAAE;QACf,IAAA,wCAAkB,EAAC;YACjB,OAAO,EAAE,MAAM;YACf,GAAG,IAAI;SACR,CAAC,CAAC;IACL,CAAC,EACD,IAAI,IAAI,IAAA,aAAI,EAAC,IAAW,CAAC,EACzB,IAAA,iBAAQ,EAAC,GAAG,QAAQ,CAAC,CACtB,CAAC;AACJ,CAAC;AAbD,gCAaC"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Inject = exports.injectMany = exports.inject = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const constants_js_1 = require("../constants/constants.js");
|
|
6
|
-
const InvalidPropertyTokenError_js_1 = require("../errors/InvalidPropertyTokenError.js");
|
|
7
|
-
const InjectorService_js_1 = require("../services/InjectorService.js");
|
|
8
|
-
const getConstructorDependencies_js_1 = require("../utils/getConstructorDependencies.js");
|
|
9
|
-
function inject(token, opts) {
|
|
10
|
-
return InjectorService_js_1.InjectorService.getInstance().invoke(token, opts?.locals || InjectorService_js_1.InjectorService.getLocals(), opts);
|
|
11
|
-
}
|
|
12
|
-
exports.inject = inject;
|
|
13
|
-
function injectMany(token, opts) {
|
|
14
|
-
return InjectorService_js_1.InjectorService.getInstance().getMany(token, opts?.locals || InjectorService_js_1.InjectorService.getLocals(), opts);
|
|
15
|
-
}
|
|
16
|
-
exports.injectMany = injectMany;
|
|
17
|
-
function setToken(token, { target, propertyKey, parameterIndex }) {
|
|
18
|
-
const paramTypes = (0, getConstructorDependencies_js_1.getConstructorDependencies)(target, propertyKey);
|
|
19
|
-
const type = paramTypes[parameterIndex];
|
|
20
|
-
paramTypes[parameterIndex] = type === Array ? [token] : token;
|
|
21
|
-
core_1.Metadata.setParamTypes(target, propertyKey, paramTypes);
|
|
22
|
-
(0, getConstructorDependencies_js_1.setConstructorDependencies)(target, paramTypes);
|
|
23
|
-
}
|
|
24
|
-
function getTokenType(token, target, propertyKey) {
|
|
25
|
-
const useType = token || core_1.Metadata.getType(target, propertyKey);
|
|
26
|
-
if (useType === Object) {
|
|
27
|
-
throw new InvalidPropertyTokenError_js_1.InvalidPropertyTokenError(target, String(propertyKey));
|
|
28
|
-
}
|
|
29
|
-
return useType;
|
|
30
|
-
}
|
|
31
|
-
function bindInjectableProperty(target, propertyKey, { token, transform = (o) => o, useOpts }) {
|
|
32
|
-
const symbol = Symbol();
|
|
33
|
-
if (!target[constants_js_1.DI_INJECTABLE_PROPS]) {
|
|
34
|
-
Reflect.defineProperty(target, constants_js_1.DI_INJECTABLE_PROPS, {
|
|
35
|
-
value: new Set(),
|
|
36
|
-
enumerable: false,
|
|
37
|
-
configurable: false
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
target[constants_js_1.DI_INJECTABLE_PROPS].add(propertyKey);
|
|
41
|
-
(0, core_1.catchError)(() => Reflect.deleteProperty(target, propertyKey));
|
|
42
|
-
Reflect.defineProperty(target, propertyKey, {
|
|
43
|
-
get() {
|
|
44
|
-
const useType = getTokenType(token, target, propertyKey);
|
|
45
|
-
const originalType = core_1.Metadata.getType(target, propertyKey);
|
|
46
|
-
const invokeOpts = {
|
|
47
|
-
rebuild: !!this[constants_js_1.DI_INVOKE_OPTIONS]?.rebuild,
|
|
48
|
-
locals: this[constants_js_1.DI_INVOKE_OPTIONS]?.locals,
|
|
49
|
-
useOpts: useOpts || core_1.Store.from(target, propertyKey).get(constants_js_1.DI_USE_OPTIONS)
|
|
50
|
-
};
|
|
51
|
-
if (this[symbol] === undefined) {
|
|
52
|
-
this[symbol] = originalType === Array ? injectMany(token, invokeOpts) : inject(useType, invokeOpts);
|
|
53
|
-
}
|
|
54
|
-
[].concat(this[symbol]).forEach((instance, index) => {
|
|
55
|
-
if ((0, core_1.isPromise)(this[symbol])) {
|
|
56
|
-
instance.then((result) => {
|
|
57
|
-
this[symbol][index] = result;
|
|
58
|
-
if (originalType !== Array) {
|
|
59
|
-
this[symbol] = result;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
return transform(this[symbol], { self: this, target, propertyKey });
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
function Inject(token, opts = {}) {
|
|
69
|
-
opts = typeof opts === "function" ? { transform: opts } : opts;
|
|
70
|
-
return (target, propertyKey, index) => {
|
|
71
|
-
const bindingType = (0, core_1.decoratorTypeOf)([target, propertyKey, index]);
|
|
72
|
-
switch (bindingType) {
|
|
73
|
-
case core_1.DecoratorTypes.PARAM_CTOR:
|
|
74
|
-
if (token) {
|
|
75
|
-
setToken(token, { target, propertyKey, parameterIndex: index });
|
|
76
|
-
}
|
|
77
|
-
break;
|
|
78
|
-
case core_1.DecoratorTypes.PROP:
|
|
79
|
-
bindInjectableProperty(target, propertyKey, { ...opts, token });
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
exports.Inject = Inject;
|
|
84
|
-
//# sourceMappingURL=inject.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../../src/common/decorators/inject.ts"],"names":[],"mappings":";;;AAAA,qCAA8G;AAC9G,4DAAiG;AACjG,yFAAiF;AAGjF,uEAA+D;AAC/D,0FAA8G;AAE9G,SAAgB,MAAM,CAAI,KAAuB,EAAE,IAAqE;IACtH,OAAO,oCAAe,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,oCAAe,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,CAAC;AACxG,CAAC;AAFD,wBAEC;AAED,SAAgB,UAAU,CAAI,KAAsB,EAAE,IAAqE;IACzH,OAAO,oCAAe,CAAC,WAAW,EAAE,CAAC,OAAO,CAAI,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,oCAAe,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,CAAC;AAC5G,CAAC;AAFD,gCAEC;AAED,SAAS,QAAQ,CACf,KAAoB,EACpB,EACE,MAAM,EACN,WAAW,EACX,cAAc,EAKf;IAED,MAAM,UAAU,GAAG,IAAA,0DAA0B,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnE,MAAM,IAAI,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAExC,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAE9D,eAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,WAAY,EAAE,UAAU,CAAC,CAAC;IACzD,IAAA,0DAA0B,EAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AACjD,CAAC;AAED,SAAS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AAM,WAAW,GAAG,IAAA,sBAAe,EAAC,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;QAElE,QAAQ,WAAW,EAAE;YACnB,KAAK,qBAAc,CAAC,UAAU;gBAC5B,IAAI,KAAK,EAAE;oBACT,QAAQ,CAAC,KAAK,EAAE,EAAC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,KAAM,EAAC,CAAC,CAAC;iBAChE;gBACD,MAAM;YACR,KAAK,qBAAc,CAAC,IAAI;gBACtB,sBAAsB,CAAC,MAAM,EAAE,WAAY,EAAE,EAAC,GAAG,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC;SAClE;IACH,CAAC,CAAC;AACJ,CAAC;AAnBD,wBAmBC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Injectable = void 0;
|
|
4
|
-
const ProviderRegistry_js_1 = require("../registries/ProviderRegistry.js");
|
|
5
|
-
/**
|
|
6
|
-
* The decorators `@Injectable()` declare a new service can be injected in other service, controller, interceptor, etc.. on there `constructor`.
|
|
7
|
-
* All classes annotated with `@Injectable()` are built one time, excepted if you change the default provider configuration.
|
|
8
|
-
*
|
|
9
|
-
* ::: tip
|
|
10
|
-
* `@Injectable()` use the `reflect-metadata` to collect and inject the built provided to other services.
|
|
11
|
-
* :::
|
|
12
|
-
*
|
|
13
|
-
* ### Options
|
|
14
|
-
*
|
|
15
|
-
* - type (@@ProviderType@@ or `string`): Kind of provider. (Default: `ProviderType.PROVIDER`)
|
|
16
|
-
* - scope (@@ProviderScope@@): Kind of provider. (Default: `ProviderScope.SINGLETON`)
|
|
17
|
-
* - provide (@@TokenProvider@@): An injection token (Note: This option override default metadata generated by Typescript).
|
|
18
|
-
* - deps (`Type<any>`): List of class or provider which will be injected to the constructor (Note: This options override default metadata generated by Typescript).
|
|
19
|
-
*
|
|
20
|
-
* @returns {Function}
|
|
21
|
-
* @decorator
|
|
22
|
-
*/
|
|
23
|
-
function Injectable(options = {}) {
|
|
24
|
-
return (target) => {
|
|
25
|
-
(0, ProviderRegistry_js_1.registerProvider)({
|
|
26
|
-
...options,
|
|
27
|
-
...(options.provide ? { useClass: target } : { provide: target })
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
exports.Injectable = Injectable;
|
|
32
|
-
//# sourceMappingURL=injectable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"injectable.js","sourceRoot":"","sources":["../../../../src/common/decorators/injectable.ts"],"names":[],"mappings":";;;AACA,2EAAmE;AAEnE;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,UAAU,CAAC,UAAiC,EAAE;IAC5D,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,sCAAgB,EAAC;YACf,GAAG,OAAO;YACV,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC,CAAC,CAAC,EAAC,OAAO,EAAE,MAAM,EAAC,CAAC;SAC9D,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAPD,gCAOC"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Intercept = exports.bindIntercept = exports.getInterceptorOptions = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const constants_js_1 = require("../constants/constants.js");
|
|
6
|
-
const inject_js_1 = require("./inject.js");
|
|
7
|
-
function getInterceptorOptions(target, propertyKey) {
|
|
8
|
-
return core_1.Store.fromMethod(target, propertyKey).get(constants_js_1.DI_INTERCEPTOR_OPTIONS);
|
|
9
|
-
}
|
|
10
|
-
exports.getInterceptorOptions = getInterceptorOptions;
|
|
11
|
-
function bindIntercept(target, propertyKey, token, options) {
|
|
12
|
-
const klass = (0, core_1.classOf)(target);
|
|
13
|
-
const descriptor = Reflect.getOwnPropertyDescriptor(klass.prototype, propertyKey);
|
|
14
|
-
const originalMethod = descriptor.value;
|
|
15
|
-
const symbol = Symbol();
|
|
16
|
-
core_1.Store.fromMethod(klass, propertyKey).set(constants_js_1.DI_INTERCEPTOR_OPTIONS, options);
|
|
17
|
-
descriptor.value = function (...args) {
|
|
18
|
-
const next = (err) => {
|
|
19
|
-
if (!err) {
|
|
20
|
-
return originalMethod.apply(this, args);
|
|
21
|
-
}
|
|
22
|
-
throw err;
|
|
23
|
-
};
|
|
24
|
-
const context = {
|
|
25
|
-
target,
|
|
26
|
-
propertyKey,
|
|
27
|
-
args,
|
|
28
|
-
options,
|
|
29
|
-
next
|
|
30
|
-
};
|
|
31
|
-
const invokeOpts = {
|
|
32
|
-
rebuild: !!this[constants_js_1.DI_INVOKE_OPTIONS]?.rebuild,
|
|
33
|
-
locals: this[constants_js_1.DI_INVOKE_OPTIONS]?.locals
|
|
34
|
-
};
|
|
35
|
-
this[symbol] = this[symbol] || (0, inject_js_1.inject)(token, invokeOpts);
|
|
36
|
-
return this[symbol].intercept({
|
|
37
|
-
...context,
|
|
38
|
-
options
|
|
39
|
-
}, next);
|
|
40
|
-
};
|
|
41
|
-
return descriptor;
|
|
42
|
-
}
|
|
43
|
-
exports.bindIntercept = bindIntercept;
|
|
44
|
-
/**
|
|
45
|
-
* Attaches interceptor to method call and executes the before and after methods
|
|
46
|
-
*
|
|
47
|
-
* @param interceptor
|
|
48
|
-
* @param options
|
|
49
|
-
* @decorator
|
|
50
|
-
*/
|
|
51
|
-
function Intercept(interceptor, options) {
|
|
52
|
-
return (...args) => {
|
|
53
|
-
const [target, propertyKey] = args;
|
|
54
|
-
const type = (0, core_1.decoratorTypeOf)(args);
|
|
55
|
-
switch (type) {
|
|
56
|
-
case core_1.DecoratorTypes.CLASS:
|
|
57
|
-
(0, core_1.decorateMethodsOf)(target, Intercept(interceptor, options));
|
|
58
|
-
break;
|
|
59
|
-
case core_1.DecoratorTypes.METHOD:
|
|
60
|
-
return bindIntercept(target, propertyKey, interceptor, options);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
exports.Intercept = Intercept;
|
|
65
|
-
//# sourceMappingURL=intercept.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intercept.js","sourceRoot":"","sources":["../../../../src/common/decorators/intercept.ts"],"names":[],"mappings":";;;AAAA,qCAAyH;AACzH,4DAAoF;AAKpF,2CAAmC;AAEnC,SAAgB,qBAAqB,CAAI,MAAiB,EAAE,WAA4B;IACtF,OAAO,YAAK,CAAC,UAAU,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,GAAG,CAAC,qCAAsB,CAAM,CAAC;AAChF,CAAC;AAFD,sDAEC;AAED,SAAgB,aAAa,CAAC,MAAW,EAAE,WAA4B,EAAE,KAAoB,EAAE,OAAgC;IAC7H,MAAM,KAAK,GAAG,IAAA,cAAO,EAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,UAAU,GAAG,OAAO,CAAC,wBAAwB,CAAC,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAClF,MAAM,cAAc,GAAG,UAAW,CAAC,KAAK,CAAC;IACzC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;IAExB,YAAK,CAAC,UAAU,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,GAAG,CAAC,qCAAsB,EAAE,OAAO,CAAC,CAAC;IAE1E,UAAW,CAAC,KAAK,GAAG,UAAU,GAAG,IAAW;QAC1C,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,EAAE;YAC3B,IAAI,CAAC,GAAG,EAAE;gBACR,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aACzC;YAED,MAAM,GAAG,CAAC;QACZ,CAAC,CAAC;QAEF,MAAM,OAAO,GAA4B;YACvC,MAAM;YACN,WAAW;YACX,IAAI;YACJ,OAAO;YACP,IAAI;SACL,CAAC;QAEF,MAAM,UAAU,GAA2B;YACzC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,gCAAiB,CAAC,EAAE,OAAO;YAC3C,MAAM,EAAE,IAAI,CAAC,gCAAiB,CAAC,EAAE,MAAM;SACxC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,IAAA,kBAAM,EAAC,KAAK,EAAE,UAAU,CAAE,CAAC;QAE1D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,SAAU,CAC5B;YACE,GAAG,OAAO;YACV,OAAO;SACR,EACD,IAAI,CACL,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,UAAU,CAAC;AACpB,CAAC;AA1CD,sCA0CC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CAA+B,WAAoB,EAAE,OAAa;IACzF,OAAO,CAAC,GAAG,IAAyB,EAAE,EAAE;QACtC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC;QACnC,MAAM,IAAI,GAAG,IAAA,sBAAe,EAAC,IAAI,CAAC,CAAC;QACnC,QAAQ,IAAI,EAAE;YACZ,KAAK,qBAAc,CAAC,KAAK;gBACvB,IAAA,wBAAiB,EAAC,MAAM,EAAE,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;gBAC3D,MAAM;YACR,KAAK,qBAAc,CAAC,MAAM;gBACxB,OAAO,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;SACnE;IACH,CAAC,CAAC;AACJ,CAAC;AAZD,8BAYC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Interceptor = void 0;
|
|
4
|
-
const ProviderType_js_1 = require("../domain/ProviderType.js");
|
|
5
|
-
const injectable_js_1 = require("./injectable.js");
|
|
6
|
-
/**
|
|
7
|
-
* The decorators `@Service()` declare a new service can be injected in other service or controller on there `constructor`.
|
|
8
|
-
* All services annotated with `@Service()` are constructed one time.
|
|
9
|
-
*
|
|
10
|
-
* > `@Service()` use the `reflect-metadata` to collect and inject service on controllers or other services.
|
|
11
|
-
*
|
|
12
|
-
* @returns {Function}
|
|
13
|
-
* @decorator
|
|
14
|
-
*/
|
|
15
|
-
function Interceptor() {
|
|
16
|
-
return (0, injectable_js_1.Injectable)({
|
|
17
|
-
type: ProviderType_js_1.ProviderType.INTERCEPTOR
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
exports.Interceptor = Interceptor;
|
|
21
|
-
//# sourceMappingURL=interceptor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interceptor.js","sourceRoot":"","sources":["../../../../src/common/decorators/interceptor.ts"],"names":[],"mappings":";;;AAAA,+DAAuD;AACvD,mDAA2C;AAE3C;;;;;;;;GAQG;AACH,SAAgB,WAAW;IACzB,OAAO,IAAA,0BAAU,EAAC;QAChB,IAAI,EAAE,8BAAY,CAAC,WAAW;KAC/B,CAAC,CAAC;AACL,CAAC;AAJD,kCAIC"}
|
|
@@ -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"}
|