@tsed/di 7.0.0-alpha.2 → 7.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/constants/constants.js +7 -0
- package/lib/cjs/constants/constants.js.map +1 -0
- package/lib/cjs/decorators/configuration.js +24 -0
- package/lib/cjs/decorators/configuration.js.map +1 -0
- package/lib/cjs/decorators/constant.js +55 -0
- package/lib/cjs/decorators/constant.js.map +1 -0
- package/lib/cjs/decorators/controller.js +53 -0
- package/lib/cjs/decorators/controller.js.map +1 -0
- package/lib/cjs/decorators/inject.js +104 -0
- package/lib/cjs/decorators/inject.js.map +1 -0
- package/lib/cjs/decorators/injectable.js +32 -0
- package/lib/cjs/decorators/injectable.js.map +1 -0
- package/lib/cjs/decorators/intercept.js +36 -0
- package/lib/cjs/decorators/intercept.js.map +1 -0
- package/lib/cjs/decorators/interceptor.js +21 -0
- package/lib/cjs/decorators/interceptor.js.map +1 -0
- package/lib/cjs/decorators/lazyInject.js +71 -0
- package/lib/cjs/decorators/lazyInject.js.map +1 -0
- package/lib/cjs/decorators/module.js +32 -0
- package/lib/cjs/decorators/module.js.map +1 -0
- package/lib/cjs/decorators/opts.js +54 -0
- package/lib/cjs/decorators/opts.js.map +1 -0
- package/lib/cjs/decorators/overrideProvider.js +17 -0
- package/lib/cjs/decorators/overrideProvider.js.map +1 -0
- package/lib/cjs/decorators/scope.js +16 -0
- package/lib/cjs/decorators/scope.js.map +1 -0
- package/lib/cjs/decorators/service.js +18 -0
- package/lib/cjs/decorators/service.js.map +1 -0
- package/lib/cjs/decorators/useOpts.js +65 -0
- package/lib/cjs/decorators/useOpts.js.map +1 -0
- package/lib/cjs/decorators/value.js +55 -0
- package/lib/cjs/decorators/value.js.map +1 -0
- package/lib/cjs/domain/Container.js +72 -0
- package/lib/cjs/domain/Container.js.map +1 -0
- package/lib/cjs/domain/ContextLogger.js +85 -0
- package/lib/cjs/domain/ContextLogger.js.map +1 -0
- package/lib/cjs/domain/DIContext.js +45 -0
- package/lib/cjs/domain/DIContext.js.map +1 -0
- package/lib/cjs/domain/InjectablePropertyType.js +12 -0
- package/lib/cjs/domain/InjectablePropertyType.js.map +1 -0
- package/lib/cjs/domain/LocalsContainer.js +55 -0
- package/lib/cjs/domain/LocalsContainer.js.map +1 -0
- package/lib/cjs/domain/Provider.js +122 -0
- package/lib/cjs/domain/Provider.js.map +1 -0
- package/lib/cjs/domain/ProviderScope.js +10 -0
- package/lib/cjs/domain/ProviderScope.js.map +1 -0
- package/lib/cjs/domain/ProviderType.js +15 -0
- package/lib/cjs/domain/ProviderType.js.map +1 -0
- package/lib/cjs/errors/InjectionError.js +58 -0
- package/lib/cjs/errors/InjectionError.js.map +1 -0
- package/lib/cjs/errors/UndefinedTokenError.js +11 -0
- package/lib/cjs/errors/UndefinedTokenError.js.map +1 -0
- package/lib/cjs/index.js +59 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/interfaces/DIConfigurationOptions.js +3 -0
- package/lib/cjs/interfaces/DIConfigurationOptions.js.map +1 -0
- package/lib/cjs/interfaces/DILogger.js +3 -0
- package/lib/cjs/interfaces/DILogger.js.map +1 -0
- package/lib/cjs/interfaces/DIResolver.js +3 -0
- package/lib/cjs/interfaces/DIResolver.js.map +1 -0
- package/lib/cjs/interfaces/InjectableProperties.js +3 -0
- package/lib/cjs/interfaces/InjectableProperties.js.map +1 -0
- package/lib/cjs/interfaces/InterceptorContext.js +3 -0
- package/lib/cjs/interfaces/InterceptorContext.js.map +1 -0
- package/lib/cjs/interfaces/InterceptorMethods.js +3 -0
- package/lib/cjs/interfaces/InterceptorMethods.js.map +1 -0
- package/lib/cjs/interfaces/InvokeOptions.js +3 -0
- package/lib/cjs/interfaces/InvokeOptions.js.map +1 -0
- package/lib/cjs/interfaces/OnDestroy.js +3 -0
- package/lib/cjs/interfaces/OnDestroy.js.map +1 -0
- package/lib/cjs/interfaces/OnInit.js +3 -0
- package/lib/cjs/interfaces/OnInit.js.map +1 -0
- package/lib/cjs/interfaces/ProviderOpts.js +3 -0
- package/lib/cjs/interfaces/ProviderOpts.js.map +1 -0
- package/lib/cjs/interfaces/RegistrySettings.js +3 -0
- package/lib/cjs/interfaces/RegistrySettings.js.map +1 -0
- package/lib/cjs/interfaces/ResolvedInvokeOptions.js +3 -0
- package/lib/cjs/interfaces/ResolvedInvokeOptions.js.map +1 -0
- package/lib/cjs/interfaces/TokenProvider.js +3 -0
- package/lib/cjs/interfaces/TokenProvider.js.map +1 -0
- package/lib/cjs/interfaces/TokenRoute.js +3 -0
- package/lib/cjs/interfaces/TokenRoute.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/registries/GlobalProviders.js +124 -0
- package/lib/cjs/registries/GlobalProviders.js.map +1 -0
- package/lib/cjs/registries/ProviderRegistry.js +86 -0
- package/lib/cjs/registries/ProviderRegistry.js.map +1 -0
- package/lib/cjs/services/DIConfiguration.js +136 -0
- package/lib/cjs/services/DIConfiguration.js.map +1 -0
- package/lib/cjs/services/DILogger.js +13 -0
- package/lib/cjs/services/DILogger.js.map +1 -0
- package/lib/cjs/services/DITest.js +116 -0
- package/lib/cjs/services/DITest.js.map +1 -0
- package/lib/cjs/services/InjectorService.js +589 -0
- package/lib/cjs/services/InjectorService.js.map +1 -0
- package/lib/cjs/utils/colors.js +10 -0
- package/lib/cjs/utils/colors.js.map +1 -0
- package/lib/cjs/utils/createContainer.js +14 -0
- package/lib/cjs/utils/createContainer.js.map +1 -0
- package/lib/cjs/utils/getConfiguration.js +29 -0
- package/lib/cjs/utils/getConfiguration.js.map +1 -0
- package/lib/cjs/utils/resolveControllers.js +47 -0
- package/lib/cjs/utils/resolveControllers.js.map +1 -0
- package/lib/cjs/utils/runInContext.js +19 -0
- package/lib/cjs/utils/runInContext.js.map +1 -0
- package/lib/cjs/utils/setLoggerLevel.js +16 -0
- package/lib/cjs/utils/setLoggerLevel.js.map +1 -0
- package/lib/esm/constants/constants.js +4 -0
- package/lib/esm/constants/constants.js.map +1 -0
- package/lib/esm/decorators/configuration.js +20 -0
- package/lib/esm/decorators/configuration.js.map +1 -0
- package/lib/esm/decorators/constant.js +51 -0
- package/lib/esm/decorators/constant.js.map +1 -0
- package/lib/esm/decorators/controller.js +49 -0
- package/lib/esm/decorators/controller.js.map +1 -0
- package/lib/esm/decorators/inject.js +98 -0
- package/lib/esm/decorators/inject.js.map +1 -0
- package/lib/esm/decorators/injectable.js +28 -0
- package/lib/esm/decorators/injectable.js.map +1 -0
- package/lib/esm/decorators/intercept.js +32 -0
- package/lib/esm/decorators/intercept.js.map +1 -0
- package/lib/esm/decorators/interceptor.js +17 -0
- package/lib/esm/decorators/interceptor.js.map +1 -0
- package/lib/esm/decorators/lazyInject.js +66 -0
- package/lib/esm/decorators/lazyInject.js.map +1 -0
- package/lib/esm/decorators/module.js +28 -0
- package/lib/esm/decorators/module.js.map +1 -0
- package/lib/esm/decorators/opts.js +50 -0
- package/lib/esm/decorators/opts.js.map +1 -0
- package/lib/esm/decorators/overrideProvider.js +13 -0
- package/lib/esm/decorators/overrideProvider.js.map +1 -0
- package/lib/esm/decorators/scope.js +12 -0
- package/lib/esm/decorators/scope.js.map +1 -0
- package/lib/esm/decorators/service.js +14 -0
- package/lib/esm/decorators/service.js.map +1 -0
- package/lib/esm/decorators/useOpts.js +61 -0
- package/lib/esm/decorators/useOpts.js.map +1 -0
- package/lib/esm/decorators/value.js +51 -0
- package/lib/esm/decorators/value.js.map +1 -0
- package/lib/esm/domain/Container.js +68 -0
- package/lib/esm/domain/Container.js.map +1 -0
- package/lib/esm/domain/ContextLogger.js +81 -0
- package/lib/esm/domain/ContextLogger.js.map +1 -0
- package/lib/esm/domain/DIContext.js +41 -0
- package/lib/esm/domain/DIContext.js.map +1 -0
- package/lib/esm/domain/InjectablePropertyType.js +9 -0
- package/lib/esm/domain/InjectablePropertyType.js.map +1 -0
- package/lib/esm/domain/LocalsContainer.js +51 -0
- package/lib/esm/domain/LocalsContainer.js.map +1 -0
- package/lib/esm/domain/Provider.js +118 -0
- package/lib/esm/domain/Provider.js.map +1 -0
- package/lib/esm/domain/ProviderScope.js +7 -0
- package/lib/esm/domain/ProviderScope.js.map +1 -0
- package/lib/esm/domain/ProviderType.js +12 -0
- package/lib/esm/domain/ProviderType.js.map +1 -0
- package/lib/esm/errors/InjectionError.js +54 -0
- package/lib/esm/errors/InjectionError.js.map +1 -0
- package/lib/esm/errors/UndefinedTokenError.js +7 -0
- package/lib/esm/errors/UndefinedTokenError.js.map +1 -0
- package/lib/esm/index.js +56 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/DIConfigurationOptions.js +2 -0
- package/lib/esm/interfaces/DIConfigurationOptions.js.map +1 -0
- package/lib/esm/interfaces/DILogger.js +2 -0
- package/lib/esm/interfaces/DILogger.js.map +1 -0
- package/lib/esm/interfaces/DIResolver.js +2 -0
- package/lib/esm/interfaces/DIResolver.js.map +1 -0
- package/lib/esm/interfaces/InjectableProperties.js +2 -0
- package/lib/esm/interfaces/InjectableProperties.js.map +1 -0
- package/lib/esm/interfaces/InterceptorContext.js +2 -0
- package/lib/esm/interfaces/InterceptorContext.js.map +1 -0
- package/lib/esm/interfaces/InterceptorMethods.js +2 -0
- package/lib/esm/interfaces/InterceptorMethods.js.map +1 -0
- package/lib/esm/interfaces/InvokeOptions.js +2 -0
- package/lib/esm/interfaces/InvokeOptions.js.map +1 -0
- package/lib/esm/interfaces/OnDestroy.js +2 -0
- package/lib/esm/interfaces/OnDestroy.js.map +1 -0
- package/lib/esm/interfaces/OnInit.js +2 -0
- package/lib/esm/interfaces/OnInit.js.map +1 -0
- package/lib/esm/interfaces/ProviderOpts.js +2 -0
- package/lib/esm/interfaces/ProviderOpts.js.map +1 -0
- package/lib/esm/interfaces/RegistrySettings.js +2 -0
- package/lib/esm/interfaces/RegistrySettings.js.map +1 -0
- package/lib/esm/interfaces/ResolvedInvokeOptions.js +2 -0
- package/lib/esm/interfaces/ResolvedInvokeOptions.js.map +1 -0
- package/lib/esm/interfaces/TokenProvider.js +2 -0
- package/lib/esm/interfaces/TokenProvider.js.map +1 -0
- package/lib/esm/interfaces/TokenRoute.js +2 -0
- package/lib/esm/interfaces/TokenRoute.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/registries/GlobalProviders.js +120 -0
- package/lib/esm/registries/GlobalProviders.js.map +1 -0
- package/lib/esm/registries/ProviderRegistry.js +81 -0
- package/lib/esm/registries/ProviderRegistry.js.map +1 -0
- package/lib/esm/services/DIConfiguration.js +132 -0
- package/lib/esm/services/DIConfiguration.js.map +1 -0
- package/lib/esm/services/DILogger.js +11 -0
- package/lib/esm/services/DILogger.js.map +1 -0
- package/lib/esm/services/DITest.js +112 -0
- package/lib/esm/services/DITest.js.map +1 -0
- package/lib/esm/services/InjectorService.js +586 -0
- package/lib/esm/services/InjectorService.js.map +1 -0
- package/lib/esm/utils/colors.js +7 -0
- package/lib/esm/utils/colors.js.map +1 -0
- package/lib/esm/utils/createContainer.js +10 -0
- package/lib/esm/utils/createContainer.js.map +1 -0
- package/lib/esm/utils/getConfiguration.js +24 -0
- package/lib/esm/utils/getConfiguration.js.map +1 -0
- package/lib/esm/utils/resolveControllers.js +42 -0
- package/lib/esm/utils/resolveControllers.js.map +1 -0
- package/lib/esm/utils/runInContext.js +13 -0
- package/lib/esm/utils/runInContext.js.map +1 -0
- package/lib/esm/utils/setLoggerLevel.js +12 -0
- package/lib/esm/utils/setLoggerLevel.js.map +1 -0
- package/lib/{constants/index.d.ts → types/constants/constants.d.ts} +0 -0
- package/lib/{decorators → types/decorators}/configuration.d.ts +0 -0
- package/lib/{decorators → types/decorators}/constant.d.ts +0 -0
- package/lib/{decorators → types/decorators}/controller.d.ts +2 -2
- package/lib/types/decorators/inject.d.ts +36 -0
- package/lib/{decorators → types/decorators}/injectable.d.ts +4 -5
- package/lib/{decorators → types/decorators}/intercept.d.ts +2 -2
- package/lib/{decorators → types/decorators}/interceptor.d.ts +0 -0
- package/lib/types/decorators/lazyInject.d.ts +43 -0
- package/lib/{decorators → types/decorators}/module.d.ts +3 -2
- package/lib/{decorators → types/decorators}/opts.d.ts +0 -0
- package/lib/{decorators → types/decorators}/overrideProvider.d.ts +0 -0
- package/lib/{decorators → types/decorators}/scope.d.ts +0 -0
- package/lib/{decorators → types/decorators}/service.d.ts +0 -0
- package/lib/{decorators → types/decorators}/useOpts.d.ts +0 -0
- package/lib/{decorators → types/decorators}/value.d.ts +0 -0
- package/lib/{domain → types/domain}/Container.d.ts +5 -6
- package/lib/{domain → types/domain}/ContextLogger.d.ts +0 -0
- package/lib/{domain → types/domain}/DIContext.d.ts +0 -6
- package/lib/{domain → types/domain}/InjectablePropertyType.d.ts +0 -0
- package/lib/{domain → types/domain}/LocalsContainer.d.ts +0 -0
- package/lib/{domain → types/domain}/Provider.d.ts +17 -3
- package/lib/{domain → types/domain}/ProviderScope.d.ts +0 -0
- package/lib/{domain → types/domain}/ProviderType.d.ts +0 -0
- package/lib/{errors → types/errors}/InjectionError.d.ts +1 -1
- package/lib/{errors → types/errors}/UndefinedTokenError.d.ts +0 -0
- package/lib/types/index.d.ts +55 -0
- package/lib/{interfaces → types/interfaces}/DIConfigurationOptions.d.ts +4 -0
- package/lib/{interfaces → types/interfaces}/DILogger.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/DIResolver.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/InjectableProperties.d.ts +8 -4
- package/lib/{interfaces → types/interfaces}/InterceptorContext.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/InterceptorMethods.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/InvokeOptions.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnDestroy.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnInit.d.ts +0 -0
- package/lib/{interfaces/IProvider.d.ts → types/interfaces/ProviderOpts.d.ts} +5 -4
- package/lib/{interfaces → types/interfaces}/RegistrySettings.d.ts +7 -3
- package/lib/types/interfaces/ResolvedInvokeOptions.d.ts +12 -0
- package/lib/{interfaces → types/interfaces}/TokenProvider.d.ts +0 -0
- package/lib/types/interfaces/TokenRoute.d.ts +5 -0
- package/lib/{registries → types/registries}/GlobalProviders.d.ts +11 -5
- package/lib/{registries → types/registries}/ProviderRegistry.d.ts +4 -4
- package/lib/{services → types/services}/DIConfiguration.d.ts +6 -2
- package/lib/{services → types/services}/DILogger.d.ts +0 -0
- package/lib/{services → types/services}/DITest.d.ts +7 -1
- package/lib/{services → types/services}/InjectorService.d.ts +45 -22
- package/lib/types/utils/colors.d.ts +5 -0
- package/lib/{utils → types/utils}/createContainer.d.ts +0 -0
- package/lib/{utils → types/utils}/getConfiguration.d.ts +1 -0
- package/lib/types/utils/resolveControllers.d.ts +12 -0
- package/lib/types/utils/runInContext.d.ts +6 -0
- package/lib/{utils → types/utils}/setLoggerLevel.d.ts +0 -0
- package/package.json +32 -16
- package/readme.md +37 -41
- package/tsconfig.compile.esm.json +25 -0
- package/lib/decorators/index.d.ts +0 -14
- package/lib/decorators/inject.d.ts +0 -19
- package/lib/domain/index.d.ts +0 -8
- package/lib/index.d.ts +0 -16
- package/lib/index.js +0 -2269
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -2232
- package/lib/index.modern.js.map +0 -1
- package/lib/interfaces/index.d.ts +0 -13
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Container } from "../domain/Container.js";
|
|
2
|
+
import { GlobalProviders } from "../registries/GlobalProviders.js";
|
|
3
|
+
export function createContainer(rootModule) {
|
|
4
|
+
const container = new Container(GlobalProviders.entries());
|
|
5
|
+
if (rootModule) {
|
|
6
|
+
container.delete(rootModule);
|
|
7
|
+
}
|
|
8
|
+
return container;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=createContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createContainer.js","sourceRoot":"","sources":["../../../src/utils/createContainer.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAE9D,MAAM,UAAU,eAAe,CAAC,UAAsB;IACpD,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IAE3D,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;KAC9B;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {Container} from \"../domain/Container\";\nimport {GlobalProviders} from \"../registries/GlobalProviders\";\n\nexport function createContainer(rootModule?: Type<any>) {\n const container = new Container(GlobalProviders.entries());\n\n if (rootModule) {\n container.delete(rootModule);\n }\n\n return container;\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Store } from "@tsed/core";
|
|
2
|
+
export function mergeMount(m1 = {}, m2 = {}) {
|
|
3
|
+
return Object.entries(m2).reduce((mount, [key, controllers]) => {
|
|
4
|
+
return {
|
|
5
|
+
...mount,
|
|
6
|
+
[key]: (mount[key] || []).concat(controllers)
|
|
7
|
+
};
|
|
8
|
+
}, m1);
|
|
9
|
+
}
|
|
10
|
+
export function getConfiguration(module, configuration = {}) {
|
|
11
|
+
const store = Store.from(module).get("configuration") || {};
|
|
12
|
+
const config = {
|
|
13
|
+
...store,
|
|
14
|
+
...configuration
|
|
15
|
+
};
|
|
16
|
+
if (store.mount && configuration.mount) {
|
|
17
|
+
config.mount = mergeMount(store.mount, configuration.mount);
|
|
18
|
+
}
|
|
19
|
+
if (store.componentsScan && configuration.componentsScan) {
|
|
20
|
+
config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];
|
|
21
|
+
}
|
|
22
|
+
return config;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=getConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConfiguration.js","sourceRoot":"","sources":["../../../src/utils/getConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAO,MAAM,YAAY,CAAC;AAEvC,MAAM,UAAU,UAAU,CAAC,KAAU,EAAE,EAAE,KAAU,EAAE;IACnD,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,EAAE;QAC7D,OAAO;YACL,GAAG,KAAK;YACR,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;SAC9C,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED,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,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;KAC7D;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 {Store, Type} from \"@tsed/core\";\n\nexport function mergeMount(m1: any = {}, m2: any = {}) {\n return Object.entries(m2).reduce((mount, [key, controllers]) => {\n return {\n ...mount,\n [key]: (mount[key] || []).concat(controllers)\n };\n }, m1);\n}\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 = mergeMount(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,42 @@
|
|
|
1
|
+
import { isArray, isClass } from "@tsed/core";
|
|
2
|
+
import { GlobalProviders } from "../registries/GlobalProviders.js";
|
|
3
|
+
import { ProviderType } from "../domain/ProviderType.js";
|
|
4
|
+
const lookupProperties = ["mount", "imports"];
|
|
5
|
+
export function getTokens(config) {
|
|
6
|
+
if (!config) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
if (isArray(config)) {
|
|
10
|
+
return config.filter(isClass).map((value) => {
|
|
11
|
+
return { token: value };
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return Object.keys(config).reduce((list, route) => {
|
|
15
|
+
return [
|
|
16
|
+
...list,
|
|
17
|
+
...[]
|
|
18
|
+
.concat(config[route])
|
|
19
|
+
.filter(isClass)
|
|
20
|
+
.map((token) => ({
|
|
21
|
+
route,
|
|
22
|
+
token
|
|
23
|
+
}))
|
|
24
|
+
];
|
|
25
|
+
}, []);
|
|
26
|
+
}
|
|
27
|
+
function resolveRecursively(providers) {
|
|
28
|
+
return providers
|
|
29
|
+
.map(({ token }) => GlobalProviders.get(token))
|
|
30
|
+
.filter((provider) => (provider === null || provider === void 0 ? void 0 : provider.type) === ProviderType.MODULE && provider.configuration)
|
|
31
|
+
.flatMap((provider) => resolveControllers(provider.configuration));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Return controllers and is base route according to his configuration in module configuration.
|
|
35
|
+
*
|
|
36
|
+
* @param settings
|
|
37
|
+
*/
|
|
38
|
+
export function resolveControllers(settings) {
|
|
39
|
+
const providers = lookupProperties.flatMap((property) => getTokens(settings[property]));
|
|
40
|
+
return [...resolveRecursively(providers), ...providers].filter((provider) => !!provider.route);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=resolveControllers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveControllers.js","sourceRoot":"","sources":["../../../src/utils/resolveControllers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAIpD,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAE9C,MAAM,UAAU,SAAS,CAAC,MAAW;IACnC,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,EAAE,CAAC;KACX;IAED,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;QACnB,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE;YAC/C,OAAO,EAAC,KAAK,EAAE,KAAK,EAAC,CAAC;QACxB,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,IAAW,EAAE,KAAa,EAAE,EAAE;QAC/D,OAAO;YACL,GAAG,IAAI;YACP,GAAG,EAAE;iBACF,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;iBACrB,MAAM,CAAC,OAAO,CAAC;iBACf,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACf,KAAK;gBACL,KAAK;aACN,CAAC,CAAC;SACN,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED,SAAS,kBAAkB,CAAC,SAAmD;IAC7E,OAAO,SAAS;SACb,GAAG,CAAC,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC5C,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,YAAY,CAAC,MAAM,IAAI,QAAQ,CAAC,aAAa,CAAC;SACtF,OAAO,CAAC,CAAC,QAAkB,EAAE,EAAE,CAAC,kBAAkB,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;AACjF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAqC;IACtE,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAExF,OAAO,CAAC,GAAG,kBAAkB,CAAC,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAU,CAAC;AAC1G,CAAC","sourcesContent":["import {isArray, isClass} from \"@tsed/core\";\nimport {TokenProvider} from \"../interfaces/TokenProvider\";\nimport {GlobalProviders} from \"../registries/GlobalProviders\";\nimport {ProviderType} from \"../domain/ProviderType\";\nimport {Provider} from \"../domain/Provider\";\nimport {TokenRoute} from \"../interfaces/TokenRoute\";\n\nconst lookupProperties = [\"mount\", \"imports\"];\n\nexport function getTokens(config: any): {route?: string; token: TokenProvider}[] {\n if (!config) {\n return [];\n }\n\n if (isArray(config)) {\n return config.filter(isClass).map((value: any) => {\n return {token: value};\n });\n }\n\n return Object.keys(config).reduce((list: any[], route: string) => {\n return [\n ...list,\n ...[]\n .concat(config[route])\n .filter(isClass)\n .map((token) => ({\n route,\n token\n }))\n ];\n }, []);\n}\n\nfunction resolveRecursively(providers: {token: TokenProvider; route?: string}[]) {\n return providers\n .map(({token}) => GlobalProviders.get(token))\n .filter((provider) => provider?.type === ProviderType.MODULE && provider.configuration)\n .flatMap((provider: Provider) => resolveControllers(provider.configuration));\n}\n\n/**\n * Return controllers and is base route according to his configuration in module configuration.\n *\n * @param settings\n */\nexport function resolveControllers(settings: Partial<TsED.Configuration>): TokenRoute[] {\n const providers = lookupProperties.flatMap((property) => getTokens(settings[property]));\n\n return [...resolveRecursively(providers), ...providers].filter((provider) => !!provider.route) as any[];\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
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
|
-
import {
|
|
2
|
+
import { ProviderOpts } from "../interfaces/ProviderOpts";
|
|
3
3
|
export declare type PathType = string | RegExp | (string | RegExp)[];
|
|
4
4
|
export interface ControllerMiddlewares {
|
|
5
5
|
useBefore: any[];
|
|
6
6
|
use: any[];
|
|
7
7
|
useAfter: any[];
|
|
8
8
|
}
|
|
9
|
-
export interface ControllerOptions extends Partial<
|
|
9
|
+
export interface ControllerOptions extends Partial<ProviderOpts<any>> {
|
|
10
10
|
path?: PathType;
|
|
11
11
|
children?: Type<any>[];
|
|
12
12
|
routerOptions?: any;
|
|
@@ -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
|
*
|
|
File without changes
|
|
@@ -10,12 +10,6 @@ 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;
|
|
File without changes
|
|
File without changes
|
|
@@ -1,15 +1,16 @@
|
|
|
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
|
+
export declare class Provider<T = any> implements ProviderOpts<T> {
|
|
6
7
|
type: ProviderType | any;
|
|
7
|
-
instance: T;
|
|
8
8
|
deps: TokenProvider[];
|
|
9
9
|
imports: any[];
|
|
10
10
|
useFactory: Function;
|
|
11
11
|
useAsyncFactory: Function;
|
|
12
12
|
useValue: any;
|
|
13
|
+
hooks?: Record<string, (instance: T, ...args: any[]) => Promise<void> | void>;
|
|
13
14
|
private _useClass;
|
|
14
15
|
private _provide;
|
|
15
16
|
private _store;
|
|
@@ -28,6 +29,8 @@ export declare class Provider<T = any> implements IProvider<T> {
|
|
|
28
29
|
get className(): string;
|
|
29
30
|
get name(): string;
|
|
30
31
|
get store(): Store;
|
|
32
|
+
get path(): string;
|
|
33
|
+
set path(path: string);
|
|
31
34
|
/**
|
|
32
35
|
* Get the scope of the provider.
|
|
33
36
|
*
|
|
@@ -45,8 +48,19 @@ export declare class Provider<T = any> implements IProvider<T> {
|
|
|
45
48
|
set scope(scope: ProviderScope);
|
|
46
49
|
get configuration(): Partial<TsED.Configuration>;
|
|
47
50
|
set configuration(configuration: Partial<TsED.Configuration>);
|
|
51
|
+
get children(): TokenProvider[];
|
|
48
52
|
get(key: string): any;
|
|
49
53
|
isAsync(): boolean;
|
|
50
54
|
clone(): Provider;
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @returns {boolean}
|
|
58
|
+
*/
|
|
59
|
+
hasChildren(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @returns {boolean}
|
|
63
|
+
*/
|
|
64
|
+
hasParent(): boolean;
|
|
51
65
|
toString(): string;
|
|
52
66
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,55 @@
|
|
|
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 "./interfaces/TokenRoute";
|
|
44
|
+
export * from "./registries/GlobalProviders";
|
|
45
|
+
export * from "./registries/ProviderRegistry";
|
|
46
|
+
export * from "./services/DIConfiguration";
|
|
47
|
+
export * from "./services/DILogger";
|
|
48
|
+
export * from "./services/DITest";
|
|
49
|
+
export * from "./services/InjectorService";
|
|
50
|
+
export * from "./utils/colors";
|
|
51
|
+
export * from "./utils/createContainer";
|
|
52
|
+
export * from "./utils/getConfiguration";
|
|
53
|
+
export * from "./utils/resolveControllers";
|
|
54
|
+
export * from "./utils/runInContext";
|
|
55
|
+
export * from "./utils/setLoggerLevel";
|
|
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
|