@zudojs/core 0.0.1 → 1.0.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/LICENSE +21 -0
- package/README.md +141 -7
- package/dist/application/application.d.ts +43 -2
- package/dist/application/application.js +111 -13
- package/dist/application/applicationContext.context.d.ts +15 -0
- package/dist/application/applicationContext.context.js +12 -0
- package/dist/application/createApplication.d.ts +78 -0
- package/dist/application/createApplication.js +104 -0
- package/dist/application/index.d.ts +2 -1
- package/dist/application/index.js +2 -1
- package/dist/configuration/configurationManager.manager.d.ts +32 -0
- package/dist/configuration/configurationManager.manager.js +86 -7
- package/dist/configuration/core/configuration.d.ts +60 -15
- package/dist/configuration/core/configuration.js +248 -51
- package/dist/configuration/core/configurationKey.key.d.ts +4 -2
- package/dist/configuration/core/configurationKey.key.js +2 -13
- package/dist/configuration/core/configurationPath.path.d.ts +17 -0
- package/dist/configuration/core/configurationPath.path.js +33 -0
- package/dist/configuration/core/index.d.ts +7 -1
- package/dist/configuration/core/index.js +1 -0
- package/dist/configuration/error/configurationError.error.d.ts +11 -0
- package/dist/configuration/error/configurationError.error.js +29 -1
- package/dist/configuration/error/configurationRedactor.redactor.d.ts +16 -0
- package/dist/configuration/error/configurationRedactor.redactor.js +83 -5
- package/dist/configuration/error/index.d.ts +2 -1
- package/dist/configuration/error/index.js +2 -1
- package/dist/configuration/index.d.ts +1 -1
- package/dist/configuration/loader/configurationLoader.loader.d.ts +47 -9
- package/dist/configuration/loader/configurationLoader.loader.js +107 -26
- package/dist/configuration/loader/index.d.ts +1 -1
- package/dist/configuration/loader/index.js +1 -1
- package/dist/configuration/registry/configurationProvider.provider.d.ts +26 -1
- package/dist/configuration/registry/configurationProvider.provider.js +33 -7
- package/dist/configuration/registry/configurationRegistry.registry.js +2 -1
- package/dist/configuration/schema/configurationSchema.schema.d.ts +0 -4
- package/dist/configuration/schema/configurationSchema.schema.js +11 -32
- package/dist/configuration/schema/configurationValidation.validator.d.ts +14 -2
- package/dist/configuration/schema/configurationValidation.validator.js +55 -7
- package/dist/configuration/schema/index.d.ts +1 -1
- package/dist/configuration/schema/index.js +1 -1
- package/dist/container/container.d.ts +52 -5
- package/dist/container/container.js +110 -33
- package/dist/container/index.d.ts +1 -1
- package/dist/container/index.js +1 -1
- package/dist/container/scope.d.ts +7 -6
- package/dist/context/core/contextAliases.deprecated.d.ts +32 -0
- package/dist/context/core/contextAliases.deprecated.js +6 -0
- package/dist/context/core/executionContext.context.d.ts +8 -0
- package/dist/context/core/executionContext.context.js +38 -15
- package/dist/context/core/index.d.ts +2 -2
- package/dist/context/core/index.js +2 -2
- package/dist/context/index.d.ts +20 -0
- package/dist/context/index.js +20 -0
- package/dist/context/provider/contextProvider.provider.d.ts +7 -4
- package/dist/context/provider/contextProvider.provider.js +9 -6
- package/dist/context/provider/contextStorage.storage.d.ts +47 -7
- package/dist/context/provider/contextStorage.storage.js +54 -12
- package/dist/context/provider/defaultContextStorage.storage.d.ts +18 -0
- package/dist/context/provider/defaultContextStorage.storage.js +20 -0
- package/dist/context/provider/index.d.ts +2 -1
- package/dist/context/provider/index.js +1 -0
- package/dist/errors/exceptions.d.ts +22 -0
- package/dist/errors/exceptions.js +38 -1
- package/dist/errors/frameworkError.error.d.ts +6 -9
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +14 -0
- package/dist/lifecycle/core/index.d.ts +1 -1
- package/dist/lifecycle/core/index.js +1 -1
- package/dist/lifecycle/core/lifecycle.d.ts +47 -2
- package/dist/lifecycle/core/lifecycle.js +251 -85
- package/dist/lifecycle/core/lifecycleRegistry.registry.d.ts +8 -0
- package/dist/lifecycle/core/lifecycleRegistry.registry.js +20 -1
- package/dist/lifecycle/manager/lifecycleManager.manager.d.ts +21 -2
- package/dist/lifecycle/manager/lifecycleManager.manager.js +62 -99
- package/dist/lifecycle/scope/lifecycleScope.scope.d.ts +22 -1
- package/dist/lifecycle/scope/lifecycleScope.scope.js +85 -17
- package/dist/logging/console/consoleLogger.logger.d.ts +20 -1
- package/dist/logging/console/consoleLogger.logger.js +77 -11
- package/dist/logging/console/loggerFactory.factory.d.ts +6 -5
- package/dist/logging/console/loggerFactory.factory.js +1 -7
- package/dist/logging/core/index.d.ts +4 -3
- package/dist/logging/core/index.js +4 -3
- package/dist/logging/core/logEntry.entry.d.ts +41 -3
- package/dist/logging/core/logEntry.entry.js +114 -4
- package/dist/logging/core/logLevel.level.d.ts +18 -0
- package/dist/logging/core/logLevel.level.js +25 -1
- package/dist/logging/core/logRedaction.redaction.d.ts +38 -0
- package/dist/logging/core/logRedaction.redaction.js +19 -0
- package/dist/logging/core/logger.d.ts +14 -11
- package/dist/logging/core/logger.js +31 -6
- package/dist/logging/core/loggerContext.context.d.ts +12 -0
- package/dist/logging/core/loggerContext.context.js +19 -0
- package/dist/logging/core/loggerOptions.options.d.ts +17 -0
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +0 -6
- package/dist/modules/module.d.ts +7 -1
- package/dist/modules/moduleContext.context.d.ts +41 -7
- package/dist/modules/moduleContext.context.js +31 -8
- package/dist/modules/moduleDefinition.definition.d.ts +11 -7
- package/dist/modules/moduleDefinition.definition.js +41 -8
- package/dist/modules/moduleDependency/index.d.ts +2 -2
- package/dist/modules/moduleDependency/index.js +1 -1
- package/dist/modules/moduleDependency/moduleDependency.graph.d.ts +19 -2
- package/dist/modules/moduleDependency/moduleDependency.graph.js +122 -8
- package/dist/modules/moduleDependency/moduleDependency.ordering.d.ts +8 -0
- package/dist/modules/moduleDependency/moduleDependency.ordering.js +85 -57
- package/dist/modules/moduleDependency/moduleDependency.type.d.ts +28 -1
- package/dist/modules/moduleError/index.d.ts +1 -1
- package/dist/modules/moduleError/index.js +1 -1
- package/dist/modules/moduleError/moduleError.dependency.d.ts +11 -0
- package/dist/modules/moduleError/moduleError.dependency.js +15 -0
- package/dist/modules/moduleLifecycle/index.d.ts +5 -2
- package/dist/modules/moduleLifecycle/index.js +4 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.d.ts +44 -6
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.js +153 -9
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.d.ts +30 -5
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.js +130 -10
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.d.ts +65 -28
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.js +15 -4
- package/dist/modules/moduleLoader/moduleLoader.loader.d.ts +39 -5
- package/dist/modules/moduleLoader/moduleLoader.loader.js +123 -50
- package/dist/modules/moduleLoader/moduleLoader.type.d.ts +4 -2
- package/dist/modules/moduleLoader/moduleLoader.type.js +10 -3
- package/dist/modules/moduleMetadata.metadata.js +15 -5
- package/dist/modules/moduleRegistry/index.d.ts +1 -1
- package/dist/modules/moduleRegistry/moduleRegistry.registry.d.ts +2 -2
- package/dist/modules/moduleRegistry/moduleRegistry.registry.js +38 -6
- package/dist/modules/moduleRegistry/moduleRegistry.type.d.ts +18 -1
- package/dist/runtime/index.d.ts +17 -15
- package/dist/runtime/index.js +14 -10
- package/dist/runtime/runtime.d.ts +135 -33
- package/dist/runtime/runtime.js +344 -114
- package/dist/runtime/runtimeBootstrap/index.d.ts +2 -1
- package/dist/runtime/runtimeBootstrap/index.js +1 -1
- package/dist/runtime/runtimeBootstrap/pipeline/index.d.ts +2 -2
- package/dist/runtime/runtimeBootstrap/pipeline/index.js +1 -2
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.d.ts +41 -15
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.js +98 -76
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.d.ts +7 -4
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.js +87 -59
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.d.ts +10 -4
- package/dist/runtime/runtimeContext/index.d.ts +3 -5
- package/dist/runtime/runtimeContext/index.js +2 -4
- package/dist/runtime/runtimeContext/runtimeContext.factory.d.ts +10 -4
- package/dist/runtime/runtimeContext/runtimeContext.factory.js +30 -7
- package/dist/runtime/runtimeContext/runtimeContext.type.d.ts +36 -47
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.d.ts +5 -0
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.js +6 -4
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.d.ts +4 -0
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.js +7 -9
- package/dist/runtime/runtimeEnvironment/index.d.ts +2 -2
- package/dist/runtime/runtimeEnvironment/index.js +1 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.d.ts +20 -17
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.js +20 -13
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.d.ts +12 -1
- package/dist/runtime/runtimeError/index.d.ts +3 -3
- package/dist/runtime/runtimeError/index.js +1 -1
- package/dist/runtime/runtimeError/runtimeError.base.d.ts +15 -18
- package/dist/runtime/runtimeError/runtimeError.base.js +38 -36
- package/dist/runtime/runtimeError/runtimeError.lifecycle.d.ts +23 -8
- package/dist/runtime/runtimeError/runtimeError.lifecycle.js +31 -7
- package/dist/runtime/runtimeError/runtimeError.specialized.d.ts +1 -1
- package/dist/runtime/runtimeError/runtimeError.specialized.js +1 -1
- package/dist/runtime/runtimeError/runtimeError.type.d.ts +5 -9
- package/dist/runtime/runtimeLogger.d.ts +2 -2
- package/dist/runtime/runtimeLogger.js +3 -3
- package/dist/runtime/runtimeOptions/index.d.ts +1 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.d.ts +1 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.js +2 -0
- package/dist/runtime/runtimeOptions/runtimeOptions.resolver.js +5 -2
- package/dist/runtime/runtimeOptions/runtimeOptions.type.d.ts +45 -16
- package/dist/runtime/runtimeOptions/runtimeOptions.validation.js +0 -1
- package/dist/runtime/runtimeShutdown/index.d.ts +3 -2
- package/dist/runtime/runtimeShutdown/index.js +2 -2
- package/dist/runtime/runtimeShutdown/pipeline/index.d.ts +2 -1
- package/dist/runtime/runtimeShutdown/pipeline/index.js +1 -1
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.d.ts +37 -7
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.js +77 -51
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.d.ts +8 -16
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.js +85 -87
- package/dist/runtime/runtimeShutdown/runtimeShutdown.type.d.ts +9 -5
- package/dist/runtime/runtimeSignals/index.d.ts +8 -0
- package/dist/runtime/runtimeSignals/index.js +7 -0
- package/dist/runtime/runtimeSignals/runtimeSignals.d.ts +93 -0
- package/dist/runtime/runtimeSignals/runtimeSignals.js +149 -0
- package/dist/runtime/runtimeState.state.d.ts +32 -14
- package/dist/runtime/runtimeState.state.js +34 -27
- package/dist/runtime/runtimeTimeout.d.ts +40 -0
- package/dist/runtime/runtimeTimeout.js +42 -0
- package/package.json +21 -15
- package/dist/.tsbuildinfo +0 -1
- package/dist/application/application.d.ts.map +0 -1
- package/dist/application/application.js.map +0 -1
- package/dist/application/applicationContext.context.d.ts.map +0 -1
- package/dist/application/applicationContext.context.js.map +0 -1
- package/dist/application/applicationState.state.d.ts.map +0 -1
- package/dist/application/applicationState.state.js.map +0 -1
- package/dist/application/index.d.ts.map +0 -1
- package/dist/application/index.js.map +0 -1
- package/dist/configuration/configurationManager.manager.d.ts.map +0 -1
- package/dist/configuration/configurationManager.manager.js.map +0 -1
- package/dist/configuration/core/configuration.d.ts.map +0 -1
- package/dist/configuration/core/configuration.js.map +0 -1
- package/dist/configuration/core/configurationKey.key.d.ts.map +0 -1
- package/dist/configuration/core/configurationKey.key.js.map +0 -1
- package/dist/configuration/core/configurationSource.source.d.ts.map +0 -1
- package/dist/configuration/core/configurationSource.source.js.map +0 -1
- package/dist/configuration/core/index.d.ts.map +0 -1
- package/dist/configuration/core/index.js.map +0 -1
- package/dist/configuration/error/configurationError.error.d.ts.map +0 -1
- package/dist/configuration/error/configurationError.error.js.map +0 -1
- package/dist/configuration/error/configurationRedactor.redactor.d.ts.map +0 -1
- package/dist/configuration/error/configurationRedactor.redactor.js.map +0 -1
- package/dist/configuration/error/index.d.ts.map +0 -1
- package/dist/configuration/error/index.js.map +0 -1
- package/dist/configuration/events/configurationEvents.events.d.ts.map +0 -1
- package/dist/configuration/events/configurationEvents.events.js.map +0 -1
- package/dist/configuration/events/index.d.ts.map +0 -1
- package/dist/configuration/events/index.js.map +0 -1
- package/dist/configuration/index.d.ts.map +0 -1
- package/dist/configuration/index.js.map +0 -1
- package/dist/configuration/loader/configurationLoader.loader.d.ts.map +0 -1
- package/dist/configuration/loader/configurationLoader.loader.js.map +0 -1
- package/dist/configuration/loader/index.d.ts.map +0 -1
- package/dist/configuration/loader/index.js.map +0 -1
- package/dist/configuration/registry/configurationProvider.provider.d.ts.map +0 -1
- package/dist/configuration/registry/configurationProvider.provider.js.map +0 -1
- package/dist/configuration/registry/configurationRegistry.registry.d.ts.map +0 -1
- package/dist/configuration/registry/configurationRegistry.registry.js.map +0 -1
- package/dist/configuration/registry/index.d.ts.map +0 -1
- package/dist/configuration/registry/index.js.map +0 -1
- package/dist/configuration/schema/configurationSchema.schema.d.ts.map +0 -1
- package/dist/configuration/schema/configurationSchema.schema.js.map +0 -1
- package/dist/configuration/schema/configurationValidation.validator.d.ts.map +0 -1
- package/dist/configuration/schema/configurationValidation.validator.js.map +0 -1
- package/dist/configuration/schema/index.d.ts.map +0 -1
- package/dist/configuration/schema/index.js.map +0 -1
- package/dist/container/container.d.ts.map +0 -1
- package/dist/container/container.js.map +0 -1
- package/dist/container/index.d.ts.map +0 -1
- package/dist/container/index.js.map +0 -1
- package/dist/container/provider.d.ts.map +0 -1
- package/dist/container/provider.js.map +0 -1
- package/dist/container/scope.d.ts.map +0 -1
- package/dist/container/scope.js.map +0 -1
- package/dist/container/token.d.ts.map +0 -1
- package/dist/container/token.js.map +0 -1
- package/dist/context/core/context.d.ts +0 -95
- package/dist/context/core/context.d.ts.map +0 -1
- package/dist/context/core/context.js +0 -103
- package/dist/context/core/context.js.map +0 -1
- package/dist/context/core/contextKey.key.d.ts.map +0 -1
- package/dist/context/core/contextKey.key.js.map +0 -1
- package/dist/context/core/executionContext.context.d.ts.map +0 -1
- package/dist/context/core/executionContext.context.js.map +0 -1
- package/dist/context/core/index.d.ts.map +0 -1
- package/dist/context/core/index.js.map +0 -1
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js.map +0 -1
- package/dist/context/provider/contextProvider.provider.d.ts.map +0 -1
- package/dist/context/provider/contextProvider.provider.js.map +0 -1
- package/dist/context/provider/contextStorage.storage.d.ts.map +0 -1
- package/dist/context/provider/contextStorage.storage.js.map +0 -1
- package/dist/context/provider/index.d.ts.map +0 -1
- package/dist/context/provider/index.js.map +0 -1
- package/dist/context/snapshot/contextSnapshot.snapshot.d.ts.map +0 -1
- package/dist/context/snapshot/contextSnapshot.snapshot.js.map +0 -1
- package/dist/context/snapshot/index.d.ts.map +0 -1
- package/dist/context/snapshot/index.js.map +0 -1
- package/dist/context/values/contextValues.values.d.ts.map +0 -1
- package/dist/context/values/contextValues.values.js.map +0 -1
- package/dist/context/values/index.d.ts.map +0 -1
- package/dist/context/values/index.js.map +0 -1
- package/dist/contracts/adapter.d.ts.map +0 -1
- package/dist/contracts/adapter.js.map +0 -1
- package/dist/contracts/disposable.d.ts.map +0 -1
- package/dist/contracts/disposable.js.map +0 -1
- package/dist/contracts/handler.d.ts.map +0 -1
- package/dist/contracts/handler.js.map +0 -1
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/contracts/index.js.map +0 -1
- package/dist/errors/errorCode.code.d.ts.map +0 -1
- package/dist/errors/errorCode.code.js.map +0 -1
- package/dist/errors/exceptions.d.ts.map +0 -1
- package/dist/errors/exceptions.js.map +0 -1
- package/dist/errors/frameworkError.error.d.ts.map +0 -1
- package/dist/errors/frameworkError.error.js.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lifecycle/core/index.d.ts.map +0 -1
- package/dist/lifecycle/core/index.js.map +0 -1
- package/dist/lifecycle/core/lifecycle.d.ts.map +0 -1
- package/dist/lifecycle/core/lifecycle.js.map +0 -1
- package/dist/lifecycle/core/lifecycleHook.hook.d.ts.map +0 -1
- package/dist/lifecycle/core/lifecycleHook.hook.js.map +0 -1
- package/dist/lifecycle/core/lifecycleRegistry.registry.d.ts.map +0 -1
- package/dist/lifecycle/core/lifecycleRegistry.registry.js.map +0 -1
- package/dist/lifecycle/core/lifecycleState.state.d.ts +0 -2
- package/dist/lifecycle/core/lifecycleState.state.d.ts.map +0 -1
- package/dist/lifecycle/core/lifecycleState.state.js +0 -2
- package/dist/lifecycle/core/lifecycleState.state.js.map +0 -1
- package/dist/lifecycle/index.d.ts.map +0 -1
- package/dist/lifecycle/index.js.map +0 -1
- package/dist/lifecycle/manager/index.d.ts.map +0 -1
- package/dist/lifecycle/manager/index.js.map +0 -1
- package/dist/lifecycle/manager/lifecycleManager.manager.d.ts.map +0 -1
- package/dist/lifecycle/manager/lifecycleManager.manager.js.map +0 -1
- package/dist/lifecycle/scope/index.d.ts.map +0 -1
- package/dist/lifecycle/scope/index.js.map +0 -1
- package/dist/lifecycle/scope/lifecycleScope.scope.d.ts.map +0 -1
- package/dist/lifecycle/scope/lifecycleScope.scope.js.map +0 -1
- package/dist/logging/console/consoleLogger.logger.d.ts.map +0 -1
- package/dist/logging/console/consoleLogger.logger.js.map +0 -1
- package/dist/logging/console/index.d.ts.map +0 -1
- package/dist/logging/console/index.js.map +0 -1
- package/dist/logging/console/loggerFactory.factory.d.ts.map +0 -1
- package/dist/logging/console/loggerFactory.factory.js.map +0 -1
- package/dist/logging/core/index.d.ts.map +0 -1
- package/dist/logging/core/index.js.map +0 -1
- package/dist/logging/core/logEntry.entry.d.ts.map +0 -1
- package/dist/logging/core/logEntry.entry.js.map +0 -1
- package/dist/logging/core/logLevel.level.d.ts.map +0 -1
- package/dist/logging/core/logLevel.level.js.map +0 -1
- package/dist/logging/core/logger.d.ts.map +0 -1
- package/dist/logging/core/logger.js.map +0 -1
- package/dist/logging/core/loggerContext.context.d.ts.map +0 -1
- package/dist/logging/core/loggerContext.context.js.map +0 -1
- package/dist/logging/core/loggerOptions.options.d.ts.map +0 -1
- package/dist/logging/core/loggerOptions.options.js.map +0 -1
- package/dist/logging/index.d.ts.map +0 -1
- package/dist/logging/index.js.map +0 -1
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/modules/index.js.map +0 -1
- package/dist/modules/module.d.ts.map +0 -1
- package/dist/modules/module.js.map +0 -1
- package/dist/modules/moduleContext.context.d.ts.map +0 -1
- package/dist/modules/moduleContext.context.js.map +0 -1
- package/dist/modules/moduleDefinition.definition.d.ts.map +0 -1
- package/dist/modules/moduleDefinition.definition.js.map +0 -1
- package/dist/modules/moduleDependency/index.d.ts.map +0 -1
- package/dist/modules/moduleDependency/index.js.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.graph.d.ts.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.graph.js.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.ordering.d.ts.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.ordering.js.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.type.d.ts.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.type.js.map +0 -1
- package/dist/modules/moduleError/index.d.ts.map +0 -1
- package/dist/modules/moduleError/index.js.map +0 -1
- package/dist/modules/moduleError/moduleError.base.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.base.js.map +0 -1
- package/dist/modules/moduleError/moduleError.dependency.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.dependency.js.map +0 -1
- package/dist/modules/moduleError/moduleError.helpers.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.helpers.js.map +0 -1
- package/dist/modules/moduleError/moduleError.lifecycle.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.lifecycle.js.map +0 -1
- package/dist/modules/moduleError/moduleError.registration.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.registration.js.map +0 -1
- package/dist/modules/moduleLifecycle/index.d.ts.map +0 -1
- package/dist/modules/moduleLifecycle/index.js.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.d.ts.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.js.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.d.ts.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.js.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.d.ts.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.js.map +0 -1
- package/dist/modules/moduleLoader/index.d.ts.map +0 -1
- package/dist/modules/moduleLoader/index.js.map +0 -1
- package/dist/modules/moduleLoader/moduleLoader.loader.d.ts.map +0 -1
- package/dist/modules/moduleLoader/moduleLoader.loader.js.map +0 -1
- package/dist/modules/moduleLoader/moduleLoader.type.d.ts.map +0 -1
- package/dist/modules/moduleLoader/moduleLoader.type.js.map +0 -1
- package/dist/modules/moduleMetadata.metadata.d.ts.map +0 -1
- package/dist/modules/moduleMetadata.metadata.js.map +0 -1
- package/dist/modules/moduleRegistry/index.d.ts.map +0 -1
- package/dist/modules/moduleRegistry/index.js.map +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.registry.d.ts.map +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.registry.js.map +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.type.d.ts.map +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.type.js.map +0 -1
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/runtime.d.ts.map +0 -1
- package/dist/runtime/runtime.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/index.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/index.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/index.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/index.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.d.ts +0 -6
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.js +0 -27
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.js.map +0 -1
- package/dist/runtime/runtimeContext/index.d.ts.map +0 -1
- package/dist/runtime/runtimeContext/index.js.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.core.d.ts +0 -38
- package/dist/runtime/runtimeContext/runtimeContext.core.d.ts.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.core.js +0 -99
- package/dist/runtime/runtimeContext/runtimeContext.core.js.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.factory.d.ts.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.factory.js.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.type.d.ts.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.type.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/index.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/index.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.detection.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.detection.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/index.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/index.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.js.map +0 -1
- package/dist/runtime/runtimeError/index.d.ts.map +0 -1
- package/dist/runtime/runtimeError/index.js.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.base.d.ts.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.base.js.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.lifecycle.d.ts.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.lifecycle.js.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.specialized.d.ts.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.specialized.js.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.type.d.ts.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.type.js.map +0 -1
- package/dist/runtime/runtimeLogger.d.ts.map +0 -1
- package/dist/runtime/runtimeLogger.js.map +0 -1
- package/dist/runtime/runtimeManager/index.d.ts +0 -12
- package/dist/runtime/runtimeManager/index.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/index.js +0 -11
- package/dist/runtime/runtimeManager/index.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.core.d.ts +0 -31
- package/dist/runtime/runtimeManager/runtimeManager.core.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.core.js +0 -136
- package/dist/runtime/runtimeManager/runtimeManager.core.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.error.d.ts +0 -14
- package/dist/runtime/runtimeManager/runtimeManager.error.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.error.js +0 -21
- package/dist/runtime/runtimeManager/runtimeManager.error.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.factory.d.ts +0 -7
- package/dist/runtime/runtimeManager/runtimeManager.factory.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.factory.js +0 -8
- package/dist/runtime/runtimeManager/runtimeManager.factory.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.lifecycle.d.ts +0 -16
- package/dist/runtime/runtimeManager/runtimeManager.lifecycle.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.lifecycle.js +0 -49
- package/dist/runtime/runtimeManager/runtimeManager.lifecycle.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.type.d.ts +0 -54
- package/dist/runtime/runtimeManager/runtimeManager.type.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.type.js +0 -2
- package/dist/runtime/runtimeManager/runtimeManager.type.js.map +0 -1
- package/dist/runtime/runtimeOptions/index.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/index.js.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.js.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.resolver.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.resolver.js.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.type.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.type.js.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.validation.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.validation.js.map +0 -1
- package/dist/runtime/runtimeShutdown/index.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/index.js.map +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/index.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/index.js.map +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.js.map +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.js.map +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.type.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.type.js.map +0 -1
- package/dist/runtime/runtimeState.state.d.ts.map +0 -1
- package/dist/runtime/runtimeState.state.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Configuration } from "../core/configuration.js";
|
|
2
2
|
import { ConfigurationSchemaRegistry } from "../schema/configurationSchema.schema.js";
|
|
3
3
|
import type { ConfigurationSchema, ConfigurationValidationIssue, ConfigurationValidationResult } from "../schema/configurationSchema.schema.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ConfigurationError } from "../error/configurationError.error.js";
|
|
5
5
|
/**
|
|
6
6
|
* Result returned after validating configuration.
|
|
7
7
|
*/
|
|
@@ -49,7 +49,7 @@ export interface ConfigurationValidationOptions {
|
|
|
49
49
|
/**
|
|
50
50
|
* Error thrown when configuration validation fails.
|
|
51
51
|
*/
|
|
52
|
-
export declare class ConfigurationValidationError extends
|
|
52
|
+
export declare class ConfigurationValidationError extends ConfigurationError {
|
|
53
53
|
/**
|
|
54
54
|
* All configuration validation issues.
|
|
55
55
|
*/
|
|
@@ -73,8 +73,20 @@ export declare function validateConfiguration(configuration: Configuration, regi
|
|
|
73
73
|
*
|
|
74
74
|
* This is the method application bootstrap code should normally
|
|
75
75
|
* use when configuration is mandatory for startup.
|
|
76
|
+
*
|
|
77
|
+
* The returned configuration has schema default values applied:
|
|
78
|
+
* every registered schema whose path is missing from the
|
|
79
|
+
* configuration and which declares a default contributes that
|
|
80
|
+
* default (attributed to the "default" source).
|
|
76
81
|
*/
|
|
77
82
|
export declare function validateConfigurationOrThrow(configuration: Configuration, registry: ConfigurationSchemaRegistry, options?: ConfigurationValidationOptions): Promise<Configuration>;
|
|
83
|
+
/**
|
|
84
|
+
* Applies schema default values to a configuration.
|
|
85
|
+
*
|
|
86
|
+
* Values already present in the configuration are never
|
|
87
|
+
* overridden.
|
|
88
|
+
*/
|
|
89
|
+
export declare function applyConfigurationSchemaDefaults(configuration: Configuration, registry: ConfigurationSchemaRegistry): Configuration;
|
|
78
90
|
/**
|
|
79
91
|
* Validates one configuration schema.
|
|
80
92
|
*/
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import { ConfigurationSchemaRegistry } from "../schema/configurationSchema.schema.js";
|
|
2
|
-
import { FrameworkError } from "../../errors/frameworkError.error.js";
|
|
3
2
|
import { ErrorCode } from "../../errors/errorCode.code.js";
|
|
3
|
+
import { ConfigurationError } from "../error/configurationError.error.js";
|
|
4
|
+
import { ConfigurationRedactor } from "../error/configurationRedactor.redactor.js";
|
|
5
|
+
/**
|
|
6
|
+
* Redactor used to scrub validation issues before they are
|
|
7
|
+
* embedded in error messages and details.
|
|
8
|
+
*/
|
|
9
|
+
const issueRedactor = new ConfigurationRedactor();
|
|
10
|
+
/**
|
|
11
|
+
* Redacts sensitive information from a validation issue.
|
|
12
|
+
*/
|
|
13
|
+
function redactValidationIssue(issue) {
|
|
14
|
+
return {
|
|
15
|
+
path: issue.path,
|
|
16
|
+
message: issueRedactor.redactText(issue.message),
|
|
17
|
+
code: issue.code,
|
|
18
|
+
...(issue.value !== undefined
|
|
19
|
+
? {
|
|
20
|
+
value: issueRedactor.redactValueAtPath(issue.path, issue.value),
|
|
21
|
+
}
|
|
22
|
+
: {}),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
4
25
|
/**
|
|
5
26
|
* Error thrown when configuration validation fails.
|
|
6
27
|
*/
|
|
7
|
-
export class ConfigurationValidationError extends
|
|
28
|
+
export class ConfigurationValidationError extends ConfigurationError {
|
|
8
29
|
/**
|
|
9
30
|
* All configuration validation issues.
|
|
10
31
|
*/
|
|
@@ -18,16 +39,21 @@ export class ConfigurationValidationError extends FrameworkError {
|
|
|
18
39
|
*/
|
|
19
40
|
invalidSchemaCount;
|
|
20
41
|
constructor(issues, schemaCount, invalidSchemaCount) {
|
|
21
|
-
|
|
22
|
-
|
|
42
|
+
/*
|
|
43
|
+
* Issue values and messages are redacted before being
|
|
44
|
+
* embedded so validation failures on sensitive paths do
|
|
45
|
+
* not leak secrets into logs.
|
|
46
|
+
*/
|
|
47
|
+
const redactedIssues = issues.map(redactValidationIssue);
|
|
48
|
+
super(ErrorCode.CONFIGURATION_VALIDATION_FAILED, createValidationErrorMessage(redactedIssues), {
|
|
23
49
|
details: {
|
|
24
|
-
issues,
|
|
50
|
+
issues: redactedIssues,
|
|
25
51
|
schemaCount,
|
|
26
52
|
invalidSchemaCount,
|
|
27
53
|
},
|
|
28
54
|
});
|
|
29
55
|
this.name = "ConfigurationValidationError";
|
|
30
|
-
this.issues =
|
|
56
|
+
this.issues = redactedIssues;
|
|
31
57
|
this.schemaCount = schemaCount;
|
|
32
58
|
this.invalidSchemaCount = invalidSchemaCount;
|
|
33
59
|
}
|
|
@@ -66,13 +92,35 @@ export async function validateConfiguration(configuration, registry, options = {
|
|
|
66
92
|
*
|
|
67
93
|
* This is the method application bootstrap code should normally
|
|
68
94
|
* use when configuration is mandatory for startup.
|
|
95
|
+
*
|
|
96
|
+
* The returned configuration has schema default values applied:
|
|
97
|
+
* every registered schema whose path is missing from the
|
|
98
|
+
* configuration and which declares a default contributes that
|
|
99
|
+
* default (attributed to the "default" source).
|
|
69
100
|
*/
|
|
70
101
|
export async function validateConfigurationOrThrow(configuration, registry, options = {}) {
|
|
71
102
|
const report = await validateConfiguration(configuration, registry, options);
|
|
72
103
|
if (!report.valid) {
|
|
73
104
|
throw new ConfigurationValidationError(report.issues, report.schemaCount, report.invalidSchemaCount);
|
|
74
105
|
}
|
|
75
|
-
return configuration;
|
|
106
|
+
return applyConfigurationSchemaDefaults(configuration, registry);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Applies schema default values to a configuration.
|
|
110
|
+
*
|
|
111
|
+
* Values already present in the configuration are never
|
|
112
|
+
* overridden.
|
|
113
|
+
*/
|
|
114
|
+
export function applyConfigurationSchemaDefaults(configuration, registry) {
|
|
115
|
+
let result = configuration;
|
|
116
|
+
for (const schema of registry.getAll()) {
|
|
117
|
+
if (schema.defaultValue === undefined)
|
|
118
|
+
continue;
|
|
119
|
+
if (result.has(schema.path))
|
|
120
|
+
continue;
|
|
121
|
+
result = result.with(schema.path, schema.defaultValue, "default");
|
|
122
|
+
}
|
|
123
|
+
return result;
|
|
76
124
|
}
|
|
77
125
|
/**
|
|
78
126
|
* Validates one configuration schema.
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { createConfigurationSchema, ConfigurationSchemaRegistry, createConfigurationSchemaRegistry, } from "./configurationSchema.schema.js";
|
|
7
7
|
export type { ConfigurationValidationResult, ConfigurationValidationIssue, ConfigurationValidationContext, ConfigurationValidator, ConfigurationSchema, ConfigurationSchemaOptions, } from "./configurationSchema.schema.js";
|
|
8
|
-
export { validateConfiguration, validateConfigurationOrThrow, validateSchema, } from "./configurationValidation.validator.js";
|
|
8
|
+
export { ConfigurationValidationError, validateConfiguration, validateConfigurationOrThrow, validateSchema, applyConfigurationSchemaDefaults, } from "./configurationValidation.validator.js";
|
|
9
9
|
export type { ConfigurationValidationReport, ConfigurationValidationOptions, } from "./configurationValidation.validator.js";
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* Configuration schemas and validation.
|
|
5
5
|
*/
|
|
6
6
|
export { createConfigurationSchema, ConfigurationSchemaRegistry, createConfigurationSchemaRegistry, } from "./configurationSchema.schema.js";
|
|
7
|
-
export { validateConfiguration, validateConfigurationOrThrow, validateSchema, } from "./configurationValidation.validator.js";
|
|
7
|
+
export { ConfigurationValidationError, validateConfiguration, validateConfigurationOrThrow, validateSchema, applyConfigurationSchemaDefaults, } from "./configurationValidation.validator.js";
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,22 +1,52 @@
|
|
|
1
1
|
import type { Provider } from "./provider.js";
|
|
2
2
|
import type { Scope } from "./scope.js";
|
|
3
3
|
import type { Token } from "./token.js";
|
|
4
|
+
/**
|
|
5
|
+
* Options for the container.
|
|
6
|
+
*/
|
|
7
|
+
export interface ContainerOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Returns the object identifying the current execution scope, for
|
|
10
|
+
* example the current ExecutionContext from a ContextStorage:
|
|
11
|
+
*
|
|
12
|
+
* new Container({ currentScope: () => storage.get() })
|
|
13
|
+
*
|
|
14
|
+
* "scoped" providers resolve to one instance per returned object.
|
|
15
|
+
* When it returns undefined and no explicit scope is active, scoped
|
|
16
|
+
* providers behave as transient.
|
|
17
|
+
*/
|
|
18
|
+
readonly currentScope?: () => object | undefined;
|
|
19
|
+
}
|
|
4
20
|
/**
|
|
5
21
|
* Dependency Injection container for Zudojs applications.
|
|
6
22
|
*
|
|
7
23
|
* The container is responsible for registering and resolving
|
|
8
|
-
* application dependencies
|
|
24
|
+
* application dependencies with singleton, scoped, and transient
|
|
25
|
+
* lifetimes.
|
|
9
26
|
*/
|
|
10
27
|
export declare class Container {
|
|
11
28
|
private readonly providers;
|
|
29
|
+
private readonly scopedInstances;
|
|
30
|
+
private readonly currentScope;
|
|
31
|
+
private readonly resolving;
|
|
32
|
+
private activeScope;
|
|
33
|
+
constructor(options?: ContainerOptions);
|
|
12
34
|
/**
|
|
13
35
|
* Registers a provider in the container.
|
|
14
36
|
*/
|
|
15
37
|
register<T>(token: Token<T>, provider: Provider<T>, scope?: Scope): void;
|
|
16
38
|
/**
|
|
17
39
|
* Resolves a dependency from the container.
|
|
40
|
+
*
|
|
41
|
+
* Scoped providers use the explicit scope active during resolution
|
|
42
|
+
* (see {@link createScope}) or the `currentScope` callback.
|
|
18
43
|
*/
|
|
19
44
|
resolve<T>(token: Token<T>): T;
|
|
45
|
+
/**
|
|
46
|
+
* Creates an explicit resolution scope. Scoped providers resolved
|
|
47
|
+
* through the returned scope share one instance per scope.
|
|
48
|
+
*/
|
|
49
|
+
createScope(): ContainerScope;
|
|
20
50
|
/**
|
|
21
51
|
* Checks whether a token has been registered.
|
|
22
52
|
*/
|
|
@@ -32,12 +62,29 @@ export declare class Container {
|
|
|
32
62
|
*/
|
|
33
63
|
clear(): void;
|
|
34
64
|
/**
|
|
35
|
-
*
|
|
65
|
+
* Resolves a token within a specific scope key.
|
|
66
|
+
*
|
|
67
|
+
* @internal Used by ContainerScope.
|
|
36
68
|
*/
|
|
37
|
-
|
|
69
|
+
resolveIn<T>(token: Token<T>, scopeKey: object | undefined): T;
|
|
38
70
|
/**
|
|
39
|
-
*
|
|
71
|
+
* Creates an instance from a provider definition, tracking the
|
|
72
|
+
* resolution chain so cycles fail fast with a diagnostic instead of
|
|
73
|
+
* a stack overflow.
|
|
40
74
|
*/
|
|
41
|
-
private
|
|
75
|
+
private createInstance;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* An explicit resolution scope created by {@link Container.createScope}.
|
|
79
|
+
*
|
|
80
|
+
* Scoped providers resolved through this object are cached for its
|
|
81
|
+
* lifetime; singleton and transient providers behave as usual.
|
|
82
|
+
*/
|
|
83
|
+
export declare class ContainerScope {
|
|
84
|
+
private readonly container;
|
|
85
|
+
private readonly key;
|
|
86
|
+
constructor(container: Container, key: object);
|
|
87
|
+
resolve<T>(token: Token<T>): T;
|
|
88
|
+
has<T>(token: Token<T>): boolean;
|
|
42
89
|
}
|
|
43
90
|
//# sourceMappingURL=container.d.ts.map
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import { ProviderNotFoundError, ProviderAlreadyRegisteredError, } from "../errors/exceptions.js";
|
|
1
|
+
import { ProviderNotFoundError, ProviderAlreadyRegisteredError, InvalidProviderError, DependencyResolutionError, } from "../errors/exceptions.js";
|
|
2
2
|
/**
|
|
3
3
|
* Dependency Injection container for Zudojs applications.
|
|
4
4
|
*
|
|
5
5
|
* The container is responsible for registering and resolving
|
|
6
|
-
* application dependencies
|
|
6
|
+
* application dependencies with singleton, scoped, and transient
|
|
7
|
+
* lifetimes.
|
|
7
8
|
*/
|
|
8
9
|
export class Container {
|
|
9
10
|
providers = new Map();
|
|
11
|
+
scopedInstances = new WeakMap();
|
|
12
|
+
currentScope;
|
|
13
|
+
resolving = [];
|
|
14
|
+
activeScope;
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
this.currentScope = options.currentScope;
|
|
17
|
+
}
|
|
10
18
|
/**
|
|
11
19
|
* Registers a provider in the container.
|
|
12
20
|
*/
|
|
@@ -14,28 +22,30 @@ export class Container {
|
|
|
14
22
|
if (this.providers.has(token)) {
|
|
15
23
|
throw new ProviderAlreadyRegisteredError(token);
|
|
16
24
|
}
|
|
25
|
+
if (!isProvider(provider)) {
|
|
26
|
+
throw new InvalidProviderError(token);
|
|
27
|
+
}
|
|
17
28
|
this.providers.set(token, {
|
|
18
29
|
provider: provider,
|
|
19
30
|
scope,
|
|
31
|
+
resolved: false,
|
|
20
32
|
});
|
|
21
33
|
}
|
|
22
34
|
/**
|
|
23
35
|
* Resolves a dependency from the container.
|
|
36
|
+
*
|
|
37
|
+
* Scoped providers use the explicit scope active during resolution
|
|
38
|
+
* (see {@link createScope}) or the `currentScope` callback.
|
|
24
39
|
*/
|
|
25
40
|
resolve(token) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
const instance = this.createInstance(registration.provider);
|
|
35
|
-
if (registration.scope === "singleton") {
|
|
36
|
-
registration.instance = instance;
|
|
37
|
-
}
|
|
38
|
-
return instance;
|
|
41
|
+
return this.resolveIn(token, this.activeScope ?? this.currentScope?.());
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates an explicit resolution scope. Scoped providers resolved
|
|
45
|
+
* through the returned scope share one instance per scope.
|
|
46
|
+
*/
|
|
47
|
+
createScope() {
|
|
48
|
+
return new ContainerScope(this, {});
|
|
39
49
|
}
|
|
40
50
|
/**
|
|
41
51
|
* Checks whether a token has been registered.
|
|
@@ -58,34 +68,101 @@ export class Container {
|
|
|
58
68
|
this.providers.clear();
|
|
59
69
|
}
|
|
60
70
|
/**
|
|
61
|
-
*
|
|
71
|
+
* Resolves a token within a specific scope key.
|
|
72
|
+
*
|
|
73
|
+
* @internal Used by ContainerScope.
|
|
62
74
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
75
|
+
resolveIn(token, scopeKey) {
|
|
76
|
+
const registration = this.providers.get(token);
|
|
77
|
+
if (!registration) {
|
|
78
|
+
throw new ProviderNotFoundError(token);
|
|
66
79
|
}
|
|
67
|
-
if ("
|
|
68
|
-
return
|
|
80
|
+
if (registration.scope === "singleton" && registration.resolved) {
|
|
81
|
+
return registration.instance;
|
|
69
82
|
}
|
|
70
|
-
if ("
|
|
71
|
-
|
|
83
|
+
if (registration.scope === "scoped" && scopeKey) {
|
|
84
|
+
const cache = this.scopedInstances.get(scopeKey);
|
|
85
|
+
if (cache?.has(token)) {
|
|
86
|
+
return cache.get(token);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const instance = this.createInstance(token, registration, scopeKey);
|
|
90
|
+
if (registration.scope === "singleton") {
|
|
91
|
+
registration.instance = instance;
|
|
92
|
+
registration.resolved = true;
|
|
93
|
+
}
|
|
94
|
+
else if (registration.scope === "scoped" && scopeKey) {
|
|
95
|
+
let cache = this.scopedInstances.get(scopeKey);
|
|
96
|
+
if (!cache) {
|
|
97
|
+
cache = new Map();
|
|
98
|
+
this.scopedInstances.set(scopeKey, cache);
|
|
99
|
+
}
|
|
100
|
+
cache.set(token, instance);
|
|
72
101
|
}
|
|
73
|
-
|
|
102
|
+
return instance;
|
|
74
103
|
}
|
|
75
104
|
/**
|
|
76
|
-
*
|
|
105
|
+
* Creates an instance from a provider definition, tracking the
|
|
106
|
+
* resolution chain so cycles fail fast with a diagnostic instead of
|
|
107
|
+
* a stack overflow.
|
|
77
108
|
*/
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
|
|
109
|
+
createInstance(token, registration, scopeKey) {
|
|
110
|
+
if (this.resolving.includes(token)) {
|
|
111
|
+
throw new DependencyResolutionError("Circular dependency detected while resolving.", [...this.resolving, token]);
|
|
112
|
+
}
|
|
113
|
+
const provider = registration.provider;
|
|
114
|
+
if ("useValue" in provider) {
|
|
115
|
+
return provider.useValue;
|
|
116
|
+
}
|
|
117
|
+
const previousScope = this.activeScope;
|
|
118
|
+
this.resolving.push(token);
|
|
119
|
+
this.activeScope = scopeKey;
|
|
120
|
+
try {
|
|
121
|
+
if ("useFactory" in provider) {
|
|
122
|
+
return provider.useFactory(this);
|
|
123
|
+
}
|
|
124
|
+
return new provider.useClass();
|
|
81
125
|
}
|
|
82
|
-
|
|
83
|
-
|
|
126
|
+
catch (error) {
|
|
127
|
+
if (error instanceof DependencyResolutionError)
|
|
128
|
+
throw error;
|
|
129
|
+
throw new DependencyResolutionError(`Failed to resolve dependency.`, [...this.resolving], error);
|
|
84
130
|
}
|
|
85
|
-
|
|
86
|
-
|
|
131
|
+
finally {
|
|
132
|
+
this.resolving.pop();
|
|
133
|
+
this.activeScope = previousScope;
|
|
87
134
|
}
|
|
88
|
-
return "unknown";
|
|
89
135
|
}
|
|
90
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* An explicit resolution scope created by {@link Container.createScope}.
|
|
139
|
+
*
|
|
140
|
+
* Scoped providers resolved through this object are cached for its
|
|
141
|
+
* lifetime; singleton and transient providers behave as usual.
|
|
142
|
+
*/
|
|
143
|
+
export class ContainerScope {
|
|
144
|
+
container;
|
|
145
|
+
key;
|
|
146
|
+
constructor(container, key) {
|
|
147
|
+
this.container = container;
|
|
148
|
+
this.key = key;
|
|
149
|
+
}
|
|
150
|
+
resolve(token) {
|
|
151
|
+
return this.container.resolveIn(token, this.key);
|
|
152
|
+
}
|
|
153
|
+
has(token) {
|
|
154
|
+
return this.container.has(token);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function isProvider(value) {
|
|
158
|
+
if (typeof value !== "object" || value === null)
|
|
159
|
+
return false;
|
|
160
|
+
if ("useValue" in value)
|
|
161
|
+
return true;
|
|
162
|
+
if ("useFactory" in value)
|
|
163
|
+
return typeof value.useFactory === "function";
|
|
164
|
+
if ("useClass" in value)
|
|
165
|
+
return typeof value.useClass === "function";
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
91
168
|
//# sourceMappingURL=container.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Dependency Injection Container.
|
|
3
3
|
*/
|
|
4
|
-
export { Container } from "./container.js";
|
|
4
|
+
export { Container, ContainerScope, type ContainerOptions, } from "./container.js";
|
|
5
5
|
export { createToken, type Token, type ConstructorToken } from "./token.js";
|
|
6
6
|
export { type Provider, type ClassProvider, type FactoryProvider, type ValueProvider, type Constructor, } from "./provider.js";
|
|
7
7
|
export { type Scope } from "./scope.js";
|
package/dist/container/index.js
CHANGED
|
@@ -8,13 +8,14 @@ export type Scope =
|
|
|
8
8
|
*/
|
|
9
9
|
"singleton"
|
|
10
10
|
/**
|
|
11
|
-
* One instance
|
|
11
|
+
* One instance per resolution scope.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* A scope is either an explicit `container.createScope()` or the
|
|
14
|
+
* object returned by the container's `currentScope` callback (for
|
|
15
|
+
* example the current ExecutionContext of an HTTP request,
|
|
16
|
+
* background job, message consumption, or RPC call).
|
|
17
|
+
*
|
|
18
|
+
* When no scope is active, scoped providers behave as transient.
|
|
18
19
|
*/
|
|
19
20
|
| "scoped"
|
|
20
21
|
/**
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CreateExecutionContextInput, ExecutionContext } from "./executionContext.context.js";
|
|
2
|
+
import { createExecutionContext } from "./executionContext.context.js";
|
|
3
|
+
/**
|
|
4
|
+
* Deprecated names kept for source compatibility.
|
|
5
|
+
*
|
|
6
|
+
* The framework has a single execution-context model: the
|
|
7
|
+
* immutable ExecutionContext propagated by ContextStorage. The
|
|
8
|
+
* former mutable `Context` class no longer exists; every alias
|
|
9
|
+
* below resolves to the canonical type or function so there is no
|
|
10
|
+
* second implementation to keep in sync.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Known execution transports.
|
|
14
|
+
*
|
|
15
|
+
* @deprecated Use ExecutionContext.transport (a free-form string);
|
|
16
|
+
* this union is kept only as documentation of the conventional
|
|
17
|
+
* values.
|
|
18
|
+
*/
|
|
19
|
+
export type ContextType = "http" | "rpc" | "message" | "job" | "cli" | "worker" | "unknown";
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use ExecutionContext.
|
|
22
|
+
*/
|
|
23
|
+
export type Context = ExecutionContext;
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated Use CreateExecutionContextInput.
|
|
26
|
+
*/
|
|
27
|
+
export type CreateContextOptions = CreateExecutionContextInput;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use createExecutionContext.
|
|
30
|
+
*/
|
|
31
|
+
export declare const createContext: typeof createExecutionContext;
|
|
32
|
+
//# sourceMappingURL=contextAliases.deprecated.d.ts.map
|
|
@@ -128,4 +128,12 @@ export declare function withExecutionMetadata(context: ExecutionContext, metadat
|
|
|
128
128
|
* Returns the duration of an execution in milliseconds.
|
|
129
129
|
*/
|
|
130
130
|
export declare function getExecutionDuration(context: ExecutionContext, endTime?: Date): number;
|
|
131
|
+
/**
|
|
132
|
+
* Creates a framework execution identifier.
|
|
133
|
+
*
|
|
134
|
+
* This is the single shared implementation used by the context
|
|
135
|
+
* subsystem. Node.js >= 24 always provides crypto.randomUUID,
|
|
136
|
+
* so no weaker fallback exists.
|
|
137
|
+
*/
|
|
138
|
+
export declare function createExecutionId(): string;
|
|
131
139
|
//# sourceMappingURL=executionContext.context.d.ts.map
|
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maximum depth to which execution metadata is frozen.
|
|
3
|
+
*
|
|
4
|
+
* Execution metadata is expected to be small JSON-ish data;
|
|
5
|
+
* the bound protects against pathological structures.
|
|
6
|
+
*/
|
|
7
|
+
const MAX_METADATA_FREEZE_DEPTH = 8;
|
|
8
|
+
/**
|
|
9
|
+
* Recursively freezes JSON-ish metadata up to a bounded depth.
|
|
10
|
+
*
|
|
11
|
+
* Already frozen nodes are skipped; non-plain objects (class
|
|
12
|
+
* instances) are frozen shallowly.
|
|
13
|
+
*/
|
|
14
|
+
function deepFreezeMetadata(value, depth = 0) {
|
|
15
|
+
if (value === null || typeof value !== "object")
|
|
16
|
+
return value;
|
|
17
|
+
if (Object.isFrozen(value))
|
|
18
|
+
return value;
|
|
19
|
+
if (depth >= MAX_METADATA_FREEZE_DEPTH)
|
|
20
|
+
return Object.freeze(value);
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
for (const item of value)
|
|
23
|
+
deepFreezeMetadata(item, depth + 1);
|
|
24
|
+
return Object.freeze(value);
|
|
25
|
+
}
|
|
26
|
+
const prototype = Object.getPrototypeOf(value);
|
|
27
|
+
if (prototype === Object.prototype || prototype === null) {
|
|
28
|
+
for (const child of Object.values(value))
|
|
29
|
+
deepFreezeMetadata(child, depth + 1);
|
|
30
|
+
}
|
|
31
|
+
return Object.freeze(value);
|
|
32
|
+
}
|
|
1
33
|
/**
|
|
2
34
|
* Creates a new execution context.
|
|
3
35
|
*/
|
|
@@ -14,7 +46,7 @@ export function createExecutionContext(input = {}) {
|
|
|
14
46
|
operation: input.operation,
|
|
15
47
|
transport: input.transport,
|
|
16
48
|
startedAt: input.startedAt ?? new Date(),
|
|
17
|
-
metadata:
|
|
49
|
+
metadata: deepFreezeMetadata({
|
|
18
50
|
...(input.metadata ?? {}),
|
|
19
51
|
}),
|
|
20
52
|
});
|
|
@@ -62,20 +94,11 @@ export function getExecutionDuration(context, endTime = new Date()) {
|
|
|
62
94
|
/**
|
|
63
95
|
* Creates a framework execution identifier.
|
|
64
96
|
*
|
|
65
|
-
*
|
|
97
|
+
* This is the single shared implementation used by the context
|
|
98
|
+
* subsystem. Node.js >= 24 always provides crypto.randomUUID,
|
|
99
|
+
* so no weaker fallback exists.
|
|
66
100
|
*/
|
|
67
|
-
function createExecutionId() {
|
|
68
|
-
|
|
69
|
-
typeof globalThis.crypto.randomUUID === "function") {
|
|
70
|
-
return globalThis.crypto.randomUUID();
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Fallback for environments where Web Crypto is unavailable.
|
|
74
|
-
*/
|
|
75
|
-
return [
|
|
76
|
-
Date.now().toString(36),
|
|
77
|
-
Math.random().toString(36).slice(2),
|
|
78
|
-
Math.random().toString(36).slice(2),
|
|
79
|
-
].join("-");
|
|
101
|
+
export function createExecutionId() {
|
|
102
|
+
return globalThis.crypto.randomUUID();
|
|
80
103
|
}
|
|
81
104
|
//# sourceMappingURL=executionContext.context.js.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Core context types and key management.
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
7
|
-
export { createExecutionContext, deriveExecutionContext, withExecutionMetadata, getExecutionDuration, type ExecutionContext, type CreateExecutionContextInput, } from "./executionContext.context.js";
|
|
6
|
+
export { createExecutionContext, deriveExecutionContext, withExecutionMetadata, getExecutionDuration, createExecutionId, type ExecutionContext, type CreateExecutionContextInput, } from "./executionContext.context.js";
|
|
8
7
|
export { createContextKey, setContextValue, getContextValue, requireContextValue, hasContextValue, deleteContextValue, type ContextKey, type ContextValueStore, } from "./contextKey.key.js";
|
|
8
|
+
export { createContext, type Context, type ContextType, type CreateContextOptions, } from "./contextAliases.deprecated.js";
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Core context types and key management.
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
7
|
-
export { createExecutionContext, deriveExecutionContext, withExecutionMetadata, getExecutionDuration, } from "./executionContext.context.js";
|
|
6
|
+
export { createExecutionContext, deriveExecutionContext, withExecutionMetadata, getExecutionDuration, createExecutionId, } from "./executionContext.context.js";
|
|
8
7
|
export { createContextKey, setContextValue, getContextValue, requireContextValue, hasContextValue, deleteContextValue, } from "./contextKey.key.js";
|
|
8
|
+
export { createContext, } from "./contextAliases.deprecated.js";
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Execution context.
|
|
3
|
+
*
|
|
4
|
+
* The framework has one execution-context model:
|
|
5
|
+
*
|
|
6
|
+
* - ExecutionContext (core/) is an immutable description of one
|
|
7
|
+
* execution (ids, tracing, principal, metadata). New contexts are
|
|
8
|
+
* created with createExecutionContext and refined with
|
|
9
|
+
* deriveExecutionContext / withExecutionMetadata.
|
|
10
|
+
* - ContextStorage (provider/) propagates the current
|
|
11
|
+
* ExecutionContext across async boundaries via AsyncLocalStorage.
|
|
12
|
+
* getDefaultContextStorage() is the shared instance the runtime,
|
|
13
|
+
* module lifecycle, application, container, and logger use unless
|
|
14
|
+
* another storage is injected.
|
|
15
|
+
* - ContextValues (values/) carries strongly typed per-execution
|
|
16
|
+
* values; ContextStorage.runWithValues / getValues / capture /
|
|
17
|
+
* runSnapshot connect them to the storage, and ContextSnapshot
|
|
18
|
+
* (snapshot/) carries both across scheduling boundaries.
|
|
19
|
+
*
|
|
20
|
+
* The runtime runs its bootstrap and shutdown pipelines, every
|
|
21
|
+
* module lifecycle hook, and application start/stop inside the
|
|
22
|
+
* runtime's own ExecutionContext (see RuntimeExecutionContext).
|
|
3
23
|
*/
|
|
4
24
|
export * from "./core/index.js";
|
|
5
25
|
export * from "./provider/index.js";
|