@zudojs/core 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +141 -7
- package/dist/application/application.d.ts +43 -2
- package/dist/application/application.js +111 -13
- package/dist/application/applicationContext.context.d.ts +15 -0
- package/dist/application/applicationContext.context.js +12 -0
- package/dist/application/createApplication.d.ts +78 -0
- package/dist/application/createApplication.js +104 -0
- package/dist/application/index.d.ts +2 -1
- package/dist/application/index.js +2 -1
- package/dist/configuration/configurationManager.manager.d.ts +32 -0
- package/dist/configuration/configurationManager.manager.js +86 -7
- package/dist/configuration/core/configuration.d.ts +60 -15
- package/dist/configuration/core/configuration.js +248 -51
- package/dist/configuration/core/configurationKey.key.d.ts +4 -2
- package/dist/configuration/core/configurationKey.key.js +2 -13
- package/dist/configuration/core/configurationPath.path.d.ts +17 -0
- package/dist/configuration/core/configurationPath.path.js +33 -0
- package/dist/configuration/core/index.d.ts +7 -1
- package/dist/configuration/core/index.js +1 -0
- package/dist/configuration/error/configurationError.error.d.ts +11 -0
- package/dist/configuration/error/configurationError.error.js +29 -1
- package/dist/configuration/error/configurationRedactor.redactor.d.ts +16 -0
- package/dist/configuration/error/configurationRedactor.redactor.js +83 -5
- package/dist/configuration/error/index.d.ts +2 -1
- package/dist/configuration/error/index.js +2 -1
- package/dist/configuration/index.d.ts +1 -1
- package/dist/configuration/loader/configurationLoader.loader.d.ts +47 -9
- package/dist/configuration/loader/configurationLoader.loader.js +107 -26
- package/dist/configuration/loader/index.d.ts +1 -1
- package/dist/configuration/loader/index.js +1 -1
- package/dist/configuration/registry/configurationProvider.provider.d.ts +26 -1
- package/dist/configuration/registry/configurationProvider.provider.js +33 -7
- package/dist/configuration/registry/configurationRegistry.registry.js +2 -1
- package/dist/configuration/schema/configurationSchema.schema.d.ts +0 -4
- package/dist/configuration/schema/configurationSchema.schema.js +11 -32
- package/dist/configuration/schema/configurationValidation.validator.d.ts +14 -2
- package/dist/configuration/schema/configurationValidation.validator.js +55 -7
- package/dist/configuration/schema/index.d.ts +1 -1
- package/dist/configuration/schema/index.js +1 -1
- package/dist/container/container.d.ts +52 -5
- package/dist/container/container.js +110 -33
- package/dist/container/index.d.ts +1 -1
- package/dist/container/index.js +1 -1
- package/dist/container/scope.d.ts +7 -6
- package/dist/context/core/contextAliases.deprecated.d.ts +32 -0
- package/dist/context/core/contextAliases.deprecated.js +6 -0
- package/dist/context/core/executionContext.context.d.ts +8 -0
- package/dist/context/core/executionContext.context.js +38 -15
- package/dist/context/core/index.d.ts +2 -2
- package/dist/context/core/index.js +2 -2
- package/dist/context/index.d.ts +20 -0
- package/dist/context/index.js +20 -0
- package/dist/context/provider/contextProvider.provider.d.ts +7 -4
- package/dist/context/provider/contextProvider.provider.js +9 -6
- package/dist/context/provider/contextStorage.storage.d.ts +47 -7
- package/dist/context/provider/contextStorage.storage.js +54 -12
- package/dist/context/provider/defaultContextStorage.storage.d.ts +18 -0
- package/dist/context/provider/defaultContextStorage.storage.js +20 -0
- package/dist/context/provider/index.d.ts +2 -1
- package/dist/context/provider/index.js +1 -0
- package/dist/errors/exceptions.d.ts +22 -0
- package/dist/errors/exceptions.js +38 -1
- package/dist/errors/frameworkError.error.d.ts +6 -9
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +14 -0
- package/dist/lifecycle/core/index.d.ts +1 -1
- package/dist/lifecycle/core/index.js +1 -1
- package/dist/lifecycle/core/lifecycle.d.ts +47 -2
- package/dist/lifecycle/core/lifecycle.js +251 -85
- package/dist/lifecycle/core/lifecycleRegistry.registry.d.ts +8 -0
- package/dist/lifecycle/core/lifecycleRegistry.registry.js +20 -1
- package/dist/lifecycle/manager/lifecycleManager.manager.d.ts +21 -2
- package/dist/lifecycle/manager/lifecycleManager.manager.js +62 -99
- package/dist/lifecycle/scope/lifecycleScope.scope.d.ts +22 -1
- package/dist/lifecycle/scope/lifecycleScope.scope.js +85 -17
- package/dist/logging/console/consoleLogger.logger.d.ts +20 -1
- package/dist/logging/console/consoleLogger.logger.js +77 -11
- package/dist/logging/console/loggerFactory.factory.d.ts +6 -5
- package/dist/logging/console/loggerFactory.factory.js +1 -7
- package/dist/logging/core/index.d.ts +4 -3
- package/dist/logging/core/index.js +4 -3
- package/dist/logging/core/logEntry.entry.d.ts +41 -3
- package/dist/logging/core/logEntry.entry.js +114 -4
- package/dist/logging/core/logLevel.level.d.ts +18 -0
- package/dist/logging/core/logLevel.level.js +25 -1
- package/dist/logging/core/logRedaction.redaction.d.ts +38 -0
- package/dist/logging/core/logRedaction.redaction.js +19 -0
- package/dist/logging/core/logger.d.ts +14 -11
- package/dist/logging/core/logger.js +31 -6
- package/dist/logging/core/loggerContext.context.d.ts +12 -0
- package/dist/logging/core/loggerContext.context.js +19 -0
- package/dist/logging/core/loggerOptions.options.d.ts +17 -0
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +0 -6
- package/dist/modules/module.d.ts +7 -1
- package/dist/modules/moduleContext.context.d.ts +41 -7
- package/dist/modules/moduleContext.context.js +31 -8
- package/dist/modules/moduleDefinition.definition.d.ts +11 -7
- package/dist/modules/moduleDefinition.definition.js +41 -8
- package/dist/modules/moduleDependency/index.d.ts +2 -2
- package/dist/modules/moduleDependency/index.js +1 -1
- package/dist/modules/moduleDependency/moduleDependency.graph.d.ts +19 -2
- package/dist/modules/moduleDependency/moduleDependency.graph.js +122 -8
- package/dist/modules/moduleDependency/moduleDependency.ordering.d.ts +8 -0
- package/dist/modules/moduleDependency/moduleDependency.ordering.js +85 -57
- package/dist/modules/moduleDependency/moduleDependency.type.d.ts +28 -1
- package/dist/modules/moduleError/index.d.ts +1 -1
- package/dist/modules/moduleError/index.js +1 -1
- package/dist/modules/moduleError/moduleError.dependency.d.ts +11 -0
- package/dist/modules/moduleError/moduleError.dependency.js +15 -0
- package/dist/modules/moduleLifecycle/index.d.ts +5 -2
- package/dist/modules/moduleLifecycle/index.js +4 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.d.ts +44 -6
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.js +153 -9
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.d.ts +30 -5
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.js +130 -10
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.d.ts +65 -28
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.js +15 -4
- package/dist/modules/moduleLoader/moduleLoader.loader.d.ts +39 -5
- package/dist/modules/moduleLoader/moduleLoader.loader.js +123 -50
- package/dist/modules/moduleLoader/moduleLoader.type.d.ts +4 -2
- package/dist/modules/moduleLoader/moduleLoader.type.js +10 -3
- package/dist/modules/moduleMetadata.metadata.js +15 -5
- package/dist/modules/moduleRegistry/index.d.ts +1 -1
- package/dist/modules/moduleRegistry/moduleRegistry.registry.d.ts +2 -2
- package/dist/modules/moduleRegistry/moduleRegistry.registry.js +38 -6
- package/dist/modules/moduleRegistry/moduleRegistry.type.d.ts +18 -1
- package/dist/runtime/index.d.ts +17 -15
- package/dist/runtime/index.js +14 -10
- package/dist/runtime/runtime.d.ts +135 -33
- package/dist/runtime/runtime.js +344 -114
- package/dist/runtime/runtimeBootstrap/index.d.ts +2 -1
- package/dist/runtime/runtimeBootstrap/index.js +1 -1
- package/dist/runtime/runtimeBootstrap/pipeline/index.d.ts +2 -2
- package/dist/runtime/runtimeBootstrap/pipeline/index.js +1 -2
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.d.ts +41 -15
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.js +98 -76
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.d.ts +7 -4
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.js +87 -59
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.d.ts +10 -4
- package/dist/runtime/runtimeContext/index.d.ts +3 -5
- package/dist/runtime/runtimeContext/index.js +2 -4
- package/dist/runtime/runtimeContext/runtimeContext.factory.d.ts +10 -4
- package/dist/runtime/runtimeContext/runtimeContext.factory.js +30 -7
- package/dist/runtime/runtimeContext/runtimeContext.type.d.ts +36 -47
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.d.ts +5 -0
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.js +6 -4
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.d.ts +4 -0
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.js +7 -9
- package/dist/runtime/runtimeEnvironment/index.d.ts +2 -2
- package/dist/runtime/runtimeEnvironment/index.js +1 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.d.ts +20 -17
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.js +20 -13
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.d.ts +12 -1
- package/dist/runtime/runtimeError/index.d.ts +3 -3
- package/dist/runtime/runtimeError/index.js +1 -1
- package/dist/runtime/runtimeError/runtimeError.base.d.ts +15 -18
- package/dist/runtime/runtimeError/runtimeError.base.js +38 -36
- package/dist/runtime/runtimeError/runtimeError.lifecycle.d.ts +23 -8
- package/dist/runtime/runtimeError/runtimeError.lifecycle.js +31 -7
- package/dist/runtime/runtimeError/runtimeError.specialized.d.ts +1 -1
- package/dist/runtime/runtimeError/runtimeError.specialized.js +1 -1
- package/dist/runtime/runtimeError/runtimeError.type.d.ts +5 -9
- package/dist/runtime/runtimeLogger.d.ts +2 -2
- package/dist/runtime/runtimeLogger.js +3 -3
- package/dist/runtime/runtimeOptions/index.d.ts +1 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.d.ts +1 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.js +2 -0
- package/dist/runtime/runtimeOptions/runtimeOptions.resolver.js +5 -2
- package/dist/runtime/runtimeOptions/runtimeOptions.type.d.ts +45 -16
- package/dist/runtime/runtimeOptions/runtimeOptions.validation.js +0 -1
- package/dist/runtime/runtimeShutdown/index.d.ts +3 -2
- package/dist/runtime/runtimeShutdown/index.js +2 -2
- package/dist/runtime/runtimeShutdown/pipeline/index.d.ts +2 -1
- package/dist/runtime/runtimeShutdown/pipeline/index.js +1 -1
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.d.ts +37 -7
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.js +77 -51
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.d.ts +8 -16
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.js +85 -87
- package/dist/runtime/runtimeShutdown/runtimeShutdown.type.d.ts +9 -5
- package/dist/runtime/runtimeSignals/index.d.ts +8 -0
- package/dist/runtime/runtimeSignals/index.js +7 -0
- package/dist/runtime/runtimeSignals/runtimeSignals.d.ts +93 -0
- package/dist/runtime/runtimeSignals/runtimeSignals.js +149 -0
- package/dist/runtime/runtimeState.state.d.ts +32 -14
- package/dist/runtime/runtimeState.state.js +34 -27
- package/dist/runtime/runtimeTimeout.d.ts +40 -0
- package/dist/runtime/runtimeTimeout.js +42 -0
- package/package.json +21 -15
- package/dist/.tsbuildinfo +0 -1
- package/dist/application/application.d.ts.map +0 -1
- package/dist/application/application.js.map +0 -1
- package/dist/application/applicationContext.context.d.ts.map +0 -1
- package/dist/application/applicationContext.context.js.map +0 -1
- package/dist/application/applicationState.state.d.ts.map +0 -1
- package/dist/application/applicationState.state.js.map +0 -1
- package/dist/application/index.d.ts.map +0 -1
- package/dist/application/index.js.map +0 -1
- package/dist/configuration/configurationManager.manager.d.ts.map +0 -1
- package/dist/configuration/configurationManager.manager.js.map +0 -1
- package/dist/configuration/core/configuration.d.ts.map +0 -1
- package/dist/configuration/core/configuration.js.map +0 -1
- package/dist/configuration/core/configurationKey.key.d.ts.map +0 -1
- package/dist/configuration/core/configurationKey.key.js.map +0 -1
- package/dist/configuration/core/configurationSource.source.d.ts.map +0 -1
- package/dist/configuration/core/configurationSource.source.js.map +0 -1
- package/dist/configuration/core/index.d.ts.map +0 -1
- package/dist/configuration/core/index.js.map +0 -1
- package/dist/configuration/error/configurationError.error.d.ts.map +0 -1
- package/dist/configuration/error/configurationError.error.js.map +0 -1
- package/dist/configuration/error/configurationRedactor.redactor.d.ts.map +0 -1
- package/dist/configuration/error/configurationRedactor.redactor.js.map +0 -1
- package/dist/configuration/error/index.d.ts.map +0 -1
- package/dist/configuration/error/index.js.map +0 -1
- package/dist/configuration/events/configurationEvents.events.d.ts.map +0 -1
- package/dist/configuration/events/configurationEvents.events.js.map +0 -1
- package/dist/configuration/events/index.d.ts.map +0 -1
- package/dist/configuration/events/index.js.map +0 -1
- package/dist/configuration/index.d.ts.map +0 -1
- package/dist/configuration/index.js.map +0 -1
- package/dist/configuration/loader/configurationLoader.loader.d.ts.map +0 -1
- package/dist/configuration/loader/configurationLoader.loader.js.map +0 -1
- package/dist/configuration/loader/index.d.ts.map +0 -1
- package/dist/configuration/loader/index.js.map +0 -1
- package/dist/configuration/registry/configurationProvider.provider.d.ts.map +0 -1
- package/dist/configuration/registry/configurationProvider.provider.js.map +0 -1
- package/dist/configuration/registry/configurationRegistry.registry.d.ts.map +0 -1
- package/dist/configuration/registry/configurationRegistry.registry.js.map +0 -1
- package/dist/configuration/registry/index.d.ts.map +0 -1
- package/dist/configuration/registry/index.js.map +0 -1
- package/dist/configuration/schema/configurationSchema.schema.d.ts.map +0 -1
- package/dist/configuration/schema/configurationSchema.schema.js.map +0 -1
- package/dist/configuration/schema/configurationValidation.validator.d.ts.map +0 -1
- package/dist/configuration/schema/configurationValidation.validator.js.map +0 -1
- package/dist/configuration/schema/index.d.ts.map +0 -1
- package/dist/configuration/schema/index.js.map +0 -1
- package/dist/container/container.d.ts.map +0 -1
- package/dist/container/container.js.map +0 -1
- package/dist/container/index.d.ts.map +0 -1
- package/dist/container/index.js.map +0 -1
- package/dist/container/provider.d.ts.map +0 -1
- package/dist/container/provider.js.map +0 -1
- package/dist/container/scope.d.ts.map +0 -1
- package/dist/container/scope.js.map +0 -1
- package/dist/container/token.d.ts.map +0 -1
- package/dist/container/token.js.map +0 -1
- package/dist/context/core/context.d.ts +0 -95
- package/dist/context/core/context.d.ts.map +0 -1
- package/dist/context/core/context.js +0 -103
- package/dist/context/core/context.js.map +0 -1
- package/dist/context/core/contextKey.key.d.ts.map +0 -1
- package/dist/context/core/contextKey.key.js.map +0 -1
- package/dist/context/core/executionContext.context.d.ts.map +0 -1
- package/dist/context/core/executionContext.context.js.map +0 -1
- package/dist/context/core/index.d.ts.map +0 -1
- package/dist/context/core/index.js.map +0 -1
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js.map +0 -1
- package/dist/context/provider/contextProvider.provider.d.ts.map +0 -1
- package/dist/context/provider/contextProvider.provider.js.map +0 -1
- package/dist/context/provider/contextStorage.storage.d.ts.map +0 -1
- package/dist/context/provider/contextStorage.storage.js.map +0 -1
- package/dist/context/provider/index.d.ts.map +0 -1
- package/dist/context/provider/index.js.map +0 -1
- package/dist/context/snapshot/contextSnapshot.snapshot.d.ts.map +0 -1
- package/dist/context/snapshot/contextSnapshot.snapshot.js.map +0 -1
- package/dist/context/snapshot/index.d.ts.map +0 -1
- package/dist/context/snapshot/index.js.map +0 -1
- package/dist/context/values/contextValues.values.d.ts.map +0 -1
- package/dist/context/values/contextValues.values.js.map +0 -1
- package/dist/context/values/index.d.ts.map +0 -1
- package/dist/context/values/index.js.map +0 -1
- package/dist/contracts/adapter.d.ts.map +0 -1
- package/dist/contracts/adapter.js.map +0 -1
- package/dist/contracts/disposable.d.ts.map +0 -1
- package/dist/contracts/disposable.js.map +0 -1
- package/dist/contracts/handler.d.ts.map +0 -1
- package/dist/contracts/handler.js.map +0 -1
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/contracts/index.js.map +0 -1
- package/dist/errors/errorCode.code.d.ts.map +0 -1
- package/dist/errors/errorCode.code.js.map +0 -1
- package/dist/errors/exceptions.d.ts.map +0 -1
- package/dist/errors/exceptions.js.map +0 -1
- package/dist/errors/frameworkError.error.d.ts.map +0 -1
- package/dist/errors/frameworkError.error.js.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lifecycle/core/index.d.ts.map +0 -1
- package/dist/lifecycle/core/index.js.map +0 -1
- package/dist/lifecycle/core/lifecycle.d.ts.map +0 -1
- package/dist/lifecycle/core/lifecycle.js.map +0 -1
- package/dist/lifecycle/core/lifecycleHook.hook.d.ts.map +0 -1
- package/dist/lifecycle/core/lifecycleHook.hook.js.map +0 -1
- package/dist/lifecycle/core/lifecycleRegistry.registry.d.ts.map +0 -1
- package/dist/lifecycle/core/lifecycleRegistry.registry.js.map +0 -1
- package/dist/lifecycle/core/lifecycleState.state.d.ts +0 -2
- package/dist/lifecycle/core/lifecycleState.state.d.ts.map +0 -1
- package/dist/lifecycle/core/lifecycleState.state.js +0 -2
- package/dist/lifecycle/core/lifecycleState.state.js.map +0 -1
- package/dist/lifecycle/index.d.ts.map +0 -1
- package/dist/lifecycle/index.js.map +0 -1
- package/dist/lifecycle/manager/index.d.ts.map +0 -1
- package/dist/lifecycle/manager/index.js.map +0 -1
- package/dist/lifecycle/manager/lifecycleManager.manager.d.ts.map +0 -1
- package/dist/lifecycle/manager/lifecycleManager.manager.js.map +0 -1
- package/dist/lifecycle/scope/index.d.ts.map +0 -1
- package/dist/lifecycle/scope/index.js.map +0 -1
- package/dist/lifecycle/scope/lifecycleScope.scope.d.ts.map +0 -1
- package/dist/lifecycle/scope/lifecycleScope.scope.js.map +0 -1
- package/dist/logging/console/consoleLogger.logger.d.ts.map +0 -1
- package/dist/logging/console/consoleLogger.logger.js.map +0 -1
- package/dist/logging/console/index.d.ts.map +0 -1
- package/dist/logging/console/index.js.map +0 -1
- package/dist/logging/console/loggerFactory.factory.d.ts.map +0 -1
- package/dist/logging/console/loggerFactory.factory.js.map +0 -1
- package/dist/logging/core/index.d.ts.map +0 -1
- package/dist/logging/core/index.js.map +0 -1
- package/dist/logging/core/logEntry.entry.d.ts.map +0 -1
- package/dist/logging/core/logEntry.entry.js.map +0 -1
- package/dist/logging/core/logLevel.level.d.ts.map +0 -1
- package/dist/logging/core/logLevel.level.js.map +0 -1
- package/dist/logging/core/logger.d.ts.map +0 -1
- package/dist/logging/core/logger.js.map +0 -1
- package/dist/logging/core/loggerContext.context.d.ts.map +0 -1
- package/dist/logging/core/loggerContext.context.js.map +0 -1
- package/dist/logging/core/loggerOptions.options.d.ts.map +0 -1
- package/dist/logging/core/loggerOptions.options.js.map +0 -1
- package/dist/logging/index.d.ts.map +0 -1
- package/dist/logging/index.js.map +0 -1
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/modules/index.js.map +0 -1
- package/dist/modules/module.d.ts.map +0 -1
- package/dist/modules/module.js.map +0 -1
- package/dist/modules/moduleContext.context.d.ts.map +0 -1
- package/dist/modules/moduleContext.context.js.map +0 -1
- package/dist/modules/moduleDefinition.definition.d.ts.map +0 -1
- package/dist/modules/moduleDefinition.definition.js.map +0 -1
- package/dist/modules/moduleDependency/index.d.ts.map +0 -1
- package/dist/modules/moduleDependency/index.js.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.graph.d.ts.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.graph.js.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.ordering.d.ts.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.ordering.js.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.type.d.ts.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.type.js.map +0 -1
- package/dist/modules/moduleError/index.d.ts.map +0 -1
- package/dist/modules/moduleError/index.js.map +0 -1
- package/dist/modules/moduleError/moduleError.base.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.base.js.map +0 -1
- package/dist/modules/moduleError/moduleError.dependency.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.dependency.js.map +0 -1
- package/dist/modules/moduleError/moduleError.helpers.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.helpers.js.map +0 -1
- package/dist/modules/moduleError/moduleError.lifecycle.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.lifecycle.js.map +0 -1
- package/dist/modules/moduleError/moduleError.registration.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.registration.js.map +0 -1
- package/dist/modules/moduleLifecycle/index.d.ts.map +0 -1
- package/dist/modules/moduleLifecycle/index.js.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.d.ts.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.js.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.d.ts.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.js.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.d.ts.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.js.map +0 -1
- package/dist/modules/moduleLoader/index.d.ts.map +0 -1
- package/dist/modules/moduleLoader/index.js.map +0 -1
- package/dist/modules/moduleLoader/moduleLoader.loader.d.ts.map +0 -1
- package/dist/modules/moduleLoader/moduleLoader.loader.js.map +0 -1
- package/dist/modules/moduleLoader/moduleLoader.type.d.ts.map +0 -1
- package/dist/modules/moduleLoader/moduleLoader.type.js.map +0 -1
- package/dist/modules/moduleMetadata.metadata.d.ts.map +0 -1
- package/dist/modules/moduleMetadata.metadata.js.map +0 -1
- package/dist/modules/moduleRegistry/index.d.ts.map +0 -1
- package/dist/modules/moduleRegistry/index.js.map +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.registry.d.ts.map +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.registry.js.map +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.type.d.ts.map +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.type.js.map +0 -1
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/runtime.d.ts.map +0 -1
- package/dist/runtime/runtime.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/index.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/index.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/index.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/index.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.d.ts +0 -6
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.js +0 -27
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.js.map +0 -1
- package/dist/runtime/runtimeContext/index.d.ts.map +0 -1
- package/dist/runtime/runtimeContext/index.js.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.core.d.ts +0 -38
- package/dist/runtime/runtimeContext/runtimeContext.core.d.ts.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.core.js +0 -99
- package/dist/runtime/runtimeContext/runtimeContext.core.js.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.factory.d.ts.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.factory.js.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.type.d.ts.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.type.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/index.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/index.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.detection.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.detection.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/index.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/index.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.js.map +0 -1
- package/dist/runtime/runtimeError/index.d.ts.map +0 -1
- package/dist/runtime/runtimeError/index.js.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.base.d.ts.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.base.js.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.lifecycle.d.ts.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.lifecycle.js.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.specialized.d.ts.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.specialized.js.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.type.d.ts.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.type.js.map +0 -1
- package/dist/runtime/runtimeLogger.d.ts.map +0 -1
- package/dist/runtime/runtimeLogger.js.map +0 -1
- package/dist/runtime/runtimeManager/index.d.ts +0 -12
- package/dist/runtime/runtimeManager/index.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/index.js +0 -11
- package/dist/runtime/runtimeManager/index.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.core.d.ts +0 -31
- package/dist/runtime/runtimeManager/runtimeManager.core.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.core.js +0 -136
- package/dist/runtime/runtimeManager/runtimeManager.core.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.error.d.ts +0 -14
- package/dist/runtime/runtimeManager/runtimeManager.error.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.error.js +0 -21
- package/dist/runtime/runtimeManager/runtimeManager.error.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.factory.d.ts +0 -7
- package/dist/runtime/runtimeManager/runtimeManager.factory.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.factory.js +0 -8
- package/dist/runtime/runtimeManager/runtimeManager.factory.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.lifecycle.d.ts +0 -16
- package/dist/runtime/runtimeManager/runtimeManager.lifecycle.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.lifecycle.js +0 -49
- package/dist/runtime/runtimeManager/runtimeManager.lifecycle.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.type.d.ts +0 -54
- package/dist/runtime/runtimeManager/runtimeManager.type.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.type.js +0 -2
- package/dist/runtime/runtimeManager/runtimeManager.type.js.map +0 -1
- package/dist/runtime/runtimeOptions/index.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/index.js.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.js.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.resolver.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.resolver.js.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.type.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.type.js.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.validation.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.validation.js.map +0 -1
- package/dist/runtime/runtimeShutdown/index.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/index.js.map +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/index.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/index.js.map +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.js.map +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.js.map +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.type.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.type.js.map +0 -1
- package/dist/runtime/runtimeState.state.d.ts.map +0 -1
- package/dist/runtime/runtimeState.state.js.map +0 -1
package/dist/runtime/runtime.js
CHANGED
|
@@ -1,179 +1,409 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
super(message, { phase: "runtime" });
|
|
13
|
-
this.moduleIds = Object.freeze([...moduleIds]);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
import { getDefaultContextStorage } from "../context/provider/defaultContextStorage.storage.js";
|
|
2
|
+
import { RuntimeState, assertRuntimeTransition, createRuntimeStateSnapshot, isRuntimeTerminal, } from "./runtimeState.state.js";
|
|
3
|
+
import { createRuntimeExecutionContext, createRuntimeIdentity, } from "./runtimeContext/index.js";
|
|
4
|
+
import { createRuntimeEnvironment } from "./runtimeEnvironment/index.js";
|
|
5
|
+
import { resolveRuntimeOptions } from "./runtimeOptions/index.js";
|
|
6
|
+
import { DefaultRuntimeBootstrap } from "./runtimeBootstrap/runtimeBootstrap.core.js";
|
|
7
|
+
import { DefaultRuntimeShutdown } from "./runtimeShutdown/runtimeShutdown.core.js";
|
|
8
|
+
import { RuntimeSignalManager } from "./runtimeSignals/runtimeSignals.js";
|
|
9
|
+
import { InvalidRuntimeStateError } from "./runtimeError/runtimeError.lifecycle.js";
|
|
10
|
+
import { RuntimeNotReadyError } from "./runtimeError/runtimeError.specialized.js";
|
|
11
|
+
import { RuntimeTimeoutError } from "./runtimeError/runtimeError.specialized.js";
|
|
16
12
|
/**
|
|
17
13
|
* Default runtime implementation.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
14
|
+
*
|
|
15
|
+
* Owns the runtime state machine and identity, and orchestrates the
|
|
16
|
+
* bootstrap and shutdown services, the module subsystem, and process
|
|
17
|
+
* signal handling.
|
|
20
18
|
*/
|
|
21
19
|
export class DefaultRuntime {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
20
|
+
_options;
|
|
21
|
+
_identity;
|
|
22
|
+
_context;
|
|
23
|
+
_contextStorage;
|
|
24
|
+
_environment;
|
|
25
|
+
_bootstrap;
|
|
26
|
+
_shutdown;
|
|
27
|
+
_signals;
|
|
28
|
+
_application;
|
|
29
|
+
_configuration;
|
|
30
|
+
_logger;
|
|
31
|
+
_moduleRegistry;
|
|
32
|
+
_moduleLoader;
|
|
33
|
+
_moduleLifecycle;
|
|
34
|
+
_state = RuntimeState.CREATED;
|
|
35
|
+
_timing;
|
|
36
|
+
_error;
|
|
37
|
+
_startPromise;
|
|
38
|
+
_stopPromise;
|
|
39
|
+
_unwound = false;
|
|
40
|
+
constructor(dependencies, options = {}) {
|
|
41
|
+
this._options = resolveRuntimeOptions(options);
|
|
42
|
+
this._application = dependencies.application;
|
|
43
|
+
this._configuration = dependencies.configuration;
|
|
44
|
+
this._logger = dependencies.logger;
|
|
45
|
+
this._moduleRegistry = dependencies.moduleRegistry;
|
|
46
|
+
this._moduleLoader = dependencies.moduleLoader;
|
|
47
|
+
this._moduleLifecycle = dependencies.moduleLifecycle;
|
|
48
|
+
this._identity = createRuntimeIdentity({
|
|
49
|
+
name: this._options.name,
|
|
50
|
+
mode: this._options.mode,
|
|
51
|
+
role: this._options.role,
|
|
52
|
+
});
|
|
53
|
+
this._timing = Object.freeze({ createdAt: this._identity.createdAt });
|
|
54
|
+
this._contextStorage =
|
|
55
|
+
dependencies.contextStorage ?? getDefaultContextStorage();
|
|
56
|
+
this._environment =
|
|
57
|
+
dependencies.environment ??
|
|
58
|
+
createRuntimeEnvironment({
|
|
59
|
+
mode: this._options.mode,
|
|
60
|
+
role: this._options.role,
|
|
61
|
+
variables: this._options.environment.variables,
|
|
62
|
+
isCI: this._options.environment.isCI,
|
|
63
|
+
isContainer: this._options.environment.isContainer,
|
|
64
|
+
});
|
|
65
|
+
this._context = createRuntimeExecutionContext(this._identity, this._options.metadata);
|
|
66
|
+
this._bootstrap =
|
|
67
|
+
dependencies.bootstrap ??
|
|
68
|
+
new DefaultRuntimeBootstrap({
|
|
69
|
+
identity: this._identity,
|
|
70
|
+
environment: this._environment,
|
|
71
|
+
moduleLoader: this._moduleLoader,
|
|
72
|
+
moduleRegistry: this._moduleRegistry,
|
|
73
|
+
moduleLifecycle: this._moduleLifecycle,
|
|
74
|
+
logger: this._logger,
|
|
75
|
+
}, this._options);
|
|
76
|
+
this._shutdown =
|
|
77
|
+
dependencies.shutdown ??
|
|
78
|
+
new DefaultRuntimeShutdown({
|
|
79
|
+
identity: this._identity,
|
|
80
|
+
environment: this._environment,
|
|
81
|
+
moduleRegistry: this._moduleRegistry,
|
|
82
|
+
moduleLifecycle: this._moduleLifecycle,
|
|
83
|
+
logger: this._logger,
|
|
84
|
+
}, this._options);
|
|
85
|
+
this._signals = new RuntimeSignalManager({
|
|
86
|
+
signals: this._options.signals,
|
|
87
|
+
target: dependencies.signalTarget,
|
|
88
|
+
logger: this._logger,
|
|
89
|
+
});
|
|
42
90
|
}
|
|
43
91
|
get state() {
|
|
44
92
|
return this._state;
|
|
45
93
|
}
|
|
94
|
+
get context() {
|
|
95
|
+
return this._context;
|
|
96
|
+
}
|
|
97
|
+
get contextStorage() {
|
|
98
|
+
return this._contextStorage;
|
|
99
|
+
}
|
|
100
|
+
get timing() {
|
|
101
|
+
return this._timing;
|
|
102
|
+
}
|
|
103
|
+
get environment() {
|
|
104
|
+
return this._environment;
|
|
105
|
+
}
|
|
106
|
+
get identity() {
|
|
107
|
+
return this._identity;
|
|
108
|
+
}
|
|
109
|
+
get options() {
|
|
110
|
+
return this._options;
|
|
111
|
+
}
|
|
112
|
+
get ready() {
|
|
113
|
+
return this._state === RuntimeState.READY;
|
|
114
|
+
}
|
|
115
|
+
get stopped() {
|
|
116
|
+
return this._state === RuntimeState.STOPPED;
|
|
117
|
+
}
|
|
118
|
+
get failed() {
|
|
119
|
+
return this._state === RuntimeState.FAILED;
|
|
120
|
+
}
|
|
121
|
+
get signalHandlersRegistered() {
|
|
122
|
+
return this._signals.registered;
|
|
123
|
+
}
|
|
46
124
|
async start() {
|
|
47
|
-
if (this._state ===
|
|
125
|
+
if (this._state === RuntimeState.READY)
|
|
48
126
|
return;
|
|
49
|
-
if (this.
|
|
50
|
-
return this.
|
|
51
|
-
if (this._state
|
|
52
|
-
throw new
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
127
|
+
if (this._startPromise)
|
|
128
|
+
return this._startPromise;
|
|
129
|
+
if (this._state !== RuntimeState.CREATED) {
|
|
130
|
+
throw new InvalidRuntimeStateError(this._state === RuntimeState.STOPPING
|
|
131
|
+
? "Cannot start the runtime while it is stopping."
|
|
132
|
+
: this._state === RuntimeState.STOPPED
|
|
133
|
+
? "A stopped runtime cannot be started again."
|
|
134
|
+
: "A failed runtime cannot be started again.", this.errorContext({ operation: "start", state: this._state }));
|
|
135
|
+
}
|
|
136
|
+
this._startPromise = this.inContext(() => this.performStart());
|
|
58
137
|
try {
|
|
59
|
-
await this.
|
|
138
|
+
await this._startPromise;
|
|
60
139
|
}
|
|
61
140
|
finally {
|
|
62
|
-
this.
|
|
141
|
+
this._startPromise = undefined;
|
|
63
142
|
}
|
|
64
143
|
}
|
|
65
144
|
async stop() {
|
|
66
|
-
if (this._state ===
|
|
145
|
+
if (this._state === RuntimeState.STOPPED)
|
|
67
146
|
return;
|
|
68
|
-
if (this.
|
|
69
|
-
return this.
|
|
70
|
-
if (this._state ===
|
|
71
|
-
|
|
72
|
-
|
|
147
|
+
if (this._stopPromise)
|
|
148
|
+
return this._stopPromise;
|
|
149
|
+
if (this._state === RuntimeState.BOOTSTRAPPING && this._startPromise) {
|
|
150
|
+
// A stop requested mid-bootstrap waits for bootstrap to settle,
|
|
151
|
+
// then unwinds whatever it produced.
|
|
152
|
+
await this._startPromise.catch(() => undefined);
|
|
153
|
+
return this.stop();
|
|
154
|
+
}
|
|
155
|
+
if (this._state === RuntimeState.CREATED) {
|
|
156
|
+
this.transitionTo(RuntimeState.STOPPED, "Runtime stopped before start.");
|
|
73
157
|
return;
|
|
74
158
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
159
|
+
this._stopPromise = this.inContext(() => this._state === RuntimeState.FAILED ? this.unwind() : this.performStop());
|
|
160
|
+
try {
|
|
161
|
+
await this._stopPromise;
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
this._stopPromise = undefined;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
fail(error) {
|
|
168
|
+
if (isRuntimeTerminal(this._state))
|
|
78
169
|
return;
|
|
79
|
-
this.
|
|
170
|
+
this._error = error;
|
|
171
|
+
this.transitionTo(RuntimeState.FAILED, "Runtime marked as failed.");
|
|
172
|
+
this._signals.unregister();
|
|
173
|
+
}
|
|
174
|
+
async dispose() {
|
|
80
175
|
try {
|
|
81
|
-
await this.
|
|
176
|
+
await this.stop();
|
|
82
177
|
}
|
|
83
178
|
finally {
|
|
84
|
-
this.
|
|
179
|
+
this._signals.unregister();
|
|
85
180
|
}
|
|
86
181
|
}
|
|
87
182
|
async performStart() {
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
183
|
+
this.transitionTo(RuntimeState.BOOTSTRAPPING, "Runtime startup initiated.");
|
|
184
|
+
this._error = undefined;
|
|
185
|
+
this._signals.register({
|
|
186
|
+
onSignal: (signal) => this.handleSignal(signal),
|
|
187
|
+
onUncaughtException: (error) => this.handleFatal("uncaughtException", error),
|
|
188
|
+
onUnhandledRejection: (reason) => this.handleFatal("unhandledRejection", reason),
|
|
189
|
+
});
|
|
90
190
|
try {
|
|
91
|
-
this.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
throw new
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
this.
|
|
101
|
-
this.logger.info("Application runtime is ready.");
|
|
191
|
+
const result = await this._bootstrap.bootstrap();
|
|
192
|
+
if (this._state !== RuntimeState.BOOTSTRAPPING) {
|
|
193
|
+
// fail() was called while bootstrapping: unwind what started.
|
|
194
|
+
await this.unwind();
|
|
195
|
+
throw new InvalidRuntimeStateError("Runtime was marked failed during bootstrap.", this.errorContext({ operation: "start", state: this._state }));
|
|
196
|
+
}
|
|
197
|
+
if (!result.success) {
|
|
198
|
+
this._logger.warn("Runtime became ready with module errors (continueOn*Error).", this.logContext({ errors: result.errors.length }));
|
|
199
|
+
}
|
|
200
|
+
this.transitionTo(RuntimeState.READY, "Runtime startup completed.");
|
|
102
201
|
}
|
|
103
202
|
catch (error) {
|
|
104
|
-
this.error
|
|
105
|
-
this.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
catch (cleanupError) {
|
|
112
|
-
this.logger.error("Runtime startup cleanup failed.", {
|
|
113
|
-
error: cleanupError,
|
|
114
|
-
});
|
|
203
|
+
this.fail(error);
|
|
204
|
+
this._logger.error("Runtime failed to start.", error, this.logContext());
|
|
205
|
+
// The module subsystem has already rolled back when the module
|
|
206
|
+
// lifecycle manager threw; a timed-out bootstrap is still
|
|
207
|
+
// running and must not be unwound concurrently.
|
|
208
|
+
if (!(error instanceof RuntimeTimeoutError)) {
|
|
209
|
+
await this.unwind();
|
|
115
210
|
}
|
|
116
211
|
throw error;
|
|
117
212
|
}
|
|
118
213
|
}
|
|
119
214
|
async performStop() {
|
|
120
|
-
this.
|
|
215
|
+
this.transitionTo(RuntimeState.STOPPING, "Runtime shutdown initiated.");
|
|
121
216
|
try {
|
|
122
|
-
this.
|
|
123
|
-
|
|
124
|
-
this.
|
|
125
|
-
|
|
126
|
-
|
|
217
|
+
await this.runShutdown();
|
|
218
|
+
// fail() may have been called while stopping; stay FAILED.
|
|
219
|
+
if (this._state === RuntimeState.STOPPING) {
|
|
220
|
+
this.transitionTo(RuntimeState.STOPPED, "Runtime shutdown completed.");
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
this.recordTiming({ stoppedAt: new Date() });
|
|
224
|
+
}
|
|
127
225
|
}
|
|
128
226
|
catch (error) {
|
|
129
|
-
this.error
|
|
130
|
-
this.
|
|
131
|
-
this._state = "failed";
|
|
132
|
-
this.logger.error("Application runtime failed to stop cleanly.", {
|
|
133
|
-
error,
|
|
134
|
-
});
|
|
227
|
+
this.fail(error);
|
|
228
|
+
this._logger.error("Runtime failed to stop cleanly.", error, this.logContext());
|
|
135
229
|
throw error;
|
|
136
230
|
}
|
|
231
|
+
finally {
|
|
232
|
+
this._signals.unregister();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Best-effort module unwinding used after a failure. Errors are
|
|
237
|
+
* logged and swallowed; the runtime stays FAILED.
|
|
238
|
+
*/
|
|
239
|
+
async unwind() {
|
|
240
|
+
if (this._unwound)
|
|
241
|
+
return;
|
|
242
|
+
try {
|
|
243
|
+
await this.runShutdown();
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
this._logger.error("Runtime cleanup after failure reported errors.", error, this.logContext());
|
|
247
|
+
}
|
|
248
|
+
finally {
|
|
249
|
+
this.recordTiming({ stoppedAt: this._timing.stoppedAt ?? new Date() });
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Runs an operation inside the runtime's execution context so that
|
|
254
|
+
* module hooks, container factories, and loggers reached from it
|
|
255
|
+
* observe the context through `contextStorage`.
|
|
256
|
+
*/
|
|
257
|
+
inContext(operation) {
|
|
258
|
+
return this._contextStorage.run(this._context, operation);
|
|
259
|
+
}
|
|
260
|
+
async runShutdown() {
|
|
261
|
+
if (this._unwound)
|
|
262
|
+
return;
|
|
263
|
+
this._unwound = true;
|
|
264
|
+
const result = await this._shutdown.shutdown();
|
|
265
|
+
if (!result.success) {
|
|
266
|
+
this._logger.warn("Runtime shutdown completed with module errors (continueOn*Error).", this.logContext({ errors: result.errors.length }));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/*
|
|
270
|
+
* Process-level callbacks run in whatever async context was active
|
|
271
|
+
* when the listener was registered, so the handlers re-establish
|
|
272
|
+
* the runtime context explicitly.
|
|
273
|
+
*/
|
|
274
|
+
handleSignal(signal) {
|
|
275
|
+
return this.inContext(async () => {
|
|
276
|
+
this._logger.info(`Stopping runtime after ${signal}.`, this.logContext({ signal }));
|
|
277
|
+
try {
|
|
278
|
+
await this.stop();
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
this._logger.error(`Runtime shutdown after ${signal} failed.`, error, this.logContext({ signal }));
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
handleFatal(event, error) {
|
|
286
|
+
return this.inContext(async () => {
|
|
287
|
+
this._logger.fatal(`Runtime received ${event}; marking runtime failed and stopping.`, error, this.logContext({ event }));
|
|
288
|
+
if (this._state === RuntimeState.BOOTSTRAPPING && this._startPromise) {
|
|
289
|
+
await this._startPromise.catch(() => undefined);
|
|
290
|
+
}
|
|
291
|
+
this.fail(error);
|
|
292
|
+
try {
|
|
293
|
+
await this.stop();
|
|
294
|
+
}
|
|
295
|
+
catch (stopError) {
|
|
296
|
+
this._logger.error(`Runtime shutdown after ${event} failed.`, stopError, this.logContext({ event }));
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
transitionTo(next, reason) {
|
|
301
|
+
const current = this._state;
|
|
302
|
+
assertRuntimeTransition(current, next);
|
|
303
|
+
this._state = next;
|
|
304
|
+
this.recordTimingForState(next);
|
|
305
|
+
try {
|
|
306
|
+
this._logger.debug(`Runtime state changed from "${current}" to "${next}".`, this.logContext({ from: current, to: next, reason }));
|
|
307
|
+
}
|
|
308
|
+
catch {
|
|
309
|
+
/* Logging must never prevent a lifecycle transition. */
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
recordTimingForState(state) {
|
|
313
|
+
const now = new Date();
|
|
314
|
+
const t = this._timing;
|
|
315
|
+
switch (state) {
|
|
316
|
+
case RuntimeState.BOOTSTRAPPING:
|
|
317
|
+
this.recordTiming({ startupStartedAt: t.startupStartedAt ?? now });
|
|
318
|
+
break;
|
|
319
|
+
case RuntimeState.READY:
|
|
320
|
+
this.recordTiming({ readyAt: t.readyAt ?? now });
|
|
321
|
+
break;
|
|
322
|
+
case RuntimeState.STOPPING:
|
|
323
|
+
this.recordTiming({ shutdownStartedAt: t.shutdownStartedAt ?? now });
|
|
324
|
+
break;
|
|
325
|
+
case RuntimeState.STOPPED:
|
|
326
|
+
this.recordTiming({ stoppedAt: t.stoppedAt ?? now });
|
|
327
|
+
break;
|
|
328
|
+
case RuntimeState.FAILED:
|
|
329
|
+
this.recordTiming({ failedAt: t.failedAt ?? now });
|
|
330
|
+
break;
|
|
331
|
+
default:
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
recordTiming(update) {
|
|
336
|
+
this._timing = Object.freeze({ ...this._timing, ...update });
|
|
337
|
+
}
|
|
338
|
+
logContext(extra = {}) {
|
|
339
|
+
return {
|
|
340
|
+
runtimeId: this._identity.id,
|
|
341
|
+
runtimeName: this._identity.name,
|
|
342
|
+
...extra,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
errorContext(extra) {
|
|
346
|
+
return {
|
|
347
|
+
...extra,
|
|
348
|
+
runtimeId: this._identity.id,
|
|
349
|
+
runtimeName: this._identity.name,
|
|
350
|
+
};
|
|
137
351
|
}
|
|
138
352
|
getStatus() {
|
|
139
353
|
return Object.freeze({
|
|
140
354
|
state: this._state,
|
|
141
|
-
startedAt: this.
|
|
142
|
-
stoppedAt: this.stoppedAt,
|
|
143
|
-
failedAt: this.failedAt,
|
|
144
|
-
|
|
355
|
+
startedAt: this._timing.readyAt,
|
|
356
|
+
stoppedAt: this._timing.stoppedAt,
|
|
357
|
+
failedAt: this._timing.failedAt,
|
|
358
|
+
timing: this._timing,
|
|
359
|
+
error: this._error,
|
|
360
|
+
bootstrap: this._bootstrap.getLastResult(),
|
|
361
|
+
shutdown: this._shutdown.getLastResult(),
|
|
145
362
|
});
|
|
146
363
|
}
|
|
364
|
+
getStateSnapshot() {
|
|
365
|
+
return createRuntimeStateSnapshot(this._state);
|
|
366
|
+
}
|
|
367
|
+
getUptime() {
|
|
368
|
+
return Date.now() - this._identity.createdAt.getTime();
|
|
369
|
+
}
|
|
147
370
|
getApplicationContext() {
|
|
148
|
-
return this.
|
|
371
|
+
return this._application;
|
|
149
372
|
}
|
|
150
373
|
getConfiguration() {
|
|
151
|
-
return this.
|
|
374
|
+
return this._configuration;
|
|
152
375
|
}
|
|
153
376
|
getLogger() {
|
|
154
|
-
return this.
|
|
377
|
+
return this._logger;
|
|
155
378
|
}
|
|
156
379
|
getModuleRegistry() {
|
|
157
|
-
return this.
|
|
380
|
+
return this._moduleRegistry;
|
|
158
381
|
}
|
|
159
382
|
getModuleLoader() {
|
|
160
|
-
return this.
|
|
383
|
+
return this._moduleLoader;
|
|
161
384
|
}
|
|
162
385
|
getModuleLifecycle() {
|
|
163
|
-
return this.
|
|
386
|
+
return this._moduleLifecycle;
|
|
164
387
|
}
|
|
165
388
|
getModule(moduleId) {
|
|
166
|
-
return this.
|
|
389
|
+
return this._moduleRegistry.get(moduleId)?.instance;
|
|
167
390
|
}
|
|
168
391
|
requireModule(moduleId) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
392
|
+
// Throws the module subsystem's ModuleNotFoundError when unknown.
|
|
393
|
+
const module = this._moduleRegistry.require(moduleId).instance;
|
|
394
|
+
if (!module) {
|
|
395
|
+
throw new RuntimeNotReadyError(`Module "${moduleId}" is registered but not loaded.`, this.errorContext({
|
|
396
|
+
moduleName: moduleId,
|
|
397
|
+
metadata: { state: this._state },
|
|
398
|
+
}));
|
|
399
|
+
}
|
|
172
400
|
return module;
|
|
173
401
|
}
|
|
174
402
|
}
|
|
175
|
-
/**
|
|
176
|
-
|
|
177
|
-
|
|
403
|
+
/**
|
|
404
|
+
* Creates a runtime.
|
|
405
|
+
*/
|
|
406
|
+
export function createRuntime(dependencies, options = {}) {
|
|
407
|
+
return new DefaultRuntime(dependencies, options);
|
|
178
408
|
}
|
|
179
409
|
//# sourceMappingURL=runtime.js.map
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* and starting runtime modules.
|
|
6
6
|
*/
|
|
7
7
|
export { DefaultRuntimeBootstrap } from "./runtimeBootstrap.core.js";
|
|
8
|
-
export {
|
|
8
|
+
export { executeBootstrapPipeline, createBootstrapPipelineState, createBootstrapResult, } from "./pipeline/index.js";
|
|
9
|
+
export type { BootstrapCounters, BootstrapPipelineServices, BootstrapPipelineState, } from "./pipeline/index.js";
|
|
9
10
|
export type { RuntimeBootstrapDependencies, RuntimeBootstrapOptions, RuntimeBootstrapPhase, RuntimeBootstrapErrorInfo, RuntimeBootstrapResult, RuntimeBootstrap, ResolvedBootstrapOptions, } from "./runtimeBootstrap.type.js";
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* and starting runtime modules.
|
|
6
6
|
*/
|
|
7
7
|
export { DefaultRuntimeBootstrap } from "./runtimeBootstrap.core.js";
|
|
8
|
-
export {
|
|
8
|
+
export { executeBootstrapPipeline, createBootstrapPipelineState, createBootstrapResult, } from "./pipeline/index.js";
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Module loading, initialization, and startup stages.
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
6
|
+
export { executeBootstrapPipeline, createBootstrapPipelineState, createBootstrapResult, } from "./runtimeBootstrap.pipeline.js";
|
|
7
|
+
export type { BootstrapCounters, BootstrapLogFn, BootstrapPipelineServices, BootstrapPipelineState, } from "./runtimeBootstrap.pipeline.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,6 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Module loading, initialization, and startup stages.
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
7
|
-
export { invokeModuleLoader, invokeInitializeModules, invokeStartModules, } from "./runtimeBootstrap.invoke.js";
|
|
6
|
+
export { executeBootstrapPipeline, createBootstrapPipelineState, createBootstrapResult, } from "./runtimeBootstrap.pipeline.js";
|
|
8
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,19 +1,45 @@
|
|
|
1
1
|
import type { ModuleLoader } from "../../../modules/moduleLoader/index.js";
|
|
2
2
|
import type { ModuleLifecycleManager } from "../../../modules/moduleLifecycle/index.js";
|
|
3
|
-
import type { RuntimeBootstrapPhase, RuntimeBootstrapErrorInfo, ResolvedBootstrapOptions } from "../runtimeBootstrap.type.js";
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import type { RuntimeBootstrapPhase, RuntimeBootstrapErrorInfo, RuntimeBootstrapResult, ResolvedBootstrapOptions } from "../runtimeBootstrap.type.js";
|
|
4
|
+
export type BootstrapLogFn = (level: "debug" | "info" | "warn" | "error", message: string, metadata?: Record<string, unknown>) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Module counts produced by the bootstrap pipeline.
|
|
7
|
+
*/
|
|
8
|
+
export interface BootstrapCounters {
|
|
9
|
+
loadedModules: number;
|
|
10
|
+
initializedModules: number;
|
|
11
|
+
startedModules: number;
|
|
9
12
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Services the bootstrap pipeline drives.
|
|
15
|
+
*/
|
|
16
|
+
export interface BootstrapPipelineServices {
|
|
17
|
+
readonly moduleLoader: ModuleLoader;
|
|
18
|
+
readonly moduleLifecycle: ModuleLifecycleManager;
|
|
19
|
+
/** Identity attached to every error the pipeline raises. */
|
|
20
|
+
readonly runtimeId?: string;
|
|
21
|
+
readonly runtimeName?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Mutable pipeline state shared with the caller so that counts and
|
|
25
|
+
* recorded errors survive a thrown failure.
|
|
26
|
+
*/
|
|
27
|
+
export interface BootstrapPipelineState {
|
|
28
|
+
readonly counters: BootstrapCounters;
|
|
29
|
+
readonly errors: RuntimeBootstrapErrorInfo[];
|
|
30
|
+
}
|
|
31
|
+
export declare function createBootstrapPipelineState(): BootstrapPipelineState;
|
|
32
|
+
/**
|
|
33
|
+
* Executes the load → initialize → start pipeline.
|
|
34
|
+
*
|
|
35
|
+
* - Module-level failures reported by the ModuleLifecycleManager are
|
|
36
|
+
* recorded once per module (with `moduleName`).
|
|
37
|
+
* - When the phase's continueOn*Error flag is false the pipeline
|
|
38
|
+
* throws; the thrown error is NOT pushed to `errors` here — the
|
|
39
|
+
* caller records it exactly once.
|
|
40
|
+
* - Once `signal` is aborted (timeout) the pipeline stops publishing
|
|
41
|
+
* phase changes so an abandoned run cannot mutate the owner.
|
|
42
|
+
*/
|
|
43
|
+
export declare function executeBootstrapPipeline(options: ResolvedBootstrapOptions, services: BootstrapPipelineServices, state: BootstrapPipelineState, signal: AbortSignal, setPhase: (phase: RuntimeBootstrapPhase) => void, log: BootstrapLogFn): Promise<void>;
|
|
44
|
+
export declare function createBootstrapResult(success: boolean, phase: RuntimeBootstrapPhase, counters: BootstrapCounters, errors: readonly RuntimeBootstrapErrorInfo[], startedAt: Date, completedAt: Date): RuntimeBootstrapResult;
|
|
19
45
|
//# sourceMappingURL=runtimeBootstrap.pipeline.d.ts.map
|