@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,18 +1,100 @@
|
|
|
1
|
-
|
|
1
|
+
import { normalizeConfigurationPath, requireConfigurationPath, } from "./configurationPath.path.js";
|
|
2
|
+
import { ConfigurationMissingError, ConfigurationPathError, ConfigurationTypeError, } from "../error/configurationError.error.js";
|
|
3
|
+
const FORBIDDEN_PATH_SEGMENTS = new Set([
|
|
4
|
+
"__proto__",
|
|
5
|
+
"constructor",
|
|
6
|
+
"prototype",
|
|
7
|
+
]);
|
|
8
|
+
/**
|
|
9
|
+
* Recursively freezes a configuration value tree.
|
|
10
|
+
*
|
|
11
|
+
* Nodes that are already frozen are assumed to be deep-frozen
|
|
12
|
+
* (which holds for all trees produced by this module) and are
|
|
13
|
+
* skipped.
|
|
14
|
+
*/
|
|
15
|
+
function deepFreezeConfigurationValue(value) {
|
|
16
|
+
if (value === null || typeof value !== "object")
|
|
17
|
+
return value;
|
|
18
|
+
if (Object.isFrozen(value))
|
|
19
|
+
return value;
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
for (const item of value)
|
|
22
|
+
deepFreezeConfigurationValue(item);
|
|
23
|
+
return Object.freeze(value);
|
|
24
|
+
}
|
|
25
|
+
for (const child of Object.values(value)) {
|
|
26
|
+
deepFreezeConfigurationValue(child);
|
|
27
|
+
}
|
|
28
|
+
return Object.freeze(value);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Deep-copies a configuration value tree.
|
|
32
|
+
*
|
|
33
|
+
* Plain objects and arrays are cloned recursively; primitives are
|
|
34
|
+
* returned as-is. Used so accessors that hand out whole subtrees
|
|
35
|
+
* never expose internal references.
|
|
36
|
+
*/
|
|
37
|
+
function cloneConfigurationValue(value) {
|
|
38
|
+
if (value === null || typeof value !== "object")
|
|
39
|
+
return value;
|
|
40
|
+
if (Array.isArray(value)) {
|
|
41
|
+
return value.map((item) => cloneConfigurationValue(item));
|
|
42
|
+
}
|
|
43
|
+
const result = {};
|
|
44
|
+
for (const [key, child] of Object.entries(value)) {
|
|
45
|
+
result[key] = cloneConfigurationValue(child);
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
const STRICT_DECIMAL_PATTERN = /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/;
|
|
50
|
+
/**
|
|
51
|
+
* Immutable configuration container.
|
|
52
|
+
*
|
|
53
|
+
* The values tree is deep-frozen at construction, so accessors can
|
|
54
|
+
* safely hand out internal references. Callers should treat any
|
|
55
|
+
* object passed into the constructor (or `with()`) as owned by the
|
|
56
|
+
* configuration afterwards: it becomes frozen.
|
|
57
|
+
*/
|
|
2
58
|
export class Configuration {
|
|
3
59
|
values;
|
|
4
60
|
source;
|
|
5
61
|
namespace;
|
|
62
|
+
pathSources;
|
|
6
63
|
constructor(options = {}) {
|
|
7
64
|
this.source = options.source ?? "runtime";
|
|
8
65
|
this.namespace = options.namespace;
|
|
9
|
-
this.values =
|
|
66
|
+
this.values = deepFreezeConfigurationValue((options.values ?? {}));
|
|
67
|
+
this.pathSources = new Map(options.sources ?? []);
|
|
10
68
|
}
|
|
11
69
|
getNamespace() {
|
|
12
70
|
return this.namespace;
|
|
13
71
|
}
|
|
14
|
-
|
|
15
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Returns the source of a configuration path, or of the whole
|
|
74
|
+
* configuration when no path is supplied.
|
|
75
|
+
*
|
|
76
|
+
* When entries originate from multiple source types, "mixed"
|
|
77
|
+
* is returned.
|
|
78
|
+
*/
|
|
79
|
+
getSource(path) {
|
|
80
|
+
if (path === undefined) {
|
|
81
|
+
const distinct = new Set(this.pathSources.values());
|
|
82
|
+
if (distinct.size === 0)
|
|
83
|
+
return this.source;
|
|
84
|
+
for (const key of Object.keys(this.values)) {
|
|
85
|
+
if (!this.hasSourceRecordFor(key)) {
|
|
86
|
+
distinct.add(this.source);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (distinct.size === 1)
|
|
91
|
+
return [...distinct][0];
|
|
92
|
+
return "mixed";
|
|
93
|
+
}
|
|
94
|
+
const normalizedPath = this.normalizePath(path);
|
|
95
|
+
if (!normalizedPath)
|
|
96
|
+
return this.source;
|
|
97
|
+
return this.resolvePathSource(normalizedPath);
|
|
16
98
|
}
|
|
17
99
|
get(path) {
|
|
18
100
|
const normalizedPath = this.normalizePath(path);
|
|
@@ -21,7 +103,9 @@ export class Configuration {
|
|
|
21
103
|
const parts = normalizedPath.split(".");
|
|
22
104
|
let current = this.values;
|
|
23
105
|
for (const part of parts) {
|
|
24
|
-
if (typeof current !== "object" ||
|
|
106
|
+
if (typeof current !== "object" ||
|
|
107
|
+
current === null ||
|
|
108
|
+
!Object.hasOwn(current, part))
|
|
25
109
|
return undefined;
|
|
26
110
|
current = current[part];
|
|
27
111
|
}
|
|
@@ -30,7 +114,7 @@ export class Configuration {
|
|
|
30
114
|
require(path) {
|
|
31
115
|
const value = this.get(path);
|
|
32
116
|
if (value === undefined)
|
|
33
|
-
throw new
|
|
117
|
+
throw new ConfigurationMissingError(path);
|
|
34
118
|
return value;
|
|
35
119
|
}
|
|
36
120
|
getByKey(key) {
|
|
@@ -39,7 +123,7 @@ export class Configuration {
|
|
|
39
123
|
requireByKey(key) {
|
|
40
124
|
const value = this.getByKey(key);
|
|
41
125
|
if (value === undefined)
|
|
42
|
-
throw new
|
|
126
|
+
throw new ConfigurationMissingError(key.path);
|
|
43
127
|
return value;
|
|
44
128
|
}
|
|
45
129
|
has(path) {
|
|
@@ -58,7 +142,7 @@ export class Configuration {
|
|
|
58
142
|
if (normalized === "false" || normalized === "0" || normalized === "no")
|
|
59
143
|
return false;
|
|
60
144
|
}
|
|
61
|
-
throw new
|
|
145
|
+
throw new ConfigurationTypeError(path, "boolean", value);
|
|
62
146
|
}
|
|
63
147
|
getNumber(path, defaultValue) {
|
|
64
148
|
const value = this.get(path);
|
|
@@ -67,14 +151,26 @@ export class Configuration {
|
|
|
67
151
|
if (typeof value === "number") {
|
|
68
152
|
if (Number.isFinite(value))
|
|
69
153
|
return value;
|
|
70
|
-
throw new
|
|
154
|
+
throw new ConfigurationTypeError(path, "number", value);
|
|
71
155
|
}
|
|
72
156
|
if (typeof value === "string") {
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
|
|
157
|
+
const trimmed = value.trim();
|
|
158
|
+
if (trimmed === "") {
|
|
159
|
+
/*
|
|
160
|
+
* Empty and whitespace-only strings are treated as
|
|
161
|
+
* "value not provided" rather than silently coerced to 0.
|
|
162
|
+
*/
|
|
163
|
+
if (defaultValue !== undefined)
|
|
164
|
+
return defaultValue;
|
|
165
|
+
throw new ConfigurationTypeError(path, "number", value);
|
|
166
|
+
}
|
|
167
|
+
if (STRICT_DECIMAL_PATTERN.test(trimmed)) {
|
|
168
|
+
const parsed = Number(trimmed);
|
|
169
|
+
if (Number.isFinite(parsed))
|
|
170
|
+
return parsed;
|
|
171
|
+
}
|
|
76
172
|
}
|
|
77
|
-
throw new
|
|
173
|
+
throw new ConfigurationTypeError(path, "number", value);
|
|
78
174
|
}
|
|
79
175
|
getString(path, defaultValue) {
|
|
80
176
|
const value = this.get(path);
|
|
@@ -84,18 +180,21 @@ export class Configuration {
|
|
|
84
180
|
return value;
|
|
85
181
|
if (typeof value === "number" || typeof value === "boolean")
|
|
86
182
|
return String(value);
|
|
87
|
-
throw new
|
|
88
|
-
}
|
|
89
|
-
createKey(path) {
|
|
90
|
-
const normalizedPath = this.normalizePath(path);
|
|
91
|
-
if (!normalizedPath)
|
|
92
|
-
throw new Error("Configuration key path cannot be empty.");
|
|
93
|
-
return Object.freeze({ path: normalizedPath, id: Symbol(normalizedPath) });
|
|
183
|
+
throw new ConfigurationTypeError(path, "string", value);
|
|
94
184
|
}
|
|
95
185
|
scope(namespace) {
|
|
96
|
-
const normalizedNamespace =
|
|
97
|
-
|
|
98
|
-
|
|
186
|
+
const normalizedNamespace = requireConfigurationPath(namespace);
|
|
187
|
+
const exactSource = this.pathSources.get(normalizedNamespace);
|
|
188
|
+
const scopedSource = exactSource ??
|
|
189
|
+
this.resolveAncestorSource(normalizedNamespace) ??
|
|
190
|
+
this.source;
|
|
191
|
+
const scopedSources = new Map();
|
|
192
|
+
const prefix = `${normalizedNamespace}.`;
|
|
193
|
+
for (const [recordedPath, source] of this.pathSources) {
|
|
194
|
+
if (recordedPath.startsWith(prefix)) {
|
|
195
|
+
scopedSources.set(recordedPath.slice(prefix.length), source);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
99
198
|
const scopedValues = this.get(normalizedNamespace);
|
|
100
199
|
if (scopedValues === undefined ||
|
|
101
200
|
typeof scopedValues !== "object" ||
|
|
@@ -103,58 +202,159 @@ export class Configuration {
|
|
|
103
202
|
Array.isArray(scopedValues)) {
|
|
104
203
|
return new Configuration({
|
|
105
204
|
values: {},
|
|
106
|
-
source:
|
|
205
|
+
source: scopedSource,
|
|
107
206
|
namespace: normalizedNamespace,
|
|
108
207
|
});
|
|
109
208
|
}
|
|
110
209
|
return new Configuration({
|
|
111
210
|
values: scopedValues,
|
|
112
|
-
source:
|
|
211
|
+
source: scopedSource,
|
|
113
212
|
namespace: normalizedNamespace,
|
|
213
|
+
sources: scopedSources,
|
|
114
214
|
});
|
|
115
215
|
}
|
|
116
216
|
entries() {
|
|
117
217
|
return Object.entries(this.values).map(([path, value]) => ({
|
|
118
218
|
path,
|
|
119
219
|
value,
|
|
120
|
-
source: this.
|
|
220
|
+
source: this.resolvePathSource(path),
|
|
121
221
|
}));
|
|
122
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Returns a deep copy of the complete values tree.
|
|
225
|
+
*
|
|
226
|
+
* The copy is unfrozen and independent of the configuration, so
|
|
227
|
+
* callers may mutate it freely without affecting this instance
|
|
228
|
+
* or anything derived from it.
|
|
229
|
+
*/
|
|
123
230
|
toObject() {
|
|
124
|
-
return this.values;
|
|
231
|
+
return cloneConfigurationValue(this.values);
|
|
125
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Deeply merges another configuration on top of this one.
|
|
235
|
+
*
|
|
236
|
+
* Objects are merged recursively, arrays and primitives are
|
|
237
|
+
* replaced. Per-path source attribution from both configurations
|
|
238
|
+
* is preserved; the other configuration wins on conflicts.
|
|
239
|
+
*/
|
|
126
240
|
merge(other) {
|
|
241
|
+
const values = this.deepMergeValues(this.values, other.values);
|
|
242
|
+
const sources = new Map(this.pathSources);
|
|
243
|
+
for (const [path, source] of other.pathSources)
|
|
244
|
+
sources.set(path, source);
|
|
127
245
|
return new Configuration({
|
|
128
|
-
values
|
|
246
|
+
values,
|
|
129
247
|
source: other.source,
|
|
130
248
|
namespace: other.namespace ?? this.namespace,
|
|
249
|
+
sources,
|
|
131
250
|
});
|
|
132
251
|
}
|
|
133
252
|
with(path, value, source = "runtime") {
|
|
134
|
-
const normalizedPath =
|
|
135
|
-
if (!normalizedPath)
|
|
136
|
-
throw new Error("Configuration path cannot be empty.");
|
|
253
|
+
const normalizedPath = requireConfigurationPath(path);
|
|
137
254
|
const values = this.setNestedValue(this.values, normalizedPath, value);
|
|
138
|
-
|
|
255
|
+
const sources = new Map(this.pathSources);
|
|
256
|
+
const prefix = `${normalizedPath}.`;
|
|
257
|
+
for (const recordedPath of sources.keys()) {
|
|
258
|
+
if (recordedPath.startsWith(prefix))
|
|
259
|
+
sources.delete(recordedPath);
|
|
260
|
+
}
|
|
261
|
+
sources.set(normalizedPath, source);
|
|
262
|
+
return new Configuration({
|
|
263
|
+
values,
|
|
264
|
+
source: this.source,
|
|
265
|
+
namespace: this.namespace,
|
|
266
|
+
sources,
|
|
267
|
+
});
|
|
139
268
|
}
|
|
140
269
|
without(path) {
|
|
141
270
|
const normalizedPath = this.normalizePath(path);
|
|
142
271
|
if (!normalizedPath)
|
|
143
272
|
return this;
|
|
144
273
|
const values = this.deleteNestedValue(this.values, normalizedPath);
|
|
274
|
+
const sources = new Map(this.pathSources);
|
|
275
|
+
const prefix = `${normalizedPath}.`;
|
|
276
|
+
sources.delete(normalizedPath);
|
|
277
|
+
for (const recordedPath of [...sources.keys()]) {
|
|
278
|
+
if (recordedPath.startsWith(prefix))
|
|
279
|
+
sources.delete(recordedPath);
|
|
280
|
+
}
|
|
145
281
|
return new Configuration({
|
|
146
282
|
values,
|
|
147
283
|
source: this.source,
|
|
148
284
|
namespace: this.namespace,
|
|
285
|
+
sources,
|
|
149
286
|
});
|
|
150
287
|
}
|
|
151
288
|
normalizePath(path) {
|
|
152
|
-
return path
|
|
289
|
+
return normalizeConfigurationPath(path);
|
|
290
|
+
}
|
|
291
|
+
hasSourceRecordFor(topLevelKey) {
|
|
292
|
+
if (this.pathSources.has(topLevelKey))
|
|
293
|
+
return true;
|
|
294
|
+
const prefix = `${topLevelKey}.`;
|
|
295
|
+
for (const recordedPath of this.pathSources.keys()) {
|
|
296
|
+
if (recordedPath.startsWith(prefix))
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
resolveAncestorSource(path) {
|
|
302
|
+
const parts = path.split(".");
|
|
303
|
+
for (let index = parts.length - 1; index > 0; index--) {
|
|
304
|
+
const ancestor = parts.slice(0, index).join(".");
|
|
305
|
+
const source = this.pathSources.get(ancestor);
|
|
306
|
+
if (source !== undefined)
|
|
307
|
+
return source;
|
|
308
|
+
}
|
|
309
|
+
return undefined;
|
|
310
|
+
}
|
|
311
|
+
resolvePathSource(path) {
|
|
312
|
+
const exact = this.pathSources.get(path);
|
|
313
|
+
if (exact !== undefined)
|
|
314
|
+
return exact;
|
|
315
|
+
const ancestor = this.resolveAncestorSource(path);
|
|
316
|
+
if (ancestor !== undefined)
|
|
317
|
+
return ancestor;
|
|
318
|
+
const prefix = `${path}.`;
|
|
319
|
+
const descendantSources = new Set();
|
|
320
|
+
for (const [recordedPath, source] of this.pathSources) {
|
|
321
|
+
if (recordedPath.startsWith(prefix))
|
|
322
|
+
descendantSources.add(source);
|
|
323
|
+
}
|
|
324
|
+
if (descendantSources.size === 1)
|
|
325
|
+
return [...descendantSources][0];
|
|
326
|
+
if (descendantSources.size > 1)
|
|
327
|
+
return "mixed";
|
|
328
|
+
return this.source;
|
|
329
|
+
}
|
|
330
|
+
deepMergeValues(base, override) {
|
|
331
|
+
if (base === null ||
|
|
332
|
+
override === null ||
|
|
333
|
+
typeof base !== "object" ||
|
|
334
|
+
typeof override !== "object" ||
|
|
335
|
+
Array.isArray(base) ||
|
|
336
|
+
Array.isArray(override)) {
|
|
337
|
+
return override;
|
|
338
|
+
}
|
|
339
|
+
const result = {};
|
|
340
|
+
for (const [key, value] of Object.entries(base)) {
|
|
341
|
+
if (FORBIDDEN_PATH_SEGMENTS.has(key))
|
|
342
|
+
continue;
|
|
343
|
+
result[key] = value;
|
|
344
|
+
}
|
|
345
|
+
for (const [key, value] of Object.entries(override)) {
|
|
346
|
+
if (FORBIDDEN_PATH_SEGMENTS.has(key))
|
|
347
|
+
continue;
|
|
348
|
+
const existing = result[key];
|
|
349
|
+
result[key] =
|
|
350
|
+
existing !== undefined ? this.deepMergeValues(existing, value) : value;
|
|
351
|
+
}
|
|
352
|
+
return result;
|
|
153
353
|
}
|
|
154
354
|
setNestedValue(source, path, value) {
|
|
155
355
|
const parts = path.split(".");
|
|
156
|
-
if (parts.some((p) => p
|
|
157
|
-
throw new
|
|
356
|
+
if (parts.some((p) => FORBIDDEN_PATH_SEGMENTS.has(p))) {
|
|
357
|
+
throw new ConfigurationPathError(path, "path names a forbidden segment.");
|
|
158
358
|
}
|
|
159
359
|
const result = { ...source };
|
|
160
360
|
let current = result;
|
|
@@ -172,34 +372,31 @@ export class Configuration {
|
|
|
172
372
|
current[parts[parts.length - 1]] = value;
|
|
173
373
|
return result;
|
|
174
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* Removes a nested value by shallow-cloning only the objects
|
|
377
|
+
* along the path, mirroring the strategy used by setNestedValue.
|
|
378
|
+
*/
|
|
175
379
|
deleteNestedValue(source, path) {
|
|
176
380
|
const parts = path.split(".");
|
|
177
|
-
if (parts.some((p) => p
|
|
178
|
-
throw new
|
|
381
|
+
if (parts.some((p) => FORBIDDEN_PATH_SEGMENTS.has(p))) {
|
|
382
|
+
throw new ConfigurationPathError(path, "path names a forbidden segment.");
|
|
179
383
|
}
|
|
180
|
-
const result =
|
|
384
|
+
const result = { ...source };
|
|
181
385
|
let current = result;
|
|
182
386
|
for (let index = 0; index < parts.length - 1; index++) {
|
|
183
387
|
const part = parts[index];
|
|
184
|
-
if (part === "__proto__" ||
|
|
185
|
-
part === "constructor" ||
|
|
186
|
-
part === "prototype")
|
|
187
|
-
return result;
|
|
188
388
|
const next = current[part];
|
|
189
389
|
if (next === null || typeof next !== "object" || Array.isArray(next))
|
|
190
390
|
return result;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
lastPart === "prototype")
|
|
197
|
-
return result;
|
|
198
|
-
delete current[lastPart];
|
|
391
|
+
const clone = { ...next };
|
|
392
|
+
current[part] = clone;
|
|
393
|
+
current = clone;
|
|
394
|
+
}
|
|
395
|
+
delete current[parts[parts.length - 1]];
|
|
199
396
|
return result;
|
|
200
397
|
}
|
|
201
398
|
}
|
|
202
|
-
/** Creates
|
|
399
|
+
/** Creates a Configuration instance. */
|
|
203
400
|
export function createConfiguration(options = {}) {
|
|
204
401
|
return new Configuration(options);
|
|
205
402
|
}
|
|
@@ -27,8 +27,10 @@ export interface ConfigurationKey<T> {
|
|
|
27
27
|
/**
|
|
28
28
|
* Unique identifier for this configuration key.
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
30
|
+
* Note that configuration lookups are performed by `path`,
|
|
31
|
+
* not by this symbol. The symbol only helps distinguish key
|
|
32
|
+
* instances from each other in debugging and diagnostics;
|
|
33
|
+
* two keys with the same path resolve the same value.
|
|
32
34
|
*/
|
|
33
35
|
readonly id: symbol;
|
|
34
36
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { requireConfigurationPath } from "./configurationPath.path.js";
|
|
1
2
|
/**
|
|
2
3
|
* Creates a strongly typed configuration key.
|
|
3
4
|
*
|
|
@@ -6,22 +7,10 @@
|
|
|
6
7
|
* type the caller expects it to have.
|
|
7
8
|
*/
|
|
8
9
|
export function createConfigurationKey(path) {
|
|
9
|
-
const normalizedPath =
|
|
10
|
-
if (!normalizedPath) {
|
|
11
|
-
throw new Error("Configuration key path cannot be empty.");
|
|
12
|
-
}
|
|
10
|
+
const normalizedPath = requireConfigurationPath(path);
|
|
13
11
|
return Object.freeze({
|
|
14
12
|
path: normalizedPath,
|
|
15
13
|
id: Symbol(normalizedPath),
|
|
16
14
|
});
|
|
17
15
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Normalizes a configuration path.
|
|
20
|
-
*/
|
|
21
|
-
function normalizeConfigurationPath(path) {
|
|
22
|
-
if (typeof path !== "string") {
|
|
23
|
-
throw new TypeError("Configuration key path must be a string.");
|
|
24
|
-
}
|
|
25
|
-
return path.trim().replace(/\s+/g, "");
|
|
26
|
-
}
|
|
27
16
|
//# sourceMappingURL=configurationKey.key.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared configuration path normalization.
|
|
3
|
+
*
|
|
4
|
+
* This is the single canonical implementation used by the
|
|
5
|
+
* configuration container, keys, schemas, and registry.
|
|
6
|
+
*
|
|
7
|
+
* Paths are trimmed. Paths that still contain whitespace after
|
|
8
|
+
* trimming are rejected instead of silently rewritten, because
|
|
9
|
+
* silently stripping whitespace can turn a typo into a lookup
|
|
10
|
+
* for a completely different configuration value.
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeConfigurationPath(path: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Normalizes a configuration path and rejects empty results.
|
|
15
|
+
*/
|
|
16
|
+
export declare function requireConfigurationPath(path: string): string;
|
|
17
|
+
//# sourceMappingURL=configurationPath.path.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ConfigurationPathError } from "../error/configurationError.error.js";
|
|
2
|
+
/**
|
|
3
|
+
* Shared configuration path normalization.
|
|
4
|
+
*
|
|
5
|
+
* This is the single canonical implementation used by the
|
|
6
|
+
* configuration container, keys, schemas, and registry.
|
|
7
|
+
*
|
|
8
|
+
* Paths are trimmed. Paths that still contain whitespace after
|
|
9
|
+
* trimming are rejected instead of silently rewritten, because
|
|
10
|
+
* silently stripping whitespace can turn a typo into a lookup
|
|
11
|
+
* for a completely different configuration value.
|
|
12
|
+
*/
|
|
13
|
+
export function normalizeConfigurationPath(path) {
|
|
14
|
+
if (typeof path !== "string") {
|
|
15
|
+
throw new ConfigurationPathError(String(path), "path must be a string.");
|
|
16
|
+
}
|
|
17
|
+
const normalized = path.trim();
|
|
18
|
+
if (/\s/.test(normalized)) {
|
|
19
|
+
throw new ConfigurationPathError(path, "path must not contain whitespace.");
|
|
20
|
+
}
|
|
21
|
+
return normalized;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Normalizes a configuration path and rejects empty results.
|
|
25
|
+
*/
|
|
26
|
+
export function requireConfigurationPath(path) {
|
|
27
|
+
const normalized = normalizeConfigurationPath(path);
|
|
28
|
+
if (!normalized) {
|
|
29
|
+
throw new ConfigurationPathError(path, "path cannot be empty.");
|
|
30
|
+
}
|
|
31
|
+
return normalized;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=configurationPath.path.js.map
|
|
@@ -4,9 +4,15 @@
|
|
|
4
4
|
* Core configuration types, keys, and source abstractions.
|
|
5
5
|
*/
|
|
6
6
|
export { Configuration, createConfiguration } from "./configuration.js";
|
|
7
|
-
export type { ConfigurationOptions, ConfigurationValue,
|
|
7
|
+
export type { ConfigurationOptions, ConfigurationValue, ConfigurationEntry, ConfigurationEntrySource, } from "./configuration.js";
|
|
8
|
+
/**
|
|
9
|
+
* Compatibility alias. The string-union source type now lives in
|
|
10
|
+
* configurationSource.source.ts as ConfigurationSourceType.
|
|
11
|
+
*/
|
|
12
|
+
export type { ConfigurationSourceType as ConfigurationValueSource } from "./configurationSource.source.js";
|
|
8
13
|
export { createConfigurationKey } from "./configurationKey.key.js";
|
|
9
14
|
export type { ConfigurationKey } from "./configurationKey.key.js";
|
|
15
|
+
export { normalizeConfigurationPath, requireConfigurationPath, } from "./configurationPath.path.js";
|
|
10
16
|
export { BaseConfigurationSource, createConfigurationSource, sortConfigurationSources, } from "./configurationSource.source.js";
|
|
11
17
|
export type { ConfigurationSource, ConfigurationSourceType, ConfigurationSourceEntry, ConfigurationSourceOptions, } from "./configurationSource.source.js";
|
|
12
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { Configuration, createConfiguration } from "./configuration.js";
|
|
7
7
|
export { createConfigurationKey } from "./configurationKey.key.js";
|
|
8
|
+
export { normalizeConfigurationPath, requireConfigurationPath, } from "./configurationPath.path.js";
|
|
8
9
|
export { BaseConfigurationSource, createConfigurationSource, sortConfigurationSources, } from "./configurationSource.source.js";
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { FrameworkError } from "../../errors/frameworkError.error.js";
|
|
2
2
|
import { ErrorCode } from "../../errors/errorCode.code.js";
|
|
3
|
+
/**
|
|
4
|
+
* Produces a redacted message from an unknown cause.
|
|
5
|
+
*/
|
|
6
|
+
export declare function describeConfigurationCause(cause: unknown): string;
|
|
3
7
|
/**
|
|
4
8
|
* Base error for all configuration related failures.
|
|
5
9
|
*
|
|
@@ -41,6 +45,13 @@ export declare class ConfigurationSourceError extends ConfigurationError {
|
|
|
41
45
|
export declare class ConfigurationMissingError extends ConfigurationError {
|
|
42
46
|
constructor(path: string);
|
|
43
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Thrown when a configuration path is malformed: empty, containing
|
|
50
|
+
* whitespace, or naming a forbidden segment such as "__proto__".
|
|
51
|
+
*/
|
|
52
|
+
export declare class ConfigurationPathError extends ConfigurationError {
|
|
53
|
+
constructor(path: string, reason: string);
|
|
54
|
+
}
|
|
44
55
|
/**
|
|
45
56
|
* Thrown when a configuration value has an invalid type
|
|
46
57
|
* or otherwise cannot be interpreted correctly.
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { FrameworkError } from "../../errors/frameworkError.error.js";
|
|
2
2
|
import { ErrorCode } from "../../errors/errorCode.code.js";
|
|
3
|
+
import { ConfigurationRedactor } from "./configurationRedactor.redactor.js";
|
|
4
|
+
/**
|
|
5
|
+
* Default redactor used to scrub raw cause text before it is
|
|
6
|
+
* embedded in configuration error messages.
|
|
7
|
+
*/
|
|
8
|
+
const defaultErrorRedactor = new ConfigurationRedactor();
|
|
9
|
+
/**
|
|
10
|
+
* Produces a redacted message from an unknown cause.
|
|
11
|
+
*/
|
|
12
|
+
export function describeConfigurationCause(cause) {
|
|
13
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
14
|
+
return defaultErrorRedactor.redactText(message);
|
|
15
|
+
}
|
|
3
16
|
/**
|
|
4
17
|
* Base error for all configuration related failures.
|
|
5
18
|
*
|
|
@@ -45,7 +58,7 @@ export class ConfigurationSourceError extends ConfigurationError {
|
|
|
45
58
|
*/
|
|
46
59
|
sourceType;
|
|
47
60
|
constructor(sourceName, sourceType, cause) {
|
|
48
|
-
const causeMessage =
|
|
61
|
+
const causeMessage = describeConfigurationCause(cause);
|
|
49
62
|
super(ErrorCode.CONFIGURATION_LOAD_FAILED, `Failed to load configuration source "${sourceName}": ${causeMessage}`, {
|
|
50
63
|
cause,
|
|
51
64
|
details: {
|
|
@@ -69,6 +82,21 @@ export class ConfigurationMissingError extends ConfigurationError {
|
|
|
69
82
|
this.name = "ConfigurationMissingError";
|
|
70
83
|
}
|
|
71
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Thrown when a configuration path is malformed: empty, containing
|
|
87
|
+
* whitespace, or naming a forbidden segment such as "__proto__".
|
|
88
|
+
*/
|
|
89
|
+
export class ConfigurationPathError extends ConfigurationError {
|
|
90
|
+
constructor(path, reason) {
|
|
91
|
+
super(ErrorCode.CONFIGURATION_INVALID, `Invalid configuration path "${path}": ${reason}`, {
|
|
92
|
+
path,
|
|
93
|
+
details: {
|
|
94
|
+
reason,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
this.name = "ConfigurationPathError";
|
|
98
|
+
}
|
|
99
|
+
}
|
|
72
100
|
/**
|
|
73
101
|
* Thrown when a configuration value has an invalid type
|
|
74
102
|
* or otherwise cannot be interpreted correctly.
|
|
@@ -97,8 +97,24 @@ export declare class ConfigurationRedactor {
|
|
|
97
97
|
/**
|
|
98
98
|
* Checks whether a path segment matches one of the
|
|
99
99
|
* configured sensitive patterns.
|
|
100
|
+
*
|
|
101
|
+
* Matching is word-boundary aware: the segment is split into
|
|
102
|
+
* words on separators and camelCase transitions, and a pattern
|
|
103
|
+
* matches only when a consecutive run of words spells it out.
|
|
104
|
+
* This means "apiToken" and "access_token" match "token", but
|
|
105
|
+
* "tokenizer" and "secretary" do not match "token"/"secret".
|
|
100
106
|
*/
|
|
101
107
|
private matchesSensitivePattern;
|
|
108
|
+
/**
|
|
109
|
+
* Redacts sensitive-looking fragments from free-form text such
|
|
110
|
+
* as error messages.
|
|
111
|
+
*
|
|
112
|
+
* Occurrences of "<sensitive>=value", "<sensitive>: value", and
|
|
113
|
+
* "<sensitive> value" have their value replaced. This is a
|
|
114
|
+
* best-effort scrub for diagnostics; it does not guarantee that
|
|
115
|
+
* arbitrary text contains no secrets.
|
|
116
|
+
*/
|
|
117
|
+
redactText(text: string): string;
|
|
102
118
|
}
|
|
103
119
|
/**
|
|
104
120
|
* Creates a ConfigurationRedactor.
|