autotel 6.5.0 → 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-e6jw5zQj.d.cts → functional-CJn2zY4o.d.cts} +96 -39
  59. package/dist/{functional-AT22vCw6.d.ts → functional-DXy1cHFF.d.ts} +96 -39
  60. package/dist/{functional-C0uAZq2X.cjs → functional-Da6Yv64r.cjs} +27 -15
  61. package/dist/{functional-DX7Zvag0.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-pPI3JRRf.d.ts → init-BgnYi2sm.d.ts} +6 -6
  75. package/dist/{init-CTtHITlX.cjs → init-D4m5rCmD.cjs} +110 -84
  76. package/dist/{init-ncTMKZ-s.d.cts → init-DrlL1eis.d.cts} +6 -6
  77. package/dist/{init-WHYwyItd.js → init-JtX-KKz_.js} +105 -85
  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
@@ -0,0 +1,267 @@
1
+
2
+ //#region src/values.ts
3
+ /** The value as an object, or undefined when it is anything else. */
4
+ function asRecord(value) {
5
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
6
+ }
7
+ /** The string the value carries, or undefined when it carries anything else. */
8
+ function asString(value) {
9
+ return typeof value === "string" ? value : void 0;
10
+ }
11
+ /**
12
+ * The value as a map of strings - a header bag, say - or undefined when it is
13
+ * not an object at all. Entries whose value is not a string are left out.
14
+ */
15
+ function asStringRecord(value) {
16
+ const record = asRecord(value);
17
+ if (record === void 0) return void 0;
18
+ const strings = {};
19
+ for (const [key, entry] of Object.entries(record)) {
20
+ const text = asString(entry);
21
+ if (text !== void 0) strings[key] = text;
22
+ }
23
+ return strings;
24
+ }
25
+ /** The scalar the value carries - string, number or boolean - or undefined. */
26
+ function asScalar(value) {
27
+ return asString(value) ?? asNumber(value) ?? asBoolean(value);
28
+ }
29
+ /** The numbers the value carries as a list, or undefined when it is not one. */
30
+ function asNumberArray(value) {
31
+ return Array.isArray(value) && value.every((v) => asNumber(v) !== void 0) ? value.map(Number) : void 0;
32
+ }
33
+ /** The booleans the value carries as a list, or undefined when it is not one. */
34
+ function asBooleanArray(value) {
35
+ return Array.isArray(value) && value.every((v) => asBoolean(v) !== void 0) ? value.map(Boolean) : void 0;
36
+ }
37
+ /** The strings the value carries as a list, or undefined when it is not one. */
38
+ function asStringArray(value) {
39
+ return Array.isArray(value) && value.every((v) => asString(v) !== void 0) ? value.map(String) : void 0;
40
+ }
41
+ /** A string with something in it - a blank one counts as absent. */
42
+ function nonEmptyString(value) {
43
+ const text = asString(value);
44
+ return text !== void 0 && text.trim() !== "" ? text : void 0;
45
+ }
46
+ /** The number the value carries, or undefined when it carries anything else. */
47
+ function asNumber(value) {
48
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
49
+ }
50
+ /** The boolean the value carries, or undefined when it carries anything else. */
51
+ function asBoolean(value) {
52
+ return typeof value === "boolean" ? value : void 0;
53
+ }
54
+ /** Whether the value is callable. */
55
+ function isFunction(value) {
56
+ return typeof value === "function";
57
+ }
58
+ /**
59
+ * A config field that may be given as a value or as a function producing one,
60
+ * resolved to the value.
61
+ */
62
+ function resolveValue(source) {
63
+ return typeof source === "function" ? source() : source;
64
+ }
65
+ /**
66
+ * An overloaded first argument that is either a name or an options object,
67
+ * split into the two.
68
+ */
69
+ function splitNameOrOptions(value) {
70
+ return typeof value === "string" ? { name: value } : { options: value };
71
+ }
72
+ /** The value as a callable, or undefined when it is not one. */
73
+ function asFunction(value) {
74
+ if (typeof value !== "function") return void 0;
75
+ return value;
76
+ }
77
+ /**
78
+ * The value as a plain object - one built from a literal, not an instance of
79
+ * some class that has its own idea of what it is.
80
+ */
81
+ function asPlainRecord(value) {
82
+ const record = asRecord(value);
83
+ return record !== void 0 && Object.getPrototypeOf(record) === Object.prototype ? record : void 0;
84
+ }
85
+ /** One field of a value, when the value is an object at all. */
86
+ function readProperty(source, key) {
87
+ return asRecord(source)?.[key];
88
+ }
89
+ /**
90
+ * What a value is, for a diagnostic message: the same words `typeof` uses,
91
+ * plus `null` and `array`, which are the two cases `typeof` answers uselessly.
92
+ */
93
+ function describeValue(value) {
94
+ if (value === null) return "null";
95
+ return Array.isArray(value) ? "array" : typeof value;
96
+ }
97
+ /**
98
+ * The Error a caller's callback expects, wrapping whatever was actually
99
+ * thrown - a string, a number, an object with no stack.
100
+ */
101
+ function toError(cause) {
102
+ return cause instanceof Error ? cause : new Error(String(cause));
103
+ }
104
+ /**
105
+ * A value as an OTel attribute, or undefined when it cannot be one.
106
+ *
107
+ * OTel accepts scalars and homogeneous arrays of scalars. Anything else - a
108
+ * nested object, a mixed array - is stringified rather than dropped, because
109
+ * a caller that attached it wanted to see it.
110
+ */
111
+ function toAttributeValue(value) {
112
+ if (value === void 0 || value === null) return void 0;
113
+ const scalar = asString(value) ?? asNumber(value) ?? asBoolean(value);
114
+ if (scalar !== void 0) return scalar;
115
+ if (Array.isArray(value)) return toAttributeArray(value);
116
+ return JSON.stringify(value);
117
+ }
118
+ /** The scalars in an array, dropping the entries OTel cannot carry. */
119
+ function toAttributeArray(values) {
120
+ const strings = values.filter((v) => typeof v === "string");
121
+ if (strings.length === values.length) return strings;
122
+ const numbers = values.filter((v) => typeof v === "number");
123
+ if (numbers.length === values.length) return numbers;
124
+ const booleans = values.filter((v) => typeof v === "boolean");
125
+ if (booleans.length === values.length) return booleans;
126
+ return values.length > 0 ? JSON.stringify(values) : void 0;
127
+ }
128
+ /** Whether a Node-style `process` global exists at all - edge runtimes have none. */
129
+ function hasProcess() {
130
+ return typeof process !== "undefined";
131
+ }
132
+ /**
133
+ * Whether this build is running outside production, for warnings meant to
134
+ * help during development. `process` is probed because the same code runs in
135
+ * edge runtimes that have no such global.
136
+ */
137
+ function isDevelopment() {
138
+ return hasProcess() && process.env.NODE_ENV !== "production";
139
+ }
140
+
141
+ //#endregion
142
+ Object.defineProperty(exports, 'asBoolean', {
143
+ enumerable: true,
144
+ get: function () {
145
+ return asBoolean;
146
+ }
147
+ });
148
+ Object.defineProperty(exports, 'asBooleanArray', {
149
+ enumerable: true,
150
+ get: function () {
151
+ return asBooleanArray;
152
+ }
153
+ });
154
+ Object.defineProperty(exports, 'asFunction', {
155
+ enumerable: true,
156
+ get: function () {
157
+ return asFunction;
158
+ }
159
+ });
160
+ Object.defineProperty(exports, 'asNumber', {
161
+ enumerable: true,
162
+ get: function () {
163
+ return asNumber;
164
+ }
165
+ });
166
+ Object.defineProperty(exports, 'asNumberArray', {
167
+ enumerable: true,
168
+ get: function () {
169
+ return asNumberArray;
170
+ }
171
+ });
172
+ Object.defineProperty(exports, 'asPlainRecord', {
173
+ enumerable: true,
174
+ get: function () {
175
+ return asPlainRecord;
176
+ }
177
+ });
178
+ Object.defineProperty(exports, 'asRecord', {
179
+ enumerable: true,
180
+ get: function () {
181
+ return asRecord;
182
+ }
183
+ });
184
+ Object.defineProperty(exports, 'asScalar', {
185
+ enumerable: true,
186
+ get: function () {
187
+ return asScalar;
188
+ }
189
+ });
190
+ Object.defineProperty(exports, 'asString', {
191
+ enumerable: true,
192
+ get: function () {
193
+ return asString;
194
+ }
195
+ });
196
+ Object.defineProperty(exports, 'asStringArray', {
197
+ enumerable: true,
198
+ get: function () {
199
+ return asStringArray;
200
+ }
201
+ });
202
+ Object.defineProperty(exports, 'asStringRecord', {
203
+ enumerable: true,
204
+ get: function () {
205
+ return asStringRecord;
206
+ }
207
+ });
208
+ Object.defineProperty(exports, 'describeValue', {
209
+ enumerable: true,
210
+ get: function () {
211
+ return describeValue;
212
+ }
213
+ });
214
+ Object.defineProperty(exports, 'hasProcess', {
215
+ enumerable: true,
216
+ get: function () {
217
+ return hasProcess;
218
+ }
219
+ });
220
+ Object.defineProperty(exports, 'isDevelopment', {
221
+ enumerable: true,
222
+ get: function () {
223
+ return isDevelopment;
224
+ }
225
+ });
226
+ Object.defineProperty(exports, 'isFunction', {
227
+ enumerable: true,
228
+ get: function () {
229
+ return isFunction;
230
+ }
231
+ });
232
+ Object.defineProperty(exports, 'nonEmptyString', {
233
+ enumerable: true,
234
+ get: function () {
235
+ return nonEmptyString;
236
+ }
237
+ });
238
+ Object.defineProperty(exports, 'readProperty', {
239
+ enumerable: true,
240
+ get: function () {
241
+ return readProperty;
242
+ }
243
+ });
244
+ Object.defineProperty(exports, 'resolveValue', {
245
+ enumerable: true,
246
+ get: function () {
247
+ return resolveValue;
248
+ }
249
+ });
250
+ Object.defineProperty(exports, 'splitNameOrOptions', {
251
+ enumerable: true,
252
+ get: function () {
253
+ return splitNameOrOptions;
254
+ }
255
+ });
256
+ Object.defineProperty(exports, 'toAttributeValue', {
257
+ enumerable: true,
258
+ get: function () {
259
+ return toAttributeValue;
260
+ }
261
+ });
262
+ Object.defineProperty(exports, 'toError', {
263
+ enumerable: true,
264
+ get: function () {
265
+ return toError;
266
+ }
267
+ });
package/dist/webhook.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_structured_error = require('./structured-error-CHg7DoIQ.cjs');
3
- const require_functional = require('./functional-C0uAZq2X.cjs');
4
- const require_correlated_events = require('./correlated-events-kSwLo3mi.cjs');
2
+ const require_structured_error = require('./structured-error--_wXpd_C.cjs');
3
+ const require_functional = require('./functional-Da6Yv64r.cjs');
4
+ const require_correlated_events = require('./correlated-events-CcuknWnU.cjs');
5
5
  let _opentelemetry_api = require("@opentelemetry/api");
6
6
 
7
7
  //#region src/webhook.ts
@@ -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 { Link, SpanContext } from "@opentelemetry/api";
3
3
  //#region src/webhook.d.ts
4
4
  /**
package/dist/webhook.d.ts CHANGED
@@ -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 { Link, SpanContext } from "@opentelemetry/api";
3
3
  //#region src/webhook.d.ts
4
4
  /**
package/dist/webhook.js CHANGED
@@ -1,6 +1,6 @@
1
- import { r as recordStructuredError } from "./structured-error-9--cxBay.js";
2
- import { c as withTracing } from "./functional-DX7Zvag0.js";
3
- import { t as emitCorrelatedEvent } from "./correlated-events-Bzh5y-UB.js";
1
+ import { r as recordStructuredError } from "./structured-error-YIuka-FE.js";
2
+ import { c as withTracing } from "./functional-uSbNnnxK.js";
3
+ import { t as emitCorrelatedEvent } from "./correlated-events-DwMMbItg.js";
4
4
  import { SpanKind, trace } from "@opentelemetry/api";
5
5
 
6
6
  //#region src/webhook.ts
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_functional = require('./functional-C0uAZq2X.cjs');
3
- const require_correlated_events = require('./correlated-events-kSwLo3mi.cjs');
2
+ const require_values = require('./values-DApyq53y.cjs');
3
+ const require_functional = require('./functional-Da6Yv64r.cjs');
4
+ const require_correlated_events = require('./correlated-events-CcuknWnU.cjs');
4
5
  const require_business_baggage = require('./business-baggage.cjs');
5
6
  let _opentelemetry_api = require("@opentelemetry/api");
6
7
 
@@ -239,10 +240,10 @@ function traceDistributedWorkflow(config) {
239
240
  require_correlated_events.emitCorrelatedEvent(baseCtx, "workflow.completed", { "workflow.id": workflowId });
240
241
  return result;
241
242
  } catch (error) {
242
- config.onError?.(workflowCtx, error);
243
+ config.onError?.(workflowCtx, require_values.toError(error));
243
244
  require_correlated_events.emitCorrelatedEvent(baseCtx, "workflow.failed", {
244
245
  "workflow.id": workflowId,
245
- "workflow.error": error.message
246
+ "workflow.error": error instanceof Error ? error.message : String(error)
246
247
  });
247
248
  throw error;
248
249
  }
@@ -299,7 +300,8 @@ function traceDistributedStep(config) {
299
300
  return async (...args) => {
300
301
  let baggageValues = null;
301
302
  const extractBaggage = config.extractBaggage ?? true;
302
- if (typeof extractBaggage === "function") baggageValues = extractBaggage(args);
303
+ const readBaggage = require_values.isFunction(extractBaggage) ? extractBaggage : void 0;
304
+ if (readBaggage) baggageValues = readBaggage(args);
303
305
  else if (extractBaggage) {
304
306
  const extracted = WorkflowBaggage.get(baseCtx);
305
307
  if (extracted.workflowId && extracted.workflowName) baggageValues = extracted;
@@ -367,10 +369,10 @@ function traceDistributedStep(config) {
367
369
  require_correlated_events.emitCorrelatedEvent(baseCtx, "workflow.step.completed", { "workflow.step.name": config.name });
368
370
  return result;
369
371
  } catch (error) {
370
- config.onError?.(stepCtx, error);
372
+ config.onError?.(stepCtx, require_values.toError(error));
371
373
  require_correlated_events.emitCorrelatedEvent(baseCtx, "workflow.step.failed", {
372
374
  "workflow.step.name": config.name,
373
- "workflow.step.error": error.message,
375
+ "workflow.step.error": error instanceof Error ? error.message : String(error),
374
376
  ...compensationData && { "workflow.step.requires_compensation": true }
375
377
  });
376
378
  throw error;
@@ -1,4 +1,5 @@
1
- import { n as TraceContext } from "./trace-context-IuyoPyNq.cjs";
1
+ import { t as UnknownRecord } from "./values-CeMH-mYG.cjs";
2
+ import { n as TraceContext } from "./trace-context-C1Cn1q0y.cjs";
2
3
  import { SafeBaggageSchema } from "./business-baggage.cjs";
3
4
  //#region src/workflow-distributed.d.ts
4
5
  /**
@@ -98,7 +99,7 @@ type WorkflowBaggageValues = {
98
99
  /**
99
100
  * Configuration for distributed workflow tracing
100
101
  */
101
- interface DistributedWorkflowConfig {
102
+ interface DistributedWorkflowConfig<TResult = unknown> {
102
103
  /** Workflow name/type (e.g., "OrderFulfillment", "UserOnboarding") */
103
104
  name: string;
104
105
  /**
@@ -135,14 +136,14 @@ interface DistributedWorkflowConfig {
135
136
  /** Callback on workflow start */
136
137
  onStart?: (ctx: DistributedWorkflowContext) => void;
137
138
  /** Callback on workflow completion */
138
- onComplete?: (ctx: DistributedWorkflowContext, result: unknown) => void;
139
+ onComplete?: (ctx: DistributedWorkflowContext, result: TResult) => void;
139
140
  /** Callback on workflow error */
140
141
  onError?: (ctx: DistributedWorkflowContext, error: Error) => void;
141
142
  }
142
143
  /**
143
144
  * Configuration for distributed workflow step
144
145
  */
145
- interface DistributedStepConfig {
146
+ interface DistributedStepConfig<TResult = unknown> {
146
147
  /** Step name (e.g., "ReserveInventory", "ChargePayment") */
147
148
  name: string;
148
149
  /**
@@ -165,7 +166,7 @@ interface DistributedStepConfig {
165
166
  /** Callback on step start */
166
167
  onStart?: (ctx: DistributedStepContext) => void;
167
168
  /** Callback on step completion */
168
- onComplete?: (ctx: DistributedStepContext, result: unknown) => void;
169
+ onComplete?: (ctx: DistributedStepContext, result: TResult) => void;
169
170
  /** Callback on step error */
170
171
  onError?: (ctx: DistributedStepContext, error: Error) => void;
171
172
  }
@@ -209,7 +210,7 @@ interface DistributedStepContext extends TraceContext {
209
210
  /** Get headers with updated workflow baggage for downstream calls */
210
211
  getWorkflowHeaders(): Record<string, string>;
211
212
  /** Mark step as requiring compensation on failure */
212
- requiresCompensation(compensationData?: Record<string, unknown>): void;
213
+ requiresCompensation(compensationData?: UnknownRecord): void;
213
214
  }
214
215
  /**
215
216
  * Create a traced distributed workflow function
@@ -239,7 +240,7 @@ interface DistributedStepContext extends TraceContext {
239
240
  * });
240
241
  * ```
241
242
  */
242
- declare function traceDistributedWorkflow(config: DistributedWorkflowConfig): <TArgs extends unknown[], TReturn>(fnFactory: (ctx: DistributedWorkflowContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
243
+ declare function traceDistributedWorkflow<TResult = unknown>(config: DistributedWorkflowConfig<TResult>): <TArgs extends unknown[], TReturn extends TResult>(fnFactory: (ctx: DistributedWorkflowContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
243
244
  /**
244
245
  * Create a traced distributed workflow step
245
246
  *
@@ -279,7 +280,7 @@ declare function traceDistributedWorkflow(config: DistributedWorkflowConfig): <T
279
280
  * });
280
281
  * ```
281
282
  */
282
- declare function traceDistributedStep(config: DistributedStepConfig): <TArgs extends unknown[], TReturn>(fnFactory: (ctx: DistributedStepContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
283
+ declare function traceDistributedStep<TResult = unknown>(config: DistributedStepConfig<TResult>): <TArgs extends unknown[], TReturn extends TResult>(fnFactory: (ctx: DistributedStepContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
283
284
  /**
284
285
  * Generate a unique workflow ID
285
286
  *
@@ -1,4 +1,5 @@
1
- import { n as TraceContext } from "./trace-context-IuyoPyNq.js";
1
+ import { t as UnknownRecord } from "./values-CeMH-mYG.js";
2
+ import { n as TraceContext } from "./trace-context-f89xPJbK.js";
2
3
  import { SafeBaggageSchema } from "./business-baggage.js";
3
4
  //#region src/workflow-distributed.d.ts
4
5
  /**
@@ -98,7 +99,7 @@ type WorkflowBaggageValues = {
98
99
  /**
99
100
  * Configuration for distributed workflow tracing
100
101
  */
101
- interface DistributedWorkflowConfig {
102
+ interface DistributedWorkflowConfig<TResult = unknown> {
102
103
  /** Workflow name/type (e.g., "OrderFulfillment", "UserOnboarding") */
103
104
  name: string;
104
105
  /**
@@ -135,14 +136,14 @@ interface DistributedWorkflowConfig {
135
136
  /** Callback on workflow start */
136
137
  onStart?: (ctx: DistributedWorkflowContext) => void;
137
138
  /** Callback on workflow completion */
138
- onComplete?: (ctx: DistributedWorkflowContext, result: unknown) => void;
139
+ onComplete?: (ctx: DistributedWorkflowContext, result: TResult) => void;
139
140
  /** Callback on workflow error */
140
141
  onError?: (ctx: DistributedWorkflowContext, error: Error) => void;
141
142
  }
142
143
  /**
143
144
  * Configuration for distributed workflow step
144
145
  */
145
- interface DistributedStepConfig {
146
+ interface DistributedStepConfig<TResult = unknown> {
146
147
  /** Step name (e.g., "ReserveInventory", "ChargePayment") */
147
148
  name: string;
148
149
  /**
@@ -165,7 +166,7 @@ interface DistributedStepConfig {
165
166
  /** Callback on step start */
166
167
  onStart?: (ctx: DistributedStepContext) => void;
167
168
  /** Callback on step completion */
168
- onComplete?: (ctx: DistributedStepContext, result: unknown) => void;
169
+ onComplete?: (ctx: DistributedStepContext, result: TResult) => void;
169
170
  /** Callback on step error */
170
171
  onError?: (ctx: DistributedStepContext, error: Error) => void;
171
172
  }
@@ -209,7 +210,7 @@ interface DistributedStepContext extends TraceContext {
209
210
  /** Get headers with updated workflow baggage for downstream calls */
210
211
  getWorkflowHeaders(): Record<string, string>;
211
212
  /** Mark step as requiring compensation on failure */
212
- requiresCompensation(compensationData?: Record<string, unknown>): void;
213
+ requiresCompensation(compensationData?: UnknownRecord): void;
213
214
  }
214
215
  /**
215
216
  * Create a traced distributed workflow function
@@ -239,7 +240,7 @@ interface DistributedStepContext extends TraceContext {
239
240
  * });
240
241
  * ```
241
242
  */
242
- declare function traceDistributedWorkflow(config: DistributedWorkflowConfig): <TArgs extends unknown[], TReturn>(fnFactory: (ctx: DistributedWorkflowContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
243
+ declare function traceDistributedWorkflow<TResult = unknown>(config: DistributedWorkflowConfig<TResult>): <TArgs extends unknown[], TReturn extends TResult>(fnFactory: (ctx: DistributedWorkflowContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
243
244
  /**
244
245
  * Create a traced distributed workflow step
245
246
  *
@@ -279,7 +280,7 @@ declare function traceDistributedWorkflow(config: DistributedWorkflowConfig): <T
279
280
  * });
280
281
  * ```
281
282
  */
282
- declare function traceDistributedStep(config: DistributedStepConfig): <TArgs extends unknown[], TReturn>(fnFactory: (ctx: DistributedStepContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
283
+ declare function traceDistributedStep<TResult = unknown>(config: DistributedStepConfig<TResult>): <TArgs extends unknown[], TReturn extends TResult>(fnFactory: (ctx: DistributedStepContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
283
284
  /**
284
285
  * Generate a unique workflow ID
285
286
  *
@@ -1,5 +1,6 @@
1
- import { c as withTracing } from "./functional-DX7Zvag0.js";
2
- import { t as emitCorrelatedEvent } from "./correlated-events-Bzh5y-UB.js";
1
+ import { h as isFunction, x as toError } from "./values-BenyvWKz.js";
2
+ import { c as withTracing } from "./functional-uSbNnnxK.js";
3
+ import { t as emitCorrelatedEvent } from "./correlated-events-DwMMbItg.js";
3
4
  import { createSafeBaggageSchema } from "./business-baggage.js";
4
5
  import { SpanKind, context, propagation } from "@opentelemetry/api";
5
6
 
@@ -238,10 +239,10 @@ function traceDistributedWorkflow(config) {
238
239
  emitCorrelatedEvent(baseCtx, "workflow.completed", { "workflow.id": workflowId });
239
240
  return result;
240
241
  } catch (error) {
241
- config.onError?.(workflowCtx, error);
242
+ config.onError?.(workflowCtx, toError(error));
242
243
  emitCorrelatedEvent(baseCtx, "workflow.failed", {
243
244
  "workflow.id": workflowId,
244
- "workflow.error": error.message
245
+ "workflow.error": error instanceof Error ? error.message : String(error)
245
246
  });
246
247
  throw error;
247
248
  }
@@ -298,7 +299,8 @@ function traceDistributedStep(config) {
298
299
  return async (...args) => {
299
300
  let baggageValues = null;
300
301
  const extractBaggage = config.extractBaggage ?? true;
301
- if (typeof extractBaggage === "function") baggageValues = extractBaggage(args);
302
+ const readBaggage = isFunction(extractBaggage) ? extractBaggage : void 0;
303
+ if (readBaggage) baggageValues = readBaggage(args);
302
304
  else if (extractBaggage) {
303
305
  const extracted = WorkflowBaggage.get(baseCtx);
304
306
  if (extracted.workflowId && extracted.workflowName) baggageValues = extracted;
@@ -366,10 +368,10 @@ function traceDistributedStep(config) {
366
368
  emitCorrelatedEvent(baseCtx, "workflow.step.completed", { "workflow.step.name": config.name });
367
369
  return result;
368
370
  } catch (error) {
369
- config.onError?.(stepCtx, error);
371
+ config.onError?.(stepCtx, toError(error));
370
372
  emitCorrelatedEvent(baseCtx, "workflow.step.failed", {
371
373
  "workflow.step.name": config.name,
372
- "workflow.step.error": error.message,
374
+ "workflow.step.error": error instanceof Error ? error.message : String(error),
373
375
  ...compensationData && { "workflow.step.requires_compensation": true }
374
376
  });
375
377
  throw error;
package/dist/workflow.cjs CHANGED
@@ -1,8 +1,9 @@
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_trace_helpers = require('./trace-helpers.cjs');
4
- const require_functional = require('./functional-C0uAZq2X.cjs');
5
- const require_correlated_events = require('./correlated-events-kSwLo3mi.cjs');
5
+ const require_functional = require('./functional-Da6Yv64r.cjs');
6
+ const require_correlated_events = require('./correlated-events-CcuknWnU.cjs');
6
7
  const require_trace_factory_validation = require('./trace-factory-validation-Dc8epn87.cjs');
7
8
  let node_async_hooks = require("node:async_hooks");
8
9
  node_async_hooks = require_rolldown_runtime.__toESM(node_async_hooks, 1);
@@ -98,23 +99,31 @@ const workflowContextStorage = new node_async_hooks.AsyncLocalStorage();
98
99
  * });
99
100
  * ```
100
101
  */
102
+ /**
103
+ * Check a config a JavaScript caller may have built by hand: TypeScript has
104
+ * already checked it for everyone else.
105
+ */
106
+ function assertNamedConfig(fn, config) {
107
+ if (!require_values.asRecord(config)) throw new TypeError(`${fn}: config must be an object`);
108
+ if (require_values.nonEmptyString(config.name) === void 0) throw new TypeError(`${fn}: config.name must be a non-empty string`);
109
+ }
101
110
  function traceWorkflow(config) {
102
- if (!config || typeof config !== "object") throw new TypeError("traceWorkflow: config must be an object");
103
- if (typeof config.name !== "string" || config.name.trim() === "") throw new TypeError("traceWorkflow: config.name must be a non-empty string");
104
- if (typeof config.workflowId !== "string" && typeof config.workflowId !== "function") throw new TypeError("traceWorkflow: config.workflowId must be a string or function");
111
+ assertNamedConfig("traceWorkflow", config);
112
+ if (require_values.asString(config.workflowId) === void 0 && !require_values.isFunction(config.workflowId)) throw new TypeError("traceWorkflow: config.workflowId must be a string or function");
105
113
  const spanName = `workflow.${config.name}`;
106
114
  return (fnFactory) => {
107
115
  require_trace_factory_validation.assertTraceFactory("traceWorkflow", fnFactory);
108
116
  return require_functional.withTracing({ name: spanName })((baseCtx) => {
109
117
  return async (...args) => {
110
- const workflowId = typeof config.workflowId === "function" ? config.workflowId(...args) : config.workflowId;
118
+ const workflowId = require_values.isFunction(config.workflowId) ? config.workflowId(...args) : config.workflowId;
111
119
  const ctx = createWorkflowContext(baseCtx, config.name, workflowId);
112
120
  ctx.setAttribute("workflow.name", config.name);
113
121
  ctx.setAttribute("workflow.id", workflowId);
114
122
  if (config.version) ctx.setAttribute("workflow.version", config.version);
115
123
  ctx.setAttribute("workflow.status", "running");
116
- if (config.attributes) {
117
- for (const [key, value] of Object.entries(config.attributes)) if (value !== void 0) ctx.setAttribute(key, value);
124
+ if (config.attributes) for (const [key, value] of Object.entries(config.attributes)) {
125
+ const attribute = require_values.toAttributeValue(value);
126
+ if (attribute !== void 0) ctx.setAttribute(key, attribute);
118
127
  }
119
128
  return workflowContextStorage.run(ctx, async () => {
120
129
  try {
@@ -126,13 +135,13 @@ function traceWorkflow(config) {
126
135
  return result;
127
136
  } catch (error) {
128
137
  ctx.setWorkflowStatus("failed");
129
- config.onFailed?.(ctx, error);
138
+ config.onFailed?.(ctx, require_values.toError(error));
130
139
  const state = getWorkflowState();
131
140
  if (state && state.compensations.size > 0) {
132
141
  ctx.setWorkflowStatus("compensating");
133
142
  config.onCompensating?.(ctx);
134
143
  try {
135
- await ctx.compensate(error);
144
+ await ctx.compensate(require_values.toError(error));
136
145
  ctx.setWorkflowStatus("compensated");
137
146
  } catch (compensationError) {
138
147
  ctx.setWorkflowStatus("compensation_failed");
@@ -147,10 +156,9 @@ function traceWorkflow(config) {
147
156
  };
148
157
  }
149
158
  function traceStep(config) {
150
- if (!config || typeof config !== "object") throw new TypeError("traceStep: config must be an object");
151
- if (typeof config.name !== "string" || config.name.trim() === "") throw new TypeError("traceStep: config.name must be a non-empty string");
159
+ assertNamedConfig("traceStep", config);
152
160
  return ((handler) => {
153
- if (typeof handler !== "function") throw new TypeError("traceStep(config)(handler): handler must be a function");
161
+ if (!require_values.isFunction(handler)) throw new TypeError("traceStep(config)(handler): handler must be a function");
154
162
  return require_functional.withTracing({ name: `step.${config.name}` })((baseCtx) => {
155
163
  return async (...args) => {
156
164
  const workflowCtx = workflowContextStorage.getStore() ?? null;
@@ -160,8 +168,9 @@ function traceStep(config) {
160
168
  ctx.setAttribute("workflow.step.status", "running");
161
169
  if (config.description) ctx.setAttribute("workflow.step.description", config.description);
162
170
  if (config.idempotent) ctx.setAttribute("workflow.step.idempotent", true);
163
- if (config.attributes) {
164
- for (const [key, value] of Object.entries(config.attributes)) if (value !== void 0) ctx.setAttribute(key, value);
171
+ if (config.attributes) for (const [key, value] of Object.entries(config.attributes)) {
172
+ const attribute = require_values.toAttributeValue(value);
173
+ if (attribute !== void 0) ctx.setAttribute(key, attribute);
165
174
  }
166
175
  await addStepLinks(ctx, config, workflowCtx);
167
176
  if (config.compensate && workflowCtx) {
@@ -188,7 +197,7 @@ function traceStep(config) {
188
197
  config.onComplete?.(ctx);
189
198
  return result;
190
199
  } catch (error) {
191
- lastError = error;
200
+ lastError = require_values.toError(error);
192
201
  if (attempt < maxAttempts) require_correlated_events.emitCorrelatedEvent(ctx, "step_retry_scheduled", {
193
202
  "workflow.step.error": String(error),
194
203
  "workflow.step.attempt": attempt
@@ -267,7 +276,7 @@ function createWorkflowContext(baseCtx, workflowName, workflowId) {
267
276
  this.recordCompensation(stepName, true);
268
277
  step.status = "compensated";
269
278
  } catch (compensationError) {
270
- this.recordCompensation(stepName, false, compensationError);
279
+ this.recordCompensation(stepName, false, require_values.toError(compensationError));
271
280
  throw compensationError;
272
281
  }
273
282
  }