@zudojs/core 1.2.3 → 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
|
@@ -29,10 +29,16 @@ export interface Logger {
|
|
|
29
29
|
warn(message: string, context?: LogContext): void;
|
|
30
30
|
/**
|
|
31
31
|
* Logs an error.
|
|
32
|
+
*
|
|
33
|
+
* Argument order differs from `@zudojs/logger`, whose signature is
|
|
34
|
+
* `error(message, metadata)`. Both conventions work here: a plain
|
|
35
|
+
* object in the second position with no third argument is treated
|
|
36
|
+
* as context, not as the error. To log a plain object AS the error,
|
|
37
|
+
* pass a third argument (`{}` will do).
|
|
32
38
|
*/
|
|
33
39
|
error(message: string, error?: unknown, context?: LogContext): void;
|
|
34
40
|
/**
|
|
35
|
-
* Logs a fatal error.
|
|
41
|
+
* Logs a fatal error. Accepts the same two conventions as `error`.
|
|
36
42
|
*/
|
|
37
43
|
fatal(message: string, error?: unknown, context?: LogContext): void;
|
|
38
44
|
/**
|
|
@@ -80,4 +86,3 @@ export declare abstract class BaseLogger implements Logger {
|
|
|
80
86
|
*/
|
|
81
87
|
protected abstract createChild(context: LogContext): Logger;
|
|
82
88
|
}
|
|
83
|
-
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -49,10 +49,12 @@ export class BaseLogger {
|
|
|
49
49
|
this.write("warn", message, this.mergeCallContext(context));
|
|
50
50
|
}
|
|
51
51
|
error(message, error, context) {
|
|
52
|
-
|
|
52
|
+
const [thrown, callContext] = splitErrorArguments(error, context);
|
|
53
|
+
this.write("error", message, this.mergeCallContext(callContext), thrown);
|
|
53
54
|
}
|
|
54
55
|
fatal(message, error, context) {
|
|
55
|
-
|
|
56
|
+
const [thrown, callContext] = splitErrorArguments(error, context);
|
|
57
|
+
this.write("fatal", message, this.mergeCallContext(callContext), thrown);
|
|
56
58
|
}
|
|
57
59
|
child(context) {
|
|
58
60
|
return this.createChild({
|
|
@@ -61,4 +63,21 @@ export class BaseLogger {
|
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Resolves the two `error()`/`fatal()` calling conventions: with no
|
|
68
|
+
* third argument, a plain object (not an Error, not a class instance)
|
|
69
|
+
* in the error position is the `@zudojs/logger`-style metadata.
|
|
70
|
+
*/
|
|
71
|
+
function splitErrorArguments(error, context) {
|
|
72
|
+
if (context === undefined && isPlainContext(error)) {
|
|
73
|
+
return [undefined, error];
|
|
74
|
+
}
|
|
75
|
+
return [error, context];
|
|
76
|
+
}
|
|
77
|
+
function isPlainContext(value) {
|
|
78
|
+
if (typeof value !== "object" || value === null || value instanceof Error) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
const prototype = Object.getPrototypeOf(value);
|
|
82
|
+
return prototype === Object.prototype || prototype === null;
|
|
83
|
+
}
|
|
@@ -71,4 +71,3 @@ export declare function loggerContextFromExecution(context: ExecutionContext): L
|
|
|
71
71
|
* with additional values.
|
|
72
72
|
*/
|
|
73
73
|
export declare function createLoggerContext(base?: LoggerContext, additional?: LoggerContext): LoggerContext;
|
|
74
|
-
//# sourceMappingURL=loggerContext.context.d.ts.map
|
|
@@ -60,9 +60,13 @@ export interface LoggerOptions {
|
|
|
60
60
|
* Redaction hook applied to structured log data (entry context
|
|
61
61
|
* and error details) before it is written.
|
|
62
62
|
*
|
|
63
|
-
*
|
|
63
|
+
* Defaults to `createLogRedactor()`, which replaces values under
|
|
64
|
+
* sensitive-looking keys (`password`, `secret`, `token`, `apiKey`,
|
|
65
|
+
* `authorization`, ...) with `"[REDACTED]"`. Logging such keys in
|
|
66
|
+
* clear used to be the default. Pass `false` to disable redaction,
|
|
67
|
+
* or your own hook to replace it.
|
|
64
68
|
*/
|
|
65
|
-
readonly redact?: LogRedactionHook;
|
|
69
|
+
readonly redact?: LogRedactionHook | false;
|
|
66
70
|
/**
|
|
67
71
|
* ContextStorage consulted on every write. When an execution
|
|
68
72
|
* context is active, its `executionId`, `correlationId`,
|
|
@@ -83,4 +87,3 @@ export type LogLevelOption = "trace" | "debug" | "info" | "warn" | "error" | "fa
|
|
|
83
87
|
* Default logging configuration.
|
|
84
88
|
*/
|
|
85
89
|
export declare const DEFAULT_LOGGER_OPTIONS: Required<Pick<LoggerOptions, "level" | "timestamps" | "structured" | "includeStackTrace">>;
|
|
86
|
-
//# sourceMappingURL=loggerOptions.options.d.ts.map
|
package/dist/logging/index.d.ts
CHANGED
package/dist/logging/index.js
CHANGED
package/dist/modules/index.d.ts
CHANGED
package/dist/modules/index.js
CHANGED
package/dist/modules/module.d.ts
CHANGED
package/dist/modules/module.js
CHANGED
|
@@ -113,4 +113,3 @@ export declare function normalizeDependencies(dependencies?: readonly (ModuleId
|
|
|
113
113
|
* Checks whether a value is a valid module definition.
|
|
114
114
|
*/
|
|
115
115
|
export declare function isModuleDefinition(value: unknown): value is ModuleDefinition;
|
|
116
|
-
//# sourceMappingURL=moduleDefinition.definition.d.ts.map
|
|
@@ -7,4 +7,3 @@
|
|
|
7
7
|
export { type ModuleDependency, type ModuleDependencies, type ModuleDependencyNode, type ModuleDependencyGraph, type ModuleDependencyInput, type ModuleDependencyNodeInput, } from "./moduleDependency.type.js";
|
|
8
8
|
export { normalizeModuleDependency, normalizeModuleDependencies, validateModuleDependencies, validateModuleDependencyGraph, createModuleDependencyGraph, createModuleDependency, isOptionalModuleDependency, hasModuleVersionConstraint, satisfiesModuleVersionConstraint, } from "./moduleDependency.graph.js";
|
|
9
9
|
export { findModuleDependencyCycle, hasModuleDependencyCycle, resolveModuleStartupOrder, resolveModuleShutdownOrder, } from "./moduleDependency.ordering.js";
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -7,4 +7,3 @@
|
|
|
7
7
|
export {} from "./moduleDependency.type.js";
|
|
8
8
|
export { normalizeModuleDependency, normalizeModuleDependencies, validateModuleDependencies, validateModuleDependencyGraph, createModuleDependencyGraph, createModuleDependency, isOptionalModuleDependency, hasModuleVersionConstraint, satisfiesModuleVersionConstraint, } from "./moduleDependency.graph.js";
|
|
9
9
|
export { findModuleDependencyCycle, hasModuleDependencyCycle, resolveModuleStartupOrder, resolveModuleShutdownOrder, } from "./moduleDependency.ordering.js";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -57,4 +57,3 @@ export declare function hasModuleVersionConstraint(dependency: ModuleDependency)
|
|
|
57
57
|
* the dependency module declares no version at all.
|
|
58
58
|
*/
|
|
59
59
|
export declare function satisfiesModuleVersionConstraint(constraint: string, version: string | undefined): boolean;
|
|
60
|
-
//# sourceMappingURL=moduleDependency.graph.d.ts.map
|
|
@@ -43,4 +43,3 @@ export declare function resolveModuleStartupOrder(graph: ModuleDependencyGraph):
|
|
|
43
43
|
* are stopped before the modules they depend on.
|
|
44
44
|
*/
|
|
45
45
|
export declare function resolveModuleShutdownOrder(graph: ModuleDependencyGraph): readonly ModuleId[];
|
|
46
|
-
//# sourceMappingURL=moduleDependency.ordering.d.ts.map
|
|
@@ -8,4 +8,3 @@ export { InvalidModuleDefinitionError, ModuleNotFoundError, DuplicateModuleError
|
|
|
8
8
|
export { InvalidModuleDependencyError, MissingModuleDependencyError, CircularModuleDependencyError, ModuleVersionMismatchError, } from "./moduleError.dependency.js";
|
|
9
9
|
export { getLifecycleErrorCode, ModuleInstantiationError, ModuleOperationError, InvalidModuleInstanceError, InvalidModuleStateError, ModuleOperationInProgressError, } from "./moduleError.lifecycle.js";
|
|
10
10
|
export { isModuleError, hasModuleErrorCode, toModuleError, } from "./moduleError.helpers.js";
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -8,4 +8,3 @@ export { InvalidModuleDefinitionError, ModuleNotFoundError, DuplicateModuleError
|
|
|
8
8
|
export { InvalidModuleDependencyError, MissingModuleDependencyError, CircularModuleDependencyError, ModuleVersionMismatchError, } from "./moduleError.dependency.js";
|
|
9
9
|
export { getLifecycleErrorCode, ModuleInstantiationError, ModuleOperationError, InvalidModuleInstanceError, InvalidModuleStateError, ModuleOperationInProgressError, } from "./moduleError.lifecycle.js";
|
|
10
10
|
export { isModuleError, hasModuleErrorCode, toModuleError, } from "./moduleError.helpers.js";
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
import type { ModuleId } from "../module.js";
|
|
2
|
+
import type { ModuleRegistrationState } from "../moduleRegistry/moduleRegistry.type.js";
|
|
2
3
|
import { ModuleError } from "./moduleError.base.js";
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* What is known about the dependency that could not be resolved.
|
|
6
|
+
*/
|
|
7
|
+
export interface MissingModuleDependencyContext {
|
|
8
|
+
/**
|
|
9
|
+
* Registration state of the dependency when it IS registered but did
|
|
10
|
+
* not take part in the lifecycle run (not loaded). Omitted when the
|
|
11
|
+
* dependency is not registered at all.
|
|
12
|
+
*/
|
|
13
|
+
readonly dependencyState?: ModuleRegistrationState;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Error thrown when a required module dependency cannot be resolved.
|
|
17
|
+
*
|
|
18
|
+
* The message distinguishes a dependency that is not registered from
|
|
19
|
+
* one that is registered but was not loaded; the latter used to be
|
|
20
|
+
* reported as "missing module", which was misleading.
|
|
5
21
|
*/
|
|
6
22
|
export declare class MissingModuleDependencyError extends ModuleError {
|
|
7
|
-
|
|
23
|
+
readonly dependencyState?: ModuleRegistrationState;
|
|
24
|
+
constructor(moduleId: ModuleId, dependencyId: ModuleId, context?: MissingModuleDependencyContext);
|
|
8
25
|
}
|
|
9
26
|
/**
|
|
10
27
|
* Error thrown when a circular dependency is detected.
|
|
@@ -53,4 +70,3 @@ export declare class ModuleVersionMismatchError extends ModuleError {
|
|
|
53
70
|
actualVersion: string | undefined;
|
|
54
71
|
};
|
|
55
72
|
}
|
|
56
|
-
//# sourceMappingURL=moduleError.dependency.d.ts.map
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { ModuleErrorCode, ModuleError } from "./moduleError.base.js";
|
|
2
|
+
function describeMissingDependency(moduleId, dependencyId, dependencyState) {
|
|
3
|
+
if (dependencyState === undefined) {
|
|
4
|
+
return `Module "${moduleId}" requires missing module "${dependencyId}".`;
|
|
5
|
+
}
|
|
6
|
+
return (`Module "${moduleId}" depends on "${dependencyId}", which is registered but not loaded ` +
|
|
7
|
+
`(state: "${dependencyState}"). Load it before starting the lifecycle, or enable autoLoad on its definition.`);
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
|
-
* Error thrown when a required module dependency
|
|
10
|
+
* Error thrown when a required module dependency cannot be resolved.
|
|
11
|
+
*
|
|
12
|
+
* The message distinguishes a dependency that is not registered from
|
|
13
|
+
* one that is registered but was not loaded; the latter used to be
|
|
14
|
+
* reported as "missing module", which was misleading.
|
|
4
15
|
*/
|
|
5
16
|
export class MissingModuleDependencyError extends ModuleError {
|
|
6
|
-
|
|
7
|
-
|
|
17
|
+
dependencyState;
|
|
18
|
+
constructor(moduleId, dependencyId, context = {}) {
|
|
19
|
+
super(describeMissingDependency(moduleId, dependencyId, context.dependencyState), {
|
|
8
20
|
code: ModuleErrorCode.MISSING_DEPENDENCY,
|
|
9
21
|
moduleId,
|
|
10
22
|
dependencyId,
|
|
11
23
|
});
|
|
12
24
|
this.name = "MissingModuleDependencyError";
|
|
25
|
+
this.dependencyState = context.dependencyState;
|
|
13
26
|
}
|
|
14
27
|
}
|
|
15
28
|
/**
|
|
@@ -67,4 +80,3 @@ export class ModuleVersionMismatchError extends ModuleError {
|
|
|
67
80
|
};
|
|
68
81
|
}
|
|
69
82
|
}
|
|
70
|
-
//# sourceMappingURL=moduleError.dependency.js.map
|
|
@@ -10,4 +10,3 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export { type ModuleLifecyclePhase, type ModuleLifecycleState, type ModuleLifecycleHookName, type ModuleLifecycleStep, type ModuleLifecycleHooks, type ModuleLifecycleOptions, type ModuleLifecyclePhaseOptions, ModuleLifecycleError, type ModuleLifecycleResult, type ModuleLifecycleSkip, } from "./moduleLifecycle.type.js";
|
|
12
12
|
export { ModuleLifecycleManager, createModuleLifecycleManager, } from "./moduleLifecycle.lifecycle.js";
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialises module lifecycle operations, detaching one that was
|
|
3
|
+
* cancelled so teardown never queues behind a hook that may never settle.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* A single-lane lock for lifecycle phases.
|
|
7
|
+
*
|
|
8
|
+
* Phases must not overlap, so each operation waits for the previous
|
|
9
|
+
* one — except an operation whose `signal` has been aborted. That is a
|
|
10
|
+
* bootstrap the startup timeout already gave up on, possibly stuck in a
|
|
11
|
+
* hook that never settles; `stop()`/`destroy()` used to wait behind it
|
|
12
|
+
* for the whole shutdown timeout (30 s by default) after `start()` had
|
|
13
|
+
* long since rejected. Such an operation keeps running detached: it
|
|
14
|
+
* starts no further hook (the phase loop checks the signal), the
|
|
15
|
+
* module it is stuck in stays in its active phase, which teardown
|
|
16
|
+
* skips, and when it finally settles `onDetachedSettled` runs so a
|
|
17
|
+
* module that came up late can still be torn down.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ExclusiveOperations {
|
|
20
|
+
private current;
|
|
21
|
+
/**
|
|
22
|
+
* Runs `operation` once no other (live) operation is running.
|
|
23
|
+
*/
|
|
24
|
+
run<T>(operation: () => Promise<T>, signal?: AbortSignal, onDetachedSettled?: () => void): Promise<T>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialises module lifecycle operations, detaching one that was
|
|
3
|
+
* cancelled so teardown never queues behind a hook that may never settle.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Resolves when `work` settles or `signal` aborts, whichever is first.
|
|
7
|
+
*/
|
|
8
|
+
function untilSettledOrAborted(work, signal) {
|
|
9
|
+
if (signal === undefined || signal.aborted)
|
|
10
|
+
return work;
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
const done = () => {
|
|
13
|
+
signal.removeEventListener("abort", done);
|
|
14
|
+
resolve();
|
|
15
|
+
};
|
|
16
|
+
signal.addEventListener("abort", done, { once: true });
|
|
17
|
+
void work.then(done, done);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A single-lane lock for lifecycle phases.
|
|
22
|
+
*
|
|
23
|
+
* Phases must not overlap, so each operation waits for the previous
|
|
24
|
+
* one — except an operation whose `signal` has been aborted. That is a
|
|
25
|
+
* bootstrap the startup timeout already gave up on, possibly stuck in a
|
|
26
|
+
* hook that never settles; `stop()`/`destroy()` used to wait behind it
|
|
27
|
+
* for the whole shutdown timeout (30 s by default) after `start()` had
|
|
28
|
+
* long since rejected. Such an operation keeps running detached: it
|
|
29
|
+
* starts no further hook (the phase loop checks the signal), the
|
|
30
|
+
* module it is stuck in stays in its active phase, which teardown
|
|
31
|
+
* skips, and when it finally settles `onDetachedSettled` runs so a
|
|
32
|
+
* module that came up late can still be torn down.
|
|
33
|
+
*/
|
|
34
|
+
export class ExclusiveOperations {
|
|
35
|
+
current;
|
|
36
|
+
/**
|
|
37
|
+
* Runs `operation` once no other (live) operation is running.
|
|
38
|
+
*/
|
|
39
|
+
async run(operation, signal, onDetachedSettled) {
|
|
40
|
+
while (this.current !== undefined && !this.current.signal?.aborted) {
|
|
41
|
+
await untilSettledOrAborted(this.current.done, this.current.signal);
|
|
42
|
+
}
|
|
43
|
+
let release = () => undefined;
|
|
44
|
+
const held = {
|
|
45
|
+
done: new Promise((resolve) => {
|
|
46
|
+
release = resolve;
|
|
47
|
+
}),
|
|
48
|
+
signal,
|
|
49
|
+
};
|
|
50
|
+
this.current = held;
|
|
51
|
+
try {
|
|
52
|
+
return await operation();
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
const detached = this.current !== held;
|
|
56
|
+
if (!detached)
|
|
57
|
+
this.current = undefined;
|
|
58
|
+
release();
|
|
59
|
+
if (detached)
|
|
60
|
+
onDetachedSettled?.();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -14,7 +14,8 @@ export declare class ModuleLifecycleManager {
|
|
|
14
14
|
private readonly options;
|
|
15
15
|
private readonly contextStorage;
|
|
16
16
|
private readonly states;
|
|
17
|
-
private
|
|
17
|
+
private readonly exclusive;
|
|
18
|
+
private tornDown;
|
|
18
19
|
constructor(registry: ModuleRegistry, loader: ModuleLoader, options?: ModuleLifecycleOptions);
|
|
19
20
|
initialize(options?: ModuleLifecyclePhaseOptions): Promise<ModuleLifecycleResult>;
|
|
20
21
|
start(options?: ModuleLifecyclePhaseOptions): Promise<ModuleLifecycleResult>;
|
|
@@ -88,9 +89,27 @@ export declare class ModuleLifecycleManager {
|
|
|
88
89
|
* as edges so the ordering reports them as missing.
|
|
89
90
|
*/
|
|
90
91
|
private createGraph;
|
|
92
|
+
/**
|
|
93
|
+
* Startup order over the loaded modules. A dependency that is
|
|
94
|
+
* registered but not loaded used to be reported as a "missing
|
|
95
|
+
* module", which sent people looking for a typo; it is now described
|
|
96
|
+
* by its registration state.
|
|
97
|
+
*/
|
|
91
98
|
private getStartupOrder;
|
|
92
99
|
private getShutdownOrder;
|
|
100
|
+
/**
|
|
101
|
+
* Serialises operations. One whose `signal` was aborted (a bootstrap
|
|
102
|
+
* abandoned by the startup timeout) is not waited for, so `stop()`
|
|
103
|
+
* and `destroy()` no longer queue behind a hook that may never
|
|
104
|
+
* settle; a module whose hook does settle later is torn down then.
|
|
105
|
+
*/
|
|
93
106
|
private runExclusive;
|
|
107
|
+
/**
|
|
108
|
+
* Best-effort teardown for modules an abandoned startup brought up
|
|
109
|
+
* after the runtime had already been shut down. Failures land on the
|
|
110
|
+
* module's lifecycle state as they would for any stop/destroy.
|
|
111
|
+
*/
|
|
112
|
+
private finalizeLateModules;
|
|
94
113
|
}
|
|
95
114
|
/**
|
|
96
115
|
* Resolves the dependencies of a registration: definition-declared
|
|
@@ -101,4 +120,3 @@ export declare class ModuleLifecycleManager {
|
|
|
101
120
|
export declare function resolveRegistrationDependencies(registry: ModuleRegistry, registration: ModuleRegistration): readonly ModuleDependency[];
|
|
102
121
|
/** Creates a module lifecycle manager. */
|
|
103
122
|
export declare function createModuleLifecycleManager(registry: ModuleRegistry, loader: ModuleLoader, options?: ModuleLifecycleOptions): ModuleLifecycleManager;
|
|
104
|
-
//# sourceMappingURL=moduleLifecycle.lifecycle.d.ts.map
|