autotel 6.5.0 → 7.0.1

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.
Files changed (166) hide show
  1. package/README.md +30 -23
  2. package/dist/{attribute-redacting-processor-Pk7lAzWd.d.cts → attribute-redacting-processor-CvBE0z1p.d.cts} +33 -1
  3. package/dist/{attribute-redacting-processor-Pk7lAzWd.d.ts → attribute-redacting-processor-CvBE0z1p.d.ts} +33 -1
  4. package/dist/attribute-redacting-processor.cjs +34 -32
  5. package/dist/attribute-redacting-processor.d.cts +1 -1
  6. package/dist/attribute-redacting-processor.d.ts +1 -1
  7. package/dist/attribute-redacting-processor.js +35 -32
  8. package/dist/{attributes-aDmJYral.cjs → attributes-Cxys8tgr.cjs} +34 -35
  9. package/dist/{attributes-B7wix2VG.js → attributes-Dt4YUYbP.js} +34 -35
  10. package/dist/attributes.cjs +1 -1
  11. package/dist/attributes.d.cts +1 -1
  12. package/dist/attributes.d.ts +1 -1
  13. package/dist/attributes.js +1 -1
  14. package/dist/auto.cjs +1 -1
  15. package/dist/auto.js +1 -1
  16. package/dist/business-baggage.cjs +19 -12
  17. package/dist/business-baggage.d.cts +8 -3
  18. package/dist/business-baggage.d.ts +8 -3
  19. package/dist/business-baggage.js +19 -12
  20. package/dist/{canonical-log-line-processor-DxtBGZIi.cjs → canonical-log-line-processor-DolzdawH.cjs} +43 -32
  21. package/dist/{canonical-log-line-processor-B4WgG-VS.d.cts → canonical-log-line-processor-cPB4Axk-.d.ts} +4 -3
  22. package/dist/{canonical-log-line-processor-B0vq_QR6.js → canonical-log-line-processor-hFUmS__K.js} +43 -32
  23. package/dist/{canonical-log-line-processor-CL_J7gb5.d.ts → canonical-log-line-processor-l0Aqe6yp.d.cts} +4 -3
  24. package/dist/config.d.cts +1 -1
  25. package/dist/config.d.ts +1 -1
  26. package/dist/{correlated-events-kSwLo3mi.cjs → correlated-events-CcuknWnU.cjs} +2 -1
  27. package/dist/{correlated-events-Bzh5y-UB.js → correlated-events-DwMMbItg.js} +3 -1
  28. package/dist/correlation-id.cjs +1 -1
  29. package/dist/correlation-id.js +1 -1
  30. package/dist/db.cjs +34 -19
  31. package/dist/db.js +34 -19
  32. package/dist/decorators.cjs +4 -2
  33. package/dist/decorators.d.cts +16 -11
  34. package/dist/decorators.d.ts +16 -11
  35. package/dist/decorators.js +4 -2
  36. package/dist/{define-event-CGG048HE.d.cts → define-event-BNeuKUPv.d.cts} +1 -1
  37. package/dist/{define-event-B2z1SBe7.d.ts → define-event-Bd8f8mST.d.ts} +1 -1
  38. package/dist/diagnostics.cjs +18 -16
  39. package/dist/diagnostics.d.cts +14 -10
  40. package/dist/diagnostics.d.ts +14 -10
  41. package/dist/diagnostics.js +18 -16
  42. package/dist/{event-subscriber-CWh8sTGh.d.cts → event-subscriber-DMACQA-1.d.cts} +19 -9
  43. package/dist/{event-subscriber-CWh8sTGh.d.ts → event-subscriber-DMACQA-1.d.ts} +19 -9
  44. package/dist/event-subscriber.d.cts +2 -2
  45. package/dist/event-subscriber.d.ts +2 -2
  46. package/dist/{event-testing-D0qWfqAy.d.cts → event-testing-CBtnJXE5.d.cts} +1 -1
  47. package/dist/{event-testing-CA2mIx1E.d.ts → event-testing-CkPgV3Ii.d.ts} +1 -1
  48. package/dist/event-testing.d.cts +1 -1
  49. package/dist/event-testing.d.ts +1 -1
  50. package/dist/event.cjs +1 -1
  51. package/dist/event.d.cts +5 -5
  52. package/dist/event.d.ts +5 -5
  53. package/dist/event.js +1 -1
  54. package/dist/exception-fingerprint.cjs +133 -0
  55. package/dist/exception-fingerprint.d.cts +51 -0
  56. package/dist/exception-fingerprint.d.ts +51 -0
  57. package/dist/exception-fingerprint.js +126 -0
  58. package/dist/{functional-C0uAZq2X.cjs → functional-C2ONG9PK.cjs} +27 -15
  59. package/dist/{functional-e6jw5zQj.d.cts → functional-CJn2zY4o.d.cts} +96 -39
  60. package/dist/{functional-AT22vCw6.d.ts → functional-DXy1cHFF.d.ts} +96 -39
  61. package/dist/{functional-DX7Zvag0.js → functional-nS5U4KCQ.js} +27 -15
  62. package/dist/functional.cjs +1 -1
  63. package/dist/functional.d.cts +2 -2
  64. package/dist/functional.d.ts +2 -2
  65. package/dist/functional.js +1 -1
  66. package/dist/http.cjs +11 -8
  67. package/dist/http.js +11 -8
  68. package/dist/{index-DolOVX6F.d.ts → index-CwrNAsgk.d.ts} +22 -26
  69. package/dist/{index-BPcxVucm.d.cts → index-DQHf4cNl.d.cts} +22 -26
  70. package/dist/index.cjs +41 -35
  71. package/dist/index.d.cts +45 -30
  72. package/dist/index.d.ts +45 -30
  73. package/dist/index.js +41 -35
  74. package/dist/{init-pPI3JRRf.d.ts → init-BgnYi2sm.d.ts} +6 -6
  75. package/dist/{init-CTtHITlX.cjs → init-C5aHRqi2.cjs} +111 -85
  76. package/dist/{init-WHYwyItd.js → init-DDyaLzeg.js} +106 -86
  77. package/dist/{init-ncTMKZ-s.d.cts → init-DrlL1eis.d.cts} +6 -6
  78. package/dist/instrumentation.cjs +2 -2
  79. package/dist/instrumentation.js +2 -2
  80. package/dist/{logger-D3Ej3DII.js → logger-DdPp__xW.js} +63 -54
  81. package/dist/{logger-CN4xpzMd.d.cts → logger-S1Fgl0g3.d.cts} +0 -20
  82. package/dist/{logger-CN4xpzMd.d.ts → logger-S1Fgl0g3.d.ts} +0 -20
  83. package/dist/{logger-thMPLpOG.cjs → logger-Sm66cjKl.cjs} +63 -54
  84. package/dist/logger.cjs +1 -1
  85. package/dist/logger.d.cts +1 -1
  86. package/dist/logger.d.ts +1 -1
  87. package/dist/logger.js +1 -1
  88. package/dist/messaging-adapters.cjs +26 -12
  89. package/dist/messaging-adapters.d.cts +0 -30
  90. package/dist/messaging-adapters.d.ts +0 -30
  91. package/dist/messaging-adapters.js +26 -12
  92. package/dist/messaging.cjs +37 -34
  93. package/dist/messaging.d.cts +21 -62
  94. package/dist/messaging.d.ts +21 -62
  95. package/dist/messaging.js +37 -34
  96. package/dist/{metric-testing-CpvP3ZIa.d.cts → metric-testing-86WO1wan.d.cts} +1 -1
  97. package/dist/{metric-testing-CWm6UhaR.d.ts → metric-testing-CbCxdPBp.d.ts} +1 -1
  98. package/dist/metric-testing.d.cts +1 -1
  99. package/dist/metric-testing.d.ts +1 -1
  100. package/dist/metric.d.cts +3 -3
  101. package/dist/metric.d.ts +3 -3
  102. package/dist/{node-require-vROmTeJ8.js → node-require-DSPjaw_l.js} +3 -2
  103. package/dist/{node-require-PFqDihze.cjs → node-require-EifOMikz.cjs} +3 -2
  104. package/dist/parse-error.cjs +18 -12
  105. package/dist/parse-error.d.cts +2 -1
  106. package/dist/parse-error.d.ts +2 -1
  107. package/dist/parse-error.js +19 -12
  108. package/dist/policy.cjs +0 -0
  109. package/dist/policy.js +0 -0
  110. package/dist/processors.cjs +1 -1
  111. package/dist/processors.d.cts +1 -1
  112. package/dist/processors.d.ts +1 -1
  113. package/dist/processors.js +1 -1
  114. package/dist/{sampling-BR9fkSwx.d.cts → sampling-CM5S2Lp3.d.ts} +5 -6
  115. package/dist/{sampling-CP3e7-Yr.d.ts → sampling-CmRdnXUi.d.cts} +5 -6
  116. package/dist/sampling.cjs +3 -2
  117. package/dist/sampling.d.cts +1 -1
  118. package/dist/sampling.d.ts +1 -1
  119. package/dist/sampling.js +3 -2
  120. package/dist/semantic-helpers.cjs +9 -9
  121. package/dist/semantic-helpers.d.cts +1 -1
  122. package/dist/semantic-helpers.d.ts +1 -1
  123. package/dist/semantic-helpers.js +9 -9
  124. package/dist/{stable-hash-ChFBIhNt.js → stable-hash-BkoAYVks.js} +4 -3
  125. package/dist/{stable-hash-CS9BxvVQ.cjs → stable-hash-C0pOegH_.cjs} +4 -3
  126. package/dist/{structured-error-CHg7DoIQ.cjs → structured-error--_wXpd_C.cjs} +34 -25
  127. package/dist/{structured-error-9--cxBay.js → structured-error-YIuka-FE.js} +34 -25
  128. package/dist/test-span-collector.cjs +15 -8
  129. package/dist/test-span-collector.js +15 -8
  130. package/dist/testing.cjs +16 -18
  131. package/dist/testing.d.cts +7 -6
  132. package/dist/testing.d.ts +7 -6
  133. package/dist/testing.js +16 -18
  134. package/dist/{trace-context-IuyoPyNq.d.cts → trace-context-C1Cn1q0y.d.cts} +8 -7
  135. package/dist/{trace-context-IuyoPyNq.d.ts → trace-context-f89xPJbK.d.ts} +8 -7
  136. package/dist/trace-helpers.cjs +16 -13
  137. package/dist/trace-helpers.d.cts +9 -4
  138. package/dist/trace-helpers.d.ts +9 -4
  139. package/dist/trace-helpers.js +16 -13
  140. package/dist/tracer-provider.cjs +8 -12
  141. package/dist/tracer-provider.js +8 -12
  142. package/dist/validate.cjs +22 -20
  143. package/dist/validate.d.cts +3 -2
  144. package/dist/validate.d.ts +3 -2
  145. package/dist/validate.js +22 -20
  146. package/dist/values-BenyvWKz.js +141 -0
  147. package/dist/values-CeMH-mYG.d.cts +8 -0
  148. package/dist/values-CeMH-mYG.d.ts +8 -0
  149. package/dist/values-DApyq53y.cjs +267 -0
  150. package/dist/webhook.cjs +3 -3
  151. package/dist/webhook.d.cts +1 -1
  152. package/dist/webhook.d.ts +1 -1
  153. package/dist/webhook.js +3 -3
  154. package/dist/workflow-distributed.cjs +9 -7
  155. package/dist/workflow-distributed.d.cts +9 -8
  156. package/dist/workflow-distributed.d.ts +9 -8
  157. package/dist/workflow-distributed.js +9 -7
  158. package/dist/workflow.cjs +26 -17
  159. package/dist/workflow.d.cts +1 -28
  160. package/dist/workflow.d.ts +1 -28
  161. package/dist/workflow.js +26 -17
  162. package/dist/yaml-config.cjs +26 -11
  163. package/dist/yaml-config.d.cts +9 -3
  164. package/dist/yaml-config.d.ts +9 -3
  165. package/dist/yaml-config.js +26 -11
  166. package/package.json +6 -1
@@ -1,4 +1,4 @@
1
- import { n as TraceContext } from "./trace-context-IuyoPyNq.cjs";
1
+ import { n as TraceContext } from "./trace-context-C1Cn1q0y.cjs";
2
2
  import { Attributes, SpanContext } from "@opentelemetry/api";
3
3
  //#region src/workflow.d.ts
4
4
  /**
@@ -106,33 +106,6 @@ interface StepContext extends TraceContext {
106
106
  /** Get workflow context */
107
107
  getWorkflowContext(): WorkflowContext | null;
108
108
  }
109
- /**
110
- * Create a traced workflow function
111
- *
112
- * Wraps business logic in a workflow span with automatic step tracking,
113
- * correlation via workflow ID, and compensation support.
114
- *
115
- * @param config - Workflow configuration
116
- * @returns Factory function that wraps your workflow logic
117
- *
118
- * @example Order fulfillment workflow
119
- * ```typescript
120
- * export const fulfillOrder = traceWorkflow({
121
- * name: 'OrderFulfillment',
122
- * workflowId: (order) => order.id,
123
- * version: '2.0',
124
- * })(ctx => async (order: Order) => {
125
- * ctx.setAttribute('order.total', order.total);
126
- *
127
- * await validateOrder(order);
128
- * await processPayment(order);
129
- * await fulfillItems(order);
130
- * await notifyCustomer(order);
131
- *
132
- * return { success: true, orderId: order.id };
133
- * });
134
- * ```
135
- */
136
109
  declare function traceWorkflow<TConfigArgs extends unknown[] = unknown[]>(config: WorkflowConfig<TConfigArgs>): <TArgs extends TConfigArgs, TReturn>(fnFactory: (ctx: WorkflowContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
137
110
  /**
138
111
  * Create a traced workflow step
@@ -1,4 +1,4 @@
1
- import { n as TraceContext } from "./trace-context-IuyoPyNq.js";
1
+ import { n as TraceContext } from "./trace-context-f89xPJbK.js";
2
2
  import { Attributes, SpanContext } from "@opentelemetry/api";
3
3
  //#region src/workflow.d.ts
4
4
  /**
@@ -106,33 +106,6 @@ interface StepContext extends TraceContext {
106
106
  /** Get workflow context */
107
107
  getWorkflowContext(): WorkflowContext | null;
108
108
  }
109
- /**
110
- * Create a traced workflow function
111
- *
112
- * Wraps business logic in a workflow span with automatic step tracking,
113
- * correlation via workflow ID, and compensation support.
114
- *
115
- * @param config - Workflow configuration
116
- * @returns Factory function that wraps your workflow logic
117
- *
118
- * @example Order fulfillment workflow
119
- * ```typescript
120
- * export const fulfillOrder = traceWorkflow({
121
- * name: 'OrderFulfillment',
122
- * workflowId: (order) => order.id,
123
- * version: '2.0',
124
- * })(ctx => async (order: Order) => {
125
- * ctx.setAttribute('order.total', order.total);
126
- *
127
- * await validateOrder(order);
128
- * await processPayment(order);
129
- * await fulfillItems(order);
130
- * await notifyCustomer(order);
131
- *
132
- * return { success: true, orderId: order.id };
133
- * });
134
- * ```
135
- */
136
109
  declare function traceWorkflow<TConfigArgs extends unknown[] = unknown[]>(config: WorkflowConfig<TConfigArgs>): <TArgs extends TConfigArgs, TReturn>(fnFactory: (ctx: WorkflowContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
137
110
  /**
138
111
  * Create a traced workflow step
package/dist/workflow.js CHANGED
@@ -1,6 +1,7 @@
1
+ import { b as toAttributeValue, g as nonEmptyString, h as isFunction, l as asString, s as asRecord, x as toError } from "./values-BenyvWKz.js";
1
2
  import { getActiveSpan } from "./trace-helpers.js";
2
- import { c as withTracing } from "./functional-DX7Zvag0.js";
3
- import { t as emitCorrelatedEvent } from "./correlated-events-Bzh5y-UB.js";
3
+ import { c as withTracing } from "./functional-nS5U4KCQ.js";
4
+ import { t as emitCorrelatedEvent } from "./correlated-events-DwMMbItg.js";
4
5
  import { t as assertTraceFactory } from "./trace-factory-validation-BjVAinz6.js";
5
6
  import * as nodeAsyncHooks from "node:async_hooks";
6
7
 
@@ -95,23 +96,31 @@ const workflowContextStorage = new nodeAsyncHooks.AsyncLocalStorage();
95
96
  * });
96
97
  * ```
97
98
  */
99
+ /**
100
+ * Check a config a JavaScript caller may have built by hand: TypeScript has
101
+ * already checked it for everyone else.
102
+ */
103
+ function assertNamedConfig(fn, config) {
104
+ if (!asRecord(config)) throw new TypeError(`${fn}: config must be an object`);
105
+ if (nonEmptyString(config.name) === void 0) throw new TypeError(`${fn}: config.name must be a non-empty string`);
106
+ }
98
107
  function traceWorkflow(config) {
99
- if (!config || typeof config !== "object") throw new TypeError("traceWorkflow: config must be an object");
100
- if (typeof config.name !== "string" || config.name.trim() === "") throw new TypeError("traceWorkflow: config.name must be a non-empty string");
101
- if (typeof config.workflowId !== "string" && typeof config.workflowId !== "function") throw new TypeError("traceWorkflow: config.workflowId must be a string or function");
108
+ assertNamedConfig("traceWorkflow", config);
109
+ if (asString(config.workflowId) === void 0 && !isFunction(config.workflowId)) throw new TypeError("traceWorkflow: config.workflowId must be a string or function");
102
110
  const spanName = `workflow.${config.name}`;
103
111
  return (fnFactory) => {
104
112
  assertTraceFactory("traceWorkflow", fnFactory);
105
113
  return withTracing({ name: spanName })((baseCtx) => {
106
114
  return async (...args) => {
107
- const workflowId = typeof config.workflowId === "function" ? config.workflowId(...args) : config.workflowId;
115
+ const workflowId = isFunction(config.workflowId) ? config.workflowId(...args) : config.workflowId;
108
116
  const ctx = createWorkflowContext(baseCtx, config.name, workflowId);
109
117
  ctx.setAttribute("workflow.name", config.name);
110
118
  ctx.setAttribute("workflow.id", workflowId);
111
119
  if (config.version) ctx.setAttribute("workflow.version", config.version);
112
120
  ctx.setAttribute("workflow.status", "running");
113
- if (config.attributes) {
114
- for (const [key, value] of Object.entries(config.attributes)) if (value !== void 0) ctx.setAttribute(key, value);
121
+ if (config.attributes) for (const [key, value] of Object.entries(config.attributes)) {
122
+ const attribute = toAttributeValue(value);
123
+ if (attribute !== void 0) ctx.setAttribute(key, attribute);
115
124
  }
116
125
  return workflowContextStorage.run(ctx, async () => {
117
126
  try {
@@ -123,13 +132,13 @@ function traceWorkflow(config) {
123
132
  return result;
124
133
  } catch (error) {
125
134
  ctx.setWorkflowStatus("failed");
126
- config.onFailed?.(ctx, error);
135
+ config.onFailed?.(ctx, toError(error));
127
136
  const state = getWorkflowState();
128
137
  if (state && state.compensations.size > 0) {
129
138
  ctx.setWorkflowStatus("compensating");
130
139
  config.onCompensating?.(ctx);
131
140
  try {
132
- await ctx.compensate(error);
141
+ await ctx.compensate(toError(error));
133
142
  ctx.setWorkflowStatus("compensated");
134
143
  } catch (compensationError) {
135
144
  ctx.setWorkflowStatus("compensation_failed");
@@ -144,10 +153,9 @@ function traceWorkflow(config) {
144
153
  };
145
154
  }
146
155
  function traceStep(config) {
147
- if (!config || typeof config !== "object") throw new TypeError("traceStep: config must be an object");
148
- if (typeof config.name !== "string" || config.name.trim() === "") throw new TypeError("traceStep: config.name must be a non-empty string");
156
+ assertNamedConfig("traceStep", config);
149
157
  return ((handler) => {
150
- if (typeof handler !== "function") throw new TypeError("traceStep(config)(handler): handler must be a function");
158
+ if (!isFunction(handler)) throw new TypeError("traceStep(config)(handler): handler must be a function");
151
159
  return withTracing({ name: `step.${config.name}` })((baseCtx) => {
152
160
  return async (...args) => {
153
161
  const workflowCtx = workflowContextStorage.getStore() ?? null;
@@ -157,8 +165,9 @@ function traceStep(config) {
157
165
  ctx.setAttribute("workflow.step.status", "running");
158
166
  if (config.description) ctx.setAttribute("workflow.step.description", config.description);
159
167
  if (config.idempotent) ctx.setAttribute("workflow.step.idempotent", true);
160
- if (config.attributes) {
161
- for (const [key, value] of Object.entries(config.attributes)) if (value !== void 0) ctx.setAttribute(key, value);
168
+ if (config.attributes) for (const [key, value] of Object.entries(config.attributes)) {
169
+ const attribute = toAttributeValue(value);
170
+ if (attribute !== void 0) ctx.setAttribute(key, attribute);
162
171
  }
163
172
  await addStepLinks(ctx, config, workflowCtx);
164
173
  if (config.compensate && workflowCtx) {
@@ -185,7 +194,7 @@ function traceStep(config) {
185
194
  config.onComplete?.(ctx);
186
195
  return result;
187
196
  } catch (error) {
188
- lastError = error;
197
+ lastError = toError(error);
189
198
  if (attempt < maxAttempts) emitCorrelatedEvent(ctx, "step_retry_scheduled", {
190
199
  "workflow.step.error": String(error),
191
200
  "workflow.step.attempt": attempt
@@ -264,7 +273,7 @@ function createWorkflowContext(baseCtx, workflowName, workflowId) {
264
273
  this.recordCompensation(stepName, true);
265
274
  step.status = "compensated";
266
275
  } catch (compensationError) {
267
- this.recordCompensation(stepName, false, compensationError);
276
+ this.recordCompensation(stepName, false, toError(compensationError));
268
277
  throw compensationError;
269
278
  }
270
279
  }
@@ -1,7 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_rolldown_runtime = require('./rolldown-runtime-C_NdSu1c.cjs');
3
+ const require_values = require('./values-DApyq53y.cjs');
3
4
  const require_sampling = require('./sampling.cjs');
4
- const require_node_require = require('./node-require-PFqDihze.cjs');
5
+ const require_node_require = require('./node-require-EifOMikz.cjs');
5
6
  let node_fs = require("node:fs");
6
7
  node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
7
8
  let node_path = require("node:path");
@@ -71,15 +72,31 @@ function substituteEnvVars(value) {
71
72
  * @param obj - Object to process
72
73
  * @returns Object with all string values having env vars substituted
73
74
  */
74
- function substituteEnvVarsDeep(obj) {
75
- if (typeof obj === "string") return substituteEnvVars(obj);
76
- if (Array.isArray(obj)) return obj.map((item) => substituteEnvVarsDeep(item));
77
- if (obj && typeof obj === "object") {
75
+ function substituteEnvVarsDeep(value) {
76
+ if (Array.isArray(value)) return value.map(substituteEnvVarsDeep);
77
+ const mapping = asYamlMapping(value);
78
+ if (mapping) {
78
79
  const result = {};
79
- for (const [key, value] of Object.entries(obj)) result[key] = substituteEnvVarsDeep(value);
80
+ for (const [key, entry] of Object.entries(mapping)) result[key] = substituteEnvVarsDeep(entry);
80
81
  return result;
81
82
  }
82
- return obj;
83
+ const text = require_values.asString(value);
84
+ return text === void 0 ? value : substituteEnvVars(text);
85
+ }
86
+ /** The mapping a YAML value is, when it is one. */
87
+ function asYamlMapping(value) {
88
+ return require_values.asRecord(value) === void 0 ? void 0 : value;
89
+ }
90
+ /**
91
+ * A YAML document read into the config shape, with `${env:...}` placeholders
92
+ * resolved.
93
+ *
94
+ * This is the boundary: the file is text until here. Every field of
95
+ * YamlConfig is optional, so any document satisfies it, and
96
+ * `yamlToAutotelConfig` picks out only the fields it understands.
97
+ */
98
+ function parseYamlConfig(content) {
99
+ return asYamlMapping(substituteEnvVarsDeep(loadYamlParser()(content))) ?? {};
83
100
  }
84
101
  /**
85
102
  * Find YAML config file path
@@ -192,8 +209,7 @@ function loadYamlConfig() {
192
209
  const filePath = findConfigFile();
193
210
  if (!filePath) return null;
194
211
  try {
195
- const content = node_fs.readFileSync(filePath, "utf8");
196
- return yamlToAutotelConfig(substituteEnvVarsDeep(loadYamlParser()(content)));
212
+ return yamlToAutotelConfig(parseYamlConfig(node_fs.readFileSync(filePath, "utf8")));
197
213
  } catch (error) {
198
214
  console.error(`[autotel] Failed to load YAML config from ${filePath}:`, error);
199
215
  return null;
@@ -217,8 +233,7 @@ function loadYamlConfig() {
217
233
  */
218
234
  function loadYamlConfigFromFile(filePath) {
219
235
  const resolved = node_path.default.resolve(filePath);
220
- const content = node_fs.readFileSync(resolved, "utf8");
221
- return yamlToAutotelConfig(substituteEnvVarsDeep(loadYamlParser()(content)));
236
+ return yamlToAutotelConfig(parseYamlConfig(node_fs.readFileSync(resolved, "utf8")));
222
237
  }
223
238
  /**
224
239
  * Check if a YAML config file exists (without loading it)
@@ -1,6 +1,12 @@
1
- import { h as SamplingPreset } from "./sampling-BR9fkSwx.cjs";
2
- import { a as AutotelConfig, o as OtlpSignal } from "./init-ncTMKZ-s.cjs";
1
+ import { h as SamplingPreset } from "./sampling-CmRdnXUi.cjs";
2
+ import { a as AutotelConfig, o as OtlpSignal } from "./init-DrlL1eis.cjs";
3
3
  //#region src/yaml-config.d.ts
4
+ /** A value as a YAML document carries it: scalars, sequences, mappings. */
5
+ type YamlValue = string | number | boolean | null | YamlValue[] | YamlMapping;
6
+ /** A YAML mapping - keys the reader has not looked at yet. */
7
+ interface YamlMapping {
8
+ [key: string]: YamlValue;
9
+ }
4
10
  /**
5
11
  * YAML config structure
6
12
  * Maps to AutotelConfig with user-friendly naming
@@ -78,4 +84,4 @@ declare function loadYamlConfigFromFile(filePath: string): Partial<AutotelConfig
78
84
  */
79
85
  declare function hasYamlConfig(): boolean;
80
86
  //#endregion
81
- export { YamlConfig, hasYamlConfig, loadYamlConfig, loadYamlConfigFromFile };
87
+ export { YamlConfig, YamlMapping, YamlValue, hasYamlConfig, loadYamlConfig, loadYamlConfigFromFile };
@@ -1,6 +1,12 @@
1
- import { h as SamplingPreset } from "./sampling-CP3e7-Yr.js";
2
- import { a as AutotelConfig, o as OtlpSignal } from "./init-pPI3JRRf.js";
1
+ import { h as SamplingPreset } from "./sampling-CM5S2Lp3.js";
2
+ import { a as AutotelConfig, o as OtlpSignal } from "./init-BgnYi2sm.js";
3
3
  //#region src/yaml-config.d.ts
4
+ /** A value as a YAML document carries it: scalars, sequences, mappings. */
5
+ type YamlValue = string | number | boolean | null | YamlValue[] | YamlMapping;
6
+ /** A YAML mapping - keys the reader has not looked at yet. */
7
+ interface YamlMapping {
8
+ [key: string]: YamlValue;
9
+ }
4
10
  /**
5
11
  * YAML config structure
6
12
  * Maps to AutotelConfig with user-friendly naming
@@ -78,4 +84,4 @@ declare function loadYamlConfigFromFile(filePath: string): Partial<AutotelConfig
78
84
  */
79
85
  declare function hasYamlConfig(): boolean;
80
86
  //#endregion
81
- export { YamlConfig, hasYamlConfig, loadYamlConfig, loadYamlConfigFromFile };
87
+ export { YamlConfig, YamlMapping, YamlValue, hasYamlConfig, loadYamlConfig, loadYamlConfigFromFile };
@@ -1,5 +1,6 @@
1
+ import { l as asString, s as asRecord } from "./values-BenyvWKz.js";
1
2
  import { AdaptiveSampler, AlwaysSampler, NeverSampler, RandomSampler } from "./sampling.js";
2
- import { t as requireModule } from "./node-require-vROmTeJ8.js";
3
+ import { t as requireModule } from "./node-require-DSPjaw_l.js";
3
4
  import * as nodeFs from "node:fs";
4
5
  import path from "node:path";
5
6
 
@@ -67,15 +68,31 @@ function substituteEnvVars(value) {
67
68
  * @param obj - Object to process
68
69
  * @returns Object with all string values having env vars substituted
69
70
  */
70
- function substituteEnvVarsDeep(obj) {
71
- if (typeof obj === "string") return substituteEnvVars(obj);
72
- if (Array.isArray(obj)) return obj.map((item) => substituteEnvVarsDeep(item));
73
- if (obj && typeof obj === "object") {
71
+ function substituteEnvVarsDeep(value) {
72
+ if (Array.isArray(value)) return value.map(substituteEnvVarsDeep);
73
+ const mapping = asYamlMapping(value);
74
+ if (mapping) {
74
75
  const result = {};
75
- for (const [key, value] of Object.entries(obj)) result[key] = substituteEnvVarsDeep(value);
76
+ for (const [key, entry] of Object.entries(mapping)) result[key] = substituteEnvVarsDeep(entry);
76
77
  return result;
77
78
  }
78
- return obj;
79
+ const text = asString(value);
80
+ return text === void 0 ? value : substituteEnvVars(text);
81
+ }
82
+ /** The mapping a YAML value is, when it is one. */
83
+ function asYamlMapping(value) {
84
+ return asRecord(value) === void 0 ? void 0 : value;
85
+ }
86
+ /**
87
+ * A YAML document read into the config shape, with `${env:...}` placeholders
88
+ * resolved.
89
+ *
90
+ * This is the boundary: the file is text until here. Every field of
91
+ * YamlConfig is optional, so any document satisfies it, and
92
+ * `yamlToAutotelConfig` picks out only the fields it understands.
93
+ */
94
+ function parseYamlConfig(content) {
95
+ return asYamlMapping(substituteEnvVarsDeep(loadYamlParser()(content))) ?? {};
79
96
  }
80
97
  /**
81
98
  * Find YAML config file path
@@ -188,8 +205,7 @@ function loadYamlConfig() {
188
205
  const filePath = findConfigFile();
189
206
  if (!filePath) return null;
190
207
  try {
191
- const content = nodeFs.readFileSync(filePath, "utf8");
192
- return yamlToAutotelConfig(substituteEnvVarsDeep(loadYamlParser()(content)));
208
+ return yamlToAutotelConfig(parseYamlConfig(nodeFs.readFileSync(filePath, "utf8")));
193
209
  } catch (error) {
194
210
  console.error(`[autotel] Failed to load YAML config from ${filePath}:`, error);
195
211
  return null;
@@ -213,8 +229,7 @@ function loadYamlConfig() {
213
229
  */
214
230
  function loadYamlConfigFromFile(filePath) {
215
231
  const resolved = path.resolve(filePath);
216
- const content = nodeFs.readFileSync(resolved, "utf8");
217
- return yamlToAutotelConfig(substituteEnvVarsDeep(loadYamlParser()(content)));
232
+ return yamlToAutotelConfig(parseYamlConfig(nodeFs.readFileSync(resolved, "utf8")));
218
233
  }
219
234
  /**
220
235
  * Check if a YAML config file exists (without loading it)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autotel",
3
- "version": "6.5.0",
3
+ "version": "7.0.1",
4
4
  "description": "Write Once, Observe Anywhere",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -125,6 +125,11 @@
125
125
  "import": "./dist/attribute-redacting-processor.js",
126
126
  "require": "./dist/attribute-redacting-processor.cjs"
127
127
  },
128
+ "./exception-fingerprint": {
129
+ "types": "./dist/exception-fingerprint.d.ts",
130
+ "import": "./dist/exception-fingerprint.js",
131
+ "require": "./dist/exception-fingerprint.cjs"
132
+ },
128
133
  "./functional": {
129
134
  "types": "./dist/functional.d.ts",
130
135
  "import": "./dist/functional.js",