@zudojs/core 1.2.4 → 1.3.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/README.md +13 -2
- package/dist/application/application.d.ts +29 -1
- package/dist/application/application.js +70 -1
- package/dist/application/applicationContext.context.d.ts +0 -1
- package/dist/application/applicationContext.context.js +0 -1
- package/dist/application/applicationState.state.d.ts +0 -1
- package/dist/application/applicationState.state.js +0 -1
- package/dist/application/createApplication.d.ts +0 -1
- package/dist/application/createApplication.js +0 -1
- package/dist/application/index.d.ts +0 -1
- package/dist/application/index.js +0 -1
- package/dist/configuration/configurationManager.manager.d.ts +0 -1
- package/dist/configuration/configurationManager.manager.js +0 -1
- package/dist/configuration/core/configuration.d.ts +0 -1
- package/dist/configuration/core/configuration.js +0 -1
- package/dist/configuration/core/configurationKey.key.d.ts +0 -1
- package/dist/configuration/core/configurationKey.key.js +0 -1
- package/dist/configuration/core/configurationPath.path.d.ts +0 -1
- package/dist/configuration/core/configurationPath.path.js +0 -1
- package/dist/configuration/core/configurationSource.source.d.ts +0 -1
- package/dist/configuration/core/configurationSource.source.js +0 -1
- package/dist/configuration/core/index.d.ts +0 -1
- package/dist/configuration/core/index.js +0 -1
- package/dist/configuration/error/configurationError.error.d.ts +0 -1
- package/dist/configuration/error/configurationError.error.js +0 -1
- package/dist/configuration/error/configurationRedactor.redactor.d.ts +0 -1
- package/dist/configuration/error/configurationRedactor.redactor.js +0 -1
- package/dist/configuration/error/index.d.ts +0 -1
- package/dist/configuration/error/index.js +0 -1
- package/dist/configuration/events/configurationEvents.events.d.ts +0 -1
- package/dist/configuration/events/configurationEvents.events.js +0 -1
- package/dist/configuration/events/index.d.ts +0 -1
- package/dist/configuration/events/index.js +0 -1
- package/dist/configuration/index.d.ts +0 -1
- package/dist/configuration/index.js +0 -1
- package/dist/configuration/loader/configurationLoader.loader.d.ts +0 -1
- package/dist/configuration/loader/configurationLoader.loader.js +0 -1
- package/dist/configuration/loader/index.d.ts +0 -1
- package/dist/configuration/loader/index.js +0 -1
- package/dist/configuration/registry/configurationProvider.provider.d.ts +0 -1
- package/dist/configuration/registry/configurationProvider.provider.js +0 -1
- package/dist/configuration/registry/configurationRegistry.registry.d.ts +0 -1
- package/dist/configuration/registry/configurationRegistry.registry.js +0 -1
- package/dist/configuration/registry/index.d.ts +0 -1
- package/dist/configuration/registry/index.js +0 -1
- package/dist/configuration/schema/configurationSchema.schema.d.ts +0 -1
- package/dist/configuration/schema/configurationSchema.schema.js +0 -1
- package/dist/configuration/schema/configurationValidation.validator.d.ts +0 -1
- package/dist/configuration/schema/configurationValidation.validator.js +0 -1
- package/dist/configuration/schema/index.d.ts +0 -1
- package/dist/configuration/schema/index.js +0 -1
- package/dist/container/container.d.ts +0 -1
- package/dist/container/container.js +0 -1
- package/dist/container/container.lifetime.d.ts +0 -1
- package/dist/container/container.lifetime.js +0 -1
- package/dist/container/index.d.ts +0 -1
- package/dist/container/index.js +0 -1
- package/dist/container/provider.d.ts +0 -1
- package/dist/container/provider.js +0 -1
- package/dist/container/scope.d.ts +0 -1
- package/dist/container/scope.js +0 -1
- package/dist/container/token.d.ts +0 -1
- package/dist/container/token.js +0 -1
- package/dist/context/core/contextAliases.deprecated.d.ts +0 -1
- package/dist/context/core/contextAliases.deprecated.js +0 -1
- package/dist/context/core/contextKey.key.d.ts +0 -1
- package/dist/context/core/contextKey.key.js +4 -3
- package/dist/context/core/executionContext.context.d.ts +0 -1
- package/dist/context/core/executionContext.context.js +0 -1
- package/dist/context/core/index.d.ts +0 -1
- package/dist/context/core/index.js +0 -1
- package/dist/context/index.d.ts +0 -1
- package/dist/context/index.js +0 -1
- package/dist/context/provider/contextProvider.provider.d.ts +0 -1
- package/dist/context/provider/contextProvider.provider.js +0 -1
- package/dist/context/provider/contextStorage.storage.d.ts +0 -1
- package/dist/context/provider/contextStorage.storage.js +0 -1
- package/dist/context/provider/defaultContextStorage.storage.d.ts +0 -1
- package/dist/context/provider/defaultContextStorage.storage.js +0 -1
- package/dist/context/provider/index.d.ts +0 -1
- package/dist/context/provider/index.js +0 -1
- package/dist/context/snapshot/contextSnapshot.snapshot.d.ts +0 -1
- package/dist/context/snapshot/contextSnapshot.snapshot.js +0 -1
- package/dist/context/snapshot/index.d.ts +0 -1
- package/dist/context/snapshot/index.js +0 -1
- package/dist/context/values/contextValues.values.d.ts +0 -1
- package/dist/context/values/contextValues.values.js +0 -1
- package/dist/context/values/index.d.ts +0 -1
- package/dist/context/values/index.js +0 -1
- package/dist/contracts/adapter.d.ts +0 -1
- package/dist/contracts/adapter.js +0 -1
- package/dist/contracts/disposable.d.ts +0 -1
- package/dist/contracts/disposable.js +0 -1
- package/dist/contracts/handler.d.ts +0 -1
- package/dist/contracts/handler.js +0 -1
- package/dist/contracts/index.d.ts +0 -1
- package/dist/contracts/index.js +0 -1
- package/dist/errors/contextValueNotFound.error.d.ts +15 -0
- package/dist/errors/contextValueNotFound.error.js +23 -0
- package/dist/errors/errorCode.code.d.ts +1 -1
- package/dist/errors/errorCode.code.js +1 -1
- package/dist/errors/exceptions.d.ts +0 -1
- package/dist/errors/exceptions.js +0 -1
- package/dist/errors/frameworkError.error.d.ts +0 -1
- package/dist/errors/frameworkError.error.js +0 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +16 -1
- package/dist/lifecycle/core/index.d.ts +0 -1
- package/dist/lifecycle/core/index.js +0 -1
- package/dist/lifecycle/core/lifecycle.d.ts +12 -2
- package/dist/lifecycle/core/lifecycle.js +12 -2
- package/dist/lifecycle/core/lifecycle.rollback.d.ts +0 -1
- package/dist/lifecycle/core/lifecycle.rollback.js +0 -1
- package/dist/lifecycle/core/lifecycleHook.hook.d.ts +0 -1
- package/dist/lifecycle/core/lifecycleHook.hook.js +0 -1
- package/dist/lifecycle/core/lifecycleRegistry.registry.d.ts +0 -1
- package/dist/lifecycle/core/lifecycleRegistry.registry.js +0 -1
- package/dist/lifecycle/index.d.ts +0 -1
- package/dist/lifecycle/index.js +0 -1
- package/dist/lifecycle/manager/index.d.ts +0 -1
- package/dist/lifecycle/manager/index.js +0 -1
- package/dist/lifecycle/manager/lifecycleManager.manager.d.ts +0 -1
- package/dist/lifecycle/manager/lifecycleManager.manager.js +0 -1
- package/dist/lifecycle/scope/index.d.ts +0 -1
- package/dist/lifecycle/scope/index.js +0 -1
- package/dist/lifecycle/scope/lifecycleScope.scope.d.ts +0 -1
- package/dist/lifecycle/scope/lifecycleScope.scope.js +0 -1
- package/dist/logging/console/consoleLogger.logger.d.ts +0 -1
- package/dist/logging/console/consoleLogger.logger.js +6 -2
- package/dist/logging/console/index.d.ts +0 -1
- package/dist/logging/console/index.js +0 -1
- package/dist/logging/console/loggerFactory.factory.d.ts +0 -1
- package/dist/logging/console/loggerFactory.factory.js +0 -1
- package/dist/logging/core/index.d.ts +0 -1
- package/dist/logging/core/index.js +0 -1
- package/dist/logging/core/logEntry.entry.d.ts +0 -1
- package/dist/logging/core/logEntry.entry.js +0 -1
- package/dist/logging/core/logLevel.level.d.ts +0 -1
- package/dist/logging/core/logLevel.level.js +0 -1
- package/dist/logging/core/logRedaction.redaction.d.ts +0 -1
- package/dist/logging/core/logRedaction.redaction.js +0 -1
- package/dist/logging/core/logger.d.ts +7 -2
- package/dist/logging/core/logger.js +22 -3
- package/dist/logging/core/loggerContext.context.d.ts +0 -1
- package/dist/logging/core/loggerContext.context.js +0 -1
- package/dist/logging/core/loggerOptions.options.d.ts +6 -3
- package/dist/logging/core/loggerOptions.options.js +0 -1
- package/dist/logging/index.d.ts +0 -1
- package/dist/logging/index.js +0 -1
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +0 -1
- package/dist/modules/module.d.ts +0 -1
- package/dist/modules/module.js +0 -1
- package/dist/modules/moduleContext.context.d.ts +0 -1
- package/dist/modules/moduleContext.context.js +0 -1
- package/dist/modules/moduleDefinition.definition.d.ts +0 -1
- package/dist/modules/moduleDefinition.definition.js +0 -1
- package/dist/modules/moduleDependency/index.d.ts +0 -1
- package/dist/modules/moduleDependency/index.js +0 -1
- package/dist/modules/moduleDependency/moduleDependency.graph.d.ts +0 -1
- package/dist/modules/moduleDependency/moduleDependency.graph.js +0 -1
- package/dist/modules/moduleDependency/moduleDependency.ordering.d.ts +0 -1
- package/dist/modules/moduleDependency/moduleDependency.ordering.js +0 -1
- package/dist/modules/moduleDependency/moduleDependency.type.d.ts +0 -1
- package/dist/modules/moduleDependency/moduleDependency.type.js +0 -1
- package/dist/modules/moduleError/index.d.ts +0 -1
- package/dist/modules/moduleError/index.js +0 -1
- package/dist/modules/moduleError/moduleError.base.d.ts +0 -1
- package/dist/modules/moduleError/moduleError.base.js +0 -1
- package/dist/modules/moduleError/moduleError.dependency.d.ts +19 -3
- package/dist/modules/moduleError/moduleError.dependency.js +16 -4
- package/dist/modules/moduleError/moduleError.helpers.d.ts +0 -1
- package/dist/modules/moduleError/moduleError.helpers.js +0 -1
- package/dist/modules/moduleError/moduleError.lifecycle.d.ts +0 -1
- package/dist/modules/moduleError/moduleError.lifecycle.js +0 -1
- package/dist/modules/moduleError/moduleError.registration.d.ts +0 -1
- package/dist/modules/moduleError/moduleError.registration.js +0 -1
- package/dist/modules/moduleLifecycle/index.d.ts +0 -1
- package/dist/modules/moduleLifecycle/index.js +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.exclusive.d.ts +25 -0
- package/dist/modules/moduleLifecycle/moduleLifecycle.exclusive.js +63 -0
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.d.ts +20 -2
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.js +52 -20
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.d.ts +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.js +4 -3
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.d.ts +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.js +0 -1
- package/dist/modules/moduleLoader/index.d.ts +0 -1
- package/dist/modules/moduleLoader/index.js +0 -1
- package/dist/modules/moduleLoader/moduleLoader.loader.d.ts +0 -1
- package/dist/modules/moduleLoader/moduleLoader.loader.js +0 -1
- package/dist/modules/moduleLoader/moduleLoader.type.d.ts +0 -1
- package/dist/modules/moduleLoader/moduleLoader.type.js +0 -1
- package/dist/modules/moduleMetadata.metadata.d.ts +0 -1
- package/dist/modules/moduleMetadata.metadata.js +0 -1
- package/dist/modules/moduleRegistry/index.d.ts +0 -1
- package/dist/modules/moduleRegistry/index.js +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.registry.d.ts +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.registry.js +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.type.d.ts +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.type.js +0 -1
- package/dist/runtime/index.d.ts +1 -2
- package/dist/runtime/index.js +0 -1
- package/dist/runtime/runtime.d.ts +18 -2
- package/dist/runtime/runtime.js +23 -1
- package/dist/runtime/runtimeBootstrap/index.d.ts +0 -1
- package/dist/runtime/runtimeBootstrap/index.js +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/index.d.ts +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/index.js +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.d.ts +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.js +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.d.ts +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.js +8 -2
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.d.ts +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.js +0 -1
- package/dist/runtime/runtimeContext/index.d.ts +0 -1
- package/dist/runtime/runtimeContext/index.js +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.factory.d.ts +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.factory.js +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.type.d.ts +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.type.js +0 -1
- package/dist/runtime/runtimeEnvironment/detection/index.d.ts +0 -1
- package/dist/runtime/runtimeEnvironment/detection/index.js +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.detection.d.ts +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.detection.js +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.d.ts +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.js +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.d.ts +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.js +0 -1
- package/dist/runtime/runtimeEnvironment/index.d.ts +0 -1
- package/dist/runtime/runtimeEnvironment/index.js +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.d.ts +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.js +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.d.ts +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.js +0 -1
- package/dist/runtime/runtimeError/index.d.ts +0 -1
- package/dist/runtime/runtimeError/index.js +0 -1
- package/dist/runtime/runtimeError/runtimeError.base.d.ts +0 -1
- package/dist/runtime/runtimeError/runtimeError.base.js +0 -1
- package/dist/runtime/runtimeError/runtimeError.lifecycle.d.ts +0 -1
- package/dist/runtime/runtimeError/runtimeError.lifecycle.js +0 -1
- package/dist/runtime/runtimeError/runtimeError.specialized.d.ts +0 -1
- package/dist/runtime/runtimeError/runtimeError.specialized.js +0 -1
- package/dist/runtime/runtimeError/runtimeError.type.d.ts +0 -1
- package/dist/runtime/runtimeError/runtimeError.type.js +0 -1
- package/dist/runtime/runtimeLogger.d.ts +0 -1
- package/dist/runtime/runtimeLogger.js +5 -2
- package/dist/runtime/runtimeOptions/index.d.ts +0 -1
- package/dist/runtime/runtimeOptions/index.js +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.d.ts +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.js +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.mode.d.ts +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.mode.js +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.resolver.d.ts +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.resolver.js +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.type.d.ts +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.type.js +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.validation.d.ts +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.validation.js +0 -1
- package/dist/runtime/runtimeShutdown/index.d.ts +0 -1
- package/dist/runtime/runtimeShutdown/index.js +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/index.d.ts +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/index.js +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.d.ts +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.js +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.d.ts +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.js +4 -2
- package/dist/runtime/runtimeShutdown/runtimeShutdown.type.d.ts +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.type.js +0 -1
- package/dist/runtime/runtimeSignals/index.d.ts +0 -1
- package/dist/runtime/runtimeSignals/index.js +0 -1
- package/dist/runtime/runtimeSignals/runtimeSignals.d.ts +7 -3
- package/dist/runtime/runtimeSignals/runtimeSignals.fatal.d.ts +0 -1
- package/dist/runtime/runtimeSignals/runtimeSignals.fatal.js +0 -1
- package/dist/runtime/runtimeSignals/runtimeSignals.js +4 -5
- package/dist/runtime/runtimeState.state.d.ts +0 -1
- package/dist/runtime/runtimeState.state.js +0 -1
- package/dist/runtime/runtimeTimeout.d.ts +0 -1
- package/dist/runtime/runtimeTimeout.js +0 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -76,6 +76,10 @@ const app = await Application.create({
|
|
|
76
76
|
|
|
77
77
|
A failed `lifecycle.start()` stops, in reverse order, every participant whose `start()` completed, so a retry starts from the first one again. `dispose()` only reaches participants whose `initialize()` ran.
|
|
78
78
|
|
|
79
|
+
### Names shared with sibling packages
|
|
80
|
+
|
|
81
|
+
`LifecycleState`, `Lifecycle`, `LifecycleManager`, `createRuntime`, `Container` and `ConfigurationManager` are also exported — with different meanings — by `@zudojs/constants`, `@zudojs/lifecycle`, `@zudojs/runtime`, `@zudojs/container` and `@zudojs/config`. This package's `LifecycleState` (`created … running … stopped`) is the state of the core `Lifecycle` participant machine; `@zudojs/constants`' is the component state used by `@zudojs/lifecycle` (`idle … ready … disposed`); `@zudojs/runtime` has its own `RuntimeState`. When two of these packages meet in one file, import the aliases `CoreLifecycleState`, `CoreLifecycle`, `CoreLifecycleManager`, `createCoreRuntime`, `CoreContainer` and `CoreConfigurationManager` instead of renaming at the import.
|
|
82
|
+
|
|
79
83
|
## Runtime
|
|
80
84
|
|
|
81
85
|
`createRuntime(dependencies, options)` returns a single-use runtime:
|
|
@@ -87,7 +91,8 @@ FAILED is reachable from every non-terminal state via fail() or a failure.
|
|
|
87
91
|
|
|
88
92
|
- `start()` loads, initializes, and starts modules through the bootstrap pipeline; `getStatus().bootstrap` reports counts, errors, and duration.
|
|
89
93
|
- `stop()` stops and destroys modules through the shutdown pipeline; `getStatus().shutdown` reports the same.
|
|
90
|
-
- `startup.timeoutMs` / `shutdown.timeoutMs` abort the pipeline with a `RuntimeTimeoutError`; the abandoned pipeline can never surface an unhandled rejection. A timed-out bootstrap starts no further phase or module hook
|
|
94
|
+
- `startup.timeoutMs` / `shutdown.timeoutMs` abort the pipeline with a `RuntimeTimeoutError`; the abandoned pipeline can never surface an unhandled rejection. `startup.timeoutMs` defaults to `0` (no deadline) — set one in production. A timed-out bootstrap starts no further phase or module hook. `stop()` does not wait behind the hook that is still running: it tears down every module that came up and returns; the stuck module stays in its active phase, and if its hook settles later it is stopped and destroyed then (best-effort, recorded on its lifecycle state).
|
|
95
|
+
- Rollback and shutdown only call `onDestroy` on modules whose `onInitialize` was invoked; a module that was never reached (a dependent of the one that failed) is left untouched.
|
|
91
96
|
- `continueOnInitializeError` / `continueOnStartError` (and the stop/destroy equivalents) make the runtime finish with `success: false` and the failures listed instead of throwing.
|
|
92
97
|
- Every error the runtime throws extends `RuntimeError` (which itself extends `RuntimeError` from `@zudojs/errors`), so `isRuntimeError()` from either package recognises it.
|
|
93
98
|
- `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()`).
|
|
@@ -96,6 +101,10 @@ FAILED is reachable from every non-terminal state via fail() or a failure.
|
|
|
96
101
|
|
|
97
102
|
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 exits the process with `signals.forceExitCode` (default 1); set `signals.forceExitOnSecondSignal: false` to log and ignore it instead. `handleUncaughtException` / `handleUnhandledRejection` mark the runtime failed, stop it, and then exit the process with code 1, because the installed handler suppresses Node's own crash and the process would otherwise end with code 0. `signals.fatalExitTimeout` (default 10000 ms) bounds a shutdown that hangs; set `signals.exitOnFatalError: false` to stop the runtime and keep the process running. The runtime never calls `process.exit()` otherwise.
|
|
98
103
|
|
|
104
|
+
An `Application` follows a stop its runtime started on its own (`runtime.onStateChange(listener)` reports every transition): after a signal it moves through `stopping` to `stopped` and stops its lifecycle participants; after a fatal error it ends `failed`. `Application.stop()` is single-flight, so a concurrent call joins the run in progress. `signalTarget` accepts `process` or any `EventEmitter` without a cast.
|
|
105
|
+
|
|
106
|
+
Diagnostics log entries carry `environment` (the runtime mode: development/test/production), `engine` (the JavaScript engine) and, for the start entries, the phase about to run.
|
|
107
|
+
|
|
99
108
|
## Modules
|
|
100
109
|
|
|
101
110
|
Modules implement the `Module` contract and are driven by `ModuleLifecycleManager` in dependency order:
|
|
@@ -125,8 +134,10 @@ onInitialize → onReady → onShutdown → onDestroy
|
|
|
125
134
|
- `logger.child({ moduleId })` merges the context into every entry it emits; `LoggerOptions.context` is attached to every entry.
|
|
126
135
|
- `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.
|
|
127
136
|
- An unknown `level` throws `InvalidArgumentError` at construction rather than silently disabling logging.
|
|
128
|
-
- Error causes are serialised recursively with a depth limit
|
|
137
|
+
- Error causes are serialised recursively with a depth limit. Sensitive keys (`password`, `secret`, `token`, `apiKey`, `authorization`, ...) in context and error details are redacted **by default** (`createLogRedactor()`); pass `redact: false` to log them in clear, or your own hook to replace the default. Child loggers inherit the setting.
|
|
138
|
+
- `logger.error(message, error, context?)` also accepts the `@zudojs/logger` convention `logger.error(message, context)`: a plain object in the second position with no third argument is logged as context. To log a plain object as the error, pass a third argument.
|
|
129
139
|
- `trace` output goes through `console.debug`, so the structured-output invariant holds.
|
|
140
|
+
- `ContextValues.require(key)` throws `ContextValueNotFoundError` (`CORE_CONTEXT_VALUE_NOT_FOUND`) rather than a bare `Error`.
|
|
130
141
|
|
|
131
142
|
## Execution context
|
|
132
143
|
|
|
@@ -28,12 +28,21 @@ export interface ApplicationOptions {
|
|
|
28
28
|
* inside the runtime's execution context (`runtime.contextStorage`
|
|
29
29
|
* / `runtime.context`), so lifecycle participants observe the same
|
|
30
30
|
* context as module hooks.
|
|
31
|
+
*
|
|
32
|
+
* A stop the runtime starts on its own — a SIGTERM handled by its
|
|
33
|
+
* signal manager, or a fatal error — is followed: the application
|
|
34
|
+
* moves through `stopping` to `stopped` (or `failed`) and its
|
|
35
|
+
* participants are stopped too. Previously the runtime reported
|
|
36
|
+
* `stopped` while the application stayed `running` with its
|
|
37
|
+
* participants still up.
|
|
31
38
|
*/
|
|
32
39
|
export declare class Application {
|
|
33
40
|
private readonly context?;
|
|
34
41
|
private readonly lifecycle?;
|
|
35
42
|
private readonly runtimeFactory?;
|
|
36
43
|
private runtime?;
|
|
44
|
+
private unobserveRuntime?;
|
|
45
|
+
private stopPromise?;
|
|
37
46
|
private _state;
|
|
38
47
|
private constructor();
|
|
39
48
|
static create(options?: ApplicationOptions): Promise<Application>;
|
|
@@ -46,7 +55,14 @@ export declare class Application {
|
|
|
46
55
|
get applicationRuntime(): Runtime | undefined;
|
|
47
56
|
initialize(): Promise<void>;
|
|
48
57
|
start(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Stops the runtime, then the lifecycle participants.
|
|
60
|
+
*
|
|
61
|
+
* Single-flight: a second call while stopping joins the first
|
|
62
|
+
* instead of throwing `InvalidStateError`.
|
|
63
|
+
*/
|
|
49
64
|
stop(): Promise<void>;
|
|
65
|
+
private performStop;
|
|
50
66
|
/**
|
|
51
67
|
* Stops the application and releases lifecycle resources. The
|
|
52
68
|
* application cannot be restarted afterwards.
|
|
@@ -62,5 +78,17 @@ export declare class Application {
|
|
|
62
78
|
* unused, or a new one from the factory after a stop/failure.
|
|
63
79
|
*/
|
|
64
80
|
private ensureRuntime;
|
|
81
|
+
/**
|
|
82
|
+
* Follows state transitions of the runtime being started.
|
|
83
|
+
*/
|
|
84
|
+
private observe;
|
|
85
|
+
/**
|
|
86
|
+
* Reacts to a stop or failure the runtime started on its own while
|
|
87
|
+
* the application was running. Deferred to a microtask: the runtime
|
|
88
|
+
* records its in-flight stop promise only after the synchronous part
|
|
89
|
+
* of `stop()` returns, so calling `stop()` from inside the listener
|
|
90
|
+
* would start a second, overlapping shutdown.
|
|
91
|
+
*/
|
|
92
|
+
private onRuntimeTransition;
|
|
93
|
+
private followRuntime;
|
|
65
94
|
}
|
|
66
|
-
//# sourceMappingURL=application.d.ts.map
|
|
@@ -11,12 +11,21 @@ import { InvalidStateError } from "../errors/exceptions.js";
|
|
|
11
11
|
* inside the runtime's execution context (`runtime.contextStorage`
|
|
12
12
|
* / `runtime.context`), so lifecycle participants observe the same
|
|
13
13
|
* context as module hooks.
|
|
14
|
+
*
|
|
15
|
+
* A stop the runtime starts on its own — a SIGTERM handled by its
|
|
16
|
+
* signal manager, or a fatal error — is followed: the application
|
|
17
|
+
* moves through `stopping` to `stopped` (or `failed`) and its
|
|
18
|
+
* participants are stopped too. Previously the runtime reported
|
|
19
|
+
* `stopped` while the application stayed `running` with its
|
|
20
|
+
* participants still up.
|
|
14
21
|
*/
|
|
15
22
|
export class Application {
|
|
16
23
|
context;
|
|
17
24
|
lifecycle;
|
|
18
25
|
runtimeFactory;
|
|
19
26
|
runtime;
|
|
27
|
+
unobserveRuntime;
|
|
28
|
+
stopPromise;
|
|
20
29
|
_state;
|
|
21
30
|
constructor(options = {}) {
|
|
22
31
|
this.context = options.context;
|
|
@@ -74,6 +83,7 @@ export class Application {
|
|
|
74
83
|
// Resolve the runtime first so a refused restart leaves the
|
|
75
84
|
// application untouched.
|
|
76
85
|
const runtime = this.ensureRuntime();
|
|
86
|
+
this.observe(runtime);
|
|
77
87
|
this._state = "starting";
|
|
78
88
|
try {
|
|
79
89
|
await this.inRuntimeContext(runtime, async () => {
|
|
@@ -87,15 +97,33 @@ export class Application {
|
|
|
87
97
|
throw error;
|
|
88
98
|
}
|
|
89
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Stops the runtime, then the lifecycle participants.
|
|
102
|
+
*
|
|
103
|
+
* Single-flight: a second call while stopping joins the first
|
|
104
|
+
* instead of throwing `InvalidStateError`.
|
|
105
|
+
*/
|
|
90
106
|
async stop() {
|
|
91
107
|
if (this._state === "stopped" ||
|
|
92
108
|
this._state === "created" ||
|
|
93
109
|
this._state === "initialized") {
|
|
94
110
|
return;
|
|
95
111
|
}
|
|
112
|
+
if (this._state === "stopping" && this.stopPromise) {
|
|
113
|
+
return this.stopPromise;
|
|
114
|
+
}
|
|
96
115
|
if (this._state !== "running" && this._state !== "failed") {
|
|
97
116
|
throw new InvalidStateError(`Application cannot stop from state "${this._state}".`, { state: this._state });
|
|
98
117
|
}
|
|
118
|
+
this.stopPromise = this.performStop();
|
|
119
|
+
try {
|
|
120
|
+
await this.stopPromise;
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
this.stopPromise = undefined;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async performStop() {
|
|
99
127
|
this._state = "stopping";
|
|
100
128
|
const errors = [];
|
|
101
129
|
const runtime = this.runtime;
|
|
@@ -180,5 +208,46 @@ export class Application {
|
|
|
180
208
|
return undefined;
|
|
181
209
|
throw new InvalidStateError(`Application runtime is "${current.state}" and cannot be restarted; supply a runtime factory to enable restart.`, { runtimeState: current.state });
|
|
182
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Follows state transitions of the runtime being started.
|
|
213
|
+
*/
|
|
214
|
+
observe(runtime) {
|
|
215
|
+
this.unobserveRuntime?.();
|
|
216
|
+
this.unobserveRuntime = runtime?.onStateChange?.((transition) => {
|
|
217
|
+
this.onRuntimeTransition(transition);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Reacts to a stop or failure the runtime started on its own while
|
|
222
|
+
* the application was running. Deferred to a microtask: the runtime
|
|
223
|
+
* records its in-flight stop promise only after the synchronous part
|
|
224
|
+
* of `stop()` returns, so calling `stop()` from inside the listener
|
|
225
|
+
* would start a second, overlapping shutdown.
|
|
226
|
+
*/
|
|
227
|
+
onRuntimeTransition(transition) {
|
|
228
|
+
if (this._state !== "running")
|
|
229
|
+
return;
|
|
230
|
+
if (transition.to !== RuntimeState.STOPPING &&
|
|
231
|
+
transition.to !== RuntimeState.FAILED) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
queueMicrotask(() => {
|
|
235
|
+
void this.followRuntime(transition.to);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
async followRuntime(target) {
|
|
239
|
+
if (this._state !== "running")
|
|
240
|
+
return;
|
|
241
|
+
try {
|
|
242
|
+
await this.stop();
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
/* stop() has already recorded the failure in the state. */
|
|
246
|
+
}
|
|
247
|
+
// Read through the getter: the guard above narrowed `this._state`
|
|
248
|
+
// to "running" and stop() has changed it since.
|
|
249
|
+
if (target === RuntimeState.FAILED && this.state === "stopped") {
|
|
250
|
+
this._state = "failed";
|
|
251
|
+
}
|
|
252
|
+
}
|
|
183
253
|
}
|
|
184
|
-
//# sourceMappingURL=application.js.map
|
|
@@ -75,4 +75,3 @@ export interface CreateApplicationOptions {
|
|
|
75
75
|
* restarted (stop() then start()) with a fresh runtime each time.
|
|
76
76
|
*/
|
|
77
77
|
export declare function createApplication(options?: CreateApplicationOptions): Promise<Application>;
|
|
78
|
-
//# sourceMappingURL=createApplication.d.ts.map
|
|
@@ -107,4 +107,3 @@ export declare class ConfigurationManager {
|
|
|
107
107
|
}
|
|
108
108
|
/** Creates a ConfigurationManager. */
|
|
109
109
|
export declare function createConfigurationManager(options?: ConfigurationManagerOptions): ConfigurationManager;
|
|
110
|
-
//# sourceMappingURL=configurationManager.manager.d.ts.map
|
|
@@ -14,4 +14,3 @@ export declare function normalizeConfigurationPath(path: string): string;
|
|
|
14
14
|
* Normalizes a configuration path and rejects empty results.
|
|
15
15
|
*/
|
|
16
16
|
export declare function requireConfigurationPath(path: string): string;
|
|
17
|
-
//# sourceMappingURL=configurationPath.path.d.ts.map
|
|
@@ -111,4 +111,3 @@ export declare function createConfigurationSource(options: ConfigurationSourceOp
|
|
|
111
111
|
* take precedence when values are merged.
|
|
112
112
|
*/
|
|
113
113
|
export declare function sortConfigurationSources(sources: readonly ConfigurationSource[]): ConfigurationSource[];
|
|
114
|
-
//# sourceMappingURL=configurationSource.source.d.ts.map
|
|
@@ -15,4 +15,3 @@ export type { ConfigurationKey } from "./configurationKey.key.js";
|
|
|
15
15
|
export { normalizeConfigurationPath, requireConfigurationPath, } from "./configurationPath.path.js";
|
|
16
16
|
export { BaseConfigurationSource, createConfigurationSource, sortConfigurationSources, } from "./configurationSource.source.js";
|
|
17
17
|
export type { ConfigurationSource, ConfigurationSourceType, ConfigurationSourceEntry, ConfigurationSourceOptions, } from "./configurationSource.source.js";
|
|
18
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -7,4 +7,3 @@ export { Configuration, createConfiguration } from "./configuration.js";
|
|
|
7
7
|
export { createConfigurationKey } from "./configurationKey.key.js";
|
|
8
8
|
export { normalizeConfigurationPath, requireConfigurationPath, } from "./configurationPath.path.js";
|
|
9
9
|
export { BaseConfigurationSource, createConfigurationSource, sortConfigurationSources, } from "./configurationSource.source.js";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -124,4 +124,3 @@ export declare function createConfigurationRedactor(options?: ConfigurationRedac
|
|
|
124
124
|
* Redacts configuration using the default redaction rules.
|
|
125
125
|
*/
|
|
126
126
|
export declare function redactConfiguration(configuration: Configuration): RedactedConfiguration;
|
|
127
|
-
//# sourceMappingURL=configurationRedactor.redactor.d.ts.map
|
|
@@ -8,4 +8,3 @@ export { describeConfigurationCause } from "./configurationError.error.js";
|
|
|
8
8
|
export type { ConfigurationErrorIssue } from "./configurationError.error.js";
|
|
9
9
|
export { ConfigurationRedactor, createConfigurationRedactor, redactConfiguration, DEFAULT_SENSITIVE_PATTERNS, DEFAULT_REDACTION_VALUE, } from "./configurationRedactor.redactor.js";
|
|
10
10
|
export type { ConfigurationRedactorOptions, ConfigurationSensitivity, RedactedConfiguration, } from "./configurationRedactor.redactor.js";
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -6,4 +6,3 @@
|
|
|
6
6
|
export { ConfigurationError, ConfigurationSourceError, ConfigurationMissingError, ConfigurationPathError, ConfigurationTypeError, ConfigurationSchemaError, ConfigurationConflictError, } from "./configurationError.error.js";
|
|
7
7
|
export { describeConfigurationCause } from "./configurationError.error.js";
|
|
8
8
|
export { ConfigurationRedactor, createConfigurationRedactor, redactConfiguration, DEFAULT_SENSITIVE_PATTERNS, DEFAULT_REDACTION_VALUE, } from "./configurationRedactor.redactor.js";
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -171,4 +171,3 @@ export declare function createConfigurationReloadingEvent(state: ConfigurationMa
|
|
|
171
171
|
* Creates a configuration reloaded event.
|
|
172
172
|
*/
|
|
173
173
|
export declare function createConfigurationReloadedEvent(state: ConfigurationManagerState, previousConfiguration: Configuration, configuration: Configuration, load: ConfigurationLoadResult, validation: ConfigurationValidationReport): ConfigurationReloadedEvent;
|
|
174
|
-
//# sourceMappingURL=configurationEvents.events.d.ts.map
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { ConfigurationEventType, createConfigurationEventBase, createConfigurationInitializingEvent, createConfigurationLoadedEvent, createConfigurationValidatedEvent, createConfigurationReadyEvent, createConfigurationFailedEvent, createConfigurationReloadingEvent, createConfigurationReloadedEvent, } from "./configurationEvents.events.js";
|
|
7
7
|
export type { ConfigurationEvent, ConfigurationInitializingEvent, ConfigurationLoadedEvent, ConfigurationValidatedEvent, ConfigurationReadyEvent, ConfigurationFailedEvent, ConfigurationReloadingEvent, ConfigurationReloadedEvent, ConfigurationLifecycleEvent, ConfigurationEventTypeValue, ConfigurationEventListener, } from "./configurationEvents.events.js";
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
* Configuration lifecycle events.
|
|
5
5
|
*/
|
|
6
6
|
export { ConfigurationEventType, createConfigurationEventBase, createConfigurationInitializingEvent, createConfigurationLoadedEvent, createConfigurationValidatedEvent, createConfigurationReadyEvent, createConfigurationFailedEvent, createConfigurationReloadingEvent, createConfigurationReloadedEvent, } from "./configurationEvents.events.js";
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -148,4 +148,3 @@ export declare class ConfigurationLoadError extends ConfigurationSourceError {
|
|
|
148
148
|
* Creates a ConfigurationLoader.
|
|
149
149
|
*/
|
|
150
150
|
export declare function createConfigurationLoader(options?: ConfigurationLoaderOptions): ConfigurationLoader;
|
|
151
|
-
//# sourceMappingURL=configurationLoader.loader.d.ts.map
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { ConfigurationLoader, ConfigurationLoadError, createConfigurationLoader, applyConfigurationSourceEntries, } from "./configurationLoader.loader.js";
|
|
7
7
|
export type { ConfigurationLoaderOptions, ConfigurationLoadResult, } from "./configurationLoader.loader.js";
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -152,4 +152,3 @@ export declare class DefaultConfigurationProvider implements ConfigurationProvid
|
|
|
152
152
|
* Creates the default configuration provider.
|
|
153
153
|
*/
|
|
154
154
|
export declare function createConfigurationProvider(options?: ConfigurationProviderOptions): ConfigurationProvider;
|
|
155
|
-
//# sourceMappingURL=configurationProvider.provider.d.ts.map
|
|
@@ -7,4 +7,3 @@ export { ConfigurationRegistry, createConfigurationRegistry, } from "./configura
|
|
|
7
7
|
export type { ConfigurationSection, ConfigurationSectionOptions, } from "./configurationRegistry.registry.js";
|
|
8
8
|
export { DefaultConfigurationProvider, createConfigurationProvider, } from "./configurationProvider.provider.js";
|
|
9
9
|
export type { ConfigurationProvider, ConfigurationProviderOptions, } from "./configurationProvider.provider.js";
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -91,4 +91,3 @@ export declare function applyConfigurationSchemaDefaults(configuration: Configur
|
|
|
91
91
|
* Validates one configuration schema.
|
|
92
92
|
*/
|
|
93
93
|
export declare function validateSchema<T>(configuration: Configuration, schema: ConfigurationSchema<T>): Promise<ConfigurationValidationResult<T>>;
|
|
94
|
-
//# sourceMappingURL=configurationValidation.validator.d.ts.map
|
|
@@ -7,4 +7,3 @@ export { createConfigurationSchema, ConfigurationSchemaRegistry, createConfigura
|
|
|
7
7
|
export type { ConfigurationValidationResult, ConfigurationValidationIssue, ConfigurationValidationContext, ConfigurationValidator, ConfigurationSchema, ConfigurationSchemaOptions, } from "./configurationSchema.schema.js";
|
|
8
8
|
export { ConfigurationValidationError, validateConfiguration, validateConfigurationOrThrow, validateSchema, applyConfigurationSchemaDefaults, } from "./configurationValidation.validator.js";
|
|
9
9
|
export type { ConfigurationValidationReport, ConfigurationValidationOptions, } from "./configurationValidation.validator.js";
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -5,4 +5,3 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { createConfigurationSchema, ConfigurationSchemaRegistry, createConfigurationSchemaRegistry, } from "./configurationSchema.schema.js";
|
|
7
7
|
export { ConfigurationValidationError, validateConfiguration, validateConfigurationOrThrow, validateSchema, applyConfigurationSchemaDefaults, } from "./configurationValidation.validator.js";
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -18,4 +18,3 @@ import type { Token } from "./token.js";
|
|
|
18
18
|
* @throws DependencyResolutionError when either rule is broken.
|
|
19
19
|
*/
|
|
20
20
|
export declare function assertScopedResolvable(token: Token<unknown>, captor: Token<unknown> | undefined, scopeKey: object | undefined, chain: readonly Token<unknown>[]): void;
|
|
21
|
-
//# sourceMappingURL=container.lifetime.d.ts.map
|
|
@@ -5,4 +5,3 @@ export { Container, ContainerScope, type ContainerOptions, } from "./container.j
|
|
|
5
5
|
export { createToken, type Token, type ConstructorToken } from "./token.js";
|
|
6
6
|
export { type Provider, type ClassProvider, type FactoryProvider, type ValueProvider, type Constructor, } from "./provider.js";
|
|
7
7
|
export { type Scope } from "./scope.js";
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/container/index.js
CHANGED
package/dist/container/scope.js
CHANGED
package/dist/container/token.js
CHANGED