@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
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
import { hasDestroyHook, hasInitializeHook, hasStartHook, hasStopHook, } from "../core/lifecycleHook.hook.js";
|
|
2
|
-
import { Lifecycle,
|
|
2
|
+
import { Lifecycle, } from "../core/lifecycle.js";
|
|
3
3
|
/**
|
|
4
4
|
* Coordinates lifecycle hooks and lifecycle participants.
|
|
5
5
|
* Primary API for application-level lifecycle management.
|
|
6
|
+
*
|
|
7
|
+
* Every component, whether it uses the hook interfaces (onInitialize,
|
|
8
|
+
* onStart, onStop, onDestroy) or the participant API (initialize,
|
|
9
|
+
* start, stop, dispose), is normalized into a single participant and
|
|
10
|
+
* driven by one Lifecycle state machine. This guarantees:
|
|
11
|
+
*
|
|
12
|
+
* - global registration order across both component kinds
|
|
13
|
+
* (initialize/start forward, stop/destroy reverse),
|
|
14
|
+
* - a component exposing both shapes runs exactly once per phase
|
|
15
|
+
* (the `onX` hook takes precedence),
|
|
16
|
+
* - state guards, retries, and concurrency rules of Lifecycle.
|
|
6
17
|
*/
|
|
7
18
|
export class LifecycleManager {
|
|
8
19
|
lifecycle;
|
|
9
20
|
components = [];
|
|
10
21
|
logger;
|
|
11
|
-
continueOnShutdownError;
|
|
12
22
|
constructor(options = {}) {
|
|
13
23
|
this.logger = options.logger;
|
|
14
|
-
this.continueOnShutdownError = options.continueOnShutdownError ?? true;
|
|
15
24
|
this.lifecycle = new Lifecycle({
|
|
16
25
|
logger: this.logger,
|
|
17
|
-
continueOnShutdownError:
|
|
26
|
+
continueOnShutdownError: options.continueOnShutdownError ?? true,
|
|
18
27
|
});
|
|
19
28
|
}
|
|
20
29
|
getState() {
|
|
@@ -23,119 +32,71 @@ export class LifecycleManager {
|
|
|
23
32
|
getComponents() {
|
|
24
33
|
return [...this.components];
|
|
25
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Registers a component. Only allowed before initialization begins.
|
|
37
|
+
*/
|
|
26
38
|
register(component) {
|
|
39
|
+
this.lifecycle.register(this.toParticipant(component));
|
|
27
40
|
this.components.push(component);
|
|
28
|
-
if (this.isLifecycleParticipant(component))
|
|
29
|
-
this.lifecycle.register(component);
|
|
30
41
|
}
|
|
31
42
|
async initialize() {
|
|
32
|
-
if (this.getState() !== LifecycleState.CREATED)
|
|
33
|
-
return;
|
|
34
43
|
this.logger?.debug("Lifecycle manager initialization started");
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (hasInitializeHook(component))
|
|
38
|
-
await this.runHook(component, "onInitialize", "initialize");
|
|
39
|
-
}
|
|
40
|
-
await this.lifecycle.initialize();
|
|
41
|
-
this.logger?.debug("Lifecycle manager initialization completed");
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
this.logger?.error("Lifecycle manager initialization failed", error);
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
44
|
+
await this.lifecycle.initialize();
|
|
45
|
+
this.logger?.debug("Lifecycle manager initialization completed");
|
|
47
46
|
}
|
|
48
47
|
async start() {
|
|
49
|
-
if (this.getState() === LifecycleState.CREATED)
|
|
50
|
-
await this.initialize();
|
|
51
48
|
this.logger?.debug("Lifecycle manager startup started");
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (hasStartHook(component))
|
|
55
|
-
await this.runHook(component, "onStart", "start");
|
|
56
|
-
}
|
|
57
|
-
await this.lifecycle.start();
|
|
58
|
-
this.logger?.debug("Lifecycle manager startup completed");
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
this.logger?.error("Lifecycle manager startup failed", error);
|
|
62
|
-
throw error;
|
|
63
|
-
}
|
|
49
|
+
await this.lifecycle.start();
|
|
50
|
+
this.logger?.debug("Lifecycle manager startup completed");
|
|
64
51
|
}
|
|
65
52
|
async stop() {
|
|
66
|
-
const errors = [];
|
|
67
53
|
this.logger?.debug("Lifecycle manager shutdown started");
|
|
68
|
-
|
|
69
|
-
const component = this.components[i];
|
|
70
|
-
if (!hasStopHook(component))
|
|
71
|
-
continue;
|
|
72
|
-
try {
|
|
73
|
-
await this.runHook(component, "onStop", "stop");
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
errors.push(error);
|
|
77
|
-
if (!this.continueOnShutdownError)
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
try {
|
|
82
|
-
await this.lifecycle.stop();
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
errors.push(error);
|
|
86
|
-
}
|
|
87
|
-
if (errors.length > 0)
|
|
88
|
-
throw new AggregateError(errors, "Lifecycle shutdown completed with errors.");
|
|
54
|
+
await this.lifecycle.stop();
|
|
89
55
|
this.logger?.debug("Lifecycle manager shutdown completed");
|
|
90
56
|
}
|
|
91
57
|
async destroy() {
|
|
92
|
-
const errors = [];
|
|
93
58
|
this.logger?.debug("Lifecycle manager destruction started");
|
|
94
|
-
|
|
95
|
-
const component = this.components[i];
|
|
96
|
-
if (!hasDestroyHook(component))
|
|
97
|
-
continue;
|
|
98
|
-
try {
|
|
99
|
-
await this.runHook(component, "onDestroy", "destroy");
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
errors.push(error);
|
|
103
|
-
if (!this.continueOnShutdownError)
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
try {
|
|
108
|
-
await this.lifecycle.dispose();
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
errors.push(error);
|
|
112
|
-
}
|
|
113
|
-
if (errors.length > 0)
|
|
114
|
-
throw new AggregateError(errors, "Lifecycle destruction completed with errors.");
|
|
59
|
+
await this.lifecycle.dispose();
|
|
115
60
|
this.logger?.debug("Lifecycle manager destruction completed");
|
|
116
61
|
}
|
|
117
62
|
async shutdown() {
|
|
118
|
-
|
|
119
|
-
try {
|
|
120
|
-
await this.stop();
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
errors.push(error);
|
|
124
|
-
}
|
|
125
|
-
try {
|
|
126
|
-
await this.destroy();
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
errors.push(error);
|
|
130
|
-
}
|
|
131
|
-
if (errors.length > 0)
|
|
132
|
-
throw new AggregateError(errors, "Application shutdown completed with errors.");
|
|
63
|
+
await this.lifecycle.shutdown();
|
|
133
64
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Normalizes a component into a LifecycleParticipant. Hook methods
|
|
67
|
+
* (onInitialize, ...) win over participant methods (initialize, ...)
|
|
68
|
+
* when a component exposes both, so each phase runs once.
|
|
69
|
+
*/
|
|
70
|
+
toParticipant(component) {
|
|
71
|
+
const name = this.getComponentName(component);
|
|
72
|
+
const participant = this.isLifecycleParticipant(component)
|
|
73
|
+
? component
|
|
74
|
+
: undefined;
|
|
75
|
+
const initialize = hasInitializeHook(component)
|
|
76
|
+
? () => this.runHook(name, "initialize", () => component.onInitialize())
|
|
77
|
+
: participant?.initialize
|
|
78
|
+
? () => this.runHook(name, "initialize", () => participant.initialize())
|
|
79
|
+
: undefined;
|
|
80
|
+
const start = hasStartHook(component)
|
|
81
|
+
? () => this.runHook(name, "start", () => component.onStart())
|
|
82
|
+
: participant?.start
|
|
83
|
+
? () => this.runHook(name, "start", () => participant.start())
|
|
84
|
+
: undefined;
|
|
85
|
+
const stop = hasStopHook(component)
|
|
86
|
+
? () => this.runHook(name, "stop", () => component.onStop())
|
|
87
|
+
: participant?.stop
|
|
88
|
+
? () => this.runHook(name, "stop", () => participant.stop())
|
|
89
|
+
: undefined;
|
|
90
|
+
const dispose = hasDestroyHook(component)
|
|
91
|
+
? () => this.runHook(name, "destroy", () => component.onDestroy())
|
|
92
|
+
: participant?.dispose
|
|
93
|
+
? () => this.runHook(name, "destroy", () => participant.dispose())
|
|
94
|
+
: undefined;
|
|
95
|
+
return { name, initialize, start, stop, dispose };
|
|
96
|
+
}
|
|
97
|
+
async runHook(component, label, hook) {
|
|
98
|
+
this.logger?.debug(`Running lifecycle ${label} hook`, { component });
|
|
99
|
+
await hook();
|
|
139
100
|
}
|
|
140
101
|
isLifecycleParticipant(component) {
|
|
141
102
|
return (typeof component === "object" &&
|
|
@@ -149,7 +110,9 @@ export class LifecycleManager {
|
|
|
149
110
|
if (typeof component === "object" &&
|
|
150
111
|
component !== null &&
|
|
151
112
|
"constructor" in component &&
|
|
152
|
-
typeof component.constructor === "function"
|
|
113
|
+
typeof component.constructor === "function" &&
|
|
114
|
+
component.constructor.name &&
|
|
115
|
+
component.constructor !== Object)
|
|
153
116
|
return component.constructor.name;
|
|
154
117
|
return "anonymous";
|
|
155
118
|
}
|
|
@@ -9,6 +9,7 @@ export declare const LifecycleScopeState: {
|
|
|
9
9
|
readonly RUNNING: "running";
|
|
10
10
|
readonly STOPPING: "stopping";
|
|
11
11
|
readonly STOPPED: "stopped";
|
|
12
|
+
readonly DESTROYED: "destroyed";
|
|
12
13
|
readonly FAILED: "failed";
|
|
13
14
|
};
|
|
14
15
|
export type LifecycleScopeState = (typeof LifecycleScopeState)[keyof typeof LifecycleScopeState];
|
|
@@ -22,11 +23,15 @@ export interface LifecycleScopeOptions {
|
|
|
22
23
|
/**
|
|
23
24
|
* Represents an independently managed lifecycle boundary.
|
|
24
25
|
* Can represent an Application, Module, Plugin, Worker, Service, or Feature.
|
|
26
|
+
*
|
|
27
|
+
* Children are initialized/started after the parent's own components
|
|
28
|
+
* and stopped/destroyed before them. A destroyed child detaches from
|
|
29
|
+
* its parent so it is never re-destroyed.
|
|
25
30
|
*/
|
|
26
31
|
export declare class LifecycleScope {
|
|
27
32
|
private state;
|
|
28
33
|
private readonly name;
|
|
29
|
-
private
|
|
34
|
+
private parent?;
|
|
30
35
|
private readonly logger?;
|
|
31
36
|
private readonly continueOnShutdownError;
|
|
32
37
|
private readonly registry;
|
|
@@ -41,9 +46,25 @@ export declare class LifecycleScope {
|
|
|
41
46
|
unregister(id: string): boolean;
|
|
42
47
|
initialize(): Promise<void>;
|
|
43
48
|
start(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Stops children (reverse order) and then this scope's components
|
|
51
|
+
* (reverse registration order).
|
|
52
|
+
*
|
|
53
|
+
* A scope that never started transitions straight to STOPPED without
|
|
54
|
+
* running any stop hook. When `continueOnShutdownError` is false the
|
|
55
|
+
* first failure aborts the phase and leaves the scope FAILED.
|
|
56
|
+
*/
|
|
44
57
|
stop(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Destroys children (reverse order) and then this scope's
|
|
60
|
+
* components. Idempotent: a destroyed scope is detached from its
|
|
61
|
+
* parent and never destroyed again.
|
|
62
|
+
*/
|
|
45
63
|
destroy(): Promise<void>;
|
|
46
64
|
shutdown(): Promise<void>;
|
|
47
65
|
private addChild;
|
|
66
|
+
private removeChild;
|
|
67
|
+
private detach;
|
|
68
|
+
private invalidState;
|
|
48
69
|
}
|
|
49
70
|
//# sourceMappingURL=lifecycleScope.scope.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LifecycleRegistry } from "../core/lifecycleRegistry.registry.js";
|
|
2
|
+
import { InvalidStateError } from "../../errors/exceptions.js";
|
|
2
3
|
/** Lifecycle scope state. */
|
|
3
4
|
export const LifecycleScopeState = {
|
|
4
5
|
CREATED: "created",
|
|
@@ -8,11 +9,16 @@ export const LifecycleScopeState = {
|
|
|
8
9
|
RUNNING: "running",
|
|
9
10
|
STOPPING: "stopping",
|
|
10
11
|
STOPPED: "stopped",
|
|
12
|
+
DESTROYED: "destroyed",
|
|
11
13
|
FAILED: "failed",
|
|
12
14
|
};
|
|
13
15
|
/**
|
|
14
16
|
* Represents an independently managed lifecycle boundary.
|
|
15
17
|
* Can represent an Application, Module, Plugin, Worker, Service, or Feature.
|
|
18
|
+
*
|
|
19
|
+
* Children are initialized/started after the parent's own components
|
|
20
|
+
* and stopped/destroyed before them. A destroyed child detaches from
|
|
21
|
+
* its parent so it is never re-destroyed.
|
|
16
22
|
*/
|
|
17
23
|
export class LifecycleScope {
|
|
18
24
|
state = LifecycleScopeState.CREATED;
|
|
@@ -48,7 +54,7 @@ export class LifecycleScope {
|
|
|
48
54
|
register(component, name) {
|
|
49
55
|
if (this.state !== LifecycleScopeState.CREATED &&
|
|
50
56
|
this.state !== LifecycleScopeState.INITIALIZED) {
|
|
51
|
-
throw new
|
|
57
|
+
throw new InvalidStateError(`Cannot register component in lifecycle scope "${this.name}" while state is "${this.state}".`, { scope: this.name, state: this.state });
|
|
52
58
|
}
|
|
53
59
|
return this.registry.register(component, name);
|
|
54
60
|
}
|
|
@@ -60,7 +66,7 @@ export class LifecycleScope {
|
|
|
60
66
|
this.state === LifecycleScopeState.RUNNING)
|
|
61
67
|
return;
|
|
62
68
|
if (this.state !== LifecycleScopeState.CREATED)
|
|
63
|
-
throw
|
|
69
|
+
throw this.invalidState("initialize");
|
|
64
70
|
this.state = LifecycleScopeState.INITIALIZING;
|
|
65
71
|
this.logger?.debug("Initializing lifecycle scope", { scope: this.name });
|
|
66
72
|
try {
|
|
@@ -75,7 +81,7 @@ export class LifecycleScope {
|
|
|
75
81
|
await component.initialize();
|
|
76
82
|
}
|
|
77
83
|
}
|
|
78
|
-
for (const child of this.children)
|
|
84
|
+
for (const child of [...this.children])
|
|
79
85
|
await child.initialize();
|
|
80
86
|
this.state = LifecycleScopeState.INITIALIZED;
|
|
81
87
|
this.logger?.debug("Lifecycle scope initialized", { scope: this.name });
|
|
@@ -94,7 +100,7 @@ export class LifecycleScope {
|
|
|
94
100
|
if (this.state === LifecycleScopeState.CREATED)
|
|
95
101
|
await this.initialize();
|
|
96
102
|
if (this.state !== LifecycleScopeState.INITIALIZED)
|
|
97
|
-
throw
|
|
103
|
+
throw this.invalidState("start");
|
|
98
104
|
this.state = LifecycleScopeState.STARTING;
|
|
99
105
|
this.logger?.debug("Starting lifecycle scope", { scope: this.name });
|
|
100
106
|
try {
|
|
@@ -108,7 +114,7 @@ export class LifecycleScope {
|
|
|
108
114
|
await component.start();
|
|
109
115
|
}
|
|
110
116
|
}
|
|
111
|
-
for (const child of this.children)
|
|
117
|
+
for (const child of [...this.children])
|
|
112
118
|
await child.start();
|
|
113
119
|
this.state = LifecycleScopeState.RUNNING;
|
|
114
120
|
this.logger?.debug("Lifecycle scope started", { scope: this.name });
|
|
@@ -121,15 +127,36 @@ export class LifecycleScope {
|
|
|
121
127
|
throw error;
|
|
122
128
|
}
|
|
123
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Stops children (reverse order) and then this scope's components
|
|
132
|
+
* (reverse registration order).
|
|
133
|
+
*
|
|
134
|
+
* A scope that never started transitions straight to STOPPED without
|
|
135
|
+
* running any stop hook. When `continueOnShutdownError` is false the
|
|
136
|
+
* first failure aborts the phase and leaves the scope FAILED.
|
|
137
|
+
*/
|
|
124
138
|
async stop() {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
139
|
+
switch (this.state) {
|
|
140
|
+
case LifecycleScopeState.STOPPED:
|
|
141
|
+
case LifecycleScopeState.DESTROYED:
|
|
142
|
+
return;
|
|
143
|
+
case LifecycleScopeState.CREATED:
|
|
144
|
+
case LifecycleScopeState.INITIALIZED:
|
|
145
|
+
// Nothing started here; cascade the state to children only.
|
|
146
|
+
for (let i = this.children.length - 1; i >= 0; i--) {
|
|
147
|
+
await this.children[i].stop();
|
|
148
|
+
}
|
|
149
|
+
this.state = LifecycleScopeState.STOPPED;
|
|
150
|
+
return;
|
|
151
|
+
case LifecycleScopeState.RUNNING:
|
|
152
|
+
case LifecycleScopeState.FAILED:
|
|
153
|
+
break;
|
|
154
|
+
default:
|
|
155
|
+
throw this.invalidState("stop");
|
|
130
156
|
}
|
|
131
157
|
this.state = LifecycleScopeState.STOPPING;
|
|
132
158
|
const errors = [];
|
|
159
|
+
let aborted = false;
|
|
133
160
|
this.logger?.debug("Stopping lifecycle scope", { scope: this.name });
|
|
134
161
|
for (let i = this.children.length - 1; i >= 0; i--) {
|
|
135
162
|
try {
|
|
@@ -137,11 +164,13 @@ export class LifecycleScope {
|
|
|
137
164
|
}
|
|
138
165
|
catch (error) {
|
|
139
166
|
errors.push(error);
|
|
140
|
-
if (!this.continueOnShutdownError)
|
|
167
|
+
if (!this.continueOnShutdownError) {
|
|
168
|
+
aborted = true;
|
|
141
169
|
break;
|
|
170
|
+
}
|
|
142
171
|
}
|
|
143
172
|
}
|
|
144
|
-
if (
|
|
173
|
+
if (!aborted) {
|
|
145
174
|
for (const registration of this.registry.getReverse()) {
|
|
146
175
|
const component = registration.component;
|
|
147
176
|
try {
|
|
@@ -159,17 +188,33 @@ export class LifecycleScope {
|
|
|
159
188
|
scope: this.name,
|
|
160
189
|
component: registration.name,
|
|
161
190
|
});
|
|
162
|
-
if (!this.continueOnShutdownError)
|
|
191
|
+
if (!this.continueOnShutdownError) {
|
|
192
|
+
aborted = true;
|
|
163
193
|
break;
|
|
194
|
+
}
|
|
164
195
|
}
|
|
165
196
|
}
|
|
166
197
|
}
|
|
167
|
-
this.state =
|
|
198
|
+
this.state = aborted
|
|
199
|
+
? LifecycleScopeState.FAILED
|
|
200
|
+
: LifecycleScopeState.STOPPED;
|
|
168
201
|
if (errors.length > 0)
|
|
169
202
|
throw new AggregateError(errors, `Lifecycle scope "${this.name}" stopped with errors.`);
|
|
170
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Destroys children (reverse order) and then this scope's
|
|
206
|
+
* components. Idempotent: a destroyed scope is detached from its
|
|
207
|
+
* parent and never destroyed again.
|
|
208
|
+
*/
|
|
171
209
|
async destroy() {
|
|
210
|
+
if (this.state === LifecycleScopeState.DESTROYED)
|
|
211
|
+
return;
|
|
212
|
+
if (this.state === LifecycleScopeState.INITIALIZING ||
|
|
213
|
+
this.state === LifecycleScopeState.STARTING ||
|
|
214
|
+
this.state === LifecycleScopeState.STOPPING)
|
|
215
|
+
throw this.invalidState("destroy");
|
|
172
216
|
const errors = [];
|
|
217
|
+
let aborted = false;
|
|
173
218
|
this.logger?.debug("Destroying lifecycle scope", { scope: this.name });
|
|
174
219
|
for (let i = this.children.length - 1; i >= 0; i--) {
|
|
175
220
|
try {
|
|
@@ -177,11 +222,13 @@ export class LifecycleScope {
|
|
|
177
222
|
}
|
|
178
223
|
catch (error) {
|
|
179
224
|
errors.push(error);
|
|
180
|
-
if (!this.continueOnShutdownError)
|
|
225
|
+
if (!this.continueOnShutdownError) {
|
|
226
|
+
aborted = true;
|
|
181
227
|
break;
|
|
228
|
+
}
|
|
182
229
|
}
|
|
183
230
|
}
|
|
184
|
-
if (
|
|
231
|
+
if (!aborted) {
|
|
185
232
|
for (const registration of this.registry.getReverse()) {
|
|
186
233
|
const component = registration.component;
|
|
187
234
|
try {
|
|
@@ -200,11 +247,20 @@ export class LifecycleScope {
|
|
|
200
247
|
scope: this.name,
|
|
201
248
|
component: registration.name,
|
|
202
249
|
});
|
|
203
|
-
if (!this.continueOnShutdownError)
|
|
250
|
+
if (!this.continueOnShutdownError) {
|
|
251
|
+
aborted = true;
|
|
204
252
|
break;
|
|
253
|
+
}
|
|
205
254
|
}
|
|
206
255
|
}
|
|
207
256
|
}
|
|
257
|
+
if (aborted) {
|
|
258
|
+
this.state = LifecycleScopeState.FAILED;
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
this.state = LifecycleScopeState.DESTROYED;
|
|
262
|
+
this.detach();
|
|
263
|
+
}
|
|
208
264
|
if (errors.length > 0)
|
|
209
265
|
throw new AggregateError(errors, `Lifecycle scope "${this.name}" destroyed with errors.`);
|
|
210
266
|
}
|
|
@@ -230,5 +286,17 @@ export class LifecycleScope {
|
|
|
230
286
|
return;
|
|
231
287
|
this.children.push(child);
|
|
232
288
|
}
|
|
289
|
+
removeChild(child) {
|
|
290
|
+
const index = this.children.indexOf(child);
|
|
291
|
+
if (index !== -1)
|
|
292
|
+
this.children.splice(index, 1);
|
|
293
|
+
}
|
|
294
|
+
detach() {
|
|
295
|
+
this.parent?.removeChild(this);
|
|
296
|
+
this.parent = undefined;
|
|
297
|
+
}
|
|
298
|
+
invalidState(operation) {
|
|
299
|
+
return new InvalidStateError(`Cannot ${operation} lifecycle scope "${this.name}" while state is "${this.state}".`, { scope: this.name, operation, state: this.state });
|
|
300
|
+
}
|
|
233
301
|
}
|
|
234
302
|
//# sourceMappingURL=lifecycleScope.scope.js.map
|
|
@@ -20,15 +20,34 @@ export declare class ConsoleLogger extends BaseLogger {
|
|
|
20
20
|
constructor(options?: LoggerOptions, context?: LoggerContext);
|
|
21
21
|
/**
|
|
22
22
|
* Writes a log entry to the console.
|
|
23
|
+
*
|
|
24
|
+
* The context received here has already been merged with the
|
|
25
|
+
* logger's persistent context by BaseLogger. Fields of the
|
|
26
|
+
* current execution context (when a ContextStorage is configured
|
|
27
|
+
* and a context is active) are merged beneath it.
|
|
23
28
|
*/
|
|
24
29
|
protected write(level: LogLevelType, message: string, context?: LogContext, error?: unknown): void;
|
|
25
30
|
/**
|
|
26
31
|
* Creates a child logger that inherits the current
|
|
27
|
-
* logger configuration
|
|
32
|
+
* logger configuration.
|
|
33
|
+
*
|
|
34
|
+
* The context received here is the fully merged context
|
|
35
|
+
* (parent persistent context plus child additions) produced
|
|
36
|
+
* by BaseLogger.child().
|
|
28
37
|
*/
|
|
29
38
|
protected createChild(context: LogContext): ConsoleLogger;
|
|
39
|
+
/**
|
|
40
|
+
* Merges the ambient execution context (if any) beneath the
|
|
41
|
+
* supplied context. Never throws: a failing storage lookup leaves
|
|
42
|
+
* the context untouched.
|
|
43
|
+
*/
|
|
44
|
+
private withExecutionContext;
|
|
30
45
|
/**
|
|
31
46
|
* Writes the log entry as JSON.
|
|
47
|
+
*
|
|
48
|
+
* Serialization is crash-safe: circular references, BigInt
|
|
49
|
+
* values, and throwing toJSON implementations degrade to
|
|
50
|
+
* placeholder strings instead of throwing.
|
|
32
51
|
*/
|
|
33
52
|
private writeStructured;
|
|
34
53
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { LogLevel, LogLevelPriority, shouldLog, } from "../core/logLevel.level.js";
|
|
2
|
-
import {
|
|
1
|
+
import { LogLevel, LogLevelPriority, isLogLevel, shouldLog, } from "../core/logLevel.level.js";
|
|
2
|
+
import { InvalidArgumentError } from "../../errors/exceptions.js";
|
|
3
|
+
import { safeLogStringify, sanitizeLogValue, serializeLogError, } from "../core/logEntry.entry.js";
|
|
4
|
+
import { loggerContextFromExecution } from "../core/loggerContext.context.js";
|
|
3
5
|
import { DEFAULT_LOGGER_OPTIONS, } from "../core/loggerOptions.options.js";
|
|
4
6
|
import { BaseLogger } from "../core/logger.js";
|
|
5
7
|
/**
|
|
@@ -22,26 +24,45 @@ export class ConsoleLogger extends BaseLogger {
|
|
|
22
24
|
...options.context,
|
|
23
25
|
...context,
|
|
24
26
|
});
|
|
27
|
+
const level = options.level ?? DEFAULT_LOGGER_OPTIONS.level;
|
|
28
|
+
/*
|
|
29
|
+
* An unknown level would make every severity comparison false
|
|
30
|
+
* and silently disable all logging, so it is rejected at
|
|
31
|
+
* construction instead. Levels are case-sensitive.
|
|
32
|
+
*/
|
|
33
|
+
if (!isLogLevel(level)) {
|
|
34
|
+
throw new InvalidArgumentError(`Unknown log level "${String(level)}". Expected one of: ${Object.keys(LogLevelPriority).join(", ")}.`, { level });
|
|
35
|
+
}
|
|
25
36
|
this.options = {
|
|
26
37
|
...DEFAULT_LOGGER_OPTIONS,
|
|
27
38
|
...options,
|
|
39
|
+
level,
|
|
28
40
|
};
|
|
29
41
|
}
|
|
30
42
|
/**
|
|
31
43
|
* Writes a log entry to the console.
|
|
44
|
+
*
|
|
45
|
+
* The context received here has already been merged with the
|
|
46
|
+
* logger's persistent context by BaseLogger. Fields of the
|
|
47
|
+
* current execution context (when a ContextStorage is configured
|
|
48
|
+
* and a context is active) are merged beneath it.
|
|
32
49
|
*/
|
|
33
50
|
write(level, message, context, error) {
|
|
34
51
|
if (!shouldLog(level, this.options.level)) {
|
|
35
52
|
return;
|
|
36
53
|
}
|
|
54
|
+
const redact = this.options.redact;
|
|
55
|
+
context = this.withExecutionContext(context);
|
|
37
56
|
const entry = {
|
|
38
57
|
level,
|
|
39
58
|
message,
|
|
40
59
|
timestamp: new Date(),
|
|
41
|
-
context
|
|
60
|
+
context: context !== undefined && redact !== undefined
|
|
61
|
+
? redact(sanitizeLogValue(context))
|
|
62
|
+
: context,
|
|
42
63
|
...(error !== undefined
|
|
43
64
|
? {
|
|
44
|
-
error: serializeLogError(error),
|
|
65
|
+
error: serializeLogError(error, { redact }),
|
|
45
66
|
}
|
|
46
67
|
: {}),
|
|
47
68
|
};
|
|
@@ -53,21 +74,61 @@ export class ConsoleLogger extends BaseLogger {
|
|
|
53
74
|
}
|
|
54
75
|
/**
|
|
55
76
|
* Creates a child logger that inherits the current
|
|
56
|
-
* logger configuration
|
|
77
|
+
* logger configuration.
|
|
78
|
+
*
|
|
79
|
+
* The context received here is the fully merged context
|
|
80
|
+
* (parent persistent context plus child additions) produced
|
|
81
|
+
* by BaseLogger.child().
|
|
57
82
|
*/
|
|
58
83
|
createChild(context) {
|
|
59
|
-
return new ConsoleLogger(
|
|
60
|
-
...this.options
|
|
84
|
+
return new ConsoleLogger({
|
|
85
|
+
...this.options,
|
|
86
|
+
context: undefined,
|
|
87
|
+
}, context);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Merges the ambient execution context (if any) beneath the
|
|
91
|
+
* supplied context. Never throws: a failing storage lookup leaves
|
|
92
|
+
* the context untouched.
|
|
93
|
+
*/
|
|
94
|
+
withExecutionContext(context) {
|
|
95
|
+
const storage = this.options.contextStorage;
|
|
96
|
+
if (!storage)
|
|
97
|
+
return context;
|
|
98
|
+
let execution;
|
|
99
|
+
try {
|
|
100
|
+
execution = storage.get();
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return context;
|
|
104
|
+
}
|
|
105
|
+
if (!execution)
|
|
106
|
+
return context;
|
|
107
|
+
return {
|
|
108
|
+
...loggerContextFromExecution(execution),
|
|
61
109
|
...context,
|
|
62
|
-
}
|
|
110
|
+
};
|
|
63
111
|
}
|
|
64
112
|
/**
|
|
65
113
|
* Writes the log entry as JSON.
|
|
114
|
+
*
|
|
115
|
+
* Serialization is crash-safe: circular references, BigInt
|
|
116
|
+
* values, and throwing toJSON implementations degrade to
|
|
117
|
+
* placeholder strings instead of throwing.
|
|
66
118
|
*/
|
|
67
119
|
writeStructured(entry) {
|
|
68
120
|
const output = {
|
|
69
121
|
level: entry.level,
|
|
70
122
|
message: entry.message,
|
|
123
|
+
...(this.options.service !== undefined
|
|
124
|
+
? { service: this.options.service }
|
|
125
|
+
: {}),
|
|
126
|
+
...(this.options.version !== undefined
|
|
127
|
+
? { version: this.options.version }
|
|
128
|
+
: {}),
|
|
129
|
+
...(this.options.environment !== undefined
|
|
130
|
+
? { environment: this.options.environment }
|
|
131
|
+
: {}),
|
|
71
132
|
...(this.options.timestamps
|
|
72
133
|
? {
|
|
73
134
|
timestamp: entry.timestamp.toISOString(),
|
|
@@ -86,7 +147,7 @@ export class ConsoleLogger extends BaseLogger {
|
|
|
86
147
|
}
|
|
87
148
|
: {}),
|
|
88
149
|
};
|
|
89
|
-
this.writeToConsole(entry.level,
|
|
150
|
+
this.writeToConsole(entry.level, safeLogStringify(output));
|
|
90
151
|
}
|
|
91
152
|
/**
|
|
92
153
|
* Writes a human-readable log entry.
|
|
@@ -108,7 +169,12 @@ export class ConsoleLogger extends BaseLogger {
|
|
|
108
169
|
writeToConsole(level, message) {
|
|
109
170
|
switch (level) {
|
|
110
171
|
case LogLevel.TRACE:
|
|
111
|
-
|
|
172
|
+
/*
|
|
173
|
+
* console.trace prints a stack trace for every call,
|
|
174
|
+
* which makes trace-level logs unreadable. Trace output
|
|
175
|
+
* goes through console.debug (console.log fallback).
|
|
176
|
+
*/
|
|
177
|
+
(console.debug ?? console.log)(message);
|
|
112
178
|
break;
|
|
113
179
|
case LogLevel.DEBUG:
|
|
114
180
|
console.debug(message);
|
|
@@ -170,7 +236,7 @@ export class ConsoleLogger extends BaseLogger {
|
|
|
170
236
|
return value;
|
|
171
237
|
}
|
|
172
238
|
try {
|
|
173
|
-
return JSON.stringify(value);
|
|
239
|
+
return JSON.stringify(sanitizeLogValue(value));
|
|
174
240
|
}
|
|
175
241
|
catch {
|
|
176
242
|
return "[unserializable]";
|