@tsed/di 7.0.0-beta.8 → 7.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/coverage.json +6 -0
- package/jest.config.js +9 -0
- package/lib/cjs/decorators/controller.js.map +1 -1
- package/lib/cjs/decorators/inject.js +7 -3
- package/lib/cjs/decorators/inject.js.map +1 -1
- package/lib/cjs/domain/Container.js +1 -2
- package/lib/cjs/domain/Container.js.map +1 -1
- package/lib/cjs/domain/ContextLogger.js +41 -30
- package/lib/cjs/domain/ContextLogger.js.map +1 -1
- package/lib/cjs/domain/ControllerProvider.js +37 -0
- package/lib/cjs/domain/ControllerProvider.js.map +1 -0
- package/lib/cjs/domain/DIContext.js +86 -30
- package/lib/cjs/domain/DIContext.js.map +1 -1
- package/lib/cjs/domain/LocalsContainer.js +3 -46
- package/lib/cjs/domain/LocalsContainer.js.map +1 -1
- package/lib/cjs/domain/Provider.js +20 -1
- package/lib/cjs/domain/Provider.js.map +1 -1
- package/lib/cjs/errors/InjectionError.js +3 -2
- package/lib/cjs/errors/InjectionError.js.map +1 -1
- package/lib/cjs/errors/InvalidPropertyTokenError.js +12 -0
- package/lib/cjs/errors/InvalidPropertyTokenError.js.map +1 -0
- package/lib/cjs/errors/UndefinedTokenError.js +1 -1
- package/lib/cjs/errors/UndefinedTokenError.js.map +1 -1
- package/lib/cjs/index.js +9 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/AlterRunInContext.js +3 -0
- package/lib/cjs/interfaces/AlterRunInContext.js.map +1 -0
- package/lib/cjs/interfaces/DIConfigurationOptions.js.map +1 -1
- package/lib/cjs/interfaces/DILoggerOptions.js +3 -0
- package/lib/cjs/interfaces/DILoggerOptions.js.map +1 -0
- package/lib/cjs/interfaces/InjectableProperties.js.map +1 -1
- package/lib/cjs/interfaces/InterceptorMethods.js.map +1 -1
- package/lib/cjs/interfaces/TokenProvider.js.map +1 -1
- package/lib/cjs/interfaces/TokenRoute.js +3 -0
- package/lib/cjs/interfaces/TokenRoute.js.map +1 -0
- package/lib/cjs/registries/GlobalProviders.js +7 -12
- package/lib/cjs/registries/GlobalProviders.js.map +1 -1
- package/lib/cjs/registries/ProviderRegistry.js +1 -1
- package/lib/cjs/registries/ProviderRegistry.js.map +1 -1
- package/lib/cjs/services/DIConfiguration.js +56 -43
- package/lib/cjs/services/DIConfiguration.js.map +1 -1
- package/lib/cjs/services/DITest.js +5 -6
- package/lib/cjs/services/DITest.js.map +1 -1
- package/lib/cjs/services/InjectorService.js +94 -92
- package/lib/cjs/services/InjectorService.js.map +1 -1
- package/lib/cjs/utils/asyncHookContext.js +42 -0
- package/lib/cjs/utils/asyncHookContext.js.map +1 -0
- package/lib/cjs/utils/getConfiguration.js +13 -10
- package/lib/cjs/utils/getConfiguration.js.map +1 -1
- package/lib/cjs/utils/resolveControllers.js +47 -0
- package/lib/cjs/utils/resolveControllers.js.map +1 -0
- package/lib/cjs/utils/setLoggerConfiguration.js +11 -0
- package/lib/cjs/utils/setLoggerConfiguration.js.map +1 -0
- package/lib/cjs/utils/setLoggerFormat.js +33 -0
- package/lib/cjs/utils/setLoggerFormat.js.map +1 -0
- package/lib/cjs/utils/setLoggerLevel.js +1 -2
- package/lib/cjs/utils/setLoggerLevel.js.map +1 -1
- package/lib/esm/decorators/controller.js.map +1 -1
- package/lib/esm/decorators/inject.js +6 -2
- package/lib/esm/decorators/inject.js.map +1 -1
- package/lib/esm/domain/Container.js +1 -2
- package/lib/esm/domain/Container.js.map +1 -1
- package/lib/esm/domain/ContextLogger.js +41 -30
- package/lib/esm/domain/ContextLogger.js.map +1 -1
- package/lib/esm/domain/ControllerProvider.js +33 -0
- package/lib/esm/domain/ControllerProvider.js.map +1 -0
- package/lib/esm/domain/DIContext.js +86 -30
- package/lib/esm/domain/DIContext.js.map +1 -1
- package/lib/esm/domain/LocalsContainer.js +3 -46
- package/lib/esm/domain/LocalsContainer.js.map +1 -1
- package/lib/esm/domain/Provider.js +21 -2
- package/lib/esm/domain/Provider.js.map +1 -1
- package/lib/esm/errors/InjectionError.js +3 -2
- package/lib/esm/errors/InjectionError.js.map +1 -1
- package/lib/esm/errors/InvalidPropertyTokenError.js +8 -0
- package/lib/esm/errors/InvalidPropertyTokenError.js.map +1 -0
- package/lib/esm/errors/UndefinedTokenError.js +1 -1
- package/lib/esm/errors/UndefinedTokenError.js.map +1 -1
- package/lib/esm/index.js +9 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/AlterRunInContext.js +2 -0
- package/lib/esm/interfaces/AlterRunInContext.js.map +1 -0
- package/lib/esm/interfaces/DIConfigurationOptions.js.map +1 -1
- package/lib/esm/interfaces/DILoggerOptions.js +2 -0
- package/lib/esm/interfaces/DILoggerOptions.js.map +1 -0
- package/lib/esm/interfaces/InjectableProperties.js.map +1 -1
- package/lib/esm/interfaces/InterceptorMethods.js.map +1 -1
- package/lib/esm/interfaces/TokenProvider.js.map +1 -1
- package/lib/esm/interfaces/TokenRoute.js +2 -0
- package/lib/esm/interfaces/TokenRoute.js.map +1 -0
- package/lib/esm/registries/GlobalProviders.js +7 -12
- package/lib/esm/registries/GlobalProviders.js.map +1 -1
- package/lib/esm/registries/ProviderRegistry.js +1 -1
- package/lib/esm/registries/ProviderRegistry.js.map +1 -1
- package/lib/esm/services/DIConfiguration.js +57 -44
- package/lib/esm/services/DIConfiguration.js.map +1 -1
- package/lib/esm/services/DITest.js +5 -6
- package/lib/esm/services/DITest.js.map +1 -1
- package/lib/esm/services/InjectorService.js +96 -94
- package/lib/esm/services/InjectorService.js.map +1 -1
- package/lib/esm/utils/asyncHookContext.js +33 -0
- package/lib/esm/utils/asyncHookContext.js.map +1 -0
- package/lib/esm/utils/getConfiguration.js +12 -10
- package/lib/esm/utils/getConfiguration.js.map +1 -1
- package/lib/esm/utils/resolveControllers.js +42 -0
- package/lib/esm/utils/resolveControllers.js.map +1 -0
- package/lib/esm/utils/setLoggerConfiguration.js +7 -0
- package/lib/esm/utils/setLoggerConfiguration.js.map +1 -0
- package/lib/esm/utils/setLoggerFormat.js +29 -0
- package/lib/esm/utils/setLoggerFormat.js.map +1 -0
- package/lib/esm/utils/setLoggerLevel.js +1 -2
- package/lib/esm/utils/setLoggerLevel.js.map +1 -1
- package/lib/types/decorators/controller.d.ts +0 -1
- package/lib/types/domain/ContextLogger.d.ts +13 -18
- package/lib/types/domain/ControllerProvider.d.ts +17 -0
- package/lib/types/domain/DIContext.d.ts +23 -29
- package/lib/types/domain/LocalsContainer.d.ts +3 -22
- package/lib/types/domain/Provider.d.ts +2 -1
- package/lib/types/errors/InvalidPropertyTokenError.d.ts +4 -0
- package/lib/types/index.d.ts +9 -1
- package/lib/types/interfaces/AlterRunInContext.d.ts +3 -0
- package/lib/types/interfaces/DIConfigurationOptions.d.ts +5 -2
- package/lib/types/interfaces/DILoggerOptions.d.ts +44 -0
- package/lib/types/interfaces/InjectableProperties.d.ts +2 -1
- package/lib/types/interfaces/InterceptorMethods.d.ts +1 -1
- package/lib/types/interfaces/TokenProvider.d.ts +1 -1
- package/lib/types/interfaces/TokenRoute.d.ts +5 -0
- package/lib/types/registries/GlobalProviders.d.ts +6 -5
- package/lib/types/registries/ProviderRegistry.d.ts +2 -1
- package/lib/types/services/DIConfiguration.d.ts +19 -11
- package/lib/types/services/InjectorService.d.ts +20 -28
- package/lib/types/utils/asyncHookContext.d.ts +14 -0
- package/lib/types/utils/getConfiguration.d.ts +1 -0
- package/lib/types/utils/resolveControllers.d.ts +12 -0
- package/lib/types/utils/setLoggerConfiguration.d.ts +2 -0
- package/lib/types/utils/setLoggerFormat.d.ts +6 -0
- package/lib/types/utils/setLoggerLevel.d.ts +1 -1
- package/package.json +15 -11
- package/readme.md +3 -2
- package/lib/cjs/utils/runInContext.js +0 -20
- package/lib/cjs/utils/runInContext.js.map +0 -1
- package/lib/esm/utils/runInContext.js +0 -14
- package/lib/esm/utils/runInContext.js.map +0 -1
- package/lib/types/utils/runInContext.d.ts +0 -6
package/coverage.json
ADDED
package/jest.config.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// For a detailed explanation regarding each configuration property, visit:
|
|
2
|
+
// https://jestjs.io/docs/en/configuration.html
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
...require("@tsed/jest-config")(__dirname, "di"),
|
|
6
|
+
coverageThreshold: {
|
|
7
|
+
global: require("./coverage.json")
|
|
8
|
+
}
|
|
9
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/decorators/controller.ts"],"names":[],"mappings":";;;AAAA,qCAAoE;AACpE,yCAA4C;AAE5C,qEAAkE;
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/decorators/controller.ts"],"names":[],"mappings":";;;AAAA,qCAAoE;AACpE,yCAA4C;AAE5C,qEAAkE;AAgBlE,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,qCAAkB,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","sourcesContent":["import {isArrayOrArrayClass, Type, useDecorators} from \"@tsed/core\";\nimport {Children, Path} from \"@tsed/schema\";\nimport {ProviderOpts} from \"../interfaces/ProviderOpts\";\nimport {registerController} from \"../registries/ProviderRegistry\";\n\nexport type PathType = string | RegExp | (string | RegExp)[];\n\nexport interface ControllerMiddlewares {\n useBefore: any[];\n use: any[];\n useAfter: any[];\n}\n\nexport interface ControllerOptions extends Partial<ProviderOpts<any>> {\n path?: PathType;\n children?: Type<any>[];\n middlewares?: Partial<ControllerMiddlewares>;\n}\n\nfunction mapOptions(options: any): ControllerOptions {\n if (typeof options === \"string\" || options instanceof RegExp || isArrayOrArrayClass(options)) {\n return {\n path: options\n };\n }\n\n return options;\n}\n\n/**\n * Declare a new controller with his Rest path. His methods annotated will be collected to build the routing list.\n * This routing listing will be built with the `express.Router` object.\n *\n * ::: tip\n * See [Controllers](/docs/controllers.md) section for more details\n * :::\n *\n * ```typescript\n * @Controller(\"/calendars\")\n * export provide CalendarCtrl {\n *\n * @Get(\"/:id\")\n * public get(\n * @Req() request: Req,\n * @Res() response: Res,\n * @Next() next: Next\n * ): void {\n *\n * }\n * }\n * ```\n *\n * @param options\n * @controller\n * @decorator\n * @classDecorator\n */\nexport function Controller(options: PathType | ControllerOptions): ClassDecorator {\n const {children = [], path, ...opts} = mapOptions(options);\n\n return useDecorators(\n (target: Type) => {\n registerController({\n provide: target,\n ...opts\n });\n },\n path && Path(path as any),\n Children(...children)\n );\n}\n"]}
|
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.InjectContext = exports.Inject = exports.injectProperty = void 0;
|
|
4
4
|
const core_1 = require("@tsed/core");
|
|
5
5
|
const constants_1 = require("../constants/constants");
|
|
6
|
-
const
|
|
6
|
+
const InvalidPropertyTokenError_1 = require("../errors/InvalidPropertyTokenError");
|
|
7
|
+
const asyncHookContext_1 = require("../utils/asyncHookContext");
|
|
7
8
|
function injectProperty(target, propertyKey, options) {
|
|
8
9
|
core_1.Store.from(target).merge(constants_1.INJECTABLE_PROP, {
|
|
9
10
|
[propertyKey]: {
|
|
@@ -45,12 +46,15 @@ function Inject(symbol, onGet = (bean) => bean) {
|
|
|
45
46
|
}
|
|
46
47
|
break;
|
|
47
48
|
case core_1.DecoratorTypes.PROP:
|
|
49
|
+
const useType = symbol || core_1.Metadata.getType(target, propertyKey);
|
|
50
|
+
if (useType === Object) {
|
|
51
|
+
throw new InvalidPropertyTokenError_1.InvalidPropertyTokenError(target, propertyKey);
|
|
52
|
+
}
|
|
48
53
|
injectProperty(target, propertyKey, {
|
|
49
54
|
resolver(injector, locals, { options, ...invokeOptions }) {
|
|
50
55
|
locals.set(constants_1.DI_PARAM_OPTIONS, { ...options });
|
|
51
56
|
let bean;
|
|
52
57
|
if (!bean) {
|
|
53
|
-
const useType = symbol || core_1.Metadata.getType(target, propertyKey);
|
|
54
58
|
bean = injector.invoke(useType, locals, invokeOptions);
|
|
55
59
|
locals.delete(constants_1.DI_PARAM_OPTIONS);
|
|
56
60
|
}
|
|
@@ -95,7 +99,7 @@ function InjectContext() {
|
|
|
95
99
|
return (target, propertyKey) => {
|
|
96
100
|
injectProperty(target, propertyKey, {
|
|
97
101
|
resolver() {
|
|
98
|
-
return () => (0,
|
|
102
|
+
return () => (0, asyncHookContext_1.getContext)();
|
|
99
103
|
}
|
|
100
104
|
});
|
|
101
105
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../src/decorators/inject.ts"],"names":[],"mappings":";;;AAAA,qCAAiH;AACjH,sDAAyE;
|
|
1
|
+
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../src/decorators/inject.ts"],"names":[],"mappings":";;;AAAA,qCAAiH;AACjH,sDAAyE;AACzE,mFAA8E;AAE9E,gEAAqD;AAErD,SAAgB,cAAc,CAAC,MAAW,EAAE,WAAmB,EAAE,OAA2C;IAC1G,YAAK,CAAC,I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AM_OPTIONS, INJECTABLE_PROP} from \"../constants/constants\";\nimport {InvalidPropertyTokenError} from \"../errors/InvalidPropertyTokenError\";\nimport type {InjectablePropertyOptions} from \"../interfaces/InjectableProperties\";\nimport {getContext} from \"../utils/asyncHookContext\";\n\nexport function injectProperty(target: any, propertyKey: string, options: Partial<InjectablePropertyOptions>) {\n Store.from(target).merge(INJECTABLE_PROP, {\n [propertyKey]: {\n bindingType: DecoratorTypes.PROP,\n propertyKey,\n ...options\n }\n });\n}\n\n/**\n * Inject a provider to another provider.\n *\n * Use this decorator to inject a custom provider on constructor parameter or property.\n *\n * ```typescript\n * @Injectable()\n * export class MyService {\n * @Inject(CONNECTION)\n * connection: CONNECTION;\n * }\n * ```\n *\n * @param symbol\n * @param onGet Use the given name method to inject\n * @returns {Function}\n * @decorator\n */\nexport function Inject(symbol?: any, onGet = (bean: any) => bean): Function {\n return (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<Function> | number): any | void => {\n const bindingType = decoratorTypeOf([target, propertyKey, descriptor]);\n\n switch (bindingType) {\n case DecoratorTypes.PARAM:\n case DecoratorTypes.PARAM_CTOR:\n if (symbol) {\n const paramTypes = Metadata.getParamTypes(target, propertyKey);\n\n paramTypes[descriptor as number] = symbol;\n Metadata.setParamTypes(target, propertyKey, paramTypes);\n }\n break;\n\n case DecoratorTypes.PROP:\n const useType = symbol || Metadata.getType(target, propertyKey);\n\n if (useType === Object) {\n throw new InvalidPropertyTokenError(target, propertyKey);\n }\n\n injectProperty(target, propertyKey, {\n resolver(injector, locals, {options, ...invokeOptions}) {\n locals.set(DI_PARAM_OPTIONS, {...options});\n\n let bean: any;\n\n if (!bean) {\n bean = injector.invoke(useType, locals, invokeOptions);\n locals.delete(DI_PARAM_OPTIONS);\n }\n\n if (isPromise(bean)) {\n bean.then((result: any) => {\n bean = result;\n });\n }\n\n return () => onGet(bean);\n }\n });\n break;\n\n case DecoratorTypes.METHOD:\n Store.from(target).merge(INJECTABLE_PROP, {\n [propertyKey]: {\n bindingType,\n propertyKey\n }\n });\n\n return descriptor;\n\n default:\n throw new UnsupportedDecoratorType(Inject, [target, propertyKey, descriptor]);\n }\n };\n}\n\n/**\n * Inject a context like PlatformContext or any BaseContext.\n *\n * ```typescript\n * @Injectable()\n * export class MyService {\n * @InjectContext()\n * ctx?: Context;\n * }\n * ```\n *\n * @returns {Function}\n * @decorator\n */\nexport function InjectContext(): PropertyDecorator {\n return (target: any, propertyKey: string): any | void => {\n injectProperty(target, propertyKey, {\n resolver() {\n return () => getContext();\n }\n });\n };\n}\n"]}
|
|
@@ -10,8 +10,7 @@ class Container extends Map {
|
|
|
10
10
|
* @param settings
|
|
11
11
|
*/
|
|
12
12
|
add(token, settings = {}) {
|
|
13
|
-
|
|
14
|
-
const provider = ((_a = GlobalProviders_1.GlobalProviders.get(token)) === null || _a === void 0 ? void 0 : _a.clone()) || new Provider_1.Provider(token);
|
|
13
|
+
const provider = GlobalProviders_1.GlobalProviders.get(token)?.clone() || new Provider_1.Provider(token);
|
|
15
14
|
Object.assign(provider, settings);
|
|
16
15
|
return super.set(token, provider);
|
|
17
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Container.js","sourceRoot":"","sources":["../../../src/domain/Container.ts"],"names":[],"mappings":";;;AAGA,mEAA8D;AAC9D,yCAAoC;AAEpC,MAAa,SAAU,SAAQ,GAA4B;IACzD;;;;OAIG;IACI,GAAG,CAAC,KAAoB,EAAE,WAAkC,EAAE
|
|
1
|
+
{"version":3,"file":"Container.js","sourceRoot":"","sources":["../../../src/domain/Container.ts"],"names":[],"mappings":";;;AAGA,mEAA8D;AAC9D,yCAAoC;AAEpC,MAAa,SAAU,SAAQ,GAA4B;IACzD;;;;OAIG;IACI,GAAG,CAAC,KAAoB,EAAE,WAAkC,EAAE;QACnE,MAAM,QAAQ,GAAG,iCAAe,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,IAAI,mBAAQ,CAAC,KAAK,CA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,CAAC;aACtD;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAvED,8BAuEC","sourcesContent":["import type {ProviderOpts} from \"../interfaces/ProviderOpts\";\nimport type {ProviderType} from \"./ProviderType\";\nimport type {TokenProvider} from \"../interfaces/TokenProvider\";\nimport {GlobalProviders} from \"../registries/GlobalProviders\";\nimport {Provider} from \"./Provider\";\n\nexport class Container extends Map<TokenProvider, Provider> {\n /**\n *\n * @param token\n * @param settings\n */\n public add(token: TokenProvider, settings: Partial<ProviderOpts> = {}): this {\n const provider = GlobalProviders.get(token)?.clone() || new Provider(token);\n\n Object.assign(provider, settings);\n\n return super.set(token, provider);\n }\n\n /**\n * Add a provider to the\n * @param token\n * @param settings\n */\n public addProvider(token: TokenProvider, settings: Partial<ProviderOpts> = {}): this {\n return this.add(token, settings);\n }\n\n /**\n *\n * @param token\n */\n public hasProvider(token: TokenProvider) {\n return super.has(token);\n }\n\n /**\n * Add a provider to the\n * @param token\n * @param provider\n */\n public setProvider(token: TokenProvider, provider: Provider) {\n return super.set(token, provider);\n }\n\n /**\n * The getProvider() method returns a specified element from a Map object.\n * @returns {T} Returns the element associated with the specified key or undefined if the key can't be found in the Map object.\n * @param token\n */\n public getProvider<T extends Provider = Provider>(token: TokenProvider): T | undefined {\n return super.get(token) as T;\n }\n\n /**\n * Get all providers registered in the injector container.\n *\n * @param {ProviderType} type Filter the list by the given ProviderType.\n * @returns {[TokenProvider , Provider<any>][]}\n */\n public getProviders(type?: ProviderType | string): Provider[] {\n return [...this].reduce((providers, [_, provider]) => {\n if (provider.type === type || !type) {\n return [...providers, provider];\n }\n return providers;\n }, []);\n }\n\n public addProviders(container: Map<TokenProvider, Provider>) {\n container.forEach((provider) => {\n if (!this.hasProvider(provider.provide)) {\n this.setProvider(provider.provide, provider.clone());\n }\n });\n }\n}\n"]}
|
|
@@ -1,61 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContextLogger = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
4
5
|
const logger_1 = require("@tsed/logger");
|
|
6
|
+
const LEVELS = (0, logger_1.levels)();
|
|
5
7
|
class ContextLogger {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
dateStart;
|
|
9
|
+
id;
|
|
10
|
+
#additionalProps;
|
|
11
|
+
maxStackSize;
|
|
12
|
+
level;
|
|
13
|
+
#hooks;
|
|
14
|
+
#stack;
|
|
15
|
+
#logger;
|
|
16
|
+
constructor({ id, logger, dateStart = new Date(), level = "all", maxStackSize = 30, additionalProps }) {
|
|
12
17
|
this.dateStart = dateStart;
|
|
13
|
-
this.
|
|
14
|
-
this
|
|
15
|
-
this
|
|
16
|
-
|
|
17
|
-
this.level = (0, logger_1.levels)()[level.toUpperCase()] || (0, logger_1.levels)().ALL;
|
|
18
|
+
this.id = id;
|
|
19
|
+
this.#logger = logger;
|
|
20
|
+
this.#additionalProps = additionalProps;
|
|
21
|
+
this.level = (LEVELS[level.toUpperCase()] || LEVELS.ALL);
|
|
18
22
|
this.maxStackSize = maxStackSize;
|
|
19
23
|
}
|
|
24
|
+
get hooks() {
|
|
25
|
+
return (this.#hooks = this.#hooks || new core_1.Hooks());
|
|
26
|
+
}
|
|
27
|
+
get stack() {
|
|
28
|
+
return (this.#stack = this.#stack || []);
|
|
29
|
+
}
|
|
30
|
+
alterLog(cb) {
|
|
31
|
+
return this.hooks.on("log", cb);
|
|
32
|
+
}
|
|
33
|
+
alterIgnoreLog(cb) {
|
|
34
|
+
return this.hooks.on("ignore", cb);
|
|
35
|
+
}
|
|
20
36
|
info(obj) {
|
|
21
|
-
this.run((0, logger_1.levels)().INFO, obj
|
|
37
|
+
this.run((0, logger_1.levels)().INFO, obj);
|
|
22
38
|
return this;
|
|
23
39
|
}
|
|
24
40
|
debug(obj, withRequest = true) {
|
|
25
|
-
this.run((0, logger_1.levels)().DEBUG, obj,
|
|
26
|
-
obj = this.getData(obj);
|
|
27
|
-
return withRequest ? this.completeRequestPicker(obj) : obj;
|
|
28
|
-
});
|
|
41
|
+
this.run((0, logger_1.levels)().DEBUG, obj, withRequest);
|
|
29
42
|
return this;
|
|
30
43
|
}
|
|
31
44
|
warn(obj) {
|
|
32
|
-
this.run((0, logger_1.levels)().WARN, obj
|
|
45
|
+
this.run((0, logger_1.levels)().WARN, obj);
|
|
33
46
|
return this;
|
|
34
47
|
}
|
|
35
48
|
error(obj) {
|
|
36
|
-
this.run((0, logger_1.levels)().ERROR, obj
|
|
49
|
+
this.run((0, logger_1.levels)().ERROR, obj);
|
|
37
50
|
return this;
|
|
38
51
|
}
|
|
39
52
|
trace(obj) {
|
|
40
|
-
this.run((0, logger_1.levels)().TRACE, obj
|
|
53
|
+
this.run((0, logger_1.levels)().TRACE, obj);
|
|
41
54
|
return this;
|
|
42
55
|
}
|
|
43
56
|
flush() {
|
|
44
57
|
if (this.stack.length) {
|
|
45
58
|
this.stack.forEach(({ level, data }) => {
|
|
46
|
-
this
|
|
59
|
+
this.#logger[level](data);
|
|
47
60
|
});
|
|
48
|
-
this
|
|
61
|
+
this.#stack = [];
|
|
49
62
|
}
|
|
50
63
|
}
|
|
51
64
|
isLevelEnabled(otherLevel) {
|
|
52
65
|
return this.level.isLessThanOrEqualTo(otherLevel);
|
|
53
66
|
}
|
|
54
|
-
destroy() {
|
|
55
|
-
this.flush();
|
|
56
|
-
this.logger = undefined;
|
|
57
|
-
this.stack = undefined;
|
|
58
|
-
}
|
|
59
67
|
/**
|
|
60
68
|
* Return the duration between the time when LogIncomingRequest has handle the request and now.
|
|
61
69
|
* @returns {number}
|
|
@@ -67,14 +75,17 @@ class ContextLogger {
|
|
|
67
75
|
if (typeof obj === "string") {
|
|
68
76
|
obj = { message: obj };
|
|
69
77
|
}
|
|
70
|
-
return { ...this
|
|
78
|
+
return { ...this.#additionalProps, reqId: this.id, time: new Date(), duration: this.getDuration(), ...obj };
|
|
71
79
|
}
|
|
72
|
-
run(level, obj,
|
|
80
|
+
run(level, obj, withRequest) {
|
|
73
81
|
if (!this.isLevelEnabled(level)) {
|
|
74
82
|
return;
|
|
75
83
|
}
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
const ignore = this.#hooks?.alter("ignore", false, [obj]);
|
|
85
|
+
if (!ignore) {
|
|
86
|
+
const levelStr = level.levelStr.toLowerCase();
|
|
87
|
+
obj = this.hooks.alter("log", this.getData(obj), [levelStr, withRequest]);
|
|
88
|
+
this.stack.push({ level: levelStr, data: obj });
|
|
78
89
|
}
|
|
79
90
|
if (this.maxStackSize < this.stack.length) {
|
|
80
91
|
this.flush();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextLogger.js","sourceRoot":"","sources":["../../../src/domain/ContextLogger.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;
|
|
1
|
+
{"version":3,"file":"ContextLogger.js","sourceRoot":"","sources":["../../../src/domain/ContextLogger.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,yCAA8C;AAY9C,MAAM,MAAM,GAA6B,IAAA,eAAM,GAAE,CAAC;AAElD,MAAa,aAAa;IACf,SAAS,CAAO;IAChB,EAAE,CAAS;IACX,gBAAgB,CAA2B;IAEpD,YAAY,CAAS;IACrB,KAAK,CAAW;IAEhB,MAAM,CAAS;IACf,MAAM,CAAS;IACf,OAAO,CAAM;IAEb,YAAY,EAAC,EAAE,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,IAAI,EAAE,EAAE,KAAK,GAAG,KAAK,EAAE,YAAY,GAAG,EAAE,EAAE,eAAe,EAAuB;QACvH,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,CAAC,M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QAE1D,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;YAE9C,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;YAE1E,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAC,CAAC,CAAC;SAC/C;QAED,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACzC,IAAI,CAAC,KAAK,EAAE,CAAC;SACd;IACH,CAAC;CACF;AA/GD,sCA+GC","sourcesContent":["import {Hooks} from \"@tsed/core\";\nimport {levels, LogLevel} from \"@tsed/logger\";\nimport {DILogger} from \"../interfaces/DILogger\";\nimport type {DIContext} from \"./DIContext\";\n\nexport interface ContextLoggerOptions extends Record<string, any> {\n id: string;\n logger?: DILogger;\n level?: \"debug\" | \"info\" | \"warn\" | \"error\" | \"off\" | \"all\";\n maxStackSize?: number;\n additionalProps?: Record<any, any>;\n}\n\nconst LEVELS: Record<string, LogLevel> = levels();\n\nexport class ContextLogger {\n readonly dateStart: Date;\n readonly id: string;\n readonly #additionalProps?: Record<string, unknown>;\n\n maxStackSize: number;\n level: LogLevel;\n\n #hooks?: Hooks;\n #stack?: any[];\n #logger: any;\n\n constructor({id, logger, dateStart = new Date(), level = \"all\", maxStackSize = 30, additionalProps}: ContextLoggerOptions) {\n this.dateStart = dateStart;\n this.id = id;\n this.#logger = logger;\n this.#additionalProps = additionalProps;\n this.level = (LEVELS[level.toUpperCase()] || LEVELS.ALL) as LogLevel;\n this.maxStackSize = maxStackSize;\n }\n\n get hooks() {\n return (this.#hooks = this.#hooks || new Hooks());\n }\n\n private get stack() {\n return (this.#stack = this.#stack || []);\n }\n\n alterLog(cb: (data: any, level: \"debug\" | \"info\" | \"warn\" | \"error\" | \"off\" | \"all\", withRequest: boolean) => any) {\n return this.hooks.on(\"log\", cb);\n }\n\n alterIgnoreLog(cb: (ignore: boolean, data: any) => boolean) {\n return this.hooks.on(\"ignore\", cb);\n }\n\n info(obj: any) {\n this.run(levels().INFO, obj);\n return this;\n }\n\n debug(obj: any, withRequest: boolean = true) {\n this.run(levels().DEBUG, obj, withRequest);\n return this;\n }\n\n warn(obj: any) {\n this.run(levels().WARN, obj);\n return this;\n }\n\n error(obj: any) {\n this.run(levels().ERROR, obj);\n return this;\n }\n\n trace(obj: any) {\n this.run(levels().TRACE, obj);\n return this;\n }\n\n public flush() {\n if (this.stack.length) {\n this.stack.forEach(({level, data}: any) => {\n this.#logger[level](data);\n });\n\n this.#stack = [];\n }\n }\n\n public isLevelEnabled(otherLevel: string | LogLevel) {\n return this.level.isLessThanOrEqualTo(otherLevel);\n }\n\n /**\n * Return the duration between the time when LogIncomingRequest has handle the request and now.\n * @returns {number}\n */\n protected getDuration(): number {\n return new Date().getTime() - this.dateStart.getTime();\n }\n\n protected getData(obj: any) {\n if (typeof obj === \"string\") {\n obj = {message: obj};\n }\n\n return {...this.#additionalProps, reqId: this.id, time: new Date(), duration: this.getDuration(), ...obj};\n }\n\n protected run(level: LogLevel, obj: any, withRequest?: boolean) {\n if (!this.isLevelEnabled(level)) {\n return;\n }\n\n const ignore = this.#hooks?.alter(\"ignore\", false, [obj]);\n\n if (!ignore) {\n const levelStr = level.levelStr.toLowerCase();\n\n obj = this.hooks.alter(\"log\", this.getData(obj), [levelStr, withRequest]);\n\n this.stack.push({level: levelStr, data: obj});\n }\n\n if (this.maxStackSize < this.stack.length) {\n this.flush();\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ControllerProvider = void 0;
|
|
4
|
+
const Provider_1 = require("./Provider");
|
|
5
|
+
const ProviderType_1 = require("./ProviderType");
|
|
6
|
+
class ControllerProvider extends Provider_1.Provider {
|
|
7
|
+
tokenRouter;
|
|
8
|
+
constructor(provide, options = {}) {
|
|
9
|
+
super(provide, options);
|
|
10
|
+
this.type = ProviderType_1.ProviderType.CONTROLLER;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @returns {any[]}
|
|
15
|
+
*/
|
|
16
|
+
get middlewares() {
|
|
17
|
+
return Object.assign({
|
|
18
|
+
use: [],
|
|
19
|
+
useAfter: [],
|
|
20
|
+
useBefore: []
|
|
21
|
+
}, this.store.get("middlewares", {}));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param middlewares
|
|
26
|
+
*/
|
|
27
|
+
set middlewares(middlewares) {
|
|
28
|
+
const mdlwrs = this.middlewares;
|
|
29
|
+
const concat = (key, a, b) => (a[key] = a[key].concat(b[key]));
|
|
30
|
+
Object.keys(middlewares).forEach((key) => {
|
|
31
|
+
concat(key, mdlwrs, middlewares);
|
|
32
|
+
});
|
|
33
|
+
this.store.set("middlewares", mdlwrs);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.ControllerProvider = ControllerProvider;
|
|
37
|
+
//# sourceMappingURL=ControllerProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ControllerProvider.js","sourceRoot":"","sources":["../../../src/domain/ControllerProvider.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,iDAA4C;AAE5C,MAAa,kBAA4B,SAAQ,mBAAW;IACnD,WAAW,CAAS;IAE3B,YAAY,OAAsB,EAAE,UAA6B,EAAE;QACjE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,2BAAY,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","sourcesContent":["import {ControllerMiddlewares} from \"../decorators/controller\";\nimport {TokenProvider} from \"../interfaces/TokenProvider\";\nimport {Provider} from \"./Provider\";\nimport {ProviderType} from \"./ProviderType\";\n\nexport class ControllerProvider<T = any> extends Provider<T> {\n public tokenRouter: string;\n\n constructor(provide: TokenProvider, options: Partial<Provider> = {}) {\n super(provide, options);\n this.type = ProviderType.CONTROLLER;\n }\n\n /**\n *\n * @returns {any[]}\n */\n get middlewares(): ControllerMiddlewares {\n return Object.assign(\n {\n use: [],\n useAfter: [],\n useBefore: []\n },\n this.store.get(\"middlewares\", {})\n );\n }\n\n /**\n *\n * @param middlewares\n */\n set middlewares(middlewares: ControllerMiddlewares) {\n const mdlwrs = this.middlewares;\n const concat = (key: string, a: any, b: any) => (a[key] = a[key].concat(b[key]));\n\n Object.keys(middlewares).forEach((key: string) => {\n concat(key, mdlwrs, middlewares);\n });\n\n this.store.set(\"middlewares\", mdlwrs);\n }\n}\n"]}
|
|
@@ -1,44 +1,100 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DIContext = void 0;
|
|
4
|
+
const asyncHookContext_1 = require("../utils/asyncHookContext");
|
|
4
5
|
const ContextLogger_1 = require("./ContextLogger");
|
|
5
6
|
const LocalsContainer_1 = require("./LocalsContainer");
|
|
6
|
-
class DIContext
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
class DIContext {
|
|
8
|
+
opts;
|
|
9
|
+
#container;
|
|
10
|
+
#cache;
|
|
11
|
+
#logger;
|
|
12
|
+
constructor(opts) {
|
|
13
|
+
this.opts = opts;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Logger attached to the context request.
|
|
17
|
+
*/
|
|
18
|
+
get logger() {
|
|
19
|
+
this.#logger = this.#logger || new ContextLogger_1.ContextLogger(this.opts);
|
|
20
|
+
return this.#logger;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Request id generated by @@contextMiddleware@@.
|
|
24
|
+
*
|
|
25
|
+
* ::: tip
|
|
26
|
+
* By default Ts.ED generate uuid like that `uuidv4().replace(/-/gi, ""))`.
|
|
27
|
+
* Dash are removed to simplify tracking logs in Kibana
|
|
28
|
+
* :::
|
|
29
|
+
*
|
|
30
|
+
* ::: tip
|
|
31
|
+
* Request id can by customized by changing the server configuration.
|
|
32
|
+
*
|
|
33
|
+
* ```typescript
|
|
34
|
+
* @Configuration({
|
|
35
|
+
* logger: {
|
|
36
|
+
* reqIdBuilder: createUniqId // give your own id generator function
|
|
37
|
+
* }
|
|
38
|
+
* })
|
|
39
|
+
* class Server {
|
|
40
|
+
*
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
* :::
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
get id() {
|
|
47
|
+
return this.opts.id;
|
|
48
|
+
}
|
|
49
|
+
get dateStart() {
|
|
50
|
+
return this.logger.dateStart;
|
|
51
|
+
}
|
|
52
|
+
get injector() {
|
|
53
|
+
return this.opts.injector;
|
|
25
54
|
}
|
|
26
55
|
get env() {
|
|
27
|
-
return this.injector.settings.env;
|
|
56
|
+
return this.injector.settings.get("env");
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The request container used by the Ts.ED DI. It contains all services annotated with `@Scope(ProviderScope.REQUEST)`
|
|
60
|
+
*/
|
|
61
|
+
get container() {
|
|
62
|
+
return (this.#container = this.#container || new LocalsContainer_1.LocalsContainer());
|
|
28
63
|
}
|
|
29
64
|
async destroy() {
|
|
30
|
-
|
|
31
|
-
this.logger.destroy();
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
delete this.container;
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
delete this.logger;
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
delete this.injector;
|
|
65
|
+
return Promise.all([this.#container?.destroy(), this.#logger?.flush()]);
|
|
38
66
|
}
|
|
39
67
|
async emit(eventName, ...args) {
|
|
40
|
-
|
|
41
|
-
|
|
68
|
+
return this.injector?.emit(eventName, ...args);
|
|
69
|
+
}
|
|
70
|
+
async runInContext(next) {
|
|
71
|
+
return (0, asyncHookContext_1.runInContext)(this, next);
|
|
72
|
+
}
|
|
73
|
+
cache(key, cb) {
|
|
74
|
+
if (!this.has(key)) {
|
|
75
|
+
this.set(key, cb());
|
|
76
|
+
}
|
|
77
|
+
return this.get(key);
|
|
78
|
+
}
|
|
79
|
+
async cacheAsync(key, cb) {
|
|
80
|
+
if (!this.has(key)) {
|
|
81
|
+
this.set(key, await cb());
|
|
82
|
+
}
|
|
83
|
+
return this.get(key);
|
|
84
|
+
}
|
|
85
|
+
delete(key) {
|
|
86
|
+
return !!this.#cache?.delete(key);
|
|
87
|
+
}
|
|
88
|
+
get(key) {
|
|
89
|
+
return this.#cache?.get(key);
|
|
90
|
+
}
|
|
91
|
+
has(key) {
|
|
92
|
+
return !!this.#cache?.has(key);
|
|
93
|
+
}
|
|
94
|
+
set(key, value) {
|
|
95
|
+
this.#cache = this.#cache || new Map();
|
|
96
|
+
this.#cache.set(key, value);
|
|
97
|
+
return this;
|
|
42
98
|
}
|
|
43
99
|
}
|
|
44
100
|
exports.DIContext = DIContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../../src/domain/DIContext.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../../src/domain/DIContext.ts"],"names":[],"mappings":";;;AACA,gEAAuD;AACvD,mDAAoE;AACpE,uDAAkD;AAQlD,MAAa,SAAS;IAOD;IAJnB,UAAU,CAAmB;IAC7B,MAAM,CAAiB;IACvB,OAAO,CAAiB;IAExB,YAAmB,IAAsB;QAAtB,SAAI,GAAJ,IAAI,CAAkB;IAAG,CAAC;IAE7C;;OAEG;IACH,IAAI,MAAM;QACR,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,6BAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACtB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED,IAAI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AAC;IAED,MAAM,CAAC,GAAQ;QACb,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,GAAG,CAAU,GAAQ;QACnB,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,GAAG,CAAC,GAAQ;QACV,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAED,GAAG,CAAC,GAAQ,EAAE,KAAU;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,GAAG,EAAY,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA7GD,8BA6GC","sourcesContent":["import {InjectorService} from \"../services/InjectorService\";\nimport {runInContext} from \"../utils/asyncHookContext\";\nimport {ContextLogger, ContextLoggerOptions} from \"./ContextLogger\";\nimport {LocalsContainer} from \"./LocalsContainer\";\n\nexport interface DIContextOptions extends Omit<ContextLoggerOptions, \"dateStart\"> {\n id: string;\n injector: InjectorService;\n logger: any;\n}\n\nexport class DIContext {\n [x: string]: any;\n\n #container?: LocalsContainer;\n #cache?: Map<any, any>;\n #logger?: ContextLogger;\n\n constructor(public opts: DIContextOptions) {}\n\n /**\n * Logger attached to the context request.\n */\n get logger() {\n this.#logger = this.#logger || new ContextLogger(this.opts);\n return this.#logger;\n }\n\n /**\n * Request id generated by @@contextMiddleware@@.\n *\n * ::: tip\n * By default Ts.ED generate uuid like that `uuidv4().replace(/-/gi, \"\"))`.\n * Dash are removed to simplify tracking logs in Kibana\n * :::\n *\n * ::: tip\n * Request id can by customized by changing the server configuration.\n *\n * ```typescript\n * @Configuration({\n * logger: {\n * reqIdBuilder: createUniqId // give your own id generator function\n * }\n * })\n * class Server {\n *\n * }\n * ```\n * :::\n *\n */\n get id() {\n return this.opts.id;\n }\n\n get dateStart() {\n return this.logger.dateStart;\n }\n\n get injector(): InjectorService {\n return this.opts.injector!;\n }\n\n get env() {\n return this.injector.settings.get(\"env\");\n }\n\n /**\n * The request container used by the Ts.ED DI. It contains all services annotated with `@Scope(ProviderScope.REQUEST)`\n */\n get container() {\n return (this.#container = this.#container || new LocalsContainer());\n }\n\n async destroy(): Promise<any> {\n return Promise.all([this.#container?.destroy(), this.#logger?.flush()]);\n }\n\n async emit(eventName: string, ...args: any[]) {\n return this.injector?.emit(eventName, ...args);\n }\n\n async runInContext(next: Function) {\n return runInContext(this, next);\n }\n\n cache<Value = any>(key: string, cb: () => Value): Value {\n if (!this.has(key)) {\n this.set(key, cb());\n }\n\n return this.get(key);\n }\n\n async cacheAsync<Value = any>(key: string, cb: () => Promise<Value>): Promise<Value> {\n if (!this.has(key)) {\n this.set(key, await cb());\n }\n\n return this.get(key);\n }\n\n delete(key: any): boolean {\n return !!this.#cache?.delete(key);\n }\n\n get<T = any>(key: any): T {\n return this.#cache?.get(key);\n }\n\n has(key: any): boolean {\n return !!this.#cache?.has(key);\n }\n\n set(key: any, value: any): this {\n this.#cache = this.#cache || new Map<any, any>();\n this.#cache.set(key, value);\n return this;\n }\n}\n\nexport type BaseContext = DIContext & TsED.Context;\n"]}
|
|
@@ -1,54 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LocalsContainer = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
4
5
|
class LocalsContainer extends Map {
|
|
5
|
-
|
|
6
|
-
* Emit an event to all service. See service [lifecycle hooks](/docs/services.md#lifecycle-hooks).
|
|
7
|
-
* @param eventName The event name to emit at all services.
|
|
8
|
-
* @param args List of the parameters to give to each services.
|
|
9
|
-
* @returns {Promise<any[]>} A list of promises.
|
|
10
|
-
*/
|
|
11
|
-
async emit(eventName, ...args) {
|
|
12
|
-
for (const handler of this.getListeners(eventName)) {
|
|
13
|
-
await handler(...args);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @param eventName
|
|
18
|
-
* @param value
|
|
19
|
-
* @param args
|
|
20
|
-
*/
|
|
21
|
-
alter(eventName, value, ...args) {
|
|
22
|
-
for (const handler of this.getListeners(eventName)) {
|
|
23
|
-
value = handler(value, ...args);
|
|
24
|
-
}
|
|
25
|
-
return value;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @param eventName
|
|
29
|
-
* @param value
|
|
30
|
-
* @param args
|
|
31
|
-
*/
|
|
32
|
-
async alterAsync(eventName, value, ...args) {
|
|
33
|
-
for (const handler of this.getListeners(eventName)) {
|
|
34
|
-
value = handler(value, ...args);
|
|
35
|
-
}
|
|
36
|
-
return value;
|
|
37
|
-
}
|
|
38
|
-
toArray() {
|
|
39
|
-
return [...this.values()];
|
|
40
|
-
}
|
|
6
|
+
hooks = new core_1.Hooks();
|
|
41
7
|
async destroy() {
|
|
42
|
-
await this.
|
|
43
|
-
this.clear();
|
|
44
|
-
}
|
|
45
|
-
getListeners(event) {
|
|
46
|
-
return this.toArray().reduce((listeners, instance) => {
|
|
47
|
-
if (typeof instance === "object" && instance && event in instance) {
|
|
48
|
-
return listeners.concat(instance[event].bind(instance));
|
|
49
|
-
}
|
|
50
|
-
return listeners;
|
|
51
|
-
}, []);
|
|
8
|
+
await this.hooks.asyncEmit("$onDestroy");
|
|
52
9
|
}
|
|
53
10
|
}
|
|
54
11
|
exports.LocalsContainer = LocalsContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalsContainer.js","sourceRoot":"","sources":["../../../src/domain/LocalsContainer.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"LocalsContainer.js","sourceRoot":"","sources":["../../../src/domain/LocalsContainer.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAGjC,MAAa,eAAgB,SAAQ,GAAuB;IACjD,KAAK,GAAG,IAAI,YAAK,EAAE,CAAC;IAE7B,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAC3C,CAAC;CACF;AAND,0CAMC","sourcesContent":["import {Hooks} from \"@tsed/core\";\nimport type {TokenProvider} from \"../interfaces/TokenProvider\";\n\nexport class LocalsContainer extends Map<TokenProvider, any> {\n readonly hooks = new Hooks();\n\n async destroy() {\n await this.hooks.asyncEmit(\"$onDestroy\");\n }\n}\n"]}
|
|
@@ -5,8 +5,18 @@ const core_1 = require("@tsed/core");
|
|
|
5
5
|
const ProviderScope_1 = require("./ProviderScope");
|
|
6
6
|
const ProviderType_1 = require("./ProviderType");
|
|
7
7
|
class Provider {
|
|
8
|
+
type = ProviderType_1.ProviderType.PROVIDER;
|
|
9
|
+
deps;
|
|
10
|
+
imports;
|
|
11
|
+
useFactory;
|
|
12
|
+
useAsyncFactory;
|
|
13
|
+
useValue;
|
|
14
|
+
hooks;
|
|
15
|
+
_useClass;
|
|
16
|
+
_provide;
|
|
17
|
+
_store;
|
|
18
|
+
_tokenStore;
|
|
8
19
|
constructor(token, options = {}) {
|
|
9
|
-
this.type = ProviderType_1.ProviderType.PROVIDER;
|
|
10
20
|
this.provide = token;
|
|
11
21
|
this.useClass = token;
|
|
12
22
|
Object.assign(this, options);
|
|
@@ -34,6 +44,15 @@ class Provider {
|
|
|
34
44
|
if ((0, core_1.isClass)(value)) {
|
|
35
45
|
this._useClass = (0, core_1.classOf)(value);
|
|
36
46
|
this._store = core_1.Store.from(value);
|
|
47
|
+
this.hooks = (0, core_1.methodsOf)(this._useClass).reduce((hooks, { propertyKey }) => {
|
|
48
|
+
if (String(propertyKey).startsWith("$")) {
|
|
49
|
+
return {
|
|
50
|
+
...hooks,
|
|
51
|
+
[propertyKey]: (instance, ...args) => instance[propertyKey](...args)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return hooks;
|
|
55
|
+
}, {});
|
|
37
56
|
}
|
|
38
57
|
}
|
|
39
58
|
get className() {
|