autotel 6.4.1 → 7.0.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.
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-AT22vCw6.d.ts → functional-CJn2zY4o.d.cts} +96 -39
  59. package/dist/{functional-e6jw5zQj.d.cts → functional-DXy1cHFF.d.ts} +96 -39
  60. package/dist/{functional-qZxRcIBp.cjs → functional-Da6Yv64r.cjs} +27 -15
  61. package/dist/{functional-0o9xSedq.js → functional-uSbNnnxK.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-CsODvlau.d.ts → init-BgnYi2sm.d.ts} +94 -90
  75. package/dist/{init-BnxHAi2M.cjs → init-D4m5rCmD.cjs} +142 -123
  76. package/dist/{init-Cc7-vvzj.d.cts → init-DrlL1eis.d.cts} +94 -90
  77. package/dist/{init-BxfZ3Vbw.js → init-JtX-KKz_.js} +137 -124
  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,3 +1,4 @@
1
+ import { t as UnknownRecord } from "./values-CeMH-mYG.js";
1
2
  import { AttributeValue, Attributes, BaggageEntry, Context, Link, Span, SpanStatusCode } from "@opentelemetry/api";
2
3
  import { AsyncLocalStorage } from "node:async_hooks";
3
4
  //#region src/trace-context.d.ts
@@ -44,21 +45,21 @@ interface SpanMethods {
44
45
  * Replaces the deprecated `recordException` (OTEP 4430). Accepts `unknown`
45
46
  * so it can be called directly with the value caught from a `catch` block.
46
47
  */
47
- recordError(error: unknown): void;
48
+ recordError(cause: unknown): void;
48
49
  /**
49
50
  * Emit a tracked event correlated to this span. Equivalent to the standalone
50
51
  * `track(event, data)` but reads naturally on `ctx`. Replaces the deprecated
51
52
  * `ctx.addEvent` (OTEP 4430) — events become correlated logs rather than
52
53
  * span events.
53
54
  */
54
- track<Events extends Record<string, unknown> = Record<string, unknown>>(event: keyof Events & string, data?: Events[keyof Events & string]): void;
55
+ track<Events extends UnknownRecord = UnknownRecord>(event: keyof Events & string, data?: Events[keyof Events & string]): void;
55
56
  }
56
57
  /**
57
58
  * Baggage methods available on trace context
58
59
  *
59
60
  * @template TBaggage - Optional type for typed baggage (defaults to undefined for untyped)
60
61
  */
61
- interface BaggageMethods<TBaggage extends Record<string, unknown> | undefined = undefined> {
62
+ interface BaggageMethods<TBaggage extends UnknownRecord | undefined = undefined> {
62
63
  /**
63
64
  * Get a baggage entry by key
64
65
  * @param key - Baggage key
@@ -104,14 +105,14 @@ interface BaggageMethods<TBaggage extends Record<string, unknown> | undefined =
104
105
  *
105
106
  * @internal
106
107
  */
107
- getTypedBaggage?: TBaggage extends Record<string, unknown> ? <T extends TBaggage>(namespace?: string) => Partial<T> | undefined : never;
108
+ getTypedBaggage?: TBaggage extends UnknownRecord ? <T extends TBaggage>(namespace?: string) => Partial<T> | undefined : never;
108
109
  /**
109
110
  * Set typed baggage (only available when TBaggage is defined)
110
111
  * This is used internally by defineBaggageSchema()
111
112
  *
112
113
  * @internal
113
114
  */
114
- setTypedBaggage?: TBaggage extends Record<string, unknown> ? <T extends TBaggage>(namespace: string | undefined, value: Partial<T>) => void : never;
115
+ setTypedBaggage?: TBaggage extends UnknownRecord ? <T extends TBaggage>(namespace: string | undefined, value: Partial<T>) => void : never;
115
116
  }
116
117
  /**
117
118
  * Complete trace context that merges base context, span methods, and baggage methods
@@ -140,7 +141,7 @@ interface BaggageMethods<TBaggage extends Record<string, unknown> | undefined =
140
141
  * });
141
142
  * ```
142
143
  */
143
- type TraceContext<TBaggage extends Record<string, unknown> | undefined = undefined> = TraceContextBase & SpanMethods & BaggageMethods<TBaggage>;
144
+ type TraceContext<TBaggage extends UnknownRecord | undefined = undefined> = TraceContextBase & SpanMethods & BaggageMethods<TBaggage>;
144
145
  /**
145
146
  * Define a typed baggage schema for type-safe baggage operations
146
147
  *
@@ -179,7 +180,7 @@ type TraceContext<TBaggage extends Record<string, unknown> | undefined = undefin
179
180
  * });
180
181
  * ```
181
182
  */
182
- declare function defineBaggageSchema<T extends Record<string, unknown>>(namespace?: string): {
183
+ declare function defineBaggageSchema<T extends UnknownRecord>(namespace?: string): {
183
184
  /**
184
185
  * Get typed baggage from context
185
186
  * @param ctx - Trace context
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_node_require = require('./node-require-PFqDihze.cjs');
2
+ const require_values = require('./values-DApyq53y.cjs');
3
+ const require_node_require = require('./node-require-EifOMikz.cjs');
3
4
  let _opentelemetry_api = require("@opentelemetry/api");
4
5
 
5
6
  //#region src/trace-helpers.ts
@@ -379,10 +380,9 @@ function runWithSpan(span, fn) {
379
380
  * }
380
381
  * ```
381
382
  */
382
- function finalizeSpan(span, error) {
383
- if (error) {
384
- if (error instanceof Error) span.recordException(error);
385
- else span.recordException(new Error(String(error)));
383
+ function finalizeSpan(span, cause) {
384
+ if (cause) {
385
+ span.recordException(require_values.toError(cause));
386
386
  span.setStatus({ code: _opentelemetry_api.SpanStatusCode.ERROR });
387
387
  } else span.setStatus({ code: _opentelemetry_api.SpanStatusCode.OK });
388
388
  span.end();
@@ -593,21 +593,24 @@ function flattenMetadata(metadata, prefix = "metadata") {
593
593
  for (const [key, value] of Object.entries(obj)) {
594
594
  if (value == null) continue;
595
595
  const attributeKey = `${currentPrefix}.${key}`;
596
- if (typeof value === "string") {
597
- flattened[attributeKey] = value;
596
+ const text = require_values.asString(value);
597
+ if (text !== void 0) {
598
+ flattened[attributeKey] = text;
598
599
  continue;
599
600
  }
600
- if (typeof value === "number" || typeof value === "boolean") {
601
- flattened[attributeKey] = String(value);
601
+ const scalar = require_values.asNumber(value) ?? require_values.asBoolean(value);
602
+ if (scalar !== void 0) {
603
+ flattened[attributeKey] = String(scalar);
602
604
  continue;
603
605
  }
604
- if (typeof value === "object" && value !== null && value.constructor === Object) {
605
- if (seen.has(value)) {
606
+ const nested = require_values.asPlainRecord(value);
607
+ if (nested !== void 0) {
608
+ if (seen.has(nested)) {
606
609
  flattened[attributeKey] = "<circular-reference>";
607
610
  continue;
608
611
  }
609
- seen.add(value);
610
- flatten(value, attributeKey);
612
+ seen.add(nested);
613
+ flatten(nested, attributeKey);
611
614
  continue;
612
615
  }
613
616
  try {
@@ -1,3 +1,4 @@
1
+ import { t as UnknownRecord } from "./values-CeMH-mYG.cjs";
1
2
  import { Context, Span, Tracer } from "@opentelemetry/api";
2
3
  //#region src/trace-helpers.d.ts
3
4
  /**
@@ -78,7 +79,7 @@ declare function getTraceContext(): TraceContext | null;
78
79
  * // { userId: '123' } - no trace fields added
79
80
  * ```
80
81
  */
81
- declare function enrichWithTraceContext<T extends Record<string, unknown>>(obj: T): T;
82
+ declare function enrichWithTraceContext<T extends UnknownRecord>(obj: T): T;
82
83
  /**
83
84
  * Check if currently in a trace context
84
85
  *
@@ -303,7 +304,7 @@ declare function runWithSpan<T>(span: Span, fn: () => T): T;
303
304
  * }
304
305
  * ```
305
306
  */
306
- declare function finalizeSpan(span: Span, error?: unknown): void;
307
+ declare function finalizeSpan(span: Span, cause?: unknown): void;
307
308
  /**
308
309
  * Creates a deterministic trace ID from a seed string.
309
310
  *
@@ -495,6 +496,10 @@ declare function createDeterministicTraceId(seed: string): Promise<string>;
495
496
  * // => 'https://grafana.example.com/explore?traceId=abc123'
496
497
  */
497
498
  declare function resolveTraceUrl(template: string | undefined, traceId: string): string | undefined;
498
- declare function flattenMetadata(metadata: Record<string, unknown>, prefix?: string): Record<string, string>;
499
+ /** Flattened metadata: every leaf rendered as the string an attribute holds. */
500
+ interface FlatMetadata {
501
+ [key: string]: string;
502
+ }
503
+ declare function flattenMetadata(metadata: UnknownRecord, prefix?: string): FlatMetadata;
499
504
  //#endregion
500
- export { TraceContext, createDeterministicTraceId, enrichWithTraceContext, finalizeSpan, flattenMetadata, getActiveContext, getActiveSpan, getTraceContext, getTracer, isTracing, resolveTraceUrl, runWithSpan, setSpanName };
505
+ export { FlatMetadata, TraceContext, createDeterministicTraceId, enrichWithTraceContext, finalizeSpan, flattenMetadata, getActiveContext, getActiveSpan, getTraceContext, getTracer, isTracing, resolveTraceUrl, runWithSpan, setSpanName };
@@ -1,3 +1,4 @@
1
+ import { t as UnknownRecord } from "./values-CeMH-mYG.js";
1
2
  import { Context, Span, Tracer } from "@opentelemetry/api";
2
3
  //#region src/trace-helpers.d.ts
3
4
  /**
@@ -78,7 +79,7 @@ declare function getTraceContext(): TraceContext | null;
78
79
  * // { userId: '123' } - no trace fields added
79
80
  * ```
80
81
  */
81
- declare function enrichWithTraceContext<T extends Record<string, unknown>>(obj: T): T;
82
+ declare function enrichWithTraceContext<T extends UnknownRecord>(obj: T): T;
82
83
  /**
83
84
  * Check if currently in a trace context
84
85
  *
@@ -303,7 +304,7 @@ declare function runWithSpan<T>(span: Span, fn: () => T): T;
303
304
  * }
304
305
  * ```
305
306
  */
306
- declare function finalizeSpan(span: Span, error?: unknown): void;
307
+ declare function finalizeSpan(span: Span, cause?: unknown): void;
307
308
  /**
308
309
  * Creates a deterministic trace ID from a seed string.
309
310
  *
@@ -495,6 +496,10 @@ declare function createDeterministicTraceId(seed: string): Promise<string>;
495
496
  * // => 'https://grafana.example.com/explore?traceId=abc123'
496
497
  */
497
498
  declare function resolveTraceUrl(template: string | undefined, traceId: string): string | undefined;
498
- declare function flattenMetadata(metadata: Record<string, unknown>, prefix?: string): Record<string, string>;
499
+ /** Flattened metadata: every leaf rendered as the string an attribute holds. */
500
+ interface FlatMetadata {
501
+ [key: string]: string;
502
+ }
503
+ declare function flattenMetadata(metadata: UnknownRecord, prefix?: string): FlatMetadata;
499
504
  //#endregion
500
- export { TraceContext, createDeterministicTraceId, enrichWithTraceContext, finalizeSpan, flattenMetadata, getActiveContext, getActiveSpan, getTraceContext, getTracer, isTracing, resolveTraceUrl, runWithSpan, setSpanName };
505
+ export { FlatMetadata, TraceContext, createDeterministicTraceId, enrichWithTraceContext, finalizeSpan, flattenMetadata, getActiveContext, getActiveSpan, getTraceContext, getTracer, isTracing, resolveTraceUrl, runWithSpan, setSpanName };
@@ -1,4 +1,5 @@
1
- import { t as requireModule } from "./node-require-vROmTeJ8.js";
1
+ import { i as asNumber, l as asString, o as asPlainRecord, t as asBoolean, x as toError } from "./values-BenyvWKz.js";
2
+ import { t as requireModule } from "./node-require-DSPjaw_l.js";
2
3
  import { SpanStatusCode, context, trace } from "@opentelemetry/api";
3
4
 
4
5
  //#region src/trace-helpers.ts
@@ -378,10 +379,9 @@ function runWithSpan(span, fn) {
378
379
  * }
379
380
  * ```
380
381
  */
381
- function finalizeSpan(span, error) {
382
- if (error) {
383
- if (error instanceof Error) span.recordException(error);
384
- else span.recordException(new Error(String(error)));
382
+ function finalizeSpan(span, cause) {
383
+ if (cause) {
384
+ span.recordException(toError(cause));
385
385
  span.setStatus({ code: SpanStatusCode.ERROR });
386
386
  } else span.setStatus({ code: SpanStatusCode.OK });
387
387
  span.end();
@@ -592,21 +592,24 @@ function flattenMetadata(metadata, prefix = "metadata") {
592
592
  for (const [key, value] of Object.entries(obj)) {
593
593
  if (value == null) continue;
594
594
  const attributeKey = `${currentPrefix}.${key}`;
595
- if (typeof value === "string") {
596
- flattened[attributeKey] = value;
595
+ const text = asString(value);
596
+ if (text !== void 0) {
597
+ flattened[attributeKey] = text;
597
598
  continue;
598
599
  }
599
- if (typeof value === "number" || typeof value === "boolean") {
600
- flattened[attributeKey] = String(value);
600
+ const scalar = asNumber(value) ?? asBoolean(value);
601
+ if (scalar !== void 0) {
602
+ flattened[attributeKey] = String(scalar);
601
603
  continue;
602
604
  }
603
- if (typeof value === "object" && value !== null && value.constructor === Object) {
604
- if (seen.has(value)) {
605
+ const nested = asPlainRecord(value);
606
+ if (nested !== void 0) {
607
+ if (seen.has(nested)) {
605
608
  flattened[attributeKey] = "<circular-reference>";
606
609
  continue;
607
610
  }
608
- seen.add(value);
609
- flatten(value, attributeKey);
611
+ seen.add(nested);
612
+ flatten(nested, attributeKey);
610
613
  continue;
611
614
  }
612
615
  try {
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_values = require('./values-DApyq53y.cjs');
2
3
  let _opentelemetry_api = require("@opentelemetry/api");
3
4
 
4
5
  //#region src/tracer-provider.ts
@@ -34,10 +35,6 @@ function getGlobalState() {
34
35
  const initialState = createState();
35
36
  try {
36
37
  const g = globalThis;
37
- if (typeof g !== "object" || g === null) {
38
- console.warn("[autotel] globalThis is not available, using fallback state");
39
- return initialState;
40
- }
41
38
  if (!g[AUTOTEL_GLOBAL_SYMBOL]) Object.defineProperty(g, AUTOTEL_GLOBAL_SYMBOL, {
42
39
  value: initialState,
43
40
  writable: false,
@@ -188,8 +185,9 @@ function getAutotelTracerProvider() {
188
185
  if (isolatedTracerProvider) return isolatedTracerProvider;
189
186
  return _opentelemetry_api.trace.getTracerProvider();
190
187
  }
191
- function isForceFlushable(value) {
192
- return typeof value === "object" && value !== null && typeof value.forceFlush === "function";
188
+ /** The candidate if it can be force-flushed, or undefined. */
189
+ function asForceFlushable(value) {
190
+ return require_values.isFunction(require_values.readProperty(value, "forceFlush")) ? value : void 0;
193
191
  }
194
192
  /**
195
193
  * Resolve a tracer provider that can be `forceFlush()`ed, so `flush()` and
@@ -205,14 +203,12 @@ function isForceFlushable(value) {
205
203
  * @returns Something with `forceFlush()`, or `undefined` if none is registered.
206
204
  */
207
205
  function getForceFlushableProvider(sdk) {
208
- const candidates = [];
209
- const sdkAny = sdk;
210
- if (sdkAny && typeof sdkAny.getTracerProvider === "function") candidates.push(sdkAny.getTracerProvider());
206
+ const candidates = [require_values.asFunction(require_values.readProperty(sdk, "getTracerProvider"))?.call(sdk)];
211
207
  const globalProvider = _opentelemetry_api.trace.getTracerProvider();
212
208
  candidates.push(globalProvider);
213
- const proxy = globalProvider;
214
- if (proxy && typeof proxy.getDelegate === "function") candidates.push(proxy.getDelegate());
215
- return candidates.find(isForceFlushable);
209
+ const getDelegate = require_values.asFunction(require_values.readProperty(globalProvider, "getDelegate"));
210
+ if (getDelegate) candidates.push(getDelegate.call(globalProvider));
211
+ return candidates.map(asForceFlushable).find((found) => found !== void 0);
216
212
  }
217
213
  /**
218
214
  * Gets the OpenTelemetry tracer instance for Autotel.
@@ -1,3 +1,4 @@
1
+ import { _ as readProperty, h as isFunction, r as asFunction } from "./values-BenyvWKz.js";
1
2
  import { trace } from "@opentelemetry/api";
2
3
 
3
4
  //#region src/tracer-provider.ts
@@ -33,10 +34,6 @@ function getGlobalState() {
33
34
  const initialState = createState();
34
35
  try {
35
36
  const g = globalThis;
36
- if (typeof g !== "object" || g === null) {
37
- console.warn("[autotel] globalThis is not available, using fallback state");
38
- return initialState;
39
- }
40
37
  if (!g[AUTOTEL_GLOBAL_SYMBOL]) Object.defineProperty(g, AUTOTEL_GLOBAL_SYMBOL, {
41
38
  value: initialState,
42
39
  writable: false,
@@ -187,8 +184,9 @@ function getAutotelTracerProvider() {
187
184
  if (isolatedTracerProvider) return isolatedTracerProvider;
188
185
  return trace.getTracerProvider();
189
186
  }
190
- function isForceFlushable(value) {
191
- return typeof value === "object" && value !== null && typeof value.forceFlush === "function";
187
+ /** The candidate if it can be force-flushed, or undefined. */
188
+ function asForceFlushable(value) {
189
+ return isFunction(readProperty(value, "forceFlush")) ? value : void 0;
192
190
  }
193
191
  /**
194
192
  * Resolve a tracer provider that can be `forceFlush()`ed, so `flush()` and
@@ -204,14 +202,12 @@ function isForceFlushable(value) {
204
202
  * @returns Something with `forceFlush()`, or `undefined` if none is registered.
205
203
  */
206
204
  function getForceFlushableProvider(sdk) {
207
- const candidates = [];
208
- const sdkAny = sdk;
209
- if (sdkAny && typeof sdkAny.getTracerProvider === "function") candidates.push(sdkAny.getTracerProvider());
205
+ const candidates = [asFunction(readProperty(sdk, "getTracerProvider"))?.call(sdk)];
210
206
  const globalProvider = trace.getTracerProvider();
211
207
  candidates.push(globalProvider);
212
- const proxy = globalProvider;
213
- if (proxy && typeof proxy.getDelegate === "function") candidates.push(proxy.getDelegate());
214
- return candidates.find(isForceFlushable);
208
+ const getDelegate = asFunction(readProperty(globalProvider, "getDelegate"));
209
+ if (getDelegate) candidates.push(getDelegate.call(globalProvider));
210
+ return candidates.map(asForceFlushable).find((found) => found !== void 0);
215
211
  }
216
212
  /**
217
213
  * Gets the OpenTelemetry tracer instance for Autotel.
package/dist/validate.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_structured_error = require('./structured-error-CHg7DoIQ.cjs');
3
- const require_stable_hash = require('./stable-hash-CS9BxvVQ.cjs');
2
+ const require_values = require('./values-DApyq53y.cjs');
3
+ const require_structured_error = require('./structured-error--_wXpd_C.cjs');
4
+ const require_stable_hash = require('./stable-hash-C0pOegH_.cjs');
4
5
  const require_metric_helpers = require('./metric-helpers.cjs');
5
6
  const require_validation_attributes = require('./validation-attributes.cjs');
6
7
  let _opentelemetry_api = require("@opentelemetry/api");
@@ -64,16 +65,18 @@ function recordValidationMismatch(mismatch) {
64
65
  const paths = mismatch.issues.map((i) => i.path).filter(Boolean);
65
66
  const codes = [...new Set(mismatch.issues.map((i) => i.code))];
66
67
  const span = _opentelemetry_api.trace.getActiveSpan();
67
- if (span) span.setAttributes({
68
- [require_validation_attributes.VALIDATION_ATTR.name]: mismatch.name,
69
- [require_validation_attributes.VALIDATION_ATTR.boundary]: mismatch.boundary,
70
- [require_validation_attributes.VALIDATION_ATTR.mode]: mismatch.mode,
71
- [require_validation_attributes.VALIDATION_ATTR.issueCount]: mismatch.issues.length,
72
- [require_validation_attributes.VALIDATION_ATTR.issuePaths]: truncate(paths),
73
- [require_validation_attributes.VALIDATION_ATTR.issueCodes]: truncate(codes),
74
- ...mismatch.hash ? { [require_validation_attributes.VALIDATION_ATTR.hash]: mismatch.hash } : {},
75
- ...mismatch.severity ? { [require_validation_attributes.VALIDATION_ATTR.severity]: mismatch.severity } : {}
76
- });
68
+ if (span) {
69
+ const attributes = {};
70
+ attributes[require_validation_attributes.VALIDATION_ATTR.name] = mismatch.name;
71
+ attributes[require_validation_attributes.VALIDATION_ATTR.boundary] = mismatch.boundary;
72
+ attributes[require_validation_attributes.VALIDATION_ATTR.mode] = mismatch.mode;
73
+ attributes[require_validation_attributes.VALIDATION_ATTR.issueCount] = mismatch.issues.length;
74
+ attributes[require_validation_attributes.VALIDATION_ATTR.issuePaths] = truncate(paths);
75
+ attributes[require_validation_attributes.VALIDATION_ATTR.issueCodes] = truncate(codes);
76
+ if (mismatch.hash) attributes[require_validation_attributes.VALIDATION_ATTR.hash] = mismatch.hash;
77
+ if (mismatch.severity) attributes[require_validation_attributes.VALIDATION_ATTR.severity] = mismatch.severity;
78
+ span.setAttributes(attributes);
79
+ }
77
80
  try {
78
81
  counter().add(1, {
79
82
  boundary: mismatch.boundary,
@@ -97,17 +100,16 @@ function formatValidationIssues(error) {
97
100
  return extractRawIssues(error).map((issue) => toSafeIssue(issue));
98
101
  }
99
102
  function extractRawIssues(error) {
100
- if (error && typeof error === "object") {
101
- const candidate = error.issues ?? error.errors;
102
- if (Array.isArray(candidate)) return candidate.filter((i) => i !== null && typeof i === "object");
103
- }
104
- return [];
103
+ const raised = require_values.asRecord(error);
104
+ const candidate = raised?.issues ?? raised?.errors;
105
+ if (!Array.isArray(candidate)) return [];
106
+ return candidate.map((issue) => require_values.asRecord(issue)).filter((issue) => issue !== void 0);
105
107
  }
106
108
  function toSafeIssue(issue) {
107
109
  const rawPath = issue.path;
108
- const path = Array.isArray(rawPath) ? rawPath.map(String).join(".") : typeof rawPath === "string" ? rawPath : "";
109
- const code = typeof issue.code === "string" ? issue.code : "invalid";
110
- const expected = typeof issue.expected === "string" ? issue.expected : void 0;
110
+ const path = Array.isArray(rawPath) ? rawPath.map(String).join(".") : require_values.asString(rawPath) ?? "";
111
+ const code = require_values.asString(issue.code) ?? "invalid";
112
+ const expected = require_values.asString(issue.expected);
111
113
  return expected ? {
112
114
  path,
113
115
  code,
@@ -1,4 +1,5 @@
1
- import { r as SchemaLike } from "./define-event-CGG048HE.cjs";
1
+ import { t as UnknownRecord } from "./values-CeMH-mYG.cjs";
2
+ import { r as SchemaLike } from "./define-event-BNeuKUPv.cjs";
2
3
  //#region src/validate.d.ts
3
4
  type ValidationMode = 'observe' | 'reject';
4
5
  type ValidationSeverity = 'info' | 'warning' | 'error';
@@ -54,7 +55,7 @@ interface DefineValidatorOptions<S> {
54
55
  /** `reject` (default): record then throw. `observe`: record then continue. */
55
56
  onMismatch?: ValidationMode;
56
57
  /** Project the schema to JSON Schema for a stable `validation.hash`. */
57
- toJsonSchema?: (schema: S) => unknown;
58
+ toJsonSchema?: (schema: S) => UnknownRecord;
58
59
  severity?: ValidationSeverity;
59
60
  /** Build the error thrown in `reject` mode (defaults to a 400 structured error). */
60
61
  onReject?: (issues: ValidationIssue[], name: string) => Error;
@@ -1,4 +1,5 @@
1
- import { r as SchemaLike } from "./define-event-B2z1SBe7.js";
1
+ import { t as UnknownRecord } from "./values-CeMH-mYG.js";
2
+ import { r as SchemaLike } from "./define-event-Bd8f8mST.js";
2
3
  //#region src/validate.d.ts
3
4
  type ValidationMode = 'observe' | 'reject';
4
5
  type ValidationSeverity = 'info' | 'warning' | 'error';
@@ -54,7 +55,7 @@ interface DefineValidatorOptions<S> {
54
55
  /** `reject` (default): record then throw. `observe`: record then continue. */
55
56
  onMismatch?: ValidationMode;
56
57
  /** Project the schema to JSON Schema for a stable `validation.hash`. */
57
- toJsonSchema?: (schema: S) => unknown;
58
+ toJsonSchema?: (schema: S) => UnknownRecord;
58
59
  severity?: ValidationSeverity;
59
60
  /** Build the error thrown in `reject` mode (defaults to a 400 structured error). */
60
61
  onReject?: (issues: ValidationIssue[], name: string) => Error;
package/dist/validate.js CHANGED
@@ -1,5 +1,6 @@
1
- import { t as createStructuredError } from "./structured-error-9--cxBay.js";
2
- import { t as hashJson } from "./stable-hash-ChFBIhNt.js";
1
+ import { l as asString, s as asRecord } from "./values-BenyvWKz.js";
2
+ import { t as createStructuredError } from "./structured-error-YIuka-FE.js";
3
+ import { t as hashJson } from "./stable-hash-BkoAYVks.js";
3
4
  import { createCounter } from "./metric-helpers.js";
4
5
  import { VALIDATION_ATTR, VALIDATION_ISSUE_CAP, VALIDATION_METRICS } from "./validation-attributes.js";
5
6
  import { trace } from "@opentelemetry/api";
@@ -63,16 +64,18 @@ function recordValidationMismatch(mismatch) {
63
64
  const paths = mismatch.issues.map((i) => i.path).filter(Boolean);
64
65
  const codes = [...new Set(mismatch.issues.map((i) => i.code))];
65
66
  const span = trace.getActiveSpan();
66
- if (span) span.setAttributes({
67
- [VALIDATION_ATTR.name]: mismatch.name,
68
- [VALIDATION_ATTR.boundary]: mismatch.boundary,
69
- [VALIDATION_ATTR.mode]: mismatch.mode,
70
- [VALIDATION_ATTR.issueCount]: mismatch.issues.length,
71
- [VALIDATION_ATTR.issuePaths]: truncate(paths),
72
- [VALIDATION_ATTR.issueCodes]: truncate(codes),
73
- ...mismatch.hash ? { [VALIDATION_ATTR.hash]: mismatch.hash } : {},
74
- ...mismatch.severity ? { [VALIDATION_ATTR.severity]: mismatch.severity } : {}
75
- });
67
+ if (span) {
68
+ const attributes = {};
69
+ attributes[VALIDATION_ATTR.name] = mismatch.name;
70
+ attributes[VALIDATION_ATTR.boundary] = mismatch.boundary;
71
+ attributes[VALIDATION_ATTR.mode] = mismatch.mode;
72
+ attributes[VALIDATION_ATTR.issueCount] = mismatch.issues.length;
73
+ attributes[VALIDATION_ATTR.issuePaths] = truncate(paths);
74
+ attributes[VALIDATION_ATTR.issueCodes] = truncate(codes);
75
+ if (mismatch.hash) attributes[VALIDATION_ATTR.hash] = mismatch.hash;
76
+ if (mismatch.severity) attributes[VALIDATION_ATTR.severity] = mismatch.severity;
77
+ span.setAttributes(attributes);
78
+ }
76
79
  try {
77
80
  counter().add(1, {
78
81
  boundary: mismatch.boundary,
@@ -96,17 +99,16 @@ function formatValidationIssues(error) {
96
99
  return extractRawIssues(error).map((issue) => toSafeIssue(issue));
97
100
  }
98
101
  function extractRawIssues(error) {
99
- if (error && typeof error === "object") {
100
- const candidate = error.issues ?? error.errors;
101
- if (Array.isArray(candidate)) return candidate.filter((i) => i !== null && typeof i === "object");
102
- }
103
- return [];
102
+ const raised = asRecord(error);
103
+ const candidate = raised?.issues ?? raised?.errors;
104
+ if (!Array.isArray(candidate)) return [];
105
+ return candidate.map((issue) => asRecord(issue)).filter((issue) => issue !== void 0);
104
106
  }
105
107
  function toSafeIssue(issue) {
106
108
  const rawPath = issue.path;
107
- const path = Array.isArray(rawPath) ? rawPath.map(String).join(".") : typeof rawPath === "string" ? rawPath : "";
108
- const code = typeof issue.code === "string" ? issue.code : "invalid";
109
- const expected = typeof issue.expected === "string" ? issue.expected : void 0;
109
+ const path = Array.isArray(rawPath) ? rawPath.map(String).join(".") : asString(rawPath) ?? "";
110
+ const code = asString(issue.code) ?? "invalid";
111
+ const expected = asString(issue.expected);
110
112
  return expected ? {
111
113
  path,
112
114
  code,
@@ -0,0 +1,141 @@
1
+ //#region src/values.ts
2
+ /** The value as an object, or undefined when it is anything else. */
3
+ function asRecord(value) {
4
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
5
+ }
6
+ /** The string the value carries, or undefined when it carries anything else. */
7
+ function asString(value) {
8
+ return typeof value === "string" ? value : void 0;
9
+ }
10
+ /**
11
+ * The value as a map of strings - a header bag, say - or undefined when it is
12
+ * not an object at all. Entries whose value is not a string are left out.
13
+ */
14
+ function asStringRecord(value) {
15
+ const record = asRecord(value);
16
+ if (record === void 0) return void 0;
17
+ const strings = {};
18
+ for (const [key, entry] of Object.entries(record)) {
19
+ const text = asString(entry);
20
+ if (text !== void 0) strings[key] = text;
21
+ }
22
+ return strings;
23
+ }
24
+ /** The scalar the value carries - string, number or boolean - or undefined. */
25
+ function asScalar(value) {
26
+ return asString(value) ?? asNumber(value) ?? asBoolean(value);
27
+ }
28
+ /** The numbers the value carries as a list, or undefined when it is not one. */
29
+ function asNumberArray(value) {
30
+ return Array.isArray(value) && value.every((v) => asNumber(v) !== void 0) ? value.map(Number) : void 0;
31
+ }
32
+ /** The booleans the value carries as a list, or undefined when it is not one. */
33
+ function asBooleanArray(value) {
34
+ return Array.isArray(value) && value.every((v) => asBoolean(v) !== void 0) ? value.map(Boolean) : void 0;
35
+ }
36
+ /** The strings the value carries as a list, or undefined when it is not one. */
37
+ function asStringArray(value) {
38
+ return Array.isArray(value) && value.every((v) => asString(v) !== void 0) ? value.map(String) : void 0;
39
+ }
40
+ /** A string with something in it - a blank one counts as absent. */
41
+ function nonEmptyString(value) {
42
+ const text = asString(value);
43
+ return text !== void 0 && text.trim() !== "" ? text : void 0;
44
+ }
45
+ /** The number the value carries, or undefined when it carries anything else. */
46
+ function asNumber(value) {
47
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
48
+ }
49
+ /** The boolean the value carries, or undefined when it carries anything else. */
50
+ function asBoolean(value) {
51
+ return typeof value === "boolean" ? value : void 0;
52
+ }
53
+ /** Whether the value is callable. */
54
+ function isFunction(value) {
55
+ return typeof value === "function";
56
+ }
57
+ /**
58
+ * A config field that may be given as a value or as a function producing one,
59
+ * resolved to the value.
60
+ */
61
+ function resolveValue(source) {
62
+ return typeof source === "function" ? source() : source;
63
+ }
64
+ /**
65
+ * An overloaded first argument that is either a name or an options object,
66
+ * split into the two.
67
+ */
68
+ function splitNameOrOptions(value) {
69
+ return typeof value === "string" ? { name: value } : { options: value };
70
+ }
71
+ /** The value as a callable, or undefined when it is not one. */
72
+ function asFunction(value) {
73
+ if (typeof value !== "function") return void 0;
74
+ return value;
75
+ }
76
+ /**
77
+ * The value as a plain object - one built from a literal, not an instance of
78
+ * some class that has its own idea of what it is.
79
+ */
80
+ function asPlainRecord(value) {
81
+ const record = asRecord(value);
82
+ return record !== void 0 && Object.getPrototypeOf(record) === Object.prototype ? record : void 0;
83
+ }
84
+ /** One field of a value, when the value is an object at all. */
85
+ function readProperty(source, key) {
86
+ return asRecord(source)?.[key];
87
+ }
88
+ /**
89
+ * What a value is, for a diagnostic message: the same words `typeof` uses,
90
+ * plus `null` and `array`, which are the two cases `typeof` answers uselessly.
91
+ */
92
+ function describeValue(value) {
93
+ if (value === null) return "null";
94
+ return Array.isArray(value) ? "array" : typeof value;
95
+ }
96
+ /**
97
+ * The Error a caller's callback expects, wrapping whatever was actually
98
+ * thrown - a string, a number, an object with no stack.
99
+ */
100
+ function toError(cause) {
101
+ return cause instanceof Error ? cause : new Error(String(cause));
102
+ }
103
+ /**
104
+ * A value as an OTel attribute, or undefined when it cannot be one.
105
+ *
106
+ * OTel accepts scalars and homogeneous arrays of scalars. Anything else - a
107
+ * nested object, a mixed array - is stringified rather than dropped, because
108
+ * a caller that attached it wanted to see it.
109
+ */
110
+ function toAttributeValue(value) {
111
+ if (value === void 0 || value === null) return void 0;
112
+ const scalar = asString(value) ?? asNumber(value) ?? asBoolean(value);
113
+ if (scalar !== void 0) return scalar;
114
+ if (Array.isArray(value)) return toAttributeArray(value);
115
+ return JSON.stringify(value);
116
+ }
117
+ /** The scalars in an array, dropping the entries OTel cannot carry. */
118
+ function toAttributeArray(values) {
119
+ const strings = values.filter((v) => typeof v === "string");
120
+ if (strings.length === values.length) return strings;
121
+ const numbers = values.filter((v) => typeof v === "number");
122
+ if (numbers.length === values.length) return numbers;
123
+ const booleans = values.filter((v) => typeof v === "boolean");
124
+ if (booleans.length === values.length) return booleans;
125
+ return values.length > 0 ? JSON.stringify(values) : void 0;
126
+ }
127
+ /** Whether a Node-style `process` global exists at all - edge runtimes have none. */
128
+ function hasProcess() {
129
+ return typeof process !== "undefined";
130
+ }
131
+ /**
132
+ * Whether this build is running outside production, for warnings meant to
133
+ * help during development. `process` is probed because the same code runs in
134
+ * edge runtimes that have no such global.
135
+ */
136
+ function isDevelopment() {
137
+ return hasProcess() && process.env.NODE_ENV !== "production";
138
+ }
139
+
140
+ //#endregion
141
+ export { readProperty as _, asNumberArray as a, toAttributeValue as b, asScalar as c, asStringRecord as d, describeValue as f, nonEmptyString as g, isFunction as h, asNumber as i, asString as l, isDevelopment as m, asBooleanArray as n, asPlainRecord as o, hasProcess as p, asFunction as r, asRecord as s, asBoolean as t, asStringArray as u, resolveValue as v, toError as x, splitNameOrOptions as y };