@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zudojs Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -11,20 +11,154 @@ npm install @zudojs/core
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { createApplication } from "@zudojs/core";
|
|
14
|
+
import { createApplication, defineModule } from "@zudojs/core";
|
|
15
15
|
|
|
16
|
-
const app = await createApplication(
|
|
16
|
+
const app = await createApplication({
|
|
17
|
+
modules: [
|
|
18
|
+
defineModule({
|
|
19
|
+
id: "users",
|
|
20
|
+
name: "Users",
|
|
21
|
+
factory: () => ({
|
|
22
|
+
id: "users",
|
|
23
|
+
name: "Users",
|
|
24
|
+
onInitialize: async () => {
|
|
25
|
+
/* prepare resources */
|
|
26
|
+
},
|
|
27
|
+
onShutdown: async () => {
|
|
28
|
+
/* release resources */
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
runtime: {
|
|
34
|
+
name: "my-service",
|
|
35
|
+
mode: "production",
|
|
36
|
+
signals: { handleSigint: true, handleSigterm: true },
|
|
37
|
+
},
|
|
38
|
+
});
|
|
17
39
|
|
|
18
|
-
await app.start();
|
|
19
|
-
await app.stop();
|
|
40
|
+
await app.start(); // loads, initializes, and starts modules
|
|
41
|
+
await app.stop(); // stops and destroys modules
|
|
42
|
+
await app.start(); // restart: a fresh runtime is created
|
|
43
|
+
await app.shutdown(); // stop + dispose; cannot be restarted afterwards
|
|
20
44
|
```
|
|
21
45
|
|
|
46
|
+
`createApplication` wires the standard graph (container, configuration manager, logger, module registry/loader/lifecycle, runtime, application lifecycle). Every piece can also be assembled by hand:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import {
|
|
50
|
+
Application,
|
|
51
|
+
ApplicationContext,
|
|
52
|
+
Lifecycle,
|
|
53
|
+
createRuntime,
|
|
54
|
+
} from "@zudojs/core";
|
|
55
|
+
|
|
56
|
+
const lifecycle = new Lifecycle();
|
|
57
|
+
lifecycle.register({
|
|
58
|
+
name: "http-server",
|
|
59
|
+
start: async () => server.listen(),
|
|
60
|
+
stop: async () => server.close(),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const app = await Application.create({
|
|
64
|
+
lifecycle,
|
|
65
|
+
runtime: () => createRuntime(dependencies, options), // factory enables restart
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Runtime
|
|
70
|
+
|
|
71
|
+
`createRuntime(dependencies, options)` returns a single-use runtime:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
CREATED → BOOTSTRAPPING → READY → STOPPING → STOPPED
|
|
75
|
+
FAILED is reachable from every non-terminal state via fail() or a failure.
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- `start()` loads, initializes, and starts modules through the bootstrap pipeline; `getStatus().bootstrap` reports counts, errors, and duration.
|
|
79
|
+
- `stop()` stops and destroys modules through the shutdown pipeline; `getStatus().shutdown` reports the same.
|
|
80
|
+
- `startup.timeoutMs` / `shutdown.timeoutMs` abort the pipeline with a `RuntimeTimeoutError`; the abandoned pipeline can never surface an unhandled rejection.
|
|
81
|
+
- `continueOnInitializeError` / `continueOnStartError` (and the stop/destroy equivalents) make the runtime finish with `success: false` and the failures listed instead of throwing.
|
|
82
|
+
- Every error the runtime throws extends `RuntimeError` (which itself extends `RuntimeError` from `@zudojs/errors`), so `isRuntimeError()` from either package recognises it.
|
|
83
|
+
- `runtime.context` is the runtime's immutable `RuntimeExecutionContext` (`executionId` = runtime id, `service` = runtime name, `metadata.runtimeId/runtimeName/runtimeMode/runtimeRole` plus `RuntimeOptions.metadata`); `runtime.timing` holds the state-transition timestamps; `runtime.contextStorage` is the `ContextStorage` the context is established in (`RuntimeDependencies.contextStorage`, default `getDefaultContextStorage()`).
|
|
84
|
+
|
|
85
|
+
### Signals
|
|
86
|
+
|
|
87
|
+
When `signals.handleSigint` / `handleSigterm` / `handleSighup` are on (SIGINT and SIGTERM default to on), the runtime registers handlers on start and removes them on stop, failure, or dispose. The first signal triggers a graceful `stop()`. A second signal during shutdown is logged and ignored unless `signals.forceExitOnSecondSignal` is explicitly enabled, in which case the process exits with `signals.forceExitCode`. `handleUncaughtException` / `handleUnhandledRejection` mark the runtime failed and stop it. The runtime never calls `process.exit()` otherwise.
|
|
88
|
+
|
|
89
|
+
## Modules
|
|
90
|
+
|
|
91
|
+
Modules implement the `Module` contract and are driven by `ModuleLifecycleManager` in dependency order:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
onInitialize → onReady → onShutdown → onDestroy
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
- Register definitions with `defineModule(...)` (or subclass `BaseModule`); dependencies may be plain ids or `{ id, optional, version }` objects, and version constraints (`^`, `~`, `>=`, exact) are checked when the graph is built.
|
|
98
|
+
- Dependents are skipped when a dependency fails, and modules initialized before a failure are rolled back (stopped and destroyed).
|
|
99
|
+
- `unloadModule(id)` stops, destroys, and forgets a module (refused while loaded dependents exist); `replaceModule(definition)` shuts the old instance down first.
|
|
100
|
+
- Only the documented `on*` hooks are invoked. The legacy `initialize/start/stop/destroy` names are no longer called.
|
|
101
|
+
|
|
102
|
+
## Configuration
|
|
103
|
+
|
|
104
|
+
`createConfigurationManager({ registry, schemas, loaderOptions, validationOptions, redactorOptions })` loads registered sources by priority, deep-merges them, applies schema defaults, validates, and exposes an immutable `Configuration`.
|
|
105
|
+
|
|
106
|
+
- `manager.on(type, listener)` / `manager.off(...)` receive the `configuration.initializing`, `configuration.loaded`, `configuration.validated`, `configuration.ready`, `configuration.failed`, `configuration.reloading`, and `configuration.reloaded` events (`"*"` subscribes to all of them).
|
|
107
|
+
- `manager.getSection(name)` returns a scoped configuration for a registered section; `manager.reload()` keeps programmatic defaults and serialises overlapping reloads.
|
|
108
|
+
- Values are deep-frozen; `toObject()` returns an independent deep copy. Path lookups never walk the prototype chain, and `getNumber` accepts only plain decimal numbers.
|
|
109
|
+
- Secrets never reach errors or logs: validation, load, and source errors pass through the redactor, which matches whole key words (`password`, `secret`, `token`, `pwd`, `passphrase`, `auth`, `dsn`, `credential`, ...).
|
|
110
|
+
|
|
111
|
+
## Logging
|
|
112
|
+
|
|
113
|
+
`new ConsoleLogger({ level, structured, service, version, environment, context, redact })` emits structured JSON (circular and `BigInt` safe) or human-readable output.
|
|
114
|
+
|
|
115
|
+
- `logger.child({ moduleId })` merges the context into every entry it emits; `LoggerOptions.context` is attached to every entry.
|
|
116
|
+
- `LoggerOptions.contextStorage` makes the logger merge `executionId`, `correlationId`, `traceId`, `spanId`, and `runtimeId` from the active execution context beneath its own context (explicit values win). `createApplication` sets it on the logger it creates.
|
|
117
|
+
- An unknown `level` throws `InvalidArgumentError` at construction rather than silently disabling logging.
|
|
118
|
+
- Error causes are serialised recursively with a depth limit; `redact` (see `createLogRedactor()`) is applied to context and error details.
|
|
119
|
+
- `trace` output goes through `console.debug`, so the structured-output invariant holds.
|
|
120
|
+
|
|
121
|
+
## Execution context
|
|
122
|
+
|
|
123
|
+
There is one execution-context model: the immutable `ExecutionContext` (`createExecutionContext`, `deriveExecutionContext`, `withExecutionMetadata`) propagated by `ContextStorage`, which wraps `AsyncLocalStorage`. `run(context, fn)` and `runDerived(overrides, fn)` establish a context for the callback and everything it awaits, `runWithValues(context, values, fn)` additionally binds a `ContextValues` collection (read back with `getValues()`), and `capture()` / `runSnapshot(snapshot, fn)` carry a context across queue or timer boundaries. `getDefaultContextStorage()` is the process-wide instance every component uses unless another is injected.
|
|
124
|
+
|
|
125
|
+
Propagation is real at runtime:
|
|
126
|
+
|
|
127
|
+
- `runtime.start()` and `runtime.stop()` run the bootstrap and shutdown pipelines inside `runtime.contextStorage.run(runtime.context, ...)`.
|
|
128
|
+
- Each module hook (`onInitialize`, `onReady`, `onShutdown`, `onDestroy`) runs in a context derived from it: `module` is the module id, `operation` is the hook name, and `{ moduleId, phase }` is merged into `metadata`. `ModuleLifecycleOptions.contextStorage` selects the storage (default: the shared one).
|
|
129
|
+
- `Application.start()` / `stop()` / `shutdown()` run lifecycle participants inside the runtime's context as well.
|
|
130
|
+
- `createApplication` threads one storage (`CreateApplicationOptions.contextStorage`) through the `ApplicationContext` (`getContextStorage()`), the container's `currentScope` (so `"scoped"` providers resolve once per execution context), the module lifecycle, the runtime, and the logger.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import { defineModule, getDefaultContextStorage } from "@zudojs/core";
|
|
134
|
+
|
|
135
|
+
defineModule({
|
|
136
|
+
id: "users",
|
|
137
|
+
name: "Users",
|
|
138
|
+
factory: () => ({
|
|
139
|
+
id: "users",
|
|
140
|
+
name: "Users",
|
|
141
|
+
onInitialize: async () => {
|
|
142
|
+
const context = getDefaultContextStorage().require();
|
|
143
|
+
// context.executionId === runtime.identity.id
|
|
144
|
+
// context.metadata.moduleId === "users", context.metadata.phase === "initializing"
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The former mutable `Context` class and `DefaultRuntimeContext` are gone; `Context`, `createContext`, `RuntimeContext`, and `createRuntimeContext` remain as deprecated aliases of the canonical names.
|
|
151
|
+
|
|
22
152
|
## Features
|
|
23
153
|
|
|
24
154
|
- Application lifecycle management (start, stop, restart)
|
|
25
|
-
- Execution context propagation
|
|
26
|
-
-
|
|
27
|
-
-
|
|
155
|
+
- Execution context propagation via `ContextStorage` (`AsyncLocalStorage`)
|
|
156
|
+
- Dependency-ordered module lifecycle with rollback on failure
|
|
157
|
+
- Configuration loading, validation, schema defaults, redaction, and events
|
|
158
|
+
- Structured, redaction-aware logging
|
|
159
|
+
- Runtime state machine with dependency-ordered module lifecycle
|
|
160
|
+
- Signal handling for graceful shutdown (SIGINT, SIGTERM, SIGHUP)
|
|
161
|
+
- Dependency injection container with singleton, scoped (per execution context), and transient lifetimes
|
|
28
162
|
|
|
29
163
|
## Use Cases
|
|
30
164
|
|
|
@@ -2,24 +2,65 @@ import type { ApplicationContext } from "./applicationContext.context.js";
|
|
|
2
2
|
import type { ApplicationState } from "./applicationState.state.js";
|
|
3
3
|
import type { Lifecycle } from "../lifecycle/core/lifecycle.js";
|
|
4
4
|
import type { Runtime } from "../runtime/runtime.js";
|
|
5
|
+
/**
|
|
6
|
+
* Creates a fresh Runtime. Because a Runtime is single-use, an
|
|
7
|
+
* Application needs a factory to support restart.
|
|
8
|
+
*/
|
|
9
|
+
export type RuntimeFactory = () => Runtime;
|
|
5
10
|
export interface ApplicationOptions {
|
|
6
11
|
readonly context?: ApplicationContext;
|
|
7
12
|
readonly lifecycle?: Lifecycle;
|
|
8
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The runtime to orchestrate, or a factory that creates one. With
|
|
15
|
+
* a factory, every start after a stop gets a new runtime so the
|
|
16
|
+
* application can be restarted; with an instance, restart throws.
|
|
17
|
+
*/
|
|
18
|
+
readonly runtime?: Runtime | RuntimeFactory;
|
|
9
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Top-level application object.
|
|
22
|
+
*
|
|
23
|
+
* Orchestrates an optional Lifecycle (application-level participants)
|
|
24
|
+
* and an optional Runtime (module subsystem): start() runs the
|
|
25
|
+
* lifecycle first and then the runtime; stop() unwinds in reverse.
|
|
26
|
+
*
|
|
27
|
+
* When a runtime is present, start(), stop(), and shutdown() run
|
|
28
|
+
* inside the runtime's execution context (`runtime.contextStorage`
|
|
29
|
+
* / `runtime.context`), so lifecycle participants observe the same
|
|
30
|
+
* context as module hooks.
|
|
31
|
+
*/
|
|
10
32
|
export declare class Application {
|
|
11
33
|
private readonly context?;
|
|
12
34
|
private readonly lifecycle?;
|
|
13
|
-
private readonly
|
|
35
|
+
private readonly runtimeFactory?;
|
|
36
|
+
private runtime?;
|
|
14
37
|
private _state;
|
|
15
38
|
private constructor();
|
|
16
39
|
static create(options?: ApplicationOptions): Promise<Application>;
|
|
17
40
|
get state(): ApplicationState;
|
|
18
41
|
get applicationContext(): ApplicationContext | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* The current runtime, if any. Changes across restarts when a
|
|
44
|
+
* runtime factory is used.
|
|
45
|
+
*/
|
|
19
46
|
get applicationRuntime(): Runtime | undefined;
|
|
20
47
|
initialize(): Promise<void>;
|
|
21
48
|
start(): Promise<void>;
|
|
22
49
|
stop(): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Stops the application and releases lifecycle resources. The
|
|
52
|
+
* application cannot be restarted afterwards.
|
|
53
|
+
*/
|
|
23
54
|
shutdown(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Runs an operation inside the runtime's execution context, or
|
|
57
|
+
* directly when the application has no runtime.
|
|
58
|
+
*/
|
|
59
|
+
private inRuntimeContext;
|
|
60
|
+
/**
|
|
61
|
+
* Returns a startable runtime: the configured instance while it is
|
|
62
|
+
* unused, or a new one from the factory after a stop/failure.
|
|
63
|
+
*/
|
|
64
|
+
private ensureRuntime;
|
|
24
65
|
}
|
|
25
66
|
//# sourceMappingURL=application.d.ts.map
|
|
@@ -1,12 +1,32 @@
|
|
|
1
|
+
import { RuntimeState } from "../runtime/runtimeState.state.js";
|
|
2
|
+
import { InvalidStateError } from "../errors/exceptions.js";
|
|
3
|
+
/**
|
|
4
|
+
* Top-level application object.
|
|
5
|
+
*
|
|
6
|
+
* Orchestrates an optional Lifecycle (application-level participants)
|
|
7
|
+
* and an optional Runtime (module subsystem): start() runs the
|
|
8
|
+
* lifecycle first and then the runtime; stop() unwinds in reverse.
|
|
9
|
+
*
|
|
10
|
+
* When a runtime is present, start(), stop(), and shutdown() run
|
|
11
|
+
* inside the runtime's execution context (`runtime.contextStorage`
|
|
12
|
+
* / `runtime.context`), so lifecycle participants observe the same
|
|
13
|
+
* context as module hooks.
|
|
14
|
+
*/
|
|
1
15
|
export class Application {
|
|
2
16
|
context;
|
|
3
17
|
lifecycle;
|
|
18
|
+
runtimeFactory;
|
|
4
19
|
runtime;
|
|
5
20
|
_state;
|
|
6
21
|
constructor(options = {}) {
|
|
7
22
|
this.context = options.context;
|
|
8
23
|
this.lifecycle = options.lifecycle;
|
|
9
|
-
|
|
24
|
+
if (typeof options.runtime === "function") {
|
|
25
|
+
this.runtimeFactory = options.runtime;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.runtime = options.runtime;
|
|
29
|
+
}
|
|
10
30
|
this._state = "created";
|
|
11
31
|
}
|
|
12
32
|
static async create(options = {}) {
|
|
@@ -20,6 +40,10 @@ export class Application {
|
|
|
20
40
|
get applicationContext() {
|
|
21
41
|
return this.context;
|
|
22
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* The current runtime, if any. Changes across restarts when a
|
|
45
|
+
* runtime factory is used.
|
|
46
|
+
*/
|
|
23
47
|
get applicationRuntime() {
|
|
24
48
|
return this.runtime;
|
|
25
49
|
}
|
|
@@ -45,11 +69,17 @@ export class Application {
|
|
|
45
69
|
await this.initialize();
|
|
46
70
|
}
|
|
47
71
|
if (this._state !== "initialized" && this._state !== "stopped") {
|
|
48
|
-
throw new
|
|
72
|
+
throw new InvalidStateError(`Application cannot start from state "${this._state}".`, { state: this._state });
|
|
49
73
|
}
|
|
74
|
+
// Resolve the runtime first so a refused restart leaves the
|
|
75
|
+
// application untouched.
|
|
76
|
+
const runtime = this.ensureRuntime();
|
|
50
77
|
this._state = "starting";
|
|
51
78
|
try {
|
|
52
|
-
await this.
|
|
79
|
+
await this.inRuntimeContext(runtime, async () => {
|
|
80
|
+
await this.lifecycle?.start();
|
|
81
|
+
await runtime?.start();
|
|
82
|
+
});
|
|
53
83
|
this._state = "running";
|
|
54
84
|
}
|
|
55
85
|
catch (error) {
|
|
@@ -64,23 +94,91 @@ export class Application {
|
|
|
64
94
|
return;
|
|
65
95
|
}
|
|
66
96
|
if (this._state !== "running" && this._state !== "failed") {
|
|
67
|
-
throw new
|
|
97
|
+
throw new InvalidStateError(`Application cannot stop from state "${this._state}".`, { state: this._state });
|
|
68
98
|
}
|
|
69
99
|
this._state = "stopping";
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
100
|
+
const errors = [];
|
|
101
|
+
const runtime = this.runtime;
|
|
102
|
+
await this.inRuntimeContext(runtime, async () => {
|
|
103
|
+
try {
|
|
104
|
+
await runtime?.stop();
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
errors.push(error);
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
await this.lifecycle?.stop();
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
errors.push(error);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
if (errors.length > 0) {
|
|
75
117
|
this._state = "failed";
|
|
76
|
-
|
|
118
|
+
if (errors.length === 1)
|
|
119
|
+
throw errors[0];
|
|
120
|
+
throw new AggregateError(errors, "Application stop completed with errors.");
|
|
77
121
|
}
|
|
122
|
+
this._state = "stopped";
|
|
78
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Stops the application and releases lifecycle resources. The
|
|
126
|
+
* application cannot be restarted afterwards.
|
|
127
|
+
*/
|
|
79
128
|
async shutdown() {
|
|
80
|
-
|
|
81
|
-
|
|
129
|
+
const errors = [];
|
|
130
|
+
const runtime = this.runtime;
|
|
131
|
+
await this.inRuntimeContext(runtime, async () => {
|
|
132
|
+
try {
|
|
133
|
+
await this.stop();
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
errors.push(error);
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
await runtime?.dispose();
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
errors.push(error);
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
await this.lifecycle?.dispose();
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
errors.push(error);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
if (errors.length === 1)
|
|
152
|
+
throw errors[0];
|
|
153
|
+
if (errors.length > 1) {
|
|
154
|
+
throw new AggregateError(errors, "Application shutdown completed with errors.");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Runs an operation inside the runtime's execution context, or
|
|
159
|
+
* directly when the application has no runtime.
|
|
160
|
+
*/
|
|
161
|
+
inRuntimeContext(runtime, operation) {
|
|
162
|
+
if (!runtime)
|
|
163
|
+
return operation();
|
|
164
|
+
return runtime.contextStorage.run(runtime.context, operation);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Returns a startable runtime: the configured instance while it is
|
|
168
|
+
* unused, or a new one from the factory after a stop/failure.
|
|
169
|
+
*/
|
|
170
|
+
ensureRuntime() {
|
|
171
|
+
const current = this.runtime;
|
|
172
|
+
const reusable = current !== undefined && current.state === RuntimeState.CREATED;
|
|
173
|
+
if (reusable)
|
|
174
|
+
return current;
|
|
175
|
+
if (this.runtimeFactory) {
|
|
176
|
+
this.runtime = this.runtimeFactory();
|
|
177
|
+
return this.runtime;
|
|
82
178
|
}
|
|
83
|
-
|
|
179
|
+
if (current === undefined)
|
|
180
|
+
return undefined;
|
|
181
|
+
throw new InvalidStateError(`Application runtime is "${current.state}" and cannot be restarted; supply a runtime factory to enable restart.`, { runtimeState: current.state });
|
|
84
182
|
}
|
|
85
183
|
}
|
|
86
184
|
//# sourceMappingURL=application.js.map
|
|
@@ -2,11 +2,25 @@ import type { Container } from "../container/container.js";
|
|
|
2
2
|
import type { Configuration } from "../configuration/core/configuration.js";
|
|
3
3
|
import type { ModuleRegistry } from "../modules/moduleRegistry/index.js";
|
|
4
4
|
import type { Logger } from "../logging/core/logger.js";
|
|
5
|
+
import type { ContextStorage } from "../context/provider/contextStorage.storage.js";
|
|
5
6
|
export interface ApplicationContextOptions {
|
|
6
7
|
readonly container: Container;
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The application configuration, or a function returning the
|
|
10
|
+
* current one. Pass a function (for example
|
|
11
|
+
* `() => manager.getConfiguration()`) so that
|
|
12
|
+
* `getConfiguration()` reflects configuration reloads instead of
|
|
13
|
+
* the snapshot taken when the context was created.
|
|
14
|
+
*/
|
|
15
|
+
readonly configuration: Configuration | (() => Configuration);
|
|
8
16
|
readonly modules: ModuleRegistry;
|
|
9
17
|
readonly logger: Logger;
|
|
18
|
+
/**
|
|
19
|
+
* ContextStorage the application's runtime propagates its
|
|
20
|
+
* execution context through. Defaults to
|
|
21
|
+
* getDefaultContextStorage().
|
|
22
|
+
*/
|
|
23
|
+
readonly contextStorage?: ContextStorage;
|
|
10
24
|
}
|
|
11
25
|
/**
|
|
12
26
|
* Provides access to the core services and state of a Zudojs application.
|
|
@@ -19,6 +33,7 @@ export declare class ApplicationContext {
|
|
|
19
33
|
private readonly configuration;
|
|
20
34
|
private readonly modules;
|
|
21
35
|
private readonly logger;
|
|
36
|
+
private readonly contextStorage;
|
|
22
37
|
constructor(options: ApplicationContextOptions);
|
|
23
38
|
/**
|
|
24
39
|
* Dependency injection container.
|
|
@@ -26,6 +41,10 @@ export declare class ApplicationContext {
|
|
|
26
41
|
getContainer(): Container;
|
|
27
42
|
/**
|
|
28
43
|
* Application configuration.
|
|
44
|
+
*
|
|
45
|
+
* When the context was created with a configuration accessor
|
|
46
|
+
* (as `createApplication` does), this returns the configuration
|
|
47
|
+
* manager's current configuration, including reloads.
|
|
29
48
|
*/
|
|
30
49
|
getConfiguration(): Configuration;
|
|
31
50
|
/**
|
|
@@ -36,5 +55,12 @@ export declare class ApplicationContext {
|
|
|
36
55
|
* Application logger.
|
|
37
56
|
*/
|
|
38
57
|
getLogger(): Logger;
|
|
58
|
+
/**
|
|
59
|
+
* Execution context storage. Inside module hooks, container
|
|
60
|
+
* factories, and lifecycle participants driven by the runtime,
|
|
61
|
+
* `getContextStorage().get()` returns the runtime's execution
|
|
62
|
+
* context.
|
|
63
|
+
*/
|
|
64
|
+
getContextStorage(): ContextStorage;
|
|
39
65
|
}
|
|
40
66
|
//# sourceMappingURL=applicationContext.context.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getDefaultContextStorage } from "../context/provider/defaultContextStorage.storage.js";
|
|
1
2
|
/**
|
|
2
3
|
* Provides access to the core services and state of a Zudojs application.
|
|
3
4
|
*
|
|
@@ -9,11 +10,17 @@ export class ApplicationContext {
|
|
|
9
10
|
configuration;
|
|
10
11
|
modules;
|
|
11
12
|
logger;
|
|
13
|
+
contextStorage;
|
|
12
14
|
constructor(options) {
|
|
13
15
|
this.container = options.container;
|
|
14
|
-
|
|
16
|
+
const configuration = options.configuration;
|
|
17
|
+
this.configuration =
|
|
18
|
+
typeof configuration === "function"
|
|
19
|
+
? configuration
|
|
20
|
+
: () => configuration;
|
|
15
21
|
this.modules = options.modules;
|
|
16
22
|
this.logger = options.logger;
|
|
23
|
+
this.contextStorage = options.contextStorage ?? getDefaultContextStorage();
|
|
17
24
|
}
|
|
18
25
|
/**
|
|
19
26
|
* Dependency injection container.
|
|
@@ -23,9 +30,13 @@ export class ApplicationContext {
|
|
|
23
30
|
}
|
|
24
31
|
/**
|
|
25
32
|
* Application configuration.
|
|
33
|
+
*
|
|
34
|
+
* When the context was created with a configuration accessor
|
|
35
|
+
* (as `createApplication` does), this returns the configuration
|
|
36
|
+
* manager's current configuration, including reloads.
|
|
26
37
|
*/
|
|
27
38
|
getConfiguration() {
|
|
28
|
-
return this.configuration;
|
|
39
|
+
return this.configuration();
|
|
29
40
|
}
|
|
30
41
|
/**
|
|
31
42
|
* Registered application modules.
|
|
@@ -39,5 +50,14 @@ export class ApplicationContext {
|
|
|
39
50
|
getLogger() {
|
|
40
51
|
return this.logger;
|
|
41
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Execution context storage. Inside module hooks, container
|
|
55
|
+
* factories, and lifecycle participants driven by the runtime,
|
|
56
|
+
* `getContextStorage().get()` returns the runtime's execution
|
|
57
|
+
* context.
|
|
58
|
+
*/
|
|
59
|
+
getContextStorage() {
|
|
60
|
+
return this.contextStorage;
|
|
61
|
+
}
|
|
42
62
|
}
|
|
43
63
|
//# sourceMappingURL=applicationContext.context.js.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Application } from "./application.js";
|
|
2
|
+
import { Container } from "../container/container.js";
|
|
3
|
+
import { ConfigurationManager } from "../configuration/configurationManager.manager.js";
|
|
4
|
+
import type { Logger } from "../logging/core/logger.js";
|
|
5
|
+
import type { LoggerOptions } from "../logging/core/loggerOptions.options.js";
|
|
6
|
+
import type { LifecycleParticipant } from "../lifecycle/core/lifecycle.js";
|
|
7
|
+
import type { ModuleDefinition } from "../modules/moduleDefinition.definition.js";
|
|
8
|
+
import type { ModuleRegistry } from "../modules/moduleRegistry/index.js";
|
|
9
|
+
import type { RuntimeOptions } from "../runtime/runtimeOptions/runtimeOptions.type.js";
|
|
10
|
+
import type { RuntimeSignalTarget } from "../runtime/runtimeSignals/runtimeSignals.js";
|
|
11
|
+
import type { ContextStorage } from "../context/provider/contextStorage.storage.js";
|
|
12
|
+
/**
|
|
13
|
+
* Options for {@link createApplication}.
|
|
14
|
+
*/
|
|
15
|
+
export interface CreateApplicationOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Module definitions to register before the runtime starts.
|
|
18
|
+
*/
|
|
19
|
+
readonly modules?: readonly ModuleDefinition[];
|
|
20
|
+
/**
|
|
21
|
+
* Application-level lifecycle participants (registered on the
|
|
22
|
+
* application Lifecycle in order).
|
|
23
|
+
*/
|
|
24
|
+
readonly participants?: readonly LifecycleParticipant[];
|
|
25
|
+
/**
|
|
26
|
+
* Runtime options (name, mode, role, startup/shutdown/signal
|
|
27
|
+
* behaviour). The startup/shutdown continueOn*Error flags are also
|
|
28
|
+
* applied to the module lifecycle manager so both layers agree.
|
|
29
|
+
*/
|
|
30
|
+
readonly runtime?: RuntimeOptions;
|
|
31
|
+
/**
|
|
32
|
+
* Pre-built configuration manager. Initialized here if it has not
|
|
33
|
+
* been initialized yet.
|
|
34
|
+
*/
|
|
35
|
+
readonly configuration?: ConfigurationManager;
|
|
36
|
+
/**
|
|
37
|
+
* Logger, or options for the default ConsoleLogger.
|
|
38
|
+
*/
|
|
39
|
+
readonly logger?: Logger | LoggerOptions;
|
|
40
|
+
/**
|
|
41
|
+
* Dependency container for the application context. When omitted a
|
|
42
|
+
* Container whose `currentScope` is the current execution context
|
|
43
|
+
* (from `contextStorage`) is created, so "scoped" providers resolve
|
|
44
|
+
* to one instance per execution context.
|
|
45
|
+
*/
|
|
46
|
+
readonly container?: Container;
|
|
47
|
+
/**
|
|
48
|
+
* ContextStorage shared by the application context, container
|
|
49
|
+
* scoping, module lifecycle, runtime, and (when the logger is
|
|
50
|
+
* created here) the logger. Defaults to getDefaultContextStorage().
|
|
51
|
+
*/
|
|
52
|
+
readonly contextStorage?: ContextStorage;
|
|
53
|
+
/**
|
|
54
|
+
* Module registry; created when omitted.
|
|
55
|
+
*/
|
|
56
|
+
readonly moduleRegistry?: ModuleRegistry;
|
|
57
|
+
/**
|
|
58
|
+
* Process-like target for signal handling (tests inject an emitter).
|
|
59
|
+
*/
|
|
60
|
+
readonly signalTarget?: RuntimeSignalTarget;
|
|
61
|
+
/**
|
|
62
|
+
* Start the application before returning. Defaults to false.
|
|
63
|
+
*/
|
|
64
|
+
readonly autoStart?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Wires the standard application graph — container, configuration,
|
|
68
|
+
* logger, module registry/loader/lifecycle, runtime, and application
|
|
69
|
+
* lifecycle — and returns an initialized Application. One
|
|
70
|
+
* ContextStorage is threaded through every piece, so the runtime's
|
|
71
|
+
* execution context is visible from module hooks, container
|
|
72
|
+
* factories, lifecycle participants, and log entries.
|
|
73
|
+
*
|
|
74
|
+
* The runtime is created through a factory, so the application can be
|
|
75
|
+
* restarted (stop() then start()) with a fresh runtime each time.
|
|
76
|
+
*/
|
|
77
|
+
export declare function createApplication(options?: CreateApplicationOptions): Promise<Application>;
|
|
78
|
+
//# sourceMappingURL=createApplication.d.ts.map
|