lifecycleion 0.0.7 → 0.0.9

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 CHANGED
@@ -1,4 +1,4 @@
1
- # Lifecycleion v0.0.7
1
+ # Lifecycleion v0.0.9
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/lifecycleion.svg)](https://badge.fury.io/js/lifecycleion)
4
4
 
@@ -89,6 +89,7 @@ Each library has comprehensive documentation in the [docs](./docs) folder. Click
89
89
  | [constants](./docs/constants.md) | `lifecycleion/constants` | Common string constants including whitespace helpers and Python-style character sets |
90
90
  | [curly-brackets](./docs/curly-brackets.md) | `lifecycleion/curly-brackets` | String templating with `{{placeholders}}`, fallbacks, escaping, and compiled templates |
91
91
  | [deep-clone](./docs/deep-clone.md) | `lifecycleion/deep-clone` | Deep clone utility with circular reference detection for objects, arrays, Maps, Sets, and more |
92
+ | [dev-mode](./docs/dev-mode.md) | `lifecycleion/dev-mode` | Runtime-settable dev/production mode flag with auto-detection from CLI args or NODE_ENV |
92
93
  | [error-to-string](./docs/error-to-string.md) | `lifecycleion/error-to-string` | Format errors into readable ASCII tables with support for nested info and sensitive field masking |
93
94
  | [event-emitter](./docs/event-emitter.md) | `lifecycleion/event-emitter` | Lightweight event emitter with protected and public variants, type safety, and memory management |
94
95
  | [id-helpers](./docs/id-helpers.md) | `lifecycleion/id-helpers` | Unified ID generation and validation for ObjectID, UUID v4, UUID v7, and ULID |
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib/dev-mode.ts
21
+ var dev_mode_exports = {};
22
+ __export(dev_mode_exports, {
23
+ getDevMode: () => getDevMode,
24
+ initDevMode: () => initDevMode,
25
+ overrideDevMode: () => overrideDevMode
26
+ });
27
+ module.exports = __toCommonJS(dev_mode_exports);
28
+ var GLOBAL_KEY = "__lifecycleion_is_dev__";
29
+ var INIT_PARAM_KEY = "__lifecycleion_init_param__";
30
+ var g = globalThis;
31
+ function detectValue(detect, isStrict) {
32
+ const argv = typeof process !== "undefined" ? process.argv ?? [] : [];
33
+ const env = typeof process !== "undefined" ? process.env?.NODE_ENV : void 0;
34
+ const cmdArg = argv.find((a) => a === "dev" || a === "prod");
35
+ if (isStrict && detect === "cmd" && cmdArg === void 0) {
36
+ throw new Error('initDevMode: expected "dev" or "prod" as a CLI argument');
37
+ }
38
+ const isFromCmd = cmdArg !== void 0 ? cmdArg === "dev" : false;
39
+ const isFromEnv = env === "development";
40
+ if (detect === "cmd") {
41
+ return isFromCmd;
42
+ }
43
+ if (detect === "node_env") {
44
+ return isFromEnv;
45
+ }
46
+ return cmdArg !== void 0 ? isFromCmd : isFromEnv;
47
+ }
48
+ function resolveInitParam(param) {
49
+ if (param === void 0) {
50
+ return detectValue("both");
51
+ }
52
+ if (typeof param === "boolean") {
53
+ return param;
54
+ }
55
+ return detectValue(param.detect, param.strict);
56
+ }
57
+ function getDevMode() {
58
+ return typeof g[GLOBAL_KEY] === "boolean" ? g[GLOBAL_KEY] : false;
59
+ }
60
+ function initDevMode(param) {
61
+ if (typeof g[GLOBAL_KEY] === "boolean") {
62
+ return;
63
+ }
64
+ g[INIT_PARAM_KEY] = param;
65
+ g[GLOBAL_KEY] = resolveInitParam(param);
66
+ }
67
+ function overrideDevMode(value) {
68
+ const savedParam = g[INIT_PARAM_KEY];
69
+ g[GLOBAL_KEY] = value === "redetect" ? resolveInitParam(savedParam) : value;
70
+ }
71
+ // Annotate the CommonJS export names for ESM import in node:
72
+ 0 && (module.exports = {
73
+ getDevMode,
74
+ initDevMode,
75
+ overrideDevMode
76
+ });
77
+ //# sourceMappingURL=dev-mode.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/dev-mode.ts"],"sourcesContent":["// Stored in globalThis so state survives module re-evaluation and works across\n// module boundaries.\nconst GLOBAL_KEY = '__lifecycleion_is_dev__';\nconst INIT_PARAM_KEY = '__lifecycleion_init_param__';\n\ntype DevModeSource = 'cmd' | 'node_env' | 'both';\ntype InitParam =\n | boolean\n | { detect: DevModeSource; strict?: boolean }\n | undefined;\n\n// Cast once at module level — avoids repeating the assertion in every function.\nconst g = globalThis as typeof globalThis & Record<string, unknown>;\n\nfunction detectValue(detect: DevModeSource, isStrict?: boolean): boolean {\n // Guard against environments where process or its properties may not exist\n // (e.g. browser without polyfill, Deno without Node compat, edge runtimes).\n // Vite statically replaces process.env.NODE_ENV at build time, so it is safe\n // on the client. process.argv is an empty array shim in browsers — harmless.\n const argv: string[] =\n typeof process !== 'undefined' ? (process.argv ?? []) : [];\n const env: string | undefined =\n typeof process !== 'undefined' ? process.env?.NODE_ENV : undefined;\n\n const cmdArg = argv.find((a) => a === 'dev' || a === 'prod');\n\n if (isStrict && detect === 'cmd' && cmdArg === undefined) {\n throw new Error('initDevMode: expected \"dev\" or \"prod\" as a CLI argument');\n }\n\n const isFromCmd = cmdArg !== undefined ? cmdArg === 'dev' : false;\n const isFromEnv = env === 'development';\n\n if (detect === 'cmd') {\n return isFromCmd;\n }\n\n if (detect === 'node_env') {\n return isFromEnv;\n }\n\n // 'both': cmd wins when explicitly present, otherwise fall back to NODE_ENV\n return cmdArg !== undefined ? isFromCmd : isFromEnv;\n}\n\nfunction resolveInitParam(param: InitParam): boolean {\n if (param === undefined) {\n return detectValue('both');\n }\n\n if (typeof param === 'boolean') {\n return param;\n }\n\n return detectValue(param.detect, param.strict);\n}\n\n/**\n * Returns the current dev mode value.\n *\n * Reads `globalThis.__lifecycleion_is_dev__`. Defaults to `false` if\n * `initDevMode()` has not been called yet.\n */\nexport function getDevMode(): boolean {\n return typeof g[GLOBAL_KEY] === 'boolean' ? g[GLOBAL_KEY] : false;\n}\n\n/**\n * Sets the dev mode global for the current process.\n *\n * First-wins: if the global is already set (e.g. set by the HTML injection on\n * the client, or by a prior `initDevMode()` call), this is a no-op. Call once\n * at startup before serving any requests.\n *\n * @param param\n * - `true` / `false` — explicit value\n * - `{ detect: 'cmd' }` — read from `process.argv` (\"dev\" or \"prod\")\n * - `{ detect: 'node_env' }` — read from `NODE_ENV`\n * - `{ detect: 'both' }` — argv takes precedence, falls back to `NODE_ENV`\n * - `{ detect: 'cmd', strict: true }` — argv required, throws if absent\n * - omitted — same as `{ detect: 'both' }`\n */\nexport function initDevMode(\n param?: boolean | { detect: DevModeSource; strict?: boolean },\n): void {\n if (typeof g[GLOBAL_KEY] === 'boolean') {\n return; // first-wins — already initialized, no-op\n }\n\n g[INIT_PARAM_KEY] = param; // save original param so 'redetect' can replay it\n g[GLOBAL_KEY] = resolveInitParam(param);\n}\n\n/**\n * Bypasses first-wins semantics and forces the dev mode value.\n *\n * Intended for testing or tooling — not for production use.\n *\n * Pass `'redetect'` to re-run the same detection logic that\n * `initDevMode()` used originally.\n */\nexport function overrideDevMode(value: boolean | 'redetect'): void {\n const savedParam = g[INIT_PARAM_KEY] as InitParam;\n g[GLOBAL_KEY] = value === 'redetect' ? resolveInitParam(savedParam) : value;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAM,aAAa;AACnB,IAAM,iBAAiB;AASvB,IAAM,IAAI;AAEV,SAAS,YAAY,QAAuB,UAA6B;AAKvE,QAAM,OACJ,OAAO,YAAY,cAAe,QAAQ,QAAQ,CAAC,IAAK,CAAC;AAC3D,QAAM,MACJ,OAAO,YAAY,cAAc,QAAQ,KAAK,WAAW;AAE3D,QAAM,SAAS,KAAK,KAAK,CAAC,MAAM,MAAM,SAAS,MAAM,MAAM;AAE3D,MAAI,YAAY,WAAW,SAAS,WAAW,QAAW;AACxD,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AAEA,QAAM,YAAY,WAAW,SAAY,WAAW,QAAQ;AAC5D,QAAM,YAAY,QAAQ;AAE1B,MAAI,WAAW,OAAO;AACpB,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,YAAY;AACzB,WAAO;AAAA,EACT;AAGA,SAAO,WAAW,SAAY,YAAY;AAC5C;AAEA,SAAS,iBAAiB,OAA2B;AACnD,MAAI,UAAU,QAAW;AACvB,WAAO,YAAY,MAAM;AAAA,EAC3B;AAEA,MAAI,OAAO,UAAU,WAAW;AAC9B,WAAO;AAAA,EACT;AAEA,SAAO,YAAY,MAAM,QAAQ,MAAM,MAAM;AAC/C;AAQO,SAAS,aAAsB;AACpC,SAAO,OAAO,EAAE,UAAU,MAAM,YAAY,EAAE,UAAU,IAAI;AAC9D;AAiBO,SAAS,YACd,OACM;AACN,MAAI,OAAO,EAAE,UAAU,MAAM,WAAW;AACtC;AAAA,EACF;AAEA,IAAE,cAAc,IAAI;AACpB,IAAE,UAAU,IAAI,iBAAiB,KAAK;AACxC;AAUO,SAAS,gBAAgB,OAAmC;AACjE,QAAM,aAAa,EAAE,cAAc;AACnC,IAAE,UAAU,IAAI,UAAU,aAAa,iBAAiB,UAAU,IAAI;AACxE;","names":[]}
@@ -0,0 +1,38 @@
1
+ type DevModeSource = 'cmd' | 'node_env' | 'both';
2
+ /**
3
+ * Returns the current dev mode value.
4
+ *
5
+ * Reads `globalThis.__lifecycleion_is_dev__`. Defaults to `false` if
6
+ * `initDevMode()` has not been called yet.
7
+ */
8
+ declare function getDevMode(): boolean;
9
+ /**
10
+ * Sets the dev mode global for the current process.
11
+ *
12
+ * First-wins: if the global is already set (e.g. set by the HTML injection on
13
+ * the client, or by a prior `initDevMode()` call), this is a no-op. Call once
14
+ * at startup before serving any requests.
15
+ *
16
+ * @param param
17
+ * - `true` / `false` — explicit value
18
+ * - `{ detect: 'cmd' }` — read from `process.argv` ("dev" or "prod")
19
+ * - `{ detect: 'node_env' }` — read from `NODE_ENV`
20
+ * - `{ detect: 'both' }` — argv takes precedence, falls back to `NODE_ENV`
21
+ * - `{ detect: 'cmd', strict: true }` — argv required, throws if absent
22
+ * - omitted — same as `{ detect: 'both' }`
23
+ */
24
+ declare function initDevMode(param?: boolean | {
25
+ detect: DevModeSource;
26
+ strict?: boolean;
27
+ }): void;
28
+ /**
29
+ * Bypasses first-wins semantics and forces the dev mode value.
30
+ *
31
+ * Intended for testing or tooling — not for production use.
32
+ *
33
+ * Pass `'redetect'` to re-run the same detection logic that
34
+ * `initDevMode()` used originally.
35
+ */
36
+ declare function overrideDevMode(value: boolean | 'redetect'): void;
37
+
38
+ export { getDevMode, initDevMode, overrideDevMode };
@@ -0,0 +1,38 @@
1
+ type DevModeSource = 'cmd' | 'node_env' | 'both';
2
+ /**
3
+ * Returns the current dev mode value.
4
+ *
5
+ * Reads `globalThis.__lifecycleion_is_dev__`. Defaults to `false` if
6
+ * `initDevMode()` has not been called yet.
7
+ */
8
+ declare function getDevMode(): boolean;
9
+ /**
10
+ * Sets the dev mode global for the current process.
11
+ *
12
+ * First-wins: if the global is already set (e.g. set by the HTML injection on
13
+ * the client, or by a prior `initDevMode()` call), this is a no-op. Call once
14
+ * at startup before serving any requests.
15
+ *
16
+ * @param param
17
+ * - `true` / `false` — explicit value
18
+ * - `{ detect: 'cmd' }` — read from `process.argv` ("dev" or "prod")
19
+ * - `{ detect: 'node_env' }` — read from `NODE_ENV`
20
+ * - `{ detect: 'both' }` — argv takes precedence, falls back to `NODE_ENV`
21
+ * - `{ detect: 'cmd', strict: true }` — argv required, throws if absent
22
+ * - omitted — same as `{ detect: 'both' }`
23
+ */
24
+ declare function initDevMode(param?: boolean | {
25
+ detect: DevModeSource;
26
+ strict?: boolean;
27
+ }): void;
28
+ /**
29
+ * Bypasses first-wins semantics and forces the dev mode value.
30
+ *
31
+ * Intended for testing or tooling — not for production use.
32
+ *
33
+ * Pass `'redetect'` to re-run the same detection logic that
34
+ * `initDevMode()` used originally.
35
+ */
36
+ declare function overrideDevMode(value: boolean | 'redetect'): void;
37
+
38
+ export { getDevMode, initDevMode, overrideDevMode };
@@ -0,0 +1,50 @@
1
+ // src/lib/dev-mode.ts
2
+ var GLOBAL_KEY = "__lifecycleion_is_dev__";
3
+ var INIT_PARAM_KEY = "__lifecycleion_init_param__";
4
+ var g = globalThis;
5
+ function detectValue(detect, isStrict) {
6
+ const argv = typeof process !== "undefined" ? process.argv ?? [] : [];
7
+ const env = typeof process !== "undefined" ? process.env?.NODE_ENV : void 0;
8
+ const cmdArg = argv.find((a) => a === "dev" || a === "prod");
9
+ if (isStrict && detect === "cmd" && cmdArg === void 0) {
10
+ throw new Error('initDevMode: expected "dev" or "prod" as a CLI argument');
11
+ }
12
+ const isFromCmd = cmdArg !== void 0 ? cmdArg === "dev" : false;
13
+ const isFromEnv = env === "development";
14
+ if (detect === "cmd") {
15
+ return isFromCmd;
16
+ }
17
+ if (detect === "node_env") {
18
+ return isFromEnv;
19
+ }
20
+ return cmdArg !== void 0 ? isFromCmd : isFromEnv;
21
+ }
22
+ function resolveInitParam(param) {
23
+ if (param === void 0) {
24
+ return detectValue("both");
25
+ }
26
+ if (typeof param === "boolean") {
27
+ return param;
28
+ }
29
+ return detectValue(param.detect, param.strict);
30
+ }
31
+ function getDevMode() {
32
+ return typeof g[GLOBAL_KEY] === "boolean" ? g[GLOBAL_KEY] : false;
33
+ }
34
+ function initDevMode(param) {
35
+ if (typeof g[GLOBAL_KEY] === "boolean") {
36
+ return;
37
+ }
38
+ g[INIT_PARAM_KEY] = param;
39
+ g[GLOBAL_KEY] = resolveInitParam(param);
40
+ }
41
+ function overrideDevMode(value) {
42
+ const savedParam = g[INIT_PARAM_KEY];
43
+ g[GLOBAL_KEY] = value === "redetect" ? resolveInitParam(savedParam) : value;
44
+ }
45
+ export {
46
+ getDevMode,
47
+ initDevMode,
48
+ overrideDevMode
49
+ };
50
+ //# sourceMappingURL=dev-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/dev-mode.ts"],"sourcesContent":["// Stored in globalThis so state survives module re-evaluation and works across\n// module boundaries.\nconst GLOBAL_KEY = '__lifecycleion_is_dev__';\nconst INIT_PARAM_KEY = '__lifecycleion_init_param__';\n\ntype DevModeSource = 'cmd' | 'node_env' | 'both';\ntype InitParam =\n | boolean\n | { detect: DevModeSource; strict?: boolean }\n | undefined;\n\n// Cast once at module level — avoids repeating the assertion in every function.\nconst g = globalThis as typeof globalThis & Record<string, unknown>;\n\nfunction detectValue(detect: DevModeSource, isStrict?: boolean): boolean {\n // Guard against environments where process or its properties may not exist\n // (e.g. browser without polyfill, Deno without Node compat, edge runtimes).\n // Vite statically replaces process.env.NODE_ENV at build time, so it is safe\n // on the client. process.argv is an empty array shim in browsers — harmless.\n const argv: string[] =\n typeof process !== 'undefined' ? (process.argv ?? []) : [];\n const env: string | undefined =\n typeof process !== 'undefined' ? process.env?.NODE_ENV : undefined;\n\n const cmdArg = argv.find((a) => a === 'dev' || a === 'prod');\n\n if (isStrict && detect === 'cmd' && cmdArg === undefined) {\n throw new Error('initDevMode: expected \"dev\" or \"prod\" as a CLI argument');\n }\n\n const isFromCmd = cmdArg !== undefined ? cmdArg === 'dev' : false;\n const isFromEnv = env === 'development';\n\n if (detect === 'cmd') {\n return isFromCmd;\n }\n\n if (detect === 'node_env') {\n return isFromEnv;\n }\n\n // 'both': cmd wins when explicitly present, otherwise fall back to NODE_ENV\n return cmdArg !== undefined ? isFromCmd : isFromEnv;\n}\n\nfunction resolveInitParam(param: InitParam): boolean {\n if (param === undefined) {\n return detectValue('both');\n }\n\n if (typeof param === 'boolean') {\n return param;\n }\n\n return detectValue(param.detect, param.strict);\n}\n\n/**\n * Returns the current dev mode value.\n *\n * Reads `globalThis.__lifecycleion_is_dev__`. Defaults to `false` if\n * `initDevMode()` has not been called yet.\n */\nexport function getDevMode(): boolean {\n return typeof g[GLOBAL_KEY] === 'boolean' ? g[GLOBAL_KEY] : false;\n}\n\n/**\n * Sets the dev mode global for the current process.\n *\n * First-wins: if the global is already set (e.g. set by the HTML injection on\n * the client, or by a prior `initDevMode()` call), this is a no-op. Call once\n * at startup before serving any requests.\n *\n * @param param\n * - `true` / `false` — explicit value\n * - `{ detect: 'cmd' }` — read from `process.argv` (\"dev\" or \"prod\")\n * - `{ detect: 'node_env' }` — read from `NODE_ENV`\n * - `{ detect: 'both' }` — argv takes precedence, falls back to `NODE_ENV`\n * - `{ detect: 'cmd', strict: true }` — argv required, throws if absent\n * - omitted — same as `{ detect: 'both' }`\n */\nexport function initDevMode(\n param?: boolean | { detect: DevModeSource; strict?: boolean },\n): void {\n if (typeof g[GLOBAL_KEY] === 'boolean') {\n return; // first-wins — already initialized, no-op\n }\n\n g[INIT_PARAM_KEY] = param; // save original param so 'redetect' can replay it\n g[GLOBAL_KEY] = resolveInitParam(param);\n}\n\n/**\n * Bypasses first-wins semantics and forces the dev mode value.\n *\n * Intended for testing or tooling — not for production use.\n *\n * Pass `'redetect'` to re-run the same detection logic that\n * `initDevMode()` used originally.\n */\nexport function overrideDevMode(value: boolean | 'redetect'): void {\n const savedParam = g[INIT_PARAM_KEY] as InitParam;\n g[GLOBAL_KEY] = value === 'redetect' ? resolveInitParam(savedParam) : value;\n}\n"],"mappings":";AAEA,IAAM,aAAa;AACnB,IAAM,iBAAiB;AASvB,IAAM,IAAI;AAEV,SAAS,YAAY,QAAuB,UAA6B;AAKvE,QAAM,OACJ,OAAO,YAAY,cAAe,QAAQ,QAAQ,CAAC,IAAK,CAAC;AAC3D,QAAM,MACJ,OAAO,YAAY,cAAc,QAAQ,KAAK,WAAW;AAE3D,QAAM,SAAS,KAAK,KAAK,CAAC,MAAM,MAAM,SAAS,MAAM,MAAM;AAE3D,MAAI,YAAY,WAAW,SAAS,WAAW,QAAW;AACxD,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AAEA,QAAM,YAAY,WAAW,SAAY,WAAW,QAAQ;AAC5D,QAAM,YAAY,QAAQ;AAE1B,MAAI,WAAW,OAAO;AACpB,WAAO;AAAA,EACT;AAEA,MAAI,WAAW,YAAY;AACzB,WAAO;AAAA,EACT;AAGA,SAAO,WAAW,SAAY,YAAY;AAC5C;AAEA,SAAS,iBAAiB,OAA2B;AACnD,MAAI,UAAU,QAAW;AACvB,WAAO,YAAY,MAAM;AAAA,EAC3B;AAEA,MAAI,OAAO,UAAU,WAAW;AAC9B,WAAO;AAAA,EACT;AAEA,SAAO,YAAY,MAAM,QAAQ,MAAM,MAAM;AAC/C;AAQO,SAAS,aAAsB;AACpC,SAAO,OAAO,EAAE,UAAU,MAAM,YAAY,EAAE,UAAU,IAAI;AAC9D;AAiBO,SAAS,YACd,OACM;AACN,MAAI,OAAO,EAAE,UAAU,MAAM,WAAW;AACtC;AAAA,EACF;AAEA,IAAE,cAAc,IAAI;AACpB,IAAE,UAAU,IAAI,iBAAiB,KAAK;AACxC;AAUO,SAAS,gBAAgB,OAAmC;AACjE,QAAM,aAAa,EAAE,cAAc;AACnC,IAAE,UAAU,IAAI,UAAU,aAAa,iBAAiB,UAAU,IAAI;AACxE;","names":[]}
@@ -2397,9 +2397,9 @@ var LifecycleManager = class extends EventEmitterProtected {
2397
2397
  startupOrder: this.getStartupOrderInternal()
2398
2398
  };
2399
2399
  } catch (error) {
2400
- const err = error;
2400
+ const err = error instanceof Error ? error : new Error(String(error));
2401
2401
  const code = err instanceof DependencyCycleError ? "dependency_cycle" : "unknown_error";
2402
- this.logger.error("Failed to resolve startup order", {
2402
+ this.logger.error("Failed to resolve startup order: {{error.message}}", {
2403
2403
  params: { error: err }
2404
2404
  });
2405
2405
  return {
@@ -2607,11 +2607,14 @@ var LifecycleManager = class extends EventEmitterProtected {
2607
2607
  try {
2608
2608
  startupOrder = this.getStartupOrderInternal();
2609
2609
  } catch (error) {
2610
- const err = error;
2610
+ const err = error instanceof Error ? error : new Error(String(error));
2611
2611
  const code = err instanceof DependencyCycleError ? "dependency_cycle" : "unknown_error";
2612
- this.logger.error("Failed to resolve startup order", {
2613
- params: { error: err }
2614
- });
2612
+ this.logger.error(
2613
+ "Failed to resolve startup order: {{error.message}}",
2614
+ {
2615
+ params: { error: err }
2616
+ }
2617
+ );
2615
2618
  return {
2616
2619
  success: false,
2617
2620
  startedComponents: [],
@@ -2714,9 +2717,14 @@ var LifecycleManager = class extends EventEmitterProtected {
2714
2717
  };
2715
2718
  } else {
2716
2719
  if (component.isOptional()) {
2717
- this.logger.entity(name).warn("Optional component failed to start, continuing", {
2718
- params: { error: result.error }
2719
- });
2720
+ this.logger.entity(name).warn(
2721
+ "Optional component failed to start, continuing: {{error.message}}",
2722
+ {
2723
+ params: {
2724
+ error: result.error || new Error(result.reason || "Unknown error")
2725
+ }
2726
+ }
2727
+ );
2720
2728
  this.lifecycleEvents.componentStartFailedOptional(
2721
2729
  name,
2722
2730
  result.error
@@ -2730,9 +2738,14 @@ var LifecycleManager = class extends EventEmitterProtected {
2730
2738
  error: result.error || new Error(result.reason || "Unknown error")
2731
2739
  });
2732
2740
  } else {
2733
- this.logger.entity(name).error("Required component failed to start, rolling back", {
2734
- params: { error: result.error }
2735
- });
2741
+ this.logger.entity(name).error(
2742
+ "Required component failed to start, rolling back: {{error.message}}",
2743
+ {
2744
+ params: {
2745
+ error: result.error || new Error(result.reason || "Unknown error")
2746
+ }
2747
+ }
2748
+ );
2736
2749
  await this.rollbackStartup(startedComponents);
2737
2750
  return {
2738
2751
  success: false,
@@ -3227,8 +3240,8 @@ var LifecycleManager = class extends EventEmitterProtected {
3227
3240
  };
3228
3241
  } catch (error) {
3229
3242
  const durationMS = Date.now() - startTime;
3230
- const err = error;
3231
- this.logger.entity(name).error("Health check failed", {
3243
+ const err = error instanceof Error ? error : new Error(String(error));
3244
+ this.logger.entity(name).error("Health check failed: {{error.message}}", {
3232
3245
  params: { error: err }
3233
3246
  });
3234
3247
  this.lifecycleEvents.componentHealthCheckFailed(name, err);
@@ -3377,7 +3390,7 @@ var LifecycleManager = class extends EventEmitterProtected {
3377
3390
  result = component.onMessage(payload, from);
3378
3391
  } catch (error) {
3379
3392
  const err = error instanceof Error ? error : new Error(String(error));
3380
- this.logger.entity(componentName).error("Message handler failed", {
3393
+ this.logger.entity(componentName).error("Message handler failed: {{error.message}}", {
3381
3394
  params: { error: err, from }
3382
3395
  });
3383
3396
  this.lifecycleEvents.componentMessageFailed(componentName, from, err, {
@@ -3437,7 +3450,7 @@ var LifecycleManager = class extends EventEmitterProtected {
3437
3450
  };
3438
3451
  } catch (error) {
3439
3452
  const err = error instanceof Error ? error : new Error(String(error));
3440
- this.logger.entity(componentName).error("Message handler failed", {
3453
+ this.logger.entity(componentName).error("Message handler failed: {{error.message}}", {
3441
3454
  params: { error: err, from, timeoutMS }
3442
3455
  });
3443
3456
  this.lifecycleEvents.componentMessageFailed(componentName, from, err, {
@@ -3645,7 +3658,7 @@ var LifecycleManager = class extends EventEmitterProtected {
3645
3658
  };
3646
3659
  } catch (error) {
3647
3660
  const err = error instanceof Error ? error : new Error(String(error));
3648
- this.logger.entity(componentName).error("getValue handler failed", {
3661
+ this.logger.entity(componentName).error("getValue handler failed: {{error.message}}", {
3649
3662
  params: { error: err, key, from }
3650
3663
  });
3651
3664
  this.lifecycleEvents.componentValueReturned(componentName, key, from, {
@@ -3811,9 +3824,13 @@ var LifecycleManager = class extends EventEmitterProtected {
3811
3824
  try {
3812
3825
  startupOrder2 = this.getStartupOrderInternal();
3813
3826
  } catch (error) {
3814
- this.logger.warn("Failed to compute startup order in error handler", {
3815
- params: { error }
3816
- });
3827
+ const err = error instanceof Error ? error : new Error(String(error));
3828
+ this.logger.warn(
3829
+ "Failed to compute startup order in error handler: {{error.message}}",
3830
+ {
3831
+ params: { error: err }
3832
+ }
3833
+ );
3817
3834
  startupOrder2 = [];
3818
3835
  }
3819
3836
  return {
@@ -3977,9 +3994,9 @@ var LifecycleManager = class extends EventEmitterProtected {
3977
3994
  startResult
3978
3995
  };
3979
3996
  } catch (error) {
3980
- const err = error;
3997
+ const err = error instanceof Error ? error : new Error(String(error));
3981
3998
  const code = err instanceof DependencyCycleError ? "dependency_cycle" : "unknown_error";
3982
- this.logger.entity(componentName).error("Registration failed with unexpected error", {
3999
+ this.logger.entity(componentName).error("Registration failed with unexpected error: {{error.message}}", {
3983
4000
  params: { error: err }
3984
4001
  });
3985
4002
  this.lifecycleEvents.componentRegistrationRejected({
@@ -4046,10 +4063,11 @@ var LifecycleManager = class extends EventEmitterProtected {
4046
4063
  const startupOrder = this.getStartupOrderInternal();
4047
4064
  shutdownOrder = [...startupOrder].reverse();
4048
4065
  } catch (error) {
4066
+ const err = error instanceof Error ? error : new Error(String(error));
4049
4067
  this.logger.warn(
4050
- "Could not resolve shutdown order, using registration order",
4068
+ "Could not resolve shutdown order, using registration order: {{error.message}}",
4051
4069
  {
4052
- params: { error }
4070
+ params: { error: err }
4053
4071
  }
4054
4072
  );
4055
4073
  shutdownOrder = this.components.map((c) => c.getName()).reverse();
@@ -4106,9 +4124,14 @@ var LifecycleManager = class extends EventEmitterProtected {
4106
4124
  if (result2.success) {
4107
4125
  stoppedComponents.push(name);
4108
4126
  } else {
4109
- this.logger.entity(name).error("Component failed to stop, continuing with others", {
4110
- params: { error: result2.error }
4111
- });
4127
+ this.logger.entity(name).error(
4128
+ "Component failed to stop, continuing with others: {{error.message}}",
4129
+ {
4130
+ params: {
4131
+ error: result2.error || new Error(result2.reason || "Unknown error")
4132
+ }
4133
+ }
4134
+ );
4112
4135
  const stallInfo = this.stalledComponents.get(name);
4113
4136
  if (stallInfo) {
4114
4137
  stalledComponents.push(stallInfo);
@@ -4330,9 +4353,13 @@ var LifecycleManager = class extends EventEmitterProtected {
4330
4353
  try {
4331
4354
  component.onStartupAborted();
4332
4355
  } catch (error) {
4333
- this.logger.entity(name).warn("Error in onStartupAborted callback", {
4334
- params: { error }
4335
- });
4356
+ const err = error instanceof Error ? error : new Error(String(error));
4357
+ this.logger.entity(name).warn(
4358
+ "Error in onStartupAborted callback: {{error.message}}",
4359
+ {
4360
+ params: { error: err }
4361
+ }
4362
+ );
4336
4363
  }
4337
4364
  } else {
4338
4365
  this.monitorLateStartupCompletion(
@@ -4402,11 +4429,11 @@ var LifecycleManager = class extends EventEmitterProtected {
4402
4429
  status: this.getComponentStatus(name)
4403
4430
  };
4404
4431
  } catch (error) {
4405
- const err = error;
4432
+ const err = error instanceof Error ? error : new Error(String(error));
4406
4433
  this.componentErrors.set(name, err);
4407
4434
  if (err instanceof ComponentStartTimeoutError && err.additionalInfo.componentName === name) {
4408
4435
  this.componentStates.set(name, "starting-timed-out");
4409
- this.logger.entity(name).error("Component startup timed out", {
4436
+ this.logger.entity(name).error("Component startup timed out: {{error.message}}", {
4410
4437
  params: { error: err }
4411
4438
  });
4412
4439
  this.lifecycleEvents.componentStartTimeout(name, err, {
@@ -4415,7 +4442,7 @@ var LifecycleManager = class extends EventEmitterProtected {
4415
4442
  });
4416
4443
  } else {
4417
4444
  this.componentStates.set(name, "registered");
4418
- this.logger.entity(name).error("Component failed to start", {
4445
+ this.logger.entity(name).error("Component failed to start: {{error.message}}", {
4419
4446
  params: { error: err }
4420
4447
  });
4421
4448
  this.lifecycleEvents.componentStartFailed(name, err, {
@@ -4547,8 +4574,9 @@ var LifecycleManager = class extends EventEmitterProtected {
4547
4574
  Promise.resolve().then(() => component.onShutdownWarning?.()).then(() => {
4548
4575
  this.lifecycleEvents.componentShutdownWarningCompleted(name);
4549
4576
  }).catch((error) => {
4550
- this.logger.entity(name).warn("Shutdown warning phase failed", {
4551
- params: { error }
4577
+ const err = error instanceof Error ? error : new Error(String(error));
4578
+ this.logger.entity(name).warn("Shutdown warning phase failed: {{error.message}}", {
4579
+ params: { error: err }
4552
4580
  });
4553
4581
  });
4554
4582
  }
@@ -4570,8 +4598,9 @@ var LifecycleManager = class extends EventEmitterProtected {
4570
4598
  this.lifecycleEvents.componentShutdownWarningCompleted(name);
4571
4599
  }).catch((error) => {
4572
4600
  statuses.set(name, "rejected");
4573
- this.logger.entity(name).warn("Shutdown warning phase failed", {
4574
- params: { error }
4601
+ const err = error instanceof Error ? error : new Error(String(error));
4602
+ this.logger.entity(name).warn("Shutdown warning phase failed: {{error.message}}", {
4603
+ params: { error: err }
4575
4604
  });
4576
4605
  })
4577
4606
  );
@@ -4630,9 +4659,13 @@ var LifecycleManager = class extends EventEmitterProtected {
4630
4659
  try {
4631
4660
  component.onGracefulStopTimeout();
4632
4661
  } catch (error) {
4633
- this.logger.entity(name).warn("Error in onGracefulStopTimeout callback", {
4634
- params: { error }
4635
- });
4662
+ const err = error instanceof Error ? error : new Error(String(error));
4663
+ this.logger.entity(name).warn(
4664
+ "Error in onGracefulStopTimeout callback: {{error.message}}",
4665
+ {
4666
+ params: { error: err }
4667
+ }
4668
+ );
4636
4669
  }
4637
4670
  }
4638
4671
  Promise.resolve(stopPromise).catch(() => {
@@ -4676,7 +4709,7 @@ var LifecycleManager = class extends EventEmitterProtected {
4676
4709
  status: this.getComponentStatus(name)
4677
4710
  };
4678
4711
  } catch (error) {
4679
- const err = error;
4712
+ const err = error instanceof Error ? error : new Error(String(error));
4680
4713
  this.componentErrors.set(name, err);
4681
4714
  if (err instanceof ComponentStopTimeoutError && err.additionalInfo.componentName === name) {
4682
4715
  this.logger.entity(name).warn("Graceful shutdown timed out");
@@ -4693,7 +4726,7 @@ var LifecycleManager = class extends EventEmitterProtected {
4693
4726
  status: this.getComponentStatus(name)
4694
4727
  };
4695
4728
  } else {
4696
- this.logger.entity(name).warn("Graceful shutdown threw error", {
4729
+ this.logger.entity(name).warn("Graceful shutdown threw error: {{error.message}}", {
4697
4730
  params: { error: err }
4698
4731
  });
4699
4732
  return {
@@ -4774,9 +4807,13 @@ var LifecycleManager = class extends EventEmitterProtected {
4774
4807
  try {
4775
4808
  component.onShutdownForceAborted();
4776
4809
  } catch (error) {
4777
- this.logger.entity(name).warn("Error in onShutdownForceAborted callback", {
4778
- params: { error }
4779
- });
4810
+ const err = error instanceof Error ? error : new Error(String(error));
4811
+ this.logger.entity(name).warn(
4812
+ "Error in onShutdownForceAborted callback: {{error.message}}",
4813
+ {
4814
+ params: { error: err }
4815
+ }
4816
+ );
4780
4817
  }
4781
4818
  }
4782
4819
  Promise.resolve(forcePromise).catch(() => {
@@ -4816,7 +4853,7 @@ var LifecycleManager = class extends EventEmitterProtected {
4816
4853
  status: this.getComponentStatus(name)
4817
4854
  };
4818
4855
  } catch (error) {
4819
- const err = error;
4856
+ const err = error instanceof Error ? error : new Error(String(error));
4820
4857
  const isTimeout = err.message === "Force shutdown timed out";
4821
4858
  const stallInfo = {
4822
4859
  name,
@@ -4837,7 +4874,7 @@ var LifecycleManager = class extends EventEmitterProtected {
4837
4874
  });
4838
4875
  this.lifecycleEvents.componentShutdownForceTimeout(name, timeoutMS);
4839
4876
  } else {
4840
- this.logger.entity(name).error("Force shutdown failed - stalled", {
4877
+ this.logger.entity(name).error("Force shutdown failed - stalled: {{error.message}}", {
4841
4878
  params: { error: err }
4842
4879
  });
4843
4880
  }
@@ -4926,9 +4963,14 @@ var LifecycleManager = class extends EventEmitterProtected {
4926
4963
  this.lifecycleEvents.componentStartupRollback(name);
4927
4964
  const result = await this.stopComponentInternal(name);
4928
4965
  if (!result.success) {
4929
- this.logger.entity(name).warn("Failed to stop component during rollback, continuing", {
4930
- params: { error: result.error }
4931
- });
4966
+ this.logger.entity(name).warn(
4967
+ "Failed to stop component during rollback, continuing: {{error.message}}",
4968
+ {
4969
+ params: {
4970
+ error: result.error || new Error(result.reason || "Unknown error")
4971
+ }
4972
+ }
4973
+ );
4932
4974
  }
4933
4975
  }
4934
4976
  this.logger.info("Rollback completed");
@@ -4991,8 +5033,9 @@ var LifecycleManager = class extends EventEmitterProtected {
4991
5033
  try {
4992
5034
  this.emit(event, data);
4993
5035
  } catch (error) {
4994
- this.logger.error("Event handler error", {
4995
- params: { event, error }
5036
+ const err = error instanceof Error ? error : new Error(String(error));
5037
+ this.logger.error("Event handler error: {{error.message}}", {
5038
+ params: { event, error: err }
4996
5039
  });
4997
5040
  }
4998
5041
  }
@@ -5001,9 +5044,13 @@ var LifecycleManager = class extends EventEmitterProtected {
5001
5044
  try {
5002
5045
  startupOrder = this.getStartupOrderInternal();
5003
5046
  } catch (error) {
5004
- this.logger.warn("Failed to compute startup order in error handler", {
5005
- params: { error }
5006
- });
5047
+ const err = error instanceof Error ? error : new Error(String(error));
5048
+ this.logger.warn(
5049
+ "Failed to compute startup order in error handler: {{error.message}}",
5050
+ {
5051
+ params: { error: err }
5052
+ }
5053
+ );
5007
5054
  startupOrder = [];
5008
5055
  }
5009
5056
  return {
@@ -5024,9 +5071,13 @@ var LifecycleManager = class extends EventEmitterProtected {
5024
5071
  try {
5025
5072
  startupOrder = this.getStartupOrderInternal();
5026
5073
  } catch (error) {
5027
- this.logger.warn("Failed to compute startup order in error handler", {
5028
- params: { error }
5029
- });
5074
+ const err = error instanceof Error ? error : new Error(String(error));
5075
+ this.logger.warn(
5076
+ "Failed to compute startup order in error handler: {{error.message}}",
5077
+ {
5078
+ params: { error: err }
5079
+ }
5080
+ );
5030
5081
  startupOrder = [];
5031
5082
  }
5032
5083
  return {
@@ -5420,7 +5471,9 @@ var LifecycleManager = class extends EventEmitterProtected {
5420
5471
  }
5421
5472
  } catch (error) {
5422
5473
  const err = error instanceof Error ? error : new Error(String(error));
5423
- this.logger.entity(name).error("Reload failed", { params: { error: err } });
5474
+ this.logger.entity(name).error("Reload failed: {{error.message}}", {
5475
+ params: { error: err }
5476
+ });
5424
5477
  this.lifecycleEvents.componentReloadFailed(name, err);
5425
5478
  results.push({
5426
5479
  name,
@@ -5515,7 +5568,9 @@ var LifecycleManager = class extends EventEmitterProtected {
5515
5568
  }
5516
5569
  } catch (error) {
5517
5570
  const err = error instanceof Error ? error : new Error(String(error));
5518
- this.logger.entity(name).error("Info handler failed", { params: { error: err } });
5571
+ this.logger.entity(name).error("Info handler failed: {{error.message}}", {
5572
+ params: { error: err }
5573
+ });
5519
5574
  this.lifecycleEvents.componentInfoFailed(name, err);
5520
5575
  results.push({
5521
5576
  name,
@@ -5610,7 +5665,9 @@ var LifecycleManager = class extends EventEmitterProtected {
5610
5665
  }
5611
5666
  } catch (error) {
5612
5667
  const err = error instanceof Error ? error : new Error(String(error));
5613
- this.logger.entity(name).error("Debug handler failed", { params: { error: err } });
5668
+ this.logger.entity(name).error("Debug handler failed: {{error.message}}", {
5669
+ params: { error: err }
5670
+ });
5614
5671
  this.lifecycleEvents.componentDebugFailed(name, err);
5615
5672
  results.push({
5616
5673
  name,