@tsed/di 6.87.2 → 6.90.0
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/{constants → cjs/constants}/index.d.ts +0 -0
- package/lib/cjs/constants/index.js +7 -0
- package/lib/cjs/constants/index.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/configuration.d.ts +0 -0
- package/lib/cjs/decorators/configuration.js +24 -0
- package/lib/cjs/decorators/configuration.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/constant.d.ts +0 -0
- package/lib/cjs/decorators/constant.js +55 -0
- package/lib/cjs/decorators/constant.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/controller.d.ts +0 -0
- package/lib/cjs/decorators/controller.js +53 -0
- package/lib/cjs/decorators/controller.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/index.d.ts +0 -0
- package/lib/cjs/decorators/index.js +19 -0
- package/lib/cjs/decorators/index.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/inject.d.ts +0 -0
- package/lib/cjs/decorators/inject.js +79 -0
- package/lib/cjs/decorators/inject.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/injectable.d.ts +0 -0
- package/lib/cjs/decorators/injectable.js +33 -0
- package/lib/cjs/decorators/injectable.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/intercept.d.ts +0 -0
- package/lib/cjs/decorators/intercept.js +28 -0
- package/lib/cjs/decorators/intercept.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/interceptor.d.ts +0 -0
- package/lib/cjs/decorators/interceptor.js +21 -0
- package/lib/cjs/decorators/interceptor.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/lazyInject.d.ts +0 -0
- package/lib/cjs/decorators/lazyInject.js +71 -0
- package/lib/cjs/decorators/lazyInject.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/module.d.ts +0 -0
- package/lib/cjs/decorators/module.js +31 -0
- package/lib/cjs/decorators/module.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/opts.d.ts +0 -0
- package/lib/cjs/decorators/opts.js +54 -0
- package/lib/cjs/decorators/opts.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/overrideProvider.d.ts +0 -0
- package/lib/cjs/decorators/overrideProvider.js +17 -0
- package/lib/cjs/decorators/overrideProvider.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/scope.d.ts +0 -0
- package/lib/cjs/decorators/scope.js +16 -0
- package/lib/cjs/decorators/scope.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/service.d.ts +0 -0
- package/lib/cjs/decorators/service.js +18 -0
- package/lib/cjs/decorators/service.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/useOpts.d.ts +0 -0
- package/lib/cjs/decorators/useOpts.js +65 -0
- package/lib/cjs/decorators/useOpts.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/value.d.ts +0 -0
- package/lib/cjs/decorators/value.js +55 -0
- package/lib/cjs/decorators/value.js.map +1 -0
- package/lib/{domain → cjs/domain}/Container.d.ts +0 -0
- package/lib/cjs/domain/Container.js +72 -0
- package/lib/cjs/domain/Container.js.map +1 -0
- package/lib/{domain → cjs/domain}/ContextLogger.d.ts +0 -0
- package/lib/cjs/domain/ContextLogger.js +85 -0
- package/lib/cjs/domain/ContextLogger.js.map +1 -0
- package/lib/{domain → cjs/domain}/DIContext.d.ts +0 -0
- package/lib/cjs/domain/DIContext.js +45 -0
- package/lib/cjs/domain/DIContext.js.map +1 -0
- package/lib/{domain → cjs/domain}/InjectablePropertyType.d.ts +0 -0
- package/lib/cjs/domain/InjectablePropertyType.js +12 -0
- package/lib/cjs/domain/InjectablePropertyType.js.map +1 -0
- package/lib/{domain → cjs/domain}/LocalsContainer.d.ts +0 -0
- package/lib/cjs/domain/LocalsContainer.js +55 -0
- package/lib/cjs/domain/LocalsContainer.js.map +1 -0
- package/lib/{domain → cjs/domain}/Provider.d.ts +0 -0
- package/lib/cjs/domain/Provider.js +122 -0
- package/lib/cjs/domain/Provider.js.map +1 -0
- package/lib/{domain → cjs/domain}/ProviderScope.d.ts +0 -0
- package/lib/cjs/domain/ProviderScope.js +10 -0
- package/lib/cjs/domain/ProviderScope.js.map +1 -0
- package/lib/{domain → cjs/domain}/ProviderType.d.ts +0 -0
- package/lib/cjs/domain/ProviderType.js +15 -0
- package/lib/cjs/domain/ProviderType.js.map +1 -0
- package/lib/{domain → cjs/domain}/index.d.ts +0 -0
- package/lib/cjs/domain/index.js +12 -0
- package/lib/cjs/domain/index.js.map +1 -0
- package/lib/{errors → cjs/errors}/InjectionError.d.ts +0 -0
- package/lib/cjs/errors/InjectionError.js +58 -0
- package/lib/cjs/errors/InjectionError.js.map +1 -0
- package/lib/{errors → cjs/errors}/UndefinedTokenError.d.ts +0 -0
- package/lib/cjs/errors/UndefinedTokenError.js +11 -0
- package/lib/cjs/errors/UndefinedTokenError.js.map +1 -0
- package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
- package/lib/cjs/index.js +21 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/DIConfigurationOptions.d.ts +0 -0
- package/lib/cjs/interfaces/DIConfigurationOptions.js +3 -0
- package/lib/cjs/interfaces/DIConfigurationOptions.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/DILogger.d.ts +0 -0
- package/lib/cjs/interfaces/DILogger.js +3 -0
- package/lib/cjs/interfaces/DILogger.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/DIResolver.d.ts +0 -0
- package/lib/cjs/interfaces/DIResolver.js +3 -0
- package/lib/cjs/interfaces/DIResolver.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/IProvider.d.ts +0 -0
- package/lib/cjs/interfaces/IProvider.js +3 -0
- package/lib/cjs/interfaces/IProvider.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/InjectableProperties.d.ts +0 -0
- package/lib/cjs/interfaces/InjectableProperties.js +3 -0
- package/lib/cjs/interfaces/InjectableProperties.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/InterceptorContext.d.ts +0 -0
- package/lib/cjs/interfaces/InterceptorContext.js +3 -0
- package/lib/cjs/interfaces/InterceptorContext.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/InterceptorMethods.d.ts +0 -0
- package/lib/cjs/interfaces/InterceptorMethods.js +3 -0
- package/lib/cjs/interfaces/InterceptorMethods.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/InvokeOptions.d.ts +0 -0
- package/lib/cjs/interfaces/InvokeOptions.js +3 -0
- package/lib/cjs/interfaces/InvokeOptions.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnDestroy.d.ts +0 -0
- package/lib/cjs/interfaces/OnDestroy.js +3 -0
- package/lib/cjs/interfaces/OnDestroy.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnInit.d.ts +0 -0
- package/lib/cjs/interfaces/OnInit.js +3 -0
- package/lib/cjs/interfaces/OnInit.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/RegistrySettings.d.ts +0 -0
- package/lib/cjs/interfaces/RegistrySettings.js +3 -0
- package/lib/cjs/interfaces/RegistrySettings.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/ResolvedInvokeOptions.d.ts +0 -0
- package/lib/cjs/interfaces/ResolvedInvokeOptions.js +3 -0
- package/lib/cjs/interfaces/ResolvedInvokeOptions.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/TokenProvider.d.ts +0 -0
- package/lib/cjs/interfaces/TokenProvider.js +3 -0
- package/lib/cjs/interfaces/TokenProvider.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/index.d.ts +0 -0
- package/lib/cjs/interfaces/index.js +18 -0
- package/lib/cjs/interfaces/index.js.map +1 -0
- package/lib/{registries → cjs/registries}/GlobalProviders.d.ts +0 -0
- package/lib/cjs/registries/GlobalProviders.js +124 -0
- package/lib/cjs/registries/GlobalProviders.js.map +1 -0
- package/lib/{registries → cjs/registries}/ProviderRegistry.d.ts +0 -0
- package/lib/cjs/registries/ProviderRegistry.js +149 -0
- package/lib/cjs/registries/ProviderRegistry.js.map +1 -0
- package/lib/{services → cjs/services}/DIConfiguration.d.ts +0 -0
- package/lib/cjs/services/DIConfiguration.js +129 -0
- package/lib/cjs/services/DIConfiguration.js.map +1 -0
- package/lib/{services → cjs/services}/DILogger.d.ts +0 -0
- package/lib/cjs/services/DILogger.js +13 -0
- package/lib/cjs/services/DILogger.js.map +1 -0
- package/lib/{services → cjs/services}/DITest.d.ts +0 -0
- package/lib/cjs/services/DITest.js +100 -0
- package/lib/cjs/services/DITest.js.map +1 -0
- package/lib/{services → cjs/services}/InjectorService.d.ts +0 -0
- package/lib/cjs/services/InjectorService.js +581 -0
- package/lib/cjs/services/InjectorService.js.map +1 -0
- package/lib/{utils → cjs/utils}/colors.d.ts +0 -0
- package/lib/cjs/utils/colors.js +10 -0
- package/lib/cjs/utils/colors.js.map +1 -0
- package/lib/{utils → cjs/utils}/createContainer.d.ts +0 -0
- package/lib/cjs/utils/createContainer.js +14 -0
- package/lib/cjs/utils/createContainer.js.map +1 -0
- package/lib/cjs/utils/data/Test1.d.ts +3 -0
- package/lib/cjs/utils/data/Test1.js +8 -0
- package/lib/cjs/utils/data/Test1.js.map +1 -0
- package/lib/cjs/utils/data/Test2.d.ts +3 -0
- package/lib/cjs/utils/data/Test2.js +8 -0
- package/lib/cjs/utils/data/Test2.js.map +1 -0
- package/lib/{utils → cjs/utils}/getConfiguration.d.ts +0 -0
- package/lib/cjs/utils/getConfiguration.js +20 -0
- package/lib/cjs/utils/getConfiguration.js.map +1 -0
- package/lib/{utils → cjs/utils}/setLoggerLevel.d.ts +0 -0
- package/lib/cjs/utils/setLoggerLevel.js +16 -0
- package/lib/cjs/utils/setLoggerLevel.js.map +1 -0
- package/lib/esm/constants/index.js +4 -0
- package/lib/esm/constants/index.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/index.js +16 -0
- package/lib/esm/decorators/index.js.map +1 -0
- package/lib/esm/decorators/inject.js +74 -0
- package/lib/esm/decorators/inject.js.map +1 -0
- package/lib/esm/decorators/injectable.js +29 -0
- package/lib/esm/decorators/injectable.js.map +1 -0
- package/lib/esm/decorators/intercept.js +24 -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 +27 -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/domain/index.js +9 -0
- package/lib/esm/domain/index.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 +18 -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/IProvider.js +2 -0
- package/lib/esm/interfaces/IProvider.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/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/index.js +15 -0
- package/lib/esm/interfaces/index.js.map +1 -0
- package/lib/esm/registries/GlobalProviders.js +120 -0
- package/lib/esm/registries/GlobalProviders.js.map +1 -0
- package/lib/esm/registries/ProviderRegistry.js +144 -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 +96 -0
- package/lib/esm/services/DITest.js.map +1 -0
- package/lib/esm/services/InjectorService.js +578 -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/data/Test1.js +4 -0
- package/lib/esm/utils/data/Test1.js.map +1 -0
- package/lib/esm/utils/data/Test2.js +4 -0
- package/lib/esm/utils/data/Test2.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/setLoggerLevel.js +12 -0
- package/lib/esm/utils/setLoggerLevel.js.map +1 -0
- package/lib/types/constants/index.d.ts +3 -0
- package/lib/types/decorators/configuration.d.ts +8 -0
- package/lib/types/decorators/constant.d.ts +36 -0
- package/lib/types/decorators/controller.d.ts +43 -0
- package/lib/types/decorators/index.d.ts +15 -0
- package/lib/types/decorators/inject.d.ts +21 -0
- package/lib/types/decorators/injectable.d.ts +21 -0
- package/lib/types/decorators/intercept.d.ts +10 -0
- package/lib/types/decorators/interceptor.d.ts +10 -0
- package/lib/types/decorators/lazyInject.d.ts +43 -0
- package/lib/types/decorators/module.d.ts +36 -0
- package/lib/types/decorators/opts.d.ts +41 -0
- package/lib/types/decorators/overrideProvider.d.ts +8 -0
- package/lib/types/decorators/scope.d.ts +8 -0
- package/lib/types/decorators/service.d.ts +10 -0
- package/lib/types/decorators/useOpts.d.ts +42 -0
- package/lib/types/decorators/value.d.ts +36 -0
- package/lib/types/domain/Container.d.ts +43 -0
- package/lib/types/domain/ContextLogger.d.ts +41 -0
- package/lib/types/domain/DIContext.d.ts +72 -0
- package/lib/types/domain/InjectablePropertyType.d.ts +7 -0
- package/lib/types/domain/LocalsContainer.d.ts +25 -0
- package/lib/types/domain/Provider.d.ts +68 -0
- package/lib/types/domain/ProviderScope.d.ts +5 -0
- package/lib/types/domain/ProviderType.d.ts +10 -0
- package/lib/types/domain/index.d.ts +8 -0
- package/lib/types/errors/InjectionError.d.ts +8 -0
- package/lib/types/errors/UndefinedTokenError.d.ts +4 -0
- package/lib/types/index.d.ts +17 -0
- package/lib/types/interfaces/DIConfigurationOptions.d.ts +25 -0
- package/lib/types/interfaces/DILogger.d.ts +8 -0
- package/lib/types/interfaces/DIResolver.d.ts +5 -0
- package/lib/types/interfaces/IProvider.d.ts +54 -0
- package/lib/types/interfaces/InjectableProperties.d.ts +24 -0
- package/lib/types/interfaces/InterceptorContext.d.ts +11 -0
- package/lib/types/interfaces/InterceptorMethods.d.ts +4 -0
- package/lib/types/interfaces/InvokeOptions.d.ts +10 -0
- package/lib/types/interfaces/OnDestroy.d.ts +3 -0
- package/lib/types/interfaces/OnInit.d.ts +3 -0
- package/lib/types/interfaces/RegistrySettings.d.ts +20 -0
- package/lib/types/interfaces/ResolvedInvokeOptions.d.ts +12 -0
- package/lib/types/interfaces/TokenProvider.d.ts +2 -0
- package/lib/types/interfaces/index.d.ts +14 -0
- package/lib/types/registries/GlobalProviders.d.ts +55 -0
- package/lib/types/registries/ProviderRegistry.d.ts +121 -0
- package/lib/types/services/DIConfiguration.d.ts +47 -0
- package/lib/types/services/DILogger.d.ts +1 -0
- package/lib/types/services/DITest.d.ts +37 -0
- package/lib/types/services/InjectorService.d.ts +229 -0
- package/lib/types/utils/colors.d.ts +5 -0
- package/lib/types/utils/createContainer.d.ts +3 -0
- package/lib/types/utils/data/Test1.d.ts +3 -0
- package/lib/types/utils/data/Test2.d.ts +3 -0
- package/lib/types/utils/getConfiguration.d.ts +2 -0
- package/lib/types/utils/setLoggerLevel.d.ts +6 -0
- package/package.json +12 -8
- package/tsconfig.compile.esm.json +24 -0
- package/lib/index.js +0 -2546
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -2508
- package/lib/index.modern.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../src/domain/Provider.ts"],"names":[],"mappings":";;;AAAA,qCAAmF;AAEnF,mDAA8C;AAC9C,iDAA4C;AAE5C,MAAa,QAAQ;IAkBnB,YAAY,KAAoB,EAAE,UAA6B,EAAE;QAjB1D,SAAI,GAAuB,2BAAY,CAAC,QAAQ,CAAC;QAkBtD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QAEtB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,OAAO,CAAC,KAAoB;QAC9B,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,QAAQ,GAAG,IAAA,uBAAgB,EAAC,KAAK,CAAC,CAAC;YACxC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,GAAG,YAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACpD;IACH,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,IAAI,QAAQ,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AAqB,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO;QACL,OAAO,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IAED;;;OAGG;IACI,WAAW;QAChB,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAChC,CAAC;IAED;;;OAGG;IACI,SAAS;QACd,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAC9C,CAAC;IAED,QAAQ;QACN,OAAO;YACL,OAAO;YACP,IAAI,CAAC,IAAI;YACT,IAAI,CAAC,QAAQ,IAAI,IAAA,aAAM,EAAC,IAAI,CAAC,QAAQ,CAAC;YACtC,IAAI,CAAC,UAAU,IAAI,SAAS;YAC5B,IAAI,CAAC,QAAQ,IAAI,OAAO;YACxB,IAAI,CAAC,eAAe,IAAI,cAAc;SACvC;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;CACF;AAxJD,4BAwJC","sourcesContent":["import {classOf, getClassOrSymbol, isClass, nameOf, Store, Type} from \"@tsed/core\";\nimport {IProvider, TokenProvider} from \"../interfaces\";\nimport {ProviderScope} from \"./ProviderScope\";\nimport {ProviderType} from \"./ProviderType\";\n\nexport class Provider<T = any> implements IProvider<T> {\n public type: ProviderType | any = ProviderType.PROVIDER;\n /**\n * @deprecated Use injector.get(provider.token) instead.\n */\n public instance: T;\n public deps: TokenProvider[];\n public imports: any[];\n public useFactory: Function;\n public useAsyncFactory: Function;\n public useValue: any;\n private _useClass: Type<T>;\n private _provide: TokenProvider;\n private _store: Store;\n private _tokenStore: Store;\n\n [key: string]: any;\n\n constructor(token: TokenProvider, options: Partial<Provider> = {}) {\n this.provide = token;\n this.useClass = token;\n\n Object.assign(this, options);\n }\n\n get token() {\n return this._provide;\n }\n\n get provide(): TokenProvider {\n return this._provide;\n }\n\n set provide(value: TokenProvider) {\n if (value) {\n this._provide = getClassOrSymbol(value);\n this._tokenStore = this._store = Store.from(value);\n }\n }\n\n get useClass(): Type<T> {\n return this._useClass;\n }\n\n /**\n * Create a new store if the given value is a class. Otherwise the value is ignored.\n * @param value\n */\n set useClass(value: Type<T>) {\n if (isClass(value)) {\n this._useClass = classOf(value);\n this._store = Store.from(value);\n }\n }\n\n get className() {\n return this.name;\n }\n\n get name() {\n return nameOf(this.provide);\n }\n\n get store(): Store {\n return this._store;\n }\n\n get path() {\n return this.store.get(\"path\", \"/\");\n }\n\n set path(path: string) {\n this.store.set(\"path\", path);\n }\n\n /**\n * Get the scope of the provider.\n *\n * ::: tip Note\n * Async provider is always a SINGLETON\n * :::\n *\n * @returns {boolean}\n */\n get scope(): ProviderScope {\n if (this.isAsync()) {\n return ProviderScope.SINGLETON;\n }\n\n return this.get(\"scope\");\n }\n\n /**\n * Change the scope value of the provider.\n * @param scope\n */\n set scope(scope: ProviderScope) {\n this.store.set(\"scope\", scope);\n }\n\n get configuration(): Partial<TsED.Configuration> {\n return this.get(\"configuration\");\n }\n\n set configuration(configuration: Partial<TsED.Configuration>) {\n this.store.set(\"configuration\", configuration);\n }\n\n get children(): TokenProvider[] {\n return this.store.get(\"childrenControllers\", []);\n }\n\n get(key: string) {\n return this.store.get(key) || this._tokenStore.get(key);\n }\n\n isAsync(): boolean {\n return !!this.useAsyncFactory;\n }\n\n clone(): Provider {\n return new (classOf(this))(this._provide, this);\n }\n\n /**\n *\n * @returns {boolean}\n */\n public hasChildren(): boolean {\n return !!this.children.length;\n }\n\n /**\n *\n * @returns {boolean}\n */\n public hasParent(): boolean {\n return !!this.store.get(\"parentController\");\n }\n\n toString() {\n return [\n \"Token\",\n this.name,\n this.useClass && nameOf(this.useClass),\n this.useFactory && \"Factory\",\n this.useValue && \"Value\",\n this.useAsyncFactory && \"AsyncFactory\"\n ]\n .filter(Boolean)\n .join(\":\");\n }\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProviderScope = void 0;
|
|
4
|
+
var ProviderScope;
|
|
5
|
+
(function (ProviderScope) {
|
|
6
|
+
ProviderScope["SINGLETON"] = "singleton";
|
|
7
|
+
ProviderScope["REQUEST"] = "request";
|
|
8
|
+
ProviderScope["INSTANCE"] = "instance";
|
|
9
|
+
})(ProviderScope = exports.ProviderScope || (exports.ProviderScope = {}));
|
|
10
|
+
//# sourceMappingURL=ProviderScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProviderScope.js","sourceRoot":"","sources":["../../../src/domain/ProviderScope.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,wCAAuB,CAAA;IACvB,oCAAmB,CAAA;IACnB,sCAAqB,CAAA;AACvB,CAAC,EAJW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAIxB","sourcesContent":["export enum ProviderScope {\n SINGLETON = \"singleton\",\n REQUEST = \"request\",\n INSTANCE = \"instance\"\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProviderType = void 0;
|
|
4
|
+
var ProviderType;
|
|
5
|
+
(function (ProviderType) {
|
|
6
|
+
ProviderType["VALUE"] = "value";
|
|
7
|
+
ProviderType["FACTORY"] = "factory";
|
|
8
|
+
ProviderType["SERVICE"] = "service";
|
|
9
|
+
ProviderType["PROVIDER"] = "provider";
|
|
10
|
+
ProviderType["MODULE"] = "module";
|
|
11
|
+
ProviderType["CONTROLLER"] = "controller";
|
|
12
|
+
ProviderType["INTERCEPTOR"] = "interceptor";
|
|
13
|
+
ProviderType["MIDDLEWARE"] = "middleware";
|
|
14
|
+
})(ProviderType = exports.ProviderType || (exports.ProviderType = {}));
|
|
15
|
+
//# sourceMappingURL=ProviderType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProviderType.js","sourceRoot":"","sources":["../../../src/domain/ProviderType.ts"],"names":[],"mappings":";;;AAAA,IAAY,YASX;AATD,WAAY,YAAY;IACtB,+BAAe,CAAA;IACf,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;IACnB,qCAAqB,CAAA;IACrB,iCAAiB,CAAA;IACjB,yCAAyB,CAAA;IACzB,2CAA2B,CAAA;IAC3B,yCAAyB,CAAA;AAC3B,CAAC,EATW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QASvB","sourcesContent":["export enum ProviderType {\n VALUE = \"value\",\n FACTORY = \"factory\",\n SERVICE = \"service\",\n PROVIDER = \"provider\",\n MODULE = \"module\",\n CONTROLLER = \"controller\",\n INTERCEPTOR = \"interceptor\",\n MIDDLEWARE = \"middleware\"\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./Container"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./InjectablePropertyType"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./LocalsContainer"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./Provider"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./ProviderScope"), exports);
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./ProviderType"), exports);
|
|
10
|
+
(0, tslib_1.__exportStar)(require("./ContextLogger"), exports);
|
|
11
|
+
(0, tslib_1.__exportStar)(require("./DIContext"), exports);
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/index.ts"],"names":[],"mappings":";;;AAAA,2DAA4B;AAC5B,wEAAyC;AACzC,iEAAkC;AAClC,0DAA2B;AAC3B,+DAAgC;AAChC,8DAA+B;AAC/B,+DAAgC;AAChC,2DAA4B","sourcesContent":["export * from \"./Container\";\nexport * from \"./InjectablePropertyType\";\nexport * from \"./LocalsContainer\";\nexport * from \"./Provider\";\nexport * from \"./ProviderScope\";\nexport * from \"./ProviderType\";\nexport * from \"./ContextLogger\";\nexport * from \"./DIContext\";\n"]}
|
|
File without changes
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InjectionError = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
5
|
+
const colors_1 = require("../utils/colors");
|
|
6
|
+
class InjectionError extends Error {
|
|
7
|
+
constructor(token, origin) {
|
|
8
|
+
super((0, core_1.isString)(origin) ? origin : "");
|
|
9
|
+
this.name = "INJECTION_ERROR";
|
|
10
|
+
this.tokens = [];
|
|
11
|
+
this.tokens = [token];
|
|
12
|
+
if (origin) {
|
|
13
|
+
if ((0, core_1.isString)(origin)) {
|
|
14
|
+
this.origin = {
|
|
15
|
+
message: origin,
|
|
16
|
+
stack: this.stack
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
if (origin.tokens) {
|
|
21
|
+
this.tokens = this.tokens.concat(origin.tokens);
|
|
22
|
+
this.origin = origin.origin;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.origin = origin;
|
|
26
|
+
this.stack = origin.stack;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const originMessage = this.origin ? "\nOrigin: " + this.origin.message : "";
|
|
31
|
+
const tokensMessage = this.tokens.map((token) => (0, core_1.nameOf)(token)).join(" > ");
|
|
32
|
+
this.message = `Injection failed on ${tokensMessage}${originMessage}`;
|
|
33
|
+
}
|
|
34
|
+
static throwInjectorError(token, currentDependency, error) {
|
|
35
|
+
if (currentDependency && (0, core_1.isClass)(token)) {
|
|
36
|
+
error.message = printDependencyInjectionError(token, { ...currentDependency, message: error.message });
|
|
37
|
+
}
|
|
38
|
+
throw new InjectionError(token, error);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.InjectionError = InjectionError;
|
|
42
|
+
function printDependencyInjectionError(token, options) {
|
|
43
|
+
let erroredArg = "";
|
|
44
|
+
const args = (0, core_1.getConstructorArgNames)(token)
|
|
45
|
+
.map((arg, index) => {
|
|
46
|
+
if (options.index === index) {
|
|
47
|
+
erroredArg = arg;
|
|
48
|
+
arg = colors_1.colors.red(arg);
|
|
49
|
+
}
|
|
50
|
+
return `${arg}: ${(0, core_1.nameOf)(options.deps[index])}`;
|
|
51
|
+
})
|
|
52
|
+
.join(", ");
|
|
53
|
+
const signature = (0, core_1.nameOf)(token) + "->constructor(" + args + ")";
|
|
54
|
+
const indexOf = signature.indexOf(erroredArg) - 5;
|
|
55
|
+
const drawline = (indexOf) => " ".repeat(indexOf) + colors_1.colors.red("^" + "‾".repeat(erroredArg.length - 1));
|
|
56
|
+
return "Unable to inject dependency. " + options.message + "\n\n" + signature + "\n" + (indexOf > -1 ? drawline(indexOf) : "");
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=InjectionError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InjectionError.js","sourceRoot":"","sources":["../../../src/errors/InjectionError.ts"],"names":[],"mappings":";;;AAAA,qCAA6E;AAE7E,4CAAuC;AAEvC,MAAa,cAAe,SAAQ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AAI,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACjI,CAAC","sourcesContent":["import {getConstructorArgNames, isClass, isString, nameOf} from \"@tsed/core\";\nimport {TokenProvider} from \"../interfaces\";\nimport {colors} from \"../utils/colors\";\n\nexport class InjectionError extends Error {\n name = \"INJECTION_ERROR\";\n\n public tokens: TokenProvider[] = [];\n public origin: any;\n\n constructor(token: TokenProvider, origin?: any) {\n super(isString(origin) ? origin : \"\");\n\n this.tokens = [token];\n\n if (origin) {\n if (isString(origin)) {\n this.origin = {\n message: origin,\n stack: this.stack\n };\n } else {\n if (origin.tokens) {\n this.tokens = this.tokens.concat(origin.tokens);\n this.origin = origin.origin;\n } else {\n this.origin = origin;\n this.stack = origin.stack;\n }\n }\n }\n\n const originMessage = this.origin ? \"\\nOrigin: \" + this.origin.message : \"\";\n const tokensMessage = this.tokens.map((token) => nameOf(token)).join(\" > \");\n\n this.message = `Injection failed on ${tokensMessage}${originMessage}`;\n }\n\n static throwInjectorError(token: any, currentDependency: any, error: any) {\n if (currentDependency && isClass(token)) {\n error.message = printDependencyInjectionError(token, {...currentDependency, message: error.message});\n }\n\n throw new InjectionError(token, error);\n }\n}\n\nfunction printDependencyInjectionError(token: any, options: {token: any; index: number; deps: any[]; message: string}) {\n let erroredArg = \"\";\n\n const args = getConstructorArgNames(token)\n .map((arg, index) => {\n if (options.index === index) {\n erroredArg = arg;\n arg = colors.red(arg);\n }\n\n return `${arg}: ${nameOf(options.deps[index])}`;\n })\n .join(\", \");\n\n const signature = nameOf(token) + \"->constructor(\" + args + \")\";\n const indexOf = signature.indexOf(erroredArg) - 5;\n const drawline = (indexOf: number) => \" \".repeat(indexOf) + colors.red(\"^\" + \"‾\".repeat(erroredArg.length - 1));\n\n return \"Unable to inject dependency. \" + options.message + \"\\n\\n\" + signature + \"\\n\" + (indexOf > -1 ? drawline(indexOf) : \"\");\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UndefinedTokenError = void 0;
|
|
4
|
+
class UndefinedTokenError extends Error {
|
|
5
|
+
constructor() {
|
|
6
|
+
super("Given token is undefined. Have you enabled emitDecoratorMetadata in your tsconfig.json or decorated your class with @Injectable, @Service, ... decorator ?");
|
|
7
|
+
this.name = "UNDEFINED_TOKEN_ERROR";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.UndefinedTokenError = UndefinedTokenError;
|
|
11
|
+
//# sourceMappingURL=UndefinedTokenError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UndefinedTokenError.js","sourceRoot":"","sources":["../../../src/errors/UndefinedTokenError.ts"],"names":[],"mappings":";;;AAAA,MAAa,mBAAoB,SAAQ,KAAK;IAG5C;QACE,KAAK,CACH,4JAA4J,CAC7J,CAAC;QALJ,SAAI,GAAG,uBAAuB,CAAC;IAM/B,CAAC;CACF;AARD,kDAQC","sourcesContent":["export class UndefinedTokenError extends Error {\n name = \"UNDEFINED_TOKEN_ERROR\";\n\n constructor() {\n super(\n \"Given token is undefined. Have you enabled emitDecoratorMetadata in your tsconfig.json or decorated your class with @Injectable, @Service, ... decorator ?\"\n );\n }\n}\n"]}
|
|
File without changes
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./constants/index"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./domain"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./interfaces"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./decorators"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./registries/ProviderRegistry"), exports);
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./registries/GlobalProviders"), exports);
|
|
10
|
+
(0, tslib_1.__exportStar)(require("./services/InjectorService"), exports);
|
|
11
|
+
(0, tslib_1.__exportStar)(require("./services/DILogger"), exports);
|
|
12
|
+
(0, tslib_1.__exportStar)(require("./services/DIConfiguration"), exports);
|
|
13
|
+
(0, tslib_1.__exportStar)(require("./services/DITest"), exports);
|
|
14
|
+
(0, tslib_1.__exportStar)(require("./errors/InjectionError"), exports);
|
|
15
|
+
(0, tslib_1.__exportStar)(require("./errors/UndefinedTokenError"), exports);
|
|
16
|
+
(0, tslib_1.__exportStar)(require("./utils/createContainer"), exports);
|
|
17
|
+
(0, tslib_1.__exportStar)(require("./utils/getConfiguration"), exports);
|
|
18
|
+
(0, tslib_1.__exportStar)(require("./utils/getConfiguration"), exports);
|
|
19
|
+
(0, tslib_1.__exportStar)(require("./utils/setLoggerLevel"), exports);
|
|
20
|
+
(0, tslib_1.__exportStar)(require("./utils/colors"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iEAAkC;AAClC,wDAAyB;AACzB,4DAA6B;AAC7B,4DAA6B;AAC7B,6EAA8C;AAC9C,4EAA6C;AAE7C,0EAA2C;AAC3C,mEAAoC;AACpC,0EAA2C;AAC3C,iEAAkC;AAElC,uEAAwC;AACxC,4EAA6C;AAE7C,uEAAwC;AACxC,wEAAyC;AACzC,wEAAyC;AACzC,sEAAuC;AACvC,8DAA+B","sourcesContent":["export * from \"./constants/index\";\nexport * from \"./domain\";\nexport * from \"./interfaces\";\nexport * from \"./decorators\";\nexport * from \"./registries/ProviderRegistry\";\nexport * from \"./registries/GlobalProviders\";\n\nexport * from \"./services/InjectorService\";\nexport * from \"./services/DILogger\";\nexport * from \"./services/DIConfiguration\";\nexport * from \"./services/DITest\";\n\nexport * from \"./errors/InjectionError\";\nexport * from \"./errors/UndefinedTokenError\";\n\nexport * from \"./utils/createContainer\";\nexport * from \"./utils/getConfiguration\";\nexport * from \"./utils/getConfiguration\";\nexport * from \"./utils/setLoggerLevel\";\nexport * from \"./utils/colors\";\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DIConfigurationOptions.js","sourceRoot":"","sources":["../../../src/interfaces/DIConfigurationOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type {DIResolver} from \"./DIResolver\";\nimport type {ProviderScope} from \"../domain/ProviderScope\";\nimport type {TokenProvider} from \"./TokenProvider\";\n\ndeclare global {\n namespace TsED {\n interface Context {}\n interface Configuration {\n scopes: {[key: string]: ProviderScope};\n /**\n * Define a list of resolvers (it can be an external DI).\n */\n resolvers: DIResolver[];\n /**\n * Define dependencies to build the provider\n */\n imports: TokenProvider[];\n\n [key: string]: any;\n }\n }\n}\n\nexport interface DIConfigurationOptions extends TsED.Configuration {}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DILogger.js","sourceRoot":"","sources":["../../../src/interfaces/DILogger.ts"],"names":[],"mappings":"","sourcesContent":["export interface DILogger {\n info(...args: any[]): void | any;\n\n warn(...args: any[]): void | any;\n\n debug(...args: any[]): void | any;\n\n error(...args: any[]): void | any;\n\n trace(...args: any[]): void | any;\n\n [key: string]: any;\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DIResolver.js","sourceRoot":"","sources":["../../../src/interfaces/DIResolver.ts"],"names":[],"mappings":"","sourcesContent":["import type {TokenProvider} from \"./TokenProvider\";\n\nexport interface DIResolver {\n deps?: TokenProvider[];\n get<T = any>(type: TokenProvider, options: any): T | undefined;\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IProvider.js","sourceRoot":"","sources":["../../../src/interfaces/IProvider.ts"],"names":[],"mappings":"","sourcesContent":["import type {Type} from \"@tsed/core\";\nimport type {DIResolver} from \"./DIResolver\";\nimport type {ProviderScope} from \"../domain/ProviderScope\";\nimport type {ProviderType} from \"../domain/ProviderType\";\nimport type {TokenProvider} from \"./TokenProvider\";\n/**\n *\n */\nexport interface IProvider<T = any> {\n /**\n * An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).\n */\n provide: TokenProvider;\n /**\n * Provider type\n */\n type?: ProviderType | string;\n /**\n * Instance build by the injector\n */\n instance?: T;\n /**\n * Define dependencies to build the provider\n */\n deps?: TokenProvider[];\n /**\n * Class to instantiate for the `token`.\n */\n useClass?: Type<T>;\n /**\n * Provide a function to build the provider\n */\n useFactory?: Function;\n /**\n * Provide an async function to build the provider\n */\n useAsyncFactory?: Function;\n /**\n * Provide predefined value\n */\n useValue?: any;\n /**\n * Scope used by the injector to build the provider.\n */\n scope?: ProviderScope;\n /**\n * A list of resolvers which will be used to resolve missing Symbol/Class when injector invoke a Class. This property allow external DI usage.\n */\n resolvers?: DIResolver[];\n\n /**\n *\n */\n [key: string]: any;\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InjectableProperties.js","sourceRoot":"","sources":["../../../src/interfaces/InjectableProperties.ts"],"names":[],"mappings":"","sourcesContent":["import type {InjectablePropertyType} from \"../domain/InjectablePropertyType\";\nimport type {TokenProvider} from \"./TokenProvider\";\nimport type {InjectorService} from \"../services/InjectorService\";\nimport type {InvokeOptions} from \"./InvokeOptions\";\n\nexport interface InjectableProperty {\n propertyKey: string;\n}\n\nexport interface InjectablePropertyOptions extends InjectableProperty {\n bindingType: InjectablePropertyType.METHOD | InjectablePropertyType.PROPERTY | InjectablePropertyType.INTERCEPTOR;\n propertyType: string;\n useType?: TokenProvider;\n resolver: (injector: InjectorService, locals: Map<TokenProvider, any>, options: Partial<InvokeOptions> & {options: any}) => () => any;\n options?: any;\n}\n\nexport interface InjectablePropertyValue extends InjectableProperty {\n bindingType: InjectablePropertyType.CONSTANT | InjectablePropertyType.VALUE;\n expression: string;\n defaultValue?: any;\n}\n\nexport interface InjectableProperties {\n [key: string]: InjectablePropertyOptions | InjectablePropertyValue;\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InterceptorContext.js","sourceRoot":"","sources":["../../../src/interfaces/InterceptorContext.ts"],"names":[],"mappings":"","sourcesContent":["import type {Type} from \"@tsed/core\";\n\nexport interface InterceptorNext {\n <T>(err?: Error): T;\n}\n\nexport interface InterceptorContext<Klass = Type, Opts = any> {\n target: Klass;\n propertyKey: string;\n args: any[];\n next: InterceptorNext;\n options?: Opts;\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InterceptorMethods.js","sourceRoot":"","sources":["../../../src/interfaces/InterceptorMethods.ts"],"names":[],"mappings":"","sourcesContent":["import type {InterceptorContext, InterceptorNext} from \"./InterceptorContext\";\n\nexport interface InterceptorMethods {\n intercept?(context: InterceptorContext, next?: InterceptorNext): any;\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvokeOptions.js","sourceRoot":"","sources":["../../../src/interfaces/InvokeOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {ProviderScope} from \"../domain/ProviderScope\";\nimport {TokenProvider} from \"./TokenProvider\";\n\nexport interface InvokeOptions<T = any> {\n deps: any[];\n imports: any[];\n parent?: TokenProvider;\n scope: ProviderScope;\n useScope: boolean;\n rebuild?: boolean;\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnDestroy.js","sourceRoot":"","sources":["../../../src/interfaces/OnDestroy.ts"],"names":[],"mappings":"","sourcesContent":["export interface OnDestroy {\n $onDestroy(): Promise<any> | void;\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnInit.js","sourceRoot":"","sources":["../../../src/interfaces/OnInit.ts"],"names":[],"mappings":"","sourcesContent":["export interface OnInit {\n $onInit(): Promise<any> | void;\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegistrySettings.js","sourceRoot":"","sources":["../../../src/interfaces/RegistrySettings.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport type {Provider} from \"../domain\";\nimport type {InjectorService} from \"../services/InjectorService\";\nimport type {ResolvedInvokeOptions} from \"./ResolvedInvokeOptions\";\n\n/**\n * @ignore\n */\nexport interface RegistrySettings {\n injectable?: boolean;\n model?: Type<Provider>;\n\n /**\n *\n * @param provider\n * @param {Map<string | Function, any>} locals\n * @param options\n */\n onInvoke?(provider: Provider, locals: Map<string | Function, any>, options: ResolvedInvokeOptions & {injector: InjectorService}): void;\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResolvedInvokeOptions.js","sourceRoot":"","sources":["../../../src/interfaces/ResolvedInvokeOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type {Provider} from \"../domain/Provider\";\nimport type {ProviderScope} from \"../domain/ProviderScope\";\nimport type {TokenProvider} from \"./TokenProvider\";\n\nexport interface ResolvedInvokeOptions {\n token: TokenProvider;\n parent?: TokenProvider;\n scope: ProviderScope;\n deps: TokenProvider[];\n imports: TokenProvider[];\n provider: Provider;\n\n construct(deps: TokenProvider[]): any;\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenProvider.js","sourceRoot":"","sources":["../../../src/interfaces/TokenProvider.ts"],"names":[],"mappings":"","sourcesContent":["import type {Type} from \"@tsed/core\";\n\nexport type TokenProvider = string | symbol | Type | Function | any;\n"]}
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./DILogger"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./DIConfigurationOptions"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./DIResolver"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./InjectableProperties"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./InterceptorMethods"), exports);
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./InterceptorContext"), exports);
|
|
10
|
+
(0, tslib_1.__exportStar)(require("./InvokeOptions"), exports);
|
|
11
|
+
(0, tslib_1.__exportStar)(require("./IProvider"), exports);
|
|
12
|
+
(0, tslib_1.__exportStar)(require("./OnInit"), exports);
|
|
13
|
+
(0, tslib_1.__exportStar)(require("./OnDestroy"), exports);
|
|
14
|
+
(0, tslib_1.__exportStar)(require("./OnInit"), exports);
|
|
15
|
+
(0, tslib_1.__exportStar)(require("./RegistrySettings"), exports);
|
|
16
|
+
(0, tslib_1.__exportStar)(require("./TokenProvider"), exports);
|
|
17
|
+
(0, tslib_1.__exportStar)(require("./ResolvedInvokeOptions"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":";;;AAAA,0DAA2B;AAC3B,wEAAyC;AACzC,4DAA6B;AAC7B,sEAAuC;AACvC,oEAAqC;AACrC,oEAAqC;AACrC,+DAAgC;AAChC,2DAA4B;AAC5B,wDAAyB;AACzB,2DAA4B;AAC5B,wDAAyB;AACzB,kEAAmC;AACnC,+DAAgC;AAChC,uEAAwC","sourcesContent":["export * from \"./DILogger\";\nexport * from \"./DIConfigurationOptions\";\nexport * from \"./DIResolver\";\nexport * from \"./InjectableProperties\";\nexport * from \"./InterceptorMethods\";\nexport * from \"./InterceptorContext\";\nexport * from \"./InvokeOptions\";\nexport * from \"./IProvider\";\nexport * from \"./OnInit\";\nexport * from \"./OnDestroy\";\nexport * from \"./OnInit\";\nexport * from \"./RegistrySettings\";\nexport * from \"./TokenProvider\";\nexport * from \"./ResolvedInvokeOptions\";\n"]}
|
|
File without changes
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _GlobalProviderRegistry_settings;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.GlobalProviders = exports.GlobalProviderRegistry = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const core_1 = require("@tsed/core");
|
|
7
|
+
const Provider_1 = require("../domain/Provider");
|
|
8
|
+
const ProviderType_1 = require("../domain/ProviderType");
|
|
9
|
+
class GlobalProviderRegistry extends Map {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
_GlobalProviderRegistry_settings.set(this, new Map());
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The get() method returns a specified element from a Map object.
|
|
16
|
+
* @param key Required. The key of the element to return from the Map object.
|
|
17
|
+
* @returns {T} Returns the element associated with the specified key or undefined if the key can't be found in the Map object.
|
|
18
|
+
*/
|
|
19
|
+
get(key) {
|
|
20
|
+
return super.get((0, core_1.getClassOrSymbol)(key));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The has() method returns a boolean indicating whether an element with the specified key exists or not.
|
|
24
|
+
* @param key
|
|
25
|
+
* @returns {boolean}
|
|
26
|
+
*/
|
|
27
|
+
has(key) {
|
|
28
|
+
return super.has((0, core_1.getClassOrSymbol)(key));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The set() method adds or updates an element with a specified key and value to a Map object.
|
|
32
|
+
* @param key Required. The key of the element to add to the Map object.
|
|
33
|
+
* @param metadata Required. The value of the element to add to the Map object.
|
|
34
|
+
*/
|
|
35
|
+
set(key, metadata) {
|
|
36
|
+
super.set((0, core_1.getClassOrSymbol)(key), metadata);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param target
|
|
42
|
+
* @param options
|
|
43
|
+
*/
|
|
44
|
+
merge(target, options) {
|
|
45
|
+
const meta = this.createIfNotExists(target, options);
|
|
46
|
+
Object.keys(options).forEach((key) => {
|
|
47
|
+
meta[key] = options[key];
|
|
48
|
+
});
|
|
49
|
+
this.set(target, meta);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The delete() method removes the specified element from a Map object.
|
|
53
|
+
* @param key Required. The key of the element to remove from the Map object.
|
|
54
|
+
* @returns {boolean} Returns true if an element in the Map object existed and has been removed, or false if the element does not exist.
|
|
55
|
+
*/
|
|
56
|
+
delete(key) {
|
|
57
|
+
return super.delete((0, core_1.getClassOrSymbol)(key));
|
|
58
|
+
}
|
|
59
|
+
createRegistry(type, model, options = {}) {
|
|
60
|
+
const defaultOptions = this.getRegistrySettings(type);
|
|
61
|
+
options = Object.assign(defaultOptions, {
|
|
62
|
+
...options,
|
|
63
|
+
model
|
|
64
|
+
});
|
|
65
|
+
(0, tslib_1.__classPrivateFieldGet)(this, _GlobalProviderRegistry_settings, "f").set(type, options);
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
onInvoke(provider, locals, options) {
|
|
69
|
+
const settings = (0, tslib_1.__classPrivateFieldGet)(this, _GlobalProviderRegistry_settings, "f").get(provider.type);
|
|
70
|
+
if (settings === null || settings === void 0 ? void 0 : settings.onInvoke) {
|
|
71
|
+
settings.onInvoke(provider, locals, options);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
getRegistrySettings(target) {
|
|
75
|
+
let type = "provider";
|
|
76
|
+
if (typeof target === "string") {
|
|
77
|
+
type = target;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const provider = this.get(target);
|
|
81
|
+
if (provider) {
|
|
82
|
+
type = provider.type;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return ((0, tslib_1.__classPrivateFieldGet)(this, _GlobalProviderRegistry_settings, "f").get(type) || {
|
|
86
|
+
model: Provider_1.Provider
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
createRegisterFn(type) {
|
|
90
|
+
return (provider, instance) => {
|
|
91
|
+
// istanbul ignore next
|
|
92
|
+
if (!provider.provide) {
|
|
93
|
+
provider = {
|
|
94
|
+
provide: provider
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
provider = Object.assign({ instance }, provider, { type });
|
|
98
|
+
this.merge(provider.provide, provider);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
* @param key
|
|
104
|
+
* @param options
|
|
105
|
+
*/
|
|
106
|
+
createIfNotExists(key, options) {
|
|
107
|
+
const type = options.type || ProviderType_1.ProviderType.PROVIDER;
|
|
108
|
+
if (!this.has(key)) {
|
|
109
|
+
const { model = Provider_1.Provider } = (0, tslib_1.__classPrivateFieldGet)(this, _GlobalProviderRegistry_settings, "f").get(type) || {};
|
|
110
|
+
const item = new model(key);
|
|
111
|
+
this.set(key, item);
|
|
112
|
+
}
|
|
113
|
+
return this.get(key);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.GlobalProviderRegistry = GlobalProviderRegistry;
|
|
117
|
+
_GlobalProviderRegistry_settings = new WeakMap();
|
|
118
|
+
/**
|
|
119
|
+
*
|
|
120
|
+
* @type {GlobalProviders}
|
|
121
|
+
*/
|
|
122
|
+
// tslint:disable-next-line: variable-name
|
|
123
|
+
exports.GlobalProviders = new GlobalProviderRegistry();
|
|
124
|
+
//# sourceMappingURL=GlobalProviders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlobalProviders.js","sourceRoot":"","sources":["../../../src/registries/GlobalProviders.ts"],"names":[],"mappings":";;;;;AAAA,q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YACvD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACzC,CAAC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACO,iBAAiB,CAAC,GAAkB,EAAE,OAA2B;QACzE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,2BAAY,CAAC,QAAQ,CAAC;QAEnD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YAClB,MAAM,EAAC,KAAK,GAAG,mBAAQ,EAAC,GAAG,oCAAA,IAAI,wCAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAE1D,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;YAE5B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;SACrB;QAED,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;IACxB,CAAC;CACF;AAhID,wDAgIC;;AAED;;;GAGG;AACH,0CAA0C;AAC7B,QAAA,eAAe,GAAG,IAAI,sBAAsB,EAAE,CAAC","sourcesContent":["import {getClassOrSymbol, Type} from \"@tsed/core\";\nimport {Provider} from \"../domain/Provider\";\nimport {ProviderType} from \"../domain/ProviderType\";\nimport type {IProvider, RegistrySettings, TokenProvider} from \"../interfaces\";\nimport type {InjectorService} from \"../services/InjectorService\";\nimport {ResolvedInvokeOptions} from \"../interfaces/ResolvedInvokeOptions\";\n\nexport class GlobalProviderRegistry extends Map<TokenProvider, Provider> {\n #settings: Map<string, RegistrySettings> = new Map();\n\n /**\n * The get() method returns a specified element from a Map object.\n * @param key Required. The key of the element to return from the 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 */\n get(key: TokenProvider): Provider | undefined {\n return super.get(getClassOrSymbol(key));\n }\n\n /**\n * The has() method returns a boolean indicating whether an element with the specified key exists or not.\n * @param key\n * @returns {boolean}\n */\n has(key: TokenProvider): boolean {\n return super.has(getClassOrSymbol(key));\n }\n\n /**\n * The set() method adds or updates an element with a specified key and value to a Map object.\n * @param key Required. The key of the element to add to the Map object.\n * @param metadata Required. The value of the element to add to the Map object.\n */\n set(key: TokenProvider, metadata: Provider): this {\n super.set(getClassOrSymbol(key), metadata);\n\n return this;\n }\n\n /**\n *\n * @param target\n * @param options\n */\n merge(target: TokenProvider, options: Partial<IProvider>): void {\n const meta = this.createIfNotExists(target, options);\n\n Object.keys(options).forEach((key) => {\n meta[key] = (options as any)[key];\n });\n\n this.set(target, meta);\n }\n\n /**\n * The delete() method removes the specified element from a Map object.\n * @param key Required. The key of the element to remove from the Map object.\n * @returns {boolean} Returns true if an element in the Map object existed and has been removed, or false if the element does not exist.\n */\n delete(key: TokenProvider): boolean {\n return super.delete(getClassOrSymbol(key));\n }\n\n createRegistry(type: string, model: Type<Provider>, options: Partial<RegistrySettings> = {}) {\n const defaultOptions = this.getRegistrySettings(type);\n\n options = Object.assign(defaultOptions, {\n ...options,\n model\n });\n\n this.#settings.set(type, options);\n\n return this;\n }\n\n onInvoke(provider: Provider, locals: Map<TokenProvider, any>, options: ResolvedInvokeOptions & {injector: InjectorService}) {\n const settings = this.#settings.get(provider.type);\n\n if (settings?.onInvoke) {\n settings.onInvoke(provider, locals, options);\n }\n }\n\n getRegistrySettings(target: string | TokenProvider): RegistrySettings {\n let type: string = \"provider\";\n\n if (typeof target === \"string\") {\n type = target;\n } else {\n const provider = this.get(target);\n if (provider) {\n type = provider.type;\n }\n }\n\n return (\n this.#settings.get(type) || {\n model: Provider\n }\n );\n }\n\n createRegisterFn(type: string) {\n return (provider: any | IProvider, instance?: any): void => {\n // istanbul ignore next\n if (!provider.provide) {\n provider = {\n provide: provider\n };\n }\n\n provider = Object.assign({instance}, provider, {type});\n this.merge(provider.provide, provider);\n };\n }\n\n /**\n *\n * @param key\n * @param options\n */\n protected createIfNotExists(key: TokenProvider, options: Partial<IProvider>): Provider {\n const type = options.type || ProviderType.PROVIDER;\n\n if (!this.has(key)) {\n const {model = Provider} = this.#settings.get(type) || {};\n\n const item = new model(key);\n\n this.set(key, item);\n }\n\n return this.get(key)!;\n }\n}\n\n/**\n *\n * @type {GlobalProviders}\n */\n// tslint:disable-next-line: variable-name\nexport const GlobalProviders = new GlobalProviderRegistry();\n"]}
|
|
File without changes
|