@tsed/di 7.0.0-alpha.1 → 7.0.0-beta.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/cjs/constants/constants.js +7 -0
- package/lib/cjs/constants/constants.js.map +1 -0
- package/lib/cjs/decorators/configuration.js +24 -0
- package/lib/cjs/decorators/configuration.js.map +1 -0
- package/lib/cjs/decorators/constant.js +55 -0
- package/lib/cjs/decorators/constant.js.map +1 -0
- package/lib/cjs/decorators/controller.js +53 -0
- package/lib/cjs/decorators/controller.js.map +1 -0
- package/lib/cjs/decorators/inject.js +104 -0
- package/lib/cjs/decorators/inject.js.map +1 -0
- package/lib/cjs/decorators/injectable.js +32 -0
- package/lib/cjs/decorators/injectable.js.map +1 -0
- package/lib/cjs/decorators/intercept.js +36 -0
- package/lib/cjs/decorators/intercept.js.map +1 -0
- package/lib/cjs/decorators/interceptor.js +21 -0
- package/lib/cjs/decorators/interceptor.js.map +1 -0
- package/lib/cjs/decorators/lazyInject.js +71 -0
- package/lib/cjs/decorators/lazyInject.js.map +1 -0
- package/lib/cjs/decorators/module.js +32 -0
- package/lib/cjs/decorators/module.js.map +1 -0
- package/lib/cjs/decorators/opts.js +54 -0
- package/lib/cjs/decorators/opts.js.map +1 -0
- package/lib/cjs/decorators/overrideProvider.js +17 -0
- package/lib/cjs/decorators/overrideProvider.js.map +1 -0
- package/lib/cjs/decorators/scope.js +16 -0
- package/lib/cjs/decorators/scope.js.map +1 -0
- package/lib/cjs/decorators/service.js +18 -0
- package/lib/cjs/decorators/service.js.map +1 -0
- package/lib/cjs/decorators/useOpts.js +65 -0
- package/lib/cjs/decorators/useOpts.js.map +1 -0
- package/lib/cjs/decorators/value.js +55 -0
- package/lib/cjs/decorators/value.js.map +1 -0
- package/lib/cjs/domain/Container.js +72 -0
- package/lib/cjs/domain/Container.js.map +1 -0
- package/lib/cjs/domain/ContextLogger.js +85 -0
- package/lib/cjs/domain/ContextLogger.js.map +1 -0
- package/lib/cjs/domain/DIContext.js +45 -0
- package/lib/cjs/domain/DIContext.js.map +1 -0
- package/lib/cjs/domain/InjectablePropertyType.js +12 -0
- package/lib/cjs/domain/InjectablePropertyType.js.map +1 -0
- package/lib/cjs/domain/LocalsContainer.js +55 -0
- package/lib/cjs/domain/LocalsContainer.js.map +1 -0
- package/lib/cjs/domain/Provider.js +122 -0
- package/lib/cjs/domain/Provider.js.map +1 -0
- package/lib/cjs/domain/ProviderScope.js +10 -0
- package/lib/cjs/domain/ProviderScope.js.map +1 -0
- package/lib/cjs/domain/ProviderType.js +15 -0
- package/lib/cjs/domain/ProviderType.js.map +1 -0
- package/lib/cjs/errors/InjectionError.js +58 -0
- package/lib/cjs/errors/InjectionError.js.map +1 -0
- package/lib/cjs/errors/UndefinedTokenError.js +11 -0
- package/lib/cjs/errors/UndefinedTokenError.js.map +1 -0
- package/lib/cjs/index.js +57 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/interfaces/DIConfigurationOptions.js +3 -0
- package/lib/cjs/interfaces/DIConfigurationOptions.js.map +1 -0
- package/lib/cjs/interfaces/DILogger.js +3 -0
- package/lib/cjs/interfaces/DILogger.js.map +1 -0
- package/lib/cjs/interfaces/DIResolver.js +3 -0
- package/lib/cjs/interfaces/DIResolver.js.map +1 -0
- package/lib/cjs/interfaces/InjectableProperties.js +3 -0
- package/lib/cjs/interfaces/InjectableProperties.js.map +1 -0
- package/lib/cjs/interfaces/InterceptorContext.js +3 -0
- package/lib/cjs/interfaces/InterceptorContext.js.map +1 -0
- package/lib/cjs/interfaces/InterceptorMethods.js +3 -0
- package/lib/cjs/interfaces/InterceptorMethods.js.map +1 -0
- package/lib/cjs/interfaces/InvokeOptions.js +3 -0
- package/lib/cjs/interfaces/InvokeOptions.js.map +1 -0
- package/lib/cjs/interfaces/OnDestroy.js +3 -0
- package/lib/cjs/interfaces/OnDestroy.js.map +1 -0
- package/lib/cjs/interfaces/OnInit.js +3 -0
- package/lib/cjs/interfaces/OnInit.js.map +1 -0
- package/lib/cjs/interfaces/ProviderOpts.js +3 -0
- package/lib/cjs/interfaces/ProviderOpts.js.map +1 -0
- package/lib/cjs/interfaces/RegistrySettings.js +3 -0
- package/lib/cjs/interfaces/RegistrySettings.js.map +1 -0
- package/lib/cjs/interfaces/ResolvedInvokeOptions.js +3 -0
- package/lib/cjs/interfaces/ResolvedInvokeOptions.js.map +1 -0
- package/lib/cjs/interfaces/TokenProvider.js +3 -0
- package/lib/cjs/interfaces/TokenProvider.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/registries/GlobalProviders.js +124 -0
- package/lib/cjs/registries/GlobalProviders.js.map +1 -0
- package/lib/cjs/registries/ProviderRegistry.js +86 -0
- package/lib/cjs/registries/ProviderRegistry.js.map +1 -0
- package/lib/cjs/services/DIConfiguration.js +129 -0
- package/lib/cjs/services/DIConfiguration.js.map +1 -0
- package/lib/cjs/services/DILogger.js +13 -0
- package/lib/cjs/services/DILogger.js.map +1 -0
- package/lib/cjs/services/DITest.js +116 -0
- package/lib/cjs/services/DITest.js.map +1 -0
- package/lib/cjs/services/InjectorService.js +572 -0
- package/lib/cjs/services/InjectorService.js.map +1 -0
- package/lib/cjs/utils/colors.js +10 -0
- package/lib/cjs/utils/colors.js.map +1 -0
- package/lib/cjs/utils/createContainer.js +14 -0
- package/lib/cjs/utils/createContainer.js.map +1 -0
- package/lib/cjs/utils/getConfiguration.js +20 -0
- package/lib/cjs/utils/getConfiguration.js.map +1 -0
- package/lib/cjs/utils/runInContext.js +19 -0
- package/lib/cjs/utils/runInContext.js.map +1 -0
- package/lib/cjs/utils/setLoggerLevel.js +16 -0
- package/lib/cjs/utils/setLoggerLevel.js.map +1 -0
- package/lib/esm/constants/constants.js +4 -0
- package/lib/esm/constants/constants.js.map +1 -0
- package/lib/esm/decorators/configuration.js +20 -0
- package/lib/esm/decorators/configuration.js.map +1 -0
- package/lib/esm/decorators/constant.js +51 -0
- package/lib/esm/decorators/constant.js.map +1 -0
- package/lib/esm/decorators/controller.js +49 -0
- package/lib/esm/decorators/controller.js.map +1 -0
- package/lib/esm/decorators/inject.js +98 -0
- package/lib/esm/decorators/inject.js.map +1 -0
- package/lib/esm/decorators/injectable.js +28 -0
- package/lib/esm/decorators/injectable.js.map +1 -0
- package/lib/esm/decorators/intercept.js +32 -0
- package/lib/esm/decorators/intercept.js.map +1 -0
- package/lib/esm/decorators/interceptor.js +17 -0
- package/lib/esm/decorators/interceptor.js.map +1 -0
- package/lib/esm/decorators/lazyInject.js +66 -0
- package/lib/esm/decorators/lazyInject.js.map +1 -0
- package/lib/esm/decorators/module.js +28 -0
- package/lib/esm/decorators/module.js.map +1 -0
- package/lib/esm/decorators/opts.js +50 -0
- package/lib/esm/decorators/opts.js.map +1 -0
- package/lib/esm/decorators/overrideProvider.js +13 -0
- package/lib/esm/decorators/overrideProvider.js.map +1 -0
- package/lib/esm/decorators/scope.js +12 -0
- package/lib/esm/decorators/scope.js.map +1 -0
- package/lib/esm/decorators/service.js +14 -0
- package/lib/esm/decorators/service.js.map +1 -0
- package/lib/esm/decorators/useOpts.js +61 -0
- package/lib/esm/decorators/useOpts.js.map +1 -0
- package/lib/esm/decorators/value.js +51 -0
- package/lib/esm/decorators/value.js.map +1 -0
- package/lib/esm/domain/Container.js +68 -0
- package/lib/esm/domain/Container.js.map +1 -0
- package/lib/esm/domain/ContextLogger.js +81 -0
- package/lib/esm/domain/ContextLogger.js.map +1 -0
- package/lib/esm/domain/DIContext.js +41 -0
- package/lib/esm/domain/DIContext.js.map +1 -0
- package/lib/esm/domain/InjectablePropertyType.js +9 -0
- package/lib/esm/domain/InjectablePropertyType.js.map +1 -0
- package/lib/esm/domain/LocalsContainer.js +51 -0
- package/lib/esm/domain/LocalsContainer.js.map +1 -0
- package/lib/esm/domain/Provider.js +118 -0
- package/lib/esm/domain/Provider.js.map +1 -0
- package/lib/esm/domain/ProviderScope.js +7 -0
- package/lib/esm/domain/ProviderScope.js.map +1 -0
- package/lib/esm/domain/ProviderType.js +12 -0
- package/lib/esm/domain/ProviderType.js.map +1 -0
- package/lib/esm/errors/InjectionError.js +54 -0
- package/lib/esm/errors/InjectionError.js.map +1 -0
- package/lib/esm/errors/UndefinedTokenError.js +7 -0
- package/lib/esm/errors/UndefinedTokenError.js.map +1 -0
- package/lib/esm/index.js +54 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/DIConfigurationOptions.js +2 -0
- package/lib/esm/interfaces/DIConfigurationOptions.js.map +1 -0
- package/lib/esm/interfaces/DILogger.js +2 -0
- package/lib/esm/interfaces/DILogger.js.map +1 -0
- package/lib/esm/interfaces/DIResolver.js +2 -0
- package/lib/esm/interfaces/DIResolver.js.map +1 -0
- package/lib/esm/interfaces/InjectableProperties.js +2 -0
- package/lib/esm/interfaces/InjectableProperties.js.map +1 -0
- package/lib/esm/interfaces/InterceptorContext.js +2 -0
- package/lib/esm/interfaces/InterceptorContext.js.map +1 -0
- package/lib/esm/interfaces/InterceptorMethods.js +2 -0
- package/lib/esm/interfaces/InterceptorMethods.js.map +1 -0
- package/lib/esm/interfaces/InvokeOptions.js +2 -0
- package/lib/esm/interfaces/InvokeOptions.js.map +1 -0
- package/lib/esm/interfaces/OnDestroy.js +2 -0
- package/lib/esm/interfaces/OnDestroy.js.map +1 -0
- package/lib/esm/interfaces/OnInit.js +2 -0
- package/lib/esm/interfaces/OnInit.js.map +1 -0
- package/lib/esm/interfaces/ProviderOpts.js +2 -0
- package/lib/esm/interfaces/ProviderOpts.js.map +1 -0
- package/lib/esm/interfaces/RegistrySettings.js +2 -0
- package/lib/esm/interfaces/RegistrySettings.js.map +1 -0
- package/lib/esm/interfaces/ResolvedInvokeOptions.js +2 -0
- package/lib/esm/interfaces/ResolvedInvokeOptions.js.map +1 -0
- package/lib/esm/interfaces/TokenProvider.js +2 -0
- package/lib/esm/interfaces/TokenProvider.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/registries/GlobalProviders.js +120 -0
- package/lib/esm/registries/GlobalProviders.js.map +1 -0
- package/lib/esm/registries/ProviderRegistry.js +81 -0
- package/lib/esm/registries/ProviderRegistry.js.map +1 -0
- package/lib/esm/services/DIConfiguration.js +125 -0
- package/lib/esm/services/DIConfiguration.js.map +1 -0
- package/lib/esm/services/DILogger.js +11 -0
- package/lib/esm/services/DILogger.js.map +1 -0
- package/lib/esm/services/DITest.js +112 -0
- package/lib/esm/services/DITest.js.map +1 -0
- package/lib/esm/services/InjectorService.js +569 -0
- package/lib/esm/services/InjectorService.js.map +1 -0
- package/lib/esm/utils/colors.js +7 -0
- package/lib/esm/utils/colors.js.map +1 -0
- package/lib/esm/utils/createContainer.js +10 -0
- package/lib/esm/utils/createContainer.js.map +1 -0
- package/lib/esm/utils/getConfiguration.js +16 -0
- package/lib/esm/utils/getConfiguration.js.map +1 -0
- package/lib/esm/utils/runInContext.js +13 -0
- package/lib/esm/utils/runInContext.js.map +1 -0
- package/lib/esm/utils/setLoggerLevel.js +12 -0
- package/lib/esm/utils/setLoggerLevel.js.map +1 -0
- package/lib/{constants/index.d.ts → types/constants/constants.d.ts} +0 -0
- package/lib/{decorators → types/decorators}/configuration.d.ts +0 -0
- package/lib/{decorators → types/decorators}/constant.d.ts +0 -0
- package/lib/types/decorators/controller.d.ts +43 -0
- package/lib/types/decorators/inject.d.ts +36 -0
- package/lib/{decorators → types/decorators}/injectable.d.ts +4 -5
- package/lib/{decorators → types/decorators}/intercept.d.ts +2 -2
- package/lib/{decorators → types/decorators}/interceptor.d.ts +0 -0
- package/lib/types/decorators/lazyInject.d.ts +43 -0
- package/lib/{decorators → types/decorators}/module.d.ts +3 -2
- package/lib/{decorators → types/decorators}/opts.d.ts +0 -0
- package/lib/{decorators → types/decorators}/overrideProvider.d.ts +0 -0
- package/lib/{decorators → types/decorators}/scope.d.ts +0 -0
- package/lib/{decorators → types/decorators}/service.d.ts +0 -0
- package/lib/{decorators → types/decorators}/useOpts.d.ts +0 -0
- package/lib/{decorators → types/decorators}/value.d.ts +0 -0
- package/lib/{domain → types/domain}/Container.d.ts +5 -6
- package/lib/{domain → types/domain}/ContextLogger.d.ts +5 -1
- package/lib/{domain → types/domain}/DIContext.d.ts +6 -13
- package/lib/{domain → types/domain}/InjectablePropertyType.d.ts +0 -0
- package/lib/{domain → types/domain}/LocalsContainer.d.ts +0 -0
- package/lib/{domain → types/domain}/Provider.d.ts +21 -5
- package/lib/{domain → types/domain}/ProviderScope.d.ts +0 -0
- package/lib/{domain → types/domain}/ProviderType.d.ts +0 -0
- package/lib/{errors → types/errors}/InjectionError.d.ts +1 -1
- package/lib/{errors → types/errors}/UndefinedTokenError.d.ts +0 -0
- package/lib/types/index.d.ts +53 -0
- package/lib/{interfaces → types/interfaces}/DIConfigurationOptions.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/DILogger.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/DIResolver.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/InjectableProperties.d.ts +8 -4
- package/lib/{interfaces → types/interfaces}/InterceptorContext.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/InterceptorMethods.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/InvokeOptions.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnDestroy.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnInit.d.ts +0 -0
- package/lib/{interfaces/IProvider.d.ts → types/interfaces/ProviderOpts.d.ts} +5 -4
- package/lib/{interfaces → types/interfaces}/RegistrySettings.d.ts +7 -3
- package/lib/types/interfaces/ResolvedInvokeOptions.d.ts +12 -0
- package/lib/{interfaces → types/interfaces}/TokenProvider.d.ts +0 -0
- package/lib/{registries → types/registries}/GlobalProviders.d.ts +11 -5
- package/lib/{registries → types/registries}/ProviderRegistry.d.ts +4 -4
- package/lib/{services → types/services}/DIConfiguration.d.ts +3 -2
- package/lib/{services → types/services}/DILogger.d.ts +0 -0
- package/lib/{services → types/services}/DITest.d.ts +7 -1
- package/lib/{services → types/services}/InjectorService.d.ts +39 -21
- package/lib/types/utils/colors.d.ts +5 -0
- package/lib/{utils → types/utils}/createContainer.d.ts +0 -0
- package/lib/{utils → types/utils}/getConfiguration.d.ts +0 -0
- package/lib/types/utils/runInContext.d.ts +6 -0
- package/lib/{utils → types/utils}/setLoggerLevel.d.ts +0 -0
- package/package.json +31 -12
- package/readme.md +38 -42
- package/tsconfig.compile.esm.json +25 -0
- package/lib/decorators/index.d.ts +0 -13
- package/lib/decorators/inject.d.ts +0 -19
- package/lib/domain/index.d.ts +0 -8
- package/lib/index.d.ts +0 -16
- package/lib/index.js +0 -2271
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -2235
- package/lib/index.modern.js.map +0 -1
- package/lib/interfaces/index.d.ts +0 -13
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { deepMerge, Store } from "@tsed/core";
|
|
2
|
+
export function getConfiguration(module, configuration = {}) {
|
|
3
|
+
const store = Store.from(module).get("configuration") || {};
|
|
4
|
+
const config = {
|
|
5
|
+
...store,
|
|
6
|
+
...configuration
|
|
7
|
+
};
|
|
8
|
+
if (store.mount && configuration.mount) {
|
|
9
|
+
config.mount = deepMerge(store.mount, configuration.mount);
|
|
10
|
+
}
|
|
11
|
+
if (store.componentsScan && configuration.componentsScan) {
|
|
12
|
+
config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];
|
|
13
|
+
}
|
|
14
|
+
return config;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=getConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConfiguration.js","sourceRoot":"","sources":["../../../src/utils/getConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AAElD,MAAM,UAAU,gBAAgB,CAAC,MAAiB,EAAE,gBAAqB,EAAE;IACzE,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IAE5D,MAAM,MAAM,GAAG;QACb,GAAG,KAAK;QACR,GAAG,aAAa;KACjB,CAAC;IAEF,IAAI,KAAK,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK,EAAE;QACtC,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;KAC5D;IAED,IAAI,KAAK,CAAC,cAAc,IAAI,aAAa,CAAC,cAAc,EAAE;QACxD,MAAM,CAAC,cAAc,GAAG,CAAC,GAAG,KAAK,CAAC,cAAc,EAAE,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;KACpF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import {deepMerge, Store, Type} from \"@tsed/core\";\n\nexport function getConfiguration(module: Type<any>, configuration: any = {}) {\n const store = Store.from(module).get(\"configuration\") || {};\n\n const config = {\n ...store,\n ...configuration\n };\n\n if (store.mount && configuration.mount) {\n config.mount = deepMerge(store.mount, configuration.mount);\n }\n\n if (store.componentsScan && configuration.componentsScan) {\n config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];\n }\n\n return config;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
2
|
+
let store;
|
|
3
|
+
export function getAsyncStore() {
|
|
4
|
+
store = store || new AsyncLocalStorage();
|
|
5
|
+
return store;
|
|
6
|
+
}
|
|
7
|
+
export function getContext() {
|
|
8
|
+
return store === null || store === void 0 ? void 0 : store.getStore();
|
|
9
|
+
}
|
|
10
|
+
export function runInContext(ctx, cb) {
|
|
11
|
+
return getAsyncStore().run(ctx, cb);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=runInContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runInContext.js","sourceRoot":"","sources":["../../../src/utils/runInContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAG9C,IAAI,KAAmC,CAAC;AAExC,MAAM,UAAU,aAAa;IAC3B,KAAK,GAAG,KAAK,IAAI,IAAI,iBAAiB,EAAE,CAAC;IACzC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,EAAE,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAc,EAAE,EAAO;IAClD,OAAO,aAAa,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import {AsyncLocalStorage} from \"async_hooks\";\nimport {DIContext} from \"../domain/DIContext\";\n\nlet store: AsyncLocalStorage<DIContext>;\n\nexport function getAsyncStore() {\n store = store || new AsyncLocalStorage();\n return store;\n}\n\nexport function getContext() {\n return store?.getStore();\n}\n\nexport function runInContext(ctx: DIContext, cb: any) {\n return getAsyncStore().run(ctx, cb);\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ignore
|
|
3
|
+
* @param injector
|
|
4
|
+
*/
|
|
5
|
+
export function setLoggerLevel(injector) {
|
|
6
|
+
var _a;
|
|
7
|
+
const level = (_a = injector.settings.logger) === null || _a === void 0 ? void 0 : _a.level;
|
|
8
|
+
if (level) {
|
|
9
|
+
injector.logger.level = level;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=setLoggerLevel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setLoggerLevel.js","sourceRoot":"","sources":["../../../src/utils/setLoggerLevel.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,QAAyB;;IACtD,MAAM,KAAK,GAAG,MAAA,QAAQ,CAAC,QAAQ,CAAC,MAAM,0CAAE,KAAK,CAAC;IAE9C,IAAI,KAAK,EAAE;QACT,QAAQ,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;KAC/B;AACH,CAAC","sourcesContent":["import {InjectorService} from \"../services/InjectorService\";\n\n/**\n * @ignore\n * @param injector\n */\nexport function setLoggerLevel(injector: InjectorService) {\n const level = injector.settings.logger?.level;\n\n if (level) {\n injector.logger.level = level;\n }\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import { ProviderOpts } from "../interfaces/ProviderOpts";
|
|
3
|
+
export declare type PathType = string | RegExp | (string | RegExp)[];
|
|
4
|
+
export interface ControllerMiddlewares {
|
|
5
|
+
useBefore: any[];
|
|
6
|
+
use: any[];
|
|
7
|
+
useAfter: any[];
|
|
8
|
+
}
|
|
9
|
+
export interface ControllerOptions extends Partial<ProviderOpts<any>> {
|
|
10
|
+
path?: PathType;
|
|
11
|
+
children?: Type<any>[];
|
|
12
|
+
routerOptions?: any;
|
|
13
|
+
middlewares?: Partial<ControllerMiddlewares>;
|
|
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
|
+
export declare function Controller(options: PathType | ControllerOptions): ClassDecorator;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { InjectablePropertyOptions } from "../interfaces/InjectableProperties";
|
|
2
|
+
export declare function injectProperty(target: any, propertyKey: string, options: Partial<InjectablePropertyOptions>): void;
|
|
3
|
+
/**
|
|
4
|
+
* Inject a provider to another provider.
|
|
5
|
+
*
|
|
6
|
+
* Use this decorator to inject a custom provider on constructor parameter or property.
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* @Injectable()
|
|
10
|
+
* export class MyService {
|
|
11
|
+
* @Inject(CONNECTION)
|
|
12
|
+
* connection: CONNECTION;
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param symbol
|
|
17
|
+
* @param onGet Use the given name method to inject
|
|
18
|
+
* @returns {Function}
|
|
19
|
+
* @decorator
|
|
20
|
+
*/
|
|
21
|
+
export declare function Inject(symbol?: any, onGet?: (bean: any) => any): Function;
|
|
22
|
+
/**
|
|
23
|
+
* Inject a context like PlatformContext or any BaseContext.
|
|
24
|
+
*
|
|
25
|
+
* ```typescript
|
|
26
|
+
* @Injectable()
|
|
27
|
+
* export class MyService {
|
|
28
|
+
* @InjectContext()
|
|
29
|
+
* ctx?: Context;
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @returns {Function}
|
|
34
|
+
* @decorator
|
|
35
|
+
*/
|
|
36
|
+
export declare function InjectContext(): PropertyDecorator;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ProviderOpts } from "../interfaces/ProviderOpts";
|
|
2
2
|
/**
|
|
3
3
|
* The decorators `@Injectable()` declare a new service can be injected in other service, controller, interceptor, etc.. on there `constructor`.
|
|
4
4
|
* All classes annotated with `@Injectable()` are built one time, excepted if you change the default provider configuration.
|
|
5
5
|
*
|
|
6
|
-
* <<< @/docs/snippets/providers/getting-started-injectable.ts
|
|
7
|
-
*
|
|
8
6
|
* ::: tip
|
|
9
7
|
* `@Injectable()` use the `reflect-metadata` to collect and inject the built provided to other services.
|
|
10
8
|
* :::
|
|
@@ -12,10 +10,11 @@ import type { IProvider } from "../interfaces";
|
|
|
12
10
|
* ### Options
|
|
13
11
|
*
|
|
14
12
|
* - type (@@ProviderType@@ or `string`): Kind of provider. (Default: `ProviderType.PROVIDER`)
|
|
15
|
-
* - scope (@@ProviderScope
|
|
13
|
+
* - scope (@@ProviderScope@@): Kind of provider. (Default: `ProviderScope.SINGLETON`)
|
|
14
|
+
* - provide (@@TokenProvider@@): An injection token (Note: This option override default metadata generated by Typescript).
|
|
16
15
|
* - deps (`Type<any>`): List of class or provider which will be injected to the constructor (Note: This options override default metadata generated by Typescript).
|
|
17
16
|
*
|
|
18
17
|
* @returns {Function}
|
|
19
18
|
* @decorator
|
|
20
19
|
*/
|
|
21
|
-
export declare function Injectable(options?: Partial<
|
|
20
|
+
export declare function Injectable(options?: Partial<ProviderOpts>): ClassDecorator;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
|
-
import type { InterceptorMethods } from "../interfaces";
|
|
2
|
+
import type { InterceptorMethods } from "../interfaces/InterceptorMethods";
|
|
3
3
|
/**
|
|
4
4
|
* Attaches interceptor to method call and executes the before and after methods
|
|
5
5
|
*
|
|
@@ -7,4 +7,4 @@ import type { InterceptorMethods } from "../interfaces";
|
|
|
7
7
|
* @param options
|
|
8
8
|
* @decorator
|
|
9
9
|
*/
|
|
10
|
-
export declare function Intercept<T extends InterceptorMethods>(interceptor: Type<T>, options?: any):
|
|
10
|
+
export declare function Intercept<T extends InterceptorMethods>(interceptor: Type<T>, options?: any): any;
|
|
File without changes
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy load a provider from his package and invoke only when the provider is used
|
|
3
|
+
*
|
|
4
|
+
* ```typescript
|
|
5
|
+
* import type {PlatformException} from "@tsed/platform-exceptions";
|
|
6
|
+
*
|
|
7
|
+
* @Injectable()
|
|
8
|
+
* export class MyService {
|
|
9
|
+
* @LazyInject("PlatformException", () => import("@tsed/platform-exceptions"))
|
|
10
|
+
* exceptions: Promise<PlatformException>;
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @param key
|
|
15
|
+
* @param packageName
|
|
16
|
+
* @param resolver
|
|
17
|
+
* @param optional
|
|
18
|
+
* @returns {Function}
|
|
19
|
+
* @decorator
|
|
20
|
+
*/
|
|
21
|
+
export declare function LazyInject(key: string, resolver: () => any, { optional, packageName }?: {
|
|
22
|
+
optional?: boolean;
|
|
23
|
+
packageName?: string;
|
|
24
|
+
}): PropertyDecorator;
|
|
25
|
+
/**
|
|
26
|
+
* Optionally Lazy load a provider from his package and invoke only when the provider is used
|
|
27
|
+
*
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import type {PlatformException} from "@tsed/platform-exceptions";
|
|
30
|
+
*
|
|
31
|
+
* @Injectable()
|
|
32
|
+
* export class MyService {
|
|
33
|
+
* @OptionalLazyInject("@tsed/platform-exceptions")
|
|
34
|
+
* exceptions: Promise<PlatformException>;
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @param key
|
|
39
|
+
* @param resolver
|
|
40
|
+
* @returns {Function}
|
|
41
|
+
* @decorator
|
|
42
|
+
*/
|
|
43
|
+
export declare function OptionalLazyInject(key: string, resolver: () => any): PropertyDecorator;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ProviderScope } from "../domain";
|
|
2
|
-
import
|
|
1
|
+
import { ProviderScope } from "../domain/ProviderScope";
|
|
2
|
+
import { TokenProvider } from "../interfaces/TokenProvider";
|
|
3
|
+
import { DIResolver } from "../interfaces/DIResolver";
|
|
3
4
|
export interface ModuleOptions extends Omit<TsED.Configuration, "scopes"> {
|
|
4
5
|
/**
|
|
5
6
|
* Provider scope
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ProviderOpts } from "../interfaces/ProviderOpts";
|
|
2
2
|
import type { ProviderType } from "./ProviderType";
|
|
3
3
|
import type { TokenProvider } from "../interfaces/TokenProvider";
|
|
4
|
-
import { LocalsContainer } from "./LocalsContainer";
|
|
5
4
|
import { Provider } from "./Provider";
|
|
6
|
-
export declare class Container extends
|
|
5
|
+
export declare class Container extends Map<TokenProvider, Provider> {
|
|
7
6
|
/**
|
|
8
7
|
*
|
|
9
8
|
* @param token
|
|
10
9
|
* @param settings
|
|
11
10
|
*/
|
|
12
|
-
add(token: TokenProvider, settings?: Partial<
|
|
11
|
+
add(token: TokenProvider, settings?: Partial<ProviderOpts>): this;
|
|
13
12
|
/**
|
|
14
13
|
* Add a provider to the
|
|
15
14
|
* @param token
|
|
16
15
|
* @param settings
|
|
17
16
|
*/
|
|
18
|
-
addProvider(token: TokenProvider, settings?: Partial<
|
|
17
|
+
addProvider(token: TokenProvider, settings?: Partial<ProviderOpts>): this;
|
|
19
18
|
/**
|
|
20
19
|
*
|
|
21
20
|
* @param token
|
|
@@ -32,7 +31,7 @@ export declare class Container extends LocalsContainer<Provider> {
|
|
|
32
31
|
* @returns {T} Returns the element associated with the specified key or undefined if the key can't be found in the Map object.
|
|
33
32
|
* @param token
|
|
34
33
|
*/
|
|
35
|
-
getProvider(token: TokenProvider):
|
|
34
|
+
getProvider<T extends Provider = Provider>(token: TokenProvider): T | undefined;
|
|
36
35
|
/**
|
|
37
36
|
* Get all providers registered in the injector container.
|
|
38
37
|
*
|
|
@@ -11,13 +11,17 @@ export interface ContextLoggerOptions extends Record<string, any> {
|
|
|
11
11
|
additionalProps?: Record<any, any>;
|
|
12
12
|
}
|
|
13
13
|
export declare class ContextLogger {
|
|
14
|
-
#private;
|
|
15
14
|
private logger;
|
|
16
15
|
id: string;
|
|
17
16
|
url: string;
|
|
18
17
|
minimalRequestPicker: Function;
|
|
19
18
|
completeRequestPicker: Function;
|
|
20
19
|
maxStackSize: number;
|
|
20
|
+
private readonly additionalProps;
|
|
21
|
+
private readonly dateStart;
|
|
22
|
+
private readonly ignoreLog;
|
|
23
|
+
private stack;
|
|
24
|
+
private level;
|
|
21
25
|
constructor(logger: any, { id, url, dateStart, ignoreUrlPatterns, minimalRequestPicker, completeRequestPicker, level, maxStackSize, ignoreLog, additionalProps }: ContextLoggerOptions);
|
|
22
26
|
info(obj: any): this;
|
|
23
27
|
debug(obj: any, withRequest?: boolean): this;
|
|
@@ -10,19 +10,12 @@ export interface ContextMethods extends Map<any, any> {
|
|
|
10
10
|
readonly env: Env;
|
|
11
11
|
destroy(): any;
|
|
12
12
|
}
|
|
13
|
-
declare global {
|
|
14
|
-
namespace TsED {
|
|
15
|
-
interface Context {
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
13
|
export interface DIContextOptions extends Omit<ContextLoggerOptions, "dateStart"> {
|
|
20
14
|
id: string;
|
|
21
15
|
logger: any;
|
|
22
16
|
injector?: InjectorService;
|
|
23
17
|
}
|
|
24
18
|
export declare class DIContext extends Map<any, any> implements ContextMethods {
|
|
25
|
-
#private;
|
|
26
19
|
[x: string]: any;
|
|
27
20
|
/**
|
|
28
21
|
* Request id generated by @@contextMiddleware@@.
|
|
@@ -54,18 +47,18 @@ export declare class DIContext extends Map<any, any> implements ContextMethods {
|
|
|
54
47
|
*/
|
|
55
48
|
readonly dateStart: Date;
|
|
56
49
|
/**
|
|
57
|
-
*
|
|
50
|
+
* The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`
|
|
58
51
|
*/
|
|
59
|
-
|
|
60
|
-
constructor({ id, injector, logger, ignoreLog, ...options }: DIContextOptions);
|
|
52
|
+
container: LocalsContainer<any>;
|
|
61
53
|
/**
|
|
62
|
-
*
|
|
54
|
+
* Logger attached to the context request.
|
|
63
55
|
*/
|
|
64
|
-
|
|
56
|
+
logger: ContextLogger;
|
|
65
57
|
/**
|
|
66
58
|
*
|
|
67
59
|
*/
|
|
68
|
-
|
|
60
|
+
injector: InjectorService;
|
|
61
|
+
constructor({ id, injector, logger, ignoreLog, ...options }: DIContextOptions);
|
|
69
62
|
get env(): any;
|
|
70
63
|
destroy(): Promise<void>;
|
|
71
64
|
emit(eventName: string, ...args: any[]): Promise<void>;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { Store, Type } from "@tsed/core";
|
|
2
|
-
import {
|
|
2
|
+
import { ProviderOpts } from "../interfaces/ProviderOpts";
|
|
3
|
+
import { TokenProvider } from "../interfaces/TokenProvider";
|
|
3
4
|
import { ProviderScope } from "./ProviderScope";
|
|
4
5
|
import { ProviderType } from "./ProviderType";
|
|
5
|
-
export declare class Provider<T = any> implements
|
|
6
|
-
#private;
|
|
6
|
+
export declare class Provider<T = any> implements ProviderOpts<T> {
|
|
7
7
|
type: ProviderType | any;
|
|
8
|
-
instance: T;
|
|
9
8
|
deps: TokenProvider[];
|
|
10
9
|
imports: any[];
|
|
11
10
|
useFactory: Function;
|
|
12
11
|
useAsyncFactory: Function;
|
|
13
12
|
useValue: any;
|
|
14
|
-
|
|
13
|
+
hooks?: Record<string, (instance: T, ...args: any[]) => Promise<void> | void>;
|
|
14
|
+
private _useClass;
|
|
15
|
+
private _provide;
|
|
16
|
+
private _store;
|
|
17
|
+
private _tokenStore;
|
|
15
18
|
[key: string]: any;
|
|
16
19
|
constructor(token: TokenProvider, options?: Partial<Provider>);
|
|
17
20
|
get token(): any;
|
|
@@ -26,6 +29,8 @@ export declare class Provider<T = any> implements IProvider<T> {
|
|
|
26
29
|
get className(): string;
|
|
27
30
|
get name(): string;
|
|
28
31
|
get store(): Store;
|
|
32
|
+
get path(): string;
|
|
33
|
+
set path(path: string);
|
|
29
34
|
/**
|
|
30
35
|
* Get the scope of the provider.
|
|
31
36
|
*
|
|
@@ -43,8 +48,19 @@ export declare class Provider<T = any> implements IProvider<T> {
|
|
|
43
48
|
set scope(scope: ProviderScope);
|
|
44
49
|
get configuration(): Partial<TsED.Configuration>;
|
|
45
50
|
set configuration(configuration: Partial<TsED.Configuration>);
|
|
51
|
+
get children(): TokenProvider[];
|
|
46
52
|
get(key: string): any;
|
|
47
53
|
isAsync(): boolean;
|
|
48
54
|
clone(): Provider;
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @returns {boolean}
|
|
58
|
+
*/
|
|
59
|
+
hasChildren(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @returns {boolean}
|
|
63
|
+
*/
|
|
64
|
+
hasParent(): boolean;
|
|
49
65
|
toString(): string;
|
|
50
66
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./constants/constants";
|
|
5
|
+
export * from "./decorators/configuration";
|
|
6
|
+
export * from "./decorators/constant";
|
|
7
|
+
export * from "./decorators/controller";
|
|
8
|
+
export * from "./decorators/inject";
|
|
9
|
+
export * from "./decorators/injectable";
|
|
10
|
+
export * from "./decorators/intercept";
|
|
11
|
+
export * from "./decorators/interceptor";
|
|
12
|
+
export * from "./decorators/lazyInject";
|
|
13
|
+
export * from "./decorators/module";
|
|
14
|
+
export * from "./decorators/opts";
|
|
15
|
+
export * from "./decorators/overrideProvider";
|
|
16
|
+
export * from "./decorators/scope";
|
|
17
|
+
export * from "./decorators/service";
|
|
18
|
+
export * from "./decorators/useOpts";
|
|
19
|
+
export * from "./decorators/value";
|
|
20
|
+
export * from "./domain/Container";
|
|
21
|
+
export * from "./domain/ContextLogger";
|
|
22
|
+
export * from "./domain/DIContext";
|
|
23
|
+
export * from "./domain/InjectablePropertyType";
|
|
24
|
+
export * from "./domain/LocalsContainer";
|
|
25
|
+
export * from "./domain/Provider";
|
|
26
|
+
export * from "./domain/ProviderScope";
|
|
27
|
+
export * from "./domain/ProviderType";
|
|
28
|
+
export * from "./errors/InjectionError";
|
|
29
|
+
export * from "./errors/UndefinedTokenError";
|
|
30
|
+
export * from "./interfaces/DIConfigurationOptions";
|
|
31
|
+
export * from "./interfaces/DILogger";
|
|
32
|
+
export * from "./interfaces/DIResolver";
|
|
33
|
+
export * from "./interfaces/InjectableProperties";
|
|
34
|
+
export * from "./interfaces/InterceptorContext";
|
|
35
|
+
export * from "./interfaces/InterceptorMethods";
|
|
36
|
+
export * from "./interfaces/InvokeOptions";
|
|
37
|
+
export * from "./interfaces/OnDestroy";
|
|
38
|
+
export * from "./interfaces/OnInit";
|
|
39
|
+
export * from "./interfaces/ProviderOpts";
|
|
40
|
+
export * from "./interfaces/RegistrySettings";
|
|
41
|
+
export * from "./interfaces/ResolvedInvokeOptions";
|
|
42
|
+
export * from "./interfaces/TokenProvider";
|
|
43
|
+
export * from "./registries/GlobalProviders";
|
|
44
|
+
export * from "./registries/ProviderRegistry";
|
|
45
|
+
export * from "./services/DIConfiguration";
|
|
46
|
+
export * from "./services/DILogger";
|
|
47
|
+
export * from "./services/DITest";
|
|
48
|
+
export * from "./services/InjectorService";
|
|
49
|
+
export * from "./utils/colors";
|
|
50
|
+
export * from "./utils/createContainer";
|
|
51
|
+
export * from "./utils/getConfiguration";
|
|
52
|
+
export * from "./utils/runInContext";
|
|
53
|
+
export * from "./utils/setLoggerLevel";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import type { InjectablePropertyType } from "../domain/InjectablePropertyType";
|
|
2
2
|
import type { TokenProvider } from "./TokenProvider";
|
|
3
|
+
import type { InjectorService } from "../services/InjectorService";
|
|
4
|
+
import type { InvokeOptions } from "./InvokeOptions";
|
|
3
5
|
export interface InjectableProperty {
|
|
4
6
|
propertyKey: string;
|
|
5
7
|
}
|
|
6
|
-
export interface
|
|
8
|
+
export interface InjectablePropertyOptions extends InjectableProperty {
|
|
7
9
|
bindingType: InjectablePropertyType.METHOD | InjectablePropertyType.PROPERTY | InjectablePropertyType.INTERCEPTOR;
|
|
8
10
|
propertyType: string;
|
|
9
|
-
useType
|
|
10
|
-
|
|
11
|
+
useType?: TokenProvider;
|
|
12
|
+
resolver: (injector: InjectorService, locals: Map<TokenProvider, any>, options: Partial<InvokeOptions> & {
|
|
13
|
+
options: any;
|
|
14
|
+
}) => () => any;
|
|
11
15
|
options?: any;
|
|
12
16
|
}
|
|
13
17
|
export interface InjectablePropertyValue extends InjectableProperty {
|
|
@@ -16,5 +20,5 @@ export interface InjectablePropertyValue extends InjectableProperty {
|
|
|
16
20
|
defaultValue?: any;
|
|
17
21
|
}
|
|
18
22
|
export interface InjectableProperties {
|
|
19
|
-
[key: string]:
|
|
23
|
+
[key: string]: InjectablePropertyOptions | InjectablePropertyValue;
|
|
20
24
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,10 +3,7 @@ import type { DIResolver } from "./DIResolver";
|
|
|
3
3
|
import type { ProviderScope } from "../domain/ProviderScope";
|
|
4
4
|
import type { ProviderType } from "../domain/ProviderType";
|
|
5
5
|
import type { TokenProvider } from "./TokenProvider";
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
export interface IProvider<T = any> {
|
|
6
|
+
export interface ProviderOpts<T = any> {
|
|
10
7
|
/**
|
|
11
8
|
* An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).
|
|
12
9
|
*/
|
|
@@ -47,6 +44,10 @@ export interface IProvider<T = any> {
|
|
|
47
44
|
* A list of resolvers which will be used to resolve missing Symbol/Class when injector invoke a Class. This property allow external DI usage.
|
|
48
45
|
*/
|
|
49
46
|
resolvers?: DIResolver[];
|
|
47
|
+
/**
|
|
48
|
+
* hooks to intercept custom events
|
|
49
|
+
*/
|
|
50
|
+
hooks?: Record<string, (instance: T, ...args: any[]) => Promise<any> | any>;
|
|
50
51
|
/**
|
|
51
52
|
*
|
|
52
53
|
*/
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
|
-
import type { Provider } from "../domain";
|
|
2
|
+
import type { Provider } from "../domain/Provider";
|
|
3
|
+
import type { InjectorService } from "../services/InjectorService";
|
|
4
|
+
import type { ResolvedInvokeOptions } from "./ResolvedInvokeOptions";
|
|
3
5
|
/**
|
|
4
6
|
* @ignore
|
|
5
7
|
*/
|
|
@@ -10,7 +12,9 @@ export interface RegistrySettings {
|
|
|
10
12
|
*
|
|
11
13
|
* @param provider
|
|
12
14
|
* @param {Map<string | Function, any>} locals
|
|
13
|
-
* @param
|
|
15
|
+
* @param options
|
|
14
16
|
*/
|
|
15
|
-
onInvoke?(provider: Provider, locals: Map<string | Function, any>,
|
|
17
|
+
onInvoke?(provider: Provider, locals: Map<string | Function, any>, options: ResolvedInvokeOptions & {
|
|
18
|
+
injector: InjectorService;
|
|
19
|
+
}): void;
|
|
16
20
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Provider } from "../domain/Provider";
|
|
2
|
+
import type { ProviderScope } from "../domain/ProviderScope";
|
|
3
|
+
import type { TokenProvider } from "./TokenProvider";
|
|
4
|
+
export interface ResolvedInvokeOptions {
|
|
5
|
+
token: TokenProvider;
|
|
6
|
+
parent?: TokenProvider;
|
|
7
|
+
scope: ProviderScope;
|
|
8
|
+
deps: TokenProvider[];
|
|
9
|
+
imports: TokenProvider[];
|
|
10
|
+
provider: Provider;
|
|
11
|
+
construct(deps: TokenProvider[]): any;
|
|
12
|
+
}
|
|
File without changes
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
2
|
import { Provider } from "../domain/Provider";
|
|
3
|
-
import type {
|
|
3
|
+
import type { InjectorService } from "../services/InjectorService";
|
|
4
|
+
import { ResolvedInvokeOptions } from "../interfaces/ResolvedInvokeOptions";
|
|
5
|
+
import { TokenProvider } from "../interfaces/TokenProvider";
|
|
6
|
+
import { RegistrySettings } from "../interfaces/RegistrySettings";
|
|
7
|
+
import { ProviderOpts } from "../interfaces/ProviderOpts";
|
|
4
8
|
export declare class GlobalProviderRegistry extends Map<TokenProvider, Provider> {
|
|
5
9
|
#private;
|
|
6
10
|
/**
|
|
@@ -26,7 +30,7 @@ export declare class GlobalProviderRegistry extends Map<TokenProvider, Provider>
|
|
|
26
30
|
* @param target
|
|
27
31
|
* @param options
|
|
28
32
|
*/
|
|
29
|
-
merge(target: TokenProvider, options: Partial<
|
|
33
|
+
merge(target: TokenProvider, options: Partial<ProviderOpts>): void;
|
|
30
34
|
/**
|
|
31
35
|
* The delete() method removes the specified element from a Map object.
|
|
32
36
|
* @param key Required. The key of the element to remove from the Map object.
|
|
@@ -34,15 +38,17 @@ export declare class GlobalProviderRegistry extends Map<TokenProvider, Provider>
|
|
|
34
38
|
*/
|
|
35
39
|
delete(key: TokenProvider): boolean;
|
|
36
40
|
createRegistry(type: string, model: Type<Provider>, options?: Partial<RegistrySettings>): this;
|
|
37
|
-
onInvoke(provider: Provider, locals: Map<TokenProvider, any>,
|
|
41
|
+
onInvoke(provider: Provider, locals: Map<TokenProvider, any>, options: ResolvedInvokeOptions & {
|
|
42
|
+
injector: InjectorService;
|
|
43
|
+
}): void;
|
|
38
44
|
getRegistrySettings(target: string | TokenProvider): RegistrySettings;
|
|
39
|
-
createRegisterFn(type: string): (provider: any |
|
|
45
|
+
createRegisterFn(type: string): (provider: any | ProviderOpts, instance?: any) => void;
|
|
40
46
|
/**
|
|
41
47
|
*
|
|
42
48
|
* @param key
|
|
43
49
|
* @param options
|
|
44
50
|
*/
|
|
45
|
-
protected createIfNotExists(key: TokenProvider, options: Partial<
|
|
51
|
+
protected createIfNotExists(key: TokenProvider, options: Partial<ProviderOpts>): Provider;
|
|
46
52
|
}
|
|
47
53
|
/**
|
|
48
54
|
*
|