@zudojs/core 0.1.0 → 1.1.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 +27 -1
- package/dist/application/applicationContext.context.js +22 -2
- package/dist/application/createApplication.d.ts +78 -0
- package/dist/application/createApplication.js +109 -0
- package/dist/application/index.d.ts +2 -1
- package/dist/application/index.js +2 -1
- package/dist/configuration/configurationManager.manager.d.ts +42 -0
- package/dist/configuration/configurationManager.manager.js +104 -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 +51 -5
- package/dist/container/container.js +104 -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 +125 -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 +73 -10
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.js +204 -19
- 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 +78 -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 +168 -59
- 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 +111 -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 +13 -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 +85 -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 +25 -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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Application } from "./application.js";
|
|
2
|
+
import { ApplicationContext } from "./applicationContext.context.js";
|
|
3
|
+
import { Container } from "../container/container.js";
|
|
4
|
+
import { ConfigurationManager, ConfigurationManagerState, createConfigurationManager, } from "../configuration/configurationManager.manager.js";
|
|
5
|
+
import { ConsoleLogger } from "../logging/console/consoleLogger.logger.js";
|
|
6
|
+
import { Lifecycle } from "../lifecycle/core/lifecycle.js";
|
|
7
|
+
import { createModuleRegistry } from "../modules/moduleRegistry/moduleRegistry.registry.js";
|
|
8
|
+
import { createModuleLoader } from "../modules/moduleLoader/moduleLoader.loader.js";
|
|
9
|
+
import { createModuleLifecycleManager } from "../modules/moduleLifecycle/moduleLifecycle.lifecycle.js";
|
|
10
|
+
import { createRuntime } from "../runtime/runtime.js";
|
|
11
|
+
import { resolveRuntimeOptions } from "../runtime/runtimeOptions/runtimeOptions.resolver.js";
|
|
12
|
+
import { getDefaultContextStorage } from "../context/provider/defaultContextStorage.storage.js";
|
|
13
|
+
function isLogger(value) {
|
|
14
|
+
return (typeof value === "object" &&
|
|
15
|
+
value !== null &&
|
|
16
|
+
typeof value.info === "function" &&
|
|
17
|
+
typeof value.error === "function");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Wires the standard application graph — container, configuration,
|
|
21
|
+
* logger, module registry/loader/lifecycle, runtime, and application
|
|
22
|
+
* lifecycle — and returns an initialized Application. One
|
|
23
|
+
* ContextStorage is threaded through every piece, so the runtime's
|
|
24
|
+
* execution context is visible from module hooks, container
|
|
25
|
+
* factories, lifecycle participants, and log entries.
|
|
26
|
+
*
|
|
27
|
+
* The runtime is created through a factory, so the application can be
|
|
28
|
+
* restarted (stop() then start()) with a fresh runtime each time.
|
|
29
|
+
*/
|
|
30
|
+
export async function createApplication(options = {}) {
|
|
31
|
+
const contextStorage = options.contextStorage ?? getDefaultContextStorage();
|
|
32
|
+
const logger = isLogger(options.logger)
|
|
33
|
+
? options.logger
|
|
34
|
+
: new ConsoleLogger({ contextStorage, ...options.logger });
|
|
35
|
+
const configuration = options.configuration ?? createConfigurationManager();
|
|
36
|
+
if (configuration.getState() === ConfigurationManagerState.CREATED) {
|
|
37
|
+
await configuration.initialize();
|
|
38
|
+
}
|
|
39
|
+
const container = options.container ??
|
|
40
|
+
new Container({ currentScope: () => contextStorage.get() });
|
|
41
|
+
const moduleRegistry = options.moduleRegistry ?? createModuleRegistry();
|
|
42
|
+
if (options.modules && options.modules.length > 0) {
|
|
43
|
+
moduleRegistry.registerMany(options.modules);
|
|
44
|
+
}
|
|
45
|
+
const context = new ApplicationContext({
|
|
46
|
+
container,
|
|
47
|
+
/*
|
|
48
|
+
* An accessor rather than a snapshot: after
|
|
49
|
+
* `configuration.reload()` the application context must hand
|
|
50
|
+
* out the reloaded configuration, not the one captured here.
|
|
51
|
+
*/
|
|
52
|
+
configuration: () => configuration.getConfiguration(),
|
|
53
|
+
modules: moduleRegistry,
|
|
54
|
+
logger,
|
|
55
|
+
contextStorage,
|
|
56
|
+
});
|
|
57
|
+
const runtimeOptions = options.runtime ?? {};
|
|
58
|
+
const resolved = resolveRuntimeOptions(runtimeOptions);
|
|
59
|
+
let previousLoader;
|
|
60
|
+
const createApplicationRuntime = () => {
|
|
61
|
+
/*
|
|
62
|
+
* A restart gets fresh module instances: the previous runtime has
|
|
63
|
+
* already stopped and destroyed them, so forget the instances and
|
|
64
|
+
* contexts before the new loader re-creates them.
|
|
65
|
+
*/
|
|
66
|
+
if (previousLoader) {
|
|
67
|
+
for (const registration of moduleRegistry.getAll()) {
|
|
68
|
+
previousLoader.unload(registration.definition.id);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const moduleLoader = createModuleLoader(moduleRegistry, {
|
|
72
|
+
application: context,
|
|
73
|
+
configuration,
|
|
74
|
+
logger,
|
|
75
|
+
});
|
|
76
|
+
previousLoader = moduleLoader;
|
|
77
|
+
const moduleLifecycle = createModuleLifecycleManager(moduleRegistry, moduleLoader, {
|
|
78
|
+
continueOnInitializeError: resolved.startup.continueOnInitializeError,
|
|
79
|
+
continueOnStartError: resolved.startup.continueOnStartError,
|
|
80
|
+
continueOnStopError: resolved.shutdown.continueOnStopError,
|
|
81
|
+
continueOnDestroyError: resolved.shutdown.continueOnDestroyError,
|
|
82
|
+
contextStorage,
|
|
83
|
+
});
|
|
84
|
+
return createRuntime({
|
|
85
|
+
application: context,
|
|
86
|
+
configuration,
|
|
87
|
+
logger,
|
|
88
|
+
moduleRegistry,
|
|
89
|
+
moduleLoader,
|
|
90
|
+
moduleLifecycle,
|
|
91
|
+
signalTarget: options.signalTarget,
|
|
92
|
+
contextStorage,
|
|
93
|
+
}, runtimeOptions);
|
|
94
|
+
};
|
|
95
|
+
const lifecycle = new Lifecycle({ logger });
|
|
96
|
+
for (const participant of options.participants ?? []) {
|
|
97
|
+
lifecycle.register(participant);
|
|
98
|
+
}
|
|
99
|
+
const application = await Application.create({
|
|
100
|
+
context,
|
|
101
|
+
lifecycle,
|
|
102
|
+
runtime: createApplicationRuntime,
|
|
103
|
+
});
|
|
104
|
+
if (options.autoStart) {
|
|
105
|
+
await application.start();
|
|
106
|
+
}
|
|
107
|
+
return application;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=createApplication.js.map
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* Application bootstrap and context management.
|
|
3
3
|
*
|
|
4
4
|
* Provides the main Application class, its context,
|
|
5
|
-
*
|
|
5
|
+
* application state types, and the createApplication factory.
|
|
6
6
|
*/
|
|
7
7
|
export * from "./application.js";
|
|
8
8
|
export * from "./applicationContext.context.js";
|
|
9
9
|
export * from "./applicationState.state.js";
|
|
10
|
+
export * from "./createApplication.js";
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* Application bootstrap and context management.
|
|
3
3
|
*
|
|
4
4
|
* Provides the main Application class, its context,
|
|
5
|
-
*
|
|
5
|
+
* application state types, and the createApplication factory.
|
|
6
6
|
*/
|
|
7
7
|
export * from "./application.js";
|
|
8
8
|
export * from "./applicationContext.context.js";
|
|
9
9
|
export * from "./applicationState.state.js";
|
|
10
|
+
export * from "./createApplication.js";
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -7,6 +7,7 @@ import { ConfigurationSchemaRegistry } from "./schema/configurationSchema.schema
|
|
|
7
7
|
import type { ConfigurationValidationOptions, ConfigurationValidationReport } from "./schema/configurationValidation.validator.js";
|
|
8
8
|
import { ConfigurationRedactor } from "./error/configurationRedactor.redactor.js";
|
|
9
9
|
import type { ConfigurationRedactorOptions, RedactedConfiguration } from "./error/configurationRedactor.redactor.js";
|
|
10
|
+
import type { ConfigurationEventListener, ConfigurationEventTypeValue } from "./events/configurationEvents.events.js";
|
|
10
11
|
/** Lifecycle state of the configuration manager. */
|
|
11
12
|
export declare enum ConfigurationManagerState {
|
|
12
13
|
CREATED = "created",
|
|
@@ -32,6 +33,12 @@ export interface ConfigurationManagerResult {
|
|
|
32
33
|
readonly load: ConfigurationLoadResult;
|
|
33
34
|
readonly validation: ConfigurationValidationReport;
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Event type accepted when subscribing to the manager.
|
|
38
|
+
*
|
|
39
|
+
* "*" subscribes to every configuration lifecycle event.
|
|
40
|
+
*/
|
|
41
|
+
export type ConfigurationEventSubscription = ConfigurationEventTypeValue | "*";
|
|
35
42
|
/** Coordinates the complete configuration lifecycle. */
|
|
36
43
|
export declare class ConfigurationManager {
|
|
37
44
|
private readonly loader;
|
|
@@ -40,17 +47,51 @@ export declare class ConfigurationManager {
|
|
|
40
47
|
private readonly schemas;
|
|
41
48
|
private readonly redactor;
|
|
42
49
|
private readonly validationOptions;
|
|
50
|
+
private readonly listeners;
|
|
51
|
+
private readonly listenerErrors;
|
|
43
52
|
private configuration;
|
|
44
53
|
private loadResult;
|
|
45
54
|
private validationReport;
|
|
55
|
+
private missingSetConfigurationWarned;
|
|
56
|
+
private inFlightReload;
|
|
46
57
|
private stateValue;
|
|
47
58
|
constructor(options?: ConfigurationManagerOptions);
|
|
59
|
+
/**
|
|
60
|
+
* Subscribes to configuration lifecycle events.
|
|
61
|
+
*
|
|
62
|
+
* Pass "*" to receive every event. Returns an unsubscribe
|
|
63
|
+
* function.
|
|
64
|
+
*/
|
|
65
|
+
on(type: ConfigurationEventSubscription, listener: ConfigurationEventListener): () => void;
|
|
66
|
+
/** Removes a previously registered event listener. */
|
|
67
|
+
off(type: ConfigurationEventSubscription, listener: ConfigurationEventListener): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Returns errors thrown by event listeners.
|
|
70
|
+
*
|
|
71
|
+
* Listener failures never interrupt configuration loading;
|
|
72
|
+
* they are collected here for diagnostics.
|
|
73
|
+
*/
|
|
74
|
+
getListenerErrors(): readonly unknown[];
|
|
48
75
|
initialize(): Promise<ConfigurationManagerResult>;
|
|
76
|
+
/**
|
|
77
|
+
* Reloads configuration from the registered sources.
|
|
78
|
+
*
|
|
79
|
+
* Overlapping calls are serialised: a reload requested while one
|
|
80
|
+
* is already in progress shares that in-flight reload instead of
|
|
81
|
+
* failing with InvalidStateError. A manager that is not ready yet
|
|
82
|
+
* is initialized instead.
|
|
83
|
+
*/
|
|
49
84
|
reload(): Promise<ConfigurationManagerResult>;
|
|
85
|
+
private performReload;
|
|
50
86
|
getConfiguration(): Configuration;
|
|
51
87
|
getProvider(): ConfigurationProvider;
|
|
52
88
|
getRegistry(): ConfigurationRegistry;
|
|
53
89
|
getSchemaRegistry(): ConfigurationSchemaRegistry;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the active configuration scoped to a section
|
|
92
|
+
* registered with the manager's registry.
|
|
93
|
+
*/
|
|
94
|
+
getSection(name: string): Configuration;
|
|
54
95
|
getLoader(): ConfigurationLoader;
|
|
55
96
|
getRedactor(): ConfigurationRedactor;
|
|
56
97
|
getState(): ConfigurationManagerState;
|
|
@@ -61,6 +102,7 @@ export declare class ConfigurationManager {
|
|
|
61
102
|
get<T = unknown>(path: string): T | undefined;
|
|
62
103
|
require<T = unknown>(path: string): T;
|
|
63
104
|
private providerConfiguration;
|
|
105
|
+
private emit;
|
|
64
106
|
private ensureReady;
|
|
65
107
|
}
|
|
66
108
|
/** Creates a ConfigurationManager. */
|
|
@@ -2,10 +2,12 @@ import { Configuration } from "./core/configuration.js";
|
|
|
2
2
|
import { ConfigurationLoader } from "./loader/configurationLoader.loader.js";
|
|
3
3
|
import { DefaultConfigurationProvider } from "./registry/configurationProvider.provider.js";
|
|
4
4
|
import { ConfigurationRegistry } from "./registry/configurationRegistry.registry.js";
|
|
5
|
+
import { InvalidStateError } from "../errors/exceptions.js";
|
|
5
6
|
import { ConfigurationSchemaRegistry } from "./schema/configurationSchema.schema.js";
|
|
6
|
-
import { validateConfiguration } from "./schema/configurationValidation.validator.js";
|
|
7
|
+
import { applyConfigurationSchemaDefaults, validateConfiguration, } from "./schema/configurationValidation.validator.js";
|
|
7
8
|
import { ConfigurationValidationError } from "./schema/configurationValidation.validator.js";
|
|
8
9
|
import { ConfigurationRedactor } from "./error/configurationRedactor.redactor.js";
|
|
10
|
+
import { createConfigurationFailedEvent, createConfigurationInitializingEvent, createConfigurationLoadedEvent, createConfigurationReadyEvent, createConfigurationReloadedEvent, createConfigurationReloadingEvent, createConfigurationValidatedEvent, } from "./events/configurationEvents.events.js";
|
|
9
11
|
/** Lifecycle state of the configuration manager. */
|
|
10
12
|
export var ConfigurationManagerState;
|
|
11
13
|
(function (ConfigurationManagerState) {
|
|
@@ -23,9 +25,13 @@ export class ConfigurationManager {
|
|
|
23
25
|
schemas;
|
|
24
26
|
redactor;
|
|
25
27
|
validationOptions;
|
|
28
|
+
listeners = new Map();
|
|
29
|
+
listenerErrors = [];
|
|
26
30
|
configuration;
|
|
27
31
|
loadResult;
|
|
28
32
|
validationReport;
|
|
33
|
+
missingSetConfigurationWarned = false;
|
|
34
|
+
inFlightReload;
|
|
29
35
|
stateValue = ConfigurationManagerState.CREATED;
|
|
30
36
|
constructor(options = {}) {
|
|
31
37
|
this.loader =
|
|
@@ -37,23 +43,56 @@ export class ConfigurationManager {
|
|
|
37
43
|
options.redactor ?? new ConfigurationRedactor(options.redactorOptions);
|
|
38
44
|
this.validationOptions = options.validationOptions ?? {};
|
|
39
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Subscribes to configuration lifecycle events.
|
|
48
|
+
*
|
|
49
|
+
* Pass "*" to receive every event. Returns an unsubscribe
|
|
50
|
+
* function.
|
|
51
|
+
*/
|
|
52
|
+
on(type, listener) {
|
|
53
|
+
let listeners = this.listeners.get(type);
|
|
54
|
+
if (!listeners) {
|
|
55
|
+
listeners = new Set();
|
|
56
|
+
this.listeners.set(type, listeners);
|
|
57
|
+
}
|
|
58
|
+
listeners.add(listener);
|
|
59
|
+
return () => this.off(type, listener);
|
|
60
|
+
}
|
|
61
|
+
/** Removes a previously registered event listener. */
|
|
62
|
+
off(type, listener) {
|
|
63
|
+
return this.listeners.get(type)?.delete(listener) ?? false;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns errors thrown by event listeners.
|
|
67
|
+
*
|
|
68
|
+
* Listener failures never interrupt configuration loading;
|
|
69
|
+
* they are collected here for diagnostics.
|
|
70
|
+
*/
|
|
71
|
+
getListenerErrors() {
|
|
72
|
+
return [...this.listenerErrors];
|
|
73
|
+
}
|
|
40
74
|
async initialize() {
|
|
41
75
|
if (this.stateValue === ConfigurationManagerState.LOADING)
|
|
42
|
-
throw new
|
|
76
|
+
throw new InvalidStateError("Configuration initialization is already in progress.", { state: this.stateValue });
|
|
43
77
|
this.stateValue = ConfigurationManagerState.LOADING;
|
|
78
|
+
this.emit(createConfigurationInitializingEvent(this.stateValue));
|
|
44
79
|
try {
|
|
45
|
-
const loadResult = await this.loader.load();
|
|
80
|
+
const loadResult = await this.loader.load(this.registry.getSources());
|
|
46
81
|
this.loadResult = loadResult;
|
|
47
82
|
this.configuration = loadResult.configuration;
|
|
48
83
|
this.stateValue = ConfigurationManagerState.LOADED;
|
|
84
|
+
this.emit(createConfigurationLoadedEvent(this.stateValue, loadResult));
|
|
49
85
|
const validation = await validateConfiguration(this.configuration, this.schemas, this.validationOptions);
|
|
50
86
|
this.validationReport = validation;
|
|
51
87
|
if (!validation.valid) {
|
|
52
88
|
this.stateValue = ConfigurationManagerState.FAILED;
|
|
53
89
|
throw new ConfigurationValidationError(validation.issues, validation.schemaCount, validation.invalidSchemaCount);
|
|
54
90
|
}
|
|
91
|
+
this.configuration = applyConfigurationSchemaDefaults(this.configuration, this.schemas);
|
|
92
|
+
this.emit(createConfigurationValidatedEvent(this.stateValue, this.configuration, validation));
|
|
55
93
|
this.providerConfiguration(this.configuration);
|
|
56
94
|
this.stateValue = ConfigurationManagerState.READY;
|
|
95
|
+
this.emit(createConfigurationReadyEvent(this.stateValue, this.configuration, validation));
|
|
57
96
|
return {
|
|
58
97
|
configuration: this.configuration,
|
|
59
98
|
load: loadResult,
|
|
@@ -62,19 +101,38 @@ export class ConfigurationManager {
|
|
|
62
101
|
}
|
|
63
102
|
catch (error) {
|
|
64
103
|
this.stateValue = ConfigurationManagerState.FAILED;
|
|
104
|
+
this.emit(createConfigurationFailedEvent(this.stateValue, error));
|
|
65
105
|
throw error;
|
|
66
106
|
}
|
|
67
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Reloads configuration from the registered sources.
|
|
110
|
+
*
|
|
111
|
+
* Overlapping calls are serialised: a reload requested while one
|
|
112
|
+
* is already in progress shares that in-flight reload instead of
|
|
113
|
+
* failing with InvalidStateError. A manager that is not ready yet
|
|
114
|
+
* is initialized instead.
|
|
115
|
+
*/
|
|
68
116
|
async reload() {
|
|
117
|
+
if (this.inFlightReload)
|
|
118
|
+
return this.inFlightReload;
|
|
69
119
|
if (this.stateValue !== ConfigurationManagerState.READY)
|
|
70
120
|
return this.initialize();
|
|
121
|
+
const reload = this.performReload().finally(() => {
|
|
122
|
+
this.inFlightReload = undefined;
|
|
123
|
+
});
|
|
124
|
+
this.inFlightReload = reload;
|
|
125
|
+
return reload;
|
|
126
|
+
}
|
|
127
|
+
async performReload() {
|
|
71
128
|
const previousConfiguration = this.configuration;
|
|
72
129
|
const previousLoadResult = this.loadResult;
|
|
73
130
|
const previousValidation = this.validationReport;
|
|
74
131
|
this.stateValue = ConfigurationManagerState.LOADING;
|
|
132
|
+
this.emit(createConfigurationReloadingEvent(this.stateValue, previousConfiguration));
|
|
75
133
|
try {
|
|
76
|
-
const loadResult = await this.loader.load();
|
|
77
|
-
|
|
134
|
+
const loadResult = await this.loader.load(this.registry.getSources());
|
|
135
|
+
let configuration = loadResult.configuration;
|
|
78
136
|
const validation = await validateConfiguration(configuration, this.schemas, this.validationOptions);
|
|
79
137
|
if (!validation.valid) {
|
|
80
138
|
this.configuration = previousConfiguration;
|
|
@@ -83,11 +141,13 @@ export class ConfigurationManager {
|
|
|
83
141
|
this.stateValue = ConfigurationManagerState.READY;
|
|
84
142
|
throw new ConfigurationValidationError(validation.issues, validation.schemaCount, validation.invalidSchemaCount);
|
|
85
143
|
}
|
|
144
|
+
configuration = applyConfigurationSchemaDefaults(configuration, this.schemas);
|
|
86
145
|
this.configuration = configuration;
|
|
87
146
|
this.loadResult = loadResult;
|
|
88
147
|
this.validationReport = validation;
|
|
89
148
|
this.providerConfiguration(configuration);
|
|
90
149
|
this.stateValue = ConfigurationManagerState.READY;
|
|
150
|
+
this.emit(createConfigurationReloadedEvent(this.stateValue, previousConfiguration, configuration, loadResult, validation));
|
|
91
151
|
return { configuration, load: loadResult, validation };
|
|
92
152
|
}
|
|
93
153
|
catch (error) {
|
|
@@ -96,6 +156,7 @@ export class ConfigurationManager {
|
|
|
96
156
|
this.stateValue = previousConfiguration
|
|
97
157
|
? ConfigurationManagerState.READY
|
|
98
158
|
: ConfigurationManagerState.FAILED;
|
|
159
|
+
this.emit(createConfigurationFailedEvent(this.stateValue, error, previousConfiguration));
|
|
99
160
|
throw error;
|
|
100
161
|
}
|
|
101
162
|
}
|
|
@@ -112,6 +173,14 @@ export class ConfigurationManager {
|
|
|
112
173
|
getSchemaRegistry() {
|
|
113
174
|
return this.schemas;
|
|
114
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Returns the active configuration scoped to a section
|
|
178
|
+
* registered with the manager's registry.
|
|
179
|
+
*/
|
|
180
|
+
getSection(name) {
|
|
181
|
+
this.ensureReady();
|
|
182
|
+
return this.registry.getConfigurationSection(this.configuration, name);
|
|
183
|
+
}
|
|
115
184
|
getLoader() {
|
|
116
185
|
return this.loader;
|
|
117
186
|
}
|
|
@@ -136,18 +205,46 @@ export class ConfigurationManager {
|
|
|
136
205
|
: undefined;
|
|
137
206
|
}
|
|
138
207
|
get(path) {
|
|
208
|
+
this.ensureReady();
|
|
139
209
|
return this.getProvider().get(path);
|
|
140
210
|
}
|
|
141
211
|
require(path) {
|
|
212
|
+
this.ensureReady();
|
|
142
213
|
return this.getProvider().require(path);
|
|
143
214
|
}
|
|
144
215
|
providerConfiguration(configuration) {
|
|
145
|
-
if (this.provider
|
|
216
|
+
if (typeof this.provider.setConfiguration === "function") {
|
|
146
217
|
this.provider.setConfiguration(configuration);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
if (!this.missingSetConfigurationWarned) {
|
|
221
|
+
this.missingSetConfigurationWarned = true;
|
|
222
|
+
console.warn("ConfigurationManager: the configured ConfigurationProvider does not implement setConfiguration(); loaded configuration will not be pushed into the provider.");
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
emit(event) {
|
|
226
|
+
const listeners = [
|
|
227
|
+
...(this.listeners.get(event.type) ?? []),
|
|
228
|
+
...(this.listeners.get("*") ?? []),
|
|
229
|
+
];
|
|
230
|
+
for (const listener of listeners) {
|
|
231
|
+
try {
|
|
232
|
+
const result = listener(event);
|
|
233
|
+
if (result instanceof Promise) {
|
|
234
|
+
void result.catch((error) => {
|
|
235
|
+
this.listenerErrors.push(error);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
/* Listener failures must never break configuration loading. */
|
|
241
|
+
this.listenerErrors.push(error);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
147
244
|
}
|
|
148
245
|
ensureReady() {
|
|
149
246
|
if (this.stateValue !== ConfigurationManagerState.READY)
|
|
150
|
-
throw new
|
|
247
|
+
throw new InvalidStateError(`Configuration is not ready. Current state: ${this.stateValue}.`, { state: this.stateValue });
|
|
151
248
|
}
|
|
152
249
|
}
|
|
153
250
|
/** Creates a ConfigurationManager. */
|
|
@@ -1,34 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { ConfigurationSourceType } from "./configurationSource.source.js";
|
|
2
|
+
import type { ConfigurationKey } from "./configurationKey.key.js";
|
|
3
3
|
/** Configuration value types supported by the core configuration system. */
|
|
4
4
|
export type ConfigurationValue = string | number | boolean | null | undefined | ConfigurationValue[] | {
|
|
5
5
|
readonly [key: string]: ConfigurationValue;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Source attribution for a configuration entry.
|
|
9
|
+
*
|
|
10
|
+
* "mixed" is reported when the values under a path originate
|
|
11
|
+
* from more than one source type.
|
|
12
|
+
*/
|
|
13
|
+
export type ConfigurationEntrySource = ConfigurationSourceType | "mixed";
|
|
7
14
|
/** Options used to create a Configuration instance. */
|
|
8
15
|
export interface ConfigurationOptions {
|
|
9
16
|
readonly values?: Record<string, ConfigurationValue>;
|
|
10
|
-
readonly source?:
|
|
17
|
+
readonly source?: ConfigurationSourceType;
|
|
11
18
|
readonly namespace?: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Per-path source attribution.
|
|
21
|
+
*
|
|
22
|
+
* Used internally when deriving configurations so entry-level
|
|
23
|
+
* source information survives `with()`, `merge()`, and `scope()`.
|
|
24
|
+
*/
|
|
25
|
+
readonly sources?: ReadonlyMap<string, ConfigurationSourceType>;
|
|
17
26
|
}
|
|
18
27
|
/** Represents a configuration entry. */
|
|
19
28
|
export interface ConfigurationEntry<T = ConfigurationValue> {
|
|
20
29
|
readonly path: string;
|
|
21
30
|
readonly value: T;
|
|
22
|
-
readonly source:
|
|
31
|
+
readonly source: ConfigurationEntrySource;
|
|
23
32
|
}
|
|
24
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Immutable configuration container.
|
|
35
|
+
*
|
|
36
|
+
* The values tree is deep-frozen at construction, so accessors can
|
|
37
|
+
* safely hand out internal references. Callers should treat any
|
|
38
|
+
* object passed into the constructor (or `with()`) as owned by the
|
|
39
|
+
* configuration afterwards: it becomes frozen.
|
|
40
|
+
*/
|
|
25
41
|
export declare class Configuration {
|
|
26
42
|
private readonly values;
|
|
27
43
|
private readonly source;
|
|
28
44
|
private readonly namespace?;
|
|
45
|
+
private readonly pathSources;
|
|
29
46
|
constructor(options?: ConfigurationOptions);
|
|
30
47
|
getNamespace(): string | undefined;
|
|
31
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Returns the source of a configuration path, or of the whole
|
|
50
|
+
* configuration when no path is supplied.
|
|
51
|
+
*
|
|
52
|
+
* When entries originate from multiple source types, "mixed"
|
|
53
|
+
* is returned.
|
|
54
|
+
*/
|
|
55
|
+
getSource(path?: string): ConfigurationEntrySource;
|
|
32
56
|
get<T = ConfigurationValue>(path: string): T | undefined;
|
|
33
57
|
require<T = ConfigurationValue>(path: string): T;
|
|
34
58
|
getByKey<T>(key: ConfigurationKey<T>): T | undefined;
|
|
@@ -37,17 +61,38 @@ export declare class Configuration {
|
|
|
37
61
|
getBoolean(path: string, defaultValue?: boolean): boolean | undefined;
|
|
38
62
|
getNumber(path: string, defaultValue?: number): number | undefined;
|
|
39
63
|
getString(path: string, defaultValue?: string): string | undefined;
|
|
40
|
-
createKey<T>(path: string): ConfigurationKey<T>;
|
|
41
64
|
scope(namespace: string): Configuration;
|
|
42
65
|
entries(): readonly ConfigurationEntry[];
|
|
43
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Returns a deep copy of the complete values tree.
|
|
68
|
+
*
|
|
69
|
+
* The copy is unfrozen and independent of the configuration, so
|
|
70
|
+
* callers may mutate it freely without affecting this instance
|
|
71
|
+
* or anything derived from it.
|
|
72
|
+
*/
|
|
73
|
+
toObject(): Record<string, ConfigurationValue>;
|
|
74
|
+
/**
|
|
75
|
+
* Deeply merges another configuration on top of this one.
|
|
76
|
+
*
|
|
77
|
+
* Objects are merged recursively, arrays and primitives are
|
|
78
|
+
* replaced. Per-path source attribution from both configurations
|
|
79
|
+
* is preserved; the other configuration wins on conflicts.
|
|
80
|
+
*/
|
|
44
81
|
merge(other: Configuration): Configuration;
|
|
45
|
-
with<T extends ConfigurationValue>(path: string, value: T, source?:
|
|
82
|
+
with<T extends ConfigurationValue>(path: string, value: T, source?: ConfigurationSourceType): Configuration;
|
|
46
83
|
without(path: string): Configuration;
|
|
47
84
|
private normalizePath;
|
|
85
|
+
private hasSourceRecordFor;
|
|
86
|
+
private resolveAncestorSource;
|
|
87
|
+
private resolvePathSource;
|
|
88
|
+
private deepMergeValues;
|
|
48
89
|
private setNestedValue;
|
|
90
|
+
/**
|
|
91
|
+
* Removes a nested value by shallow-cloning only the objects
|
|
92
|
+
* along the path, mirroring the strategy used by setNestedValue.
|
|
93
|
+
*/
|
|
49
94
|
private deleteNestedValue;
|
|
50
95
|
}
|
|
51
|
-
/** Creates
|
|
96
|
+
/** Creates a Configuration instance. */
|
|
52
97
|
export declare function createConfiguration(options?: ConfigurationOptions): Configuration;
|
|
53
98
|
//# sourceMappingURL=configuration.d.ts.map
|