autotel 3.0.3 → 3.0.4

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 (39) hide show
  1. package/dist/{chunk-TFRZOUTV.js → chunk-34X3TKHA.js} +3 -3
  2. package/dist/{chunk-TFRZOUTV.js.map → chunk-34X3TKHA.js.map} +1 -1
  3. package/dist/{chunk-K7HSRLP5.js → chunk-4LF6FV2V.js} +3 -3
  4. package/dist/{chunk-K7HSRLP5.js.map → chunk-4LF6FV2V.js.map} +1 -1
  5. package/dist/{chunk-7SMNC4LS.cjs → chunk-AAYCDHH6.cjs} +7 -7
  6. package/dist/{chunk-7SMNC4LS.cjs.map → chunk-AAYCDHH6.cjs.map} +1 -1
  7. package/dist/{chunk-MOO75VE4.cjs → chunk-AY2SY3MO.cjs} +5 -5
  8. package/dist/{chunk-MOO75VE4.cjs.map → chunk-AY2SY3MO.cjs.map} +1 -1
  9. package/dist/{chunk-PMRWMRXY.js → chunk-F3TNRW2P.js} +4 -3
  10. package/dist/chunk-F3TNRW2P.js.map +1 -0
  11. package/dist/{chunk-52PUSFC2.js → chunk-HBLWOI6P.js} +3 -3
  12. package/dist/{chunk-52PUSFC2.js.map → chunk-HBLWOI6P.js.map} +1 -1
  13. package/dist/{chunk-HKZHUGGN.cjs → chunk-LMFPZHI4.cjs} +5 -5
  14. package/dist/{chunk-HKZHUGGN.cjs.map → chunk-LMFPZHI4.cjs.map} +1 -1
  15. package/dist/{chunk-QPH5ZKP5.cjs → chunk-WSGAHSZQ.cjs} +4 -3
  16. package/dist/chunk-WSGAHSZQ.cjs.map +1 -0
  17. package/dist/decorators.cjs +1 -1
  18. package/dist/decorators.js +1 -1
  19. package/dist/functional.cjs +8 -8
  20. package/dist/functional.d.cts +20 -17
  21. package/dist/functional.d.ts +20 -17
  22. package/dist/functional.js +1 -1
  23. package/dist/index.cjs +21 -21
  24. package/dist/index.js +5 -5
  25. package/dist/messaging.cjs +5 -5
  26. package/dist/messaging.js +2 -2
  27. package/dist/semantic-helpers.cjs +6 -6
  28. package/dist/semantic-helpers.js +2 -2
  29. package/dist/webhook.cjs +2 -2
  30. package/dist/webhook.js +1 -1
  31. package/dist/workflow-distributed.cjs +3 -3
  32. package/dist/workflow-distributed.js +1 -1
  33. package/dist/workflow.cjs +6 -6
  34. package/dist/workflow.js +2 -2
  35. package/package.json +1 -1
  36. package/src/functional.test.ts +18 -0
  37. package/src/functional.ts +32 -20
  38. package/dist/chunk-PMRWMRXY.js.map +0 -1
  39. package/dist/chunk-QPH5ZKP5.cjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
1
  export { createDrainPipeline } from './chunk-KFOHQK7X.js';
2
- export { getCurrentWorkflowContext, isInWorkflow, traceStep, traceWorkflow } from './chunk-K7HSRLP5.js';
2
+ export { getCurrentWorkflowContext, isInWorkflow, traceStep, traceWorkflow } from './chunk-4LF6FV2V.js';
3
3
  export { attrs, autoRedactPII, dbClient, httpClient, httpServer, identify, mergeAttrs, mergeServiceResource, request, safeSetAttributes, setDevice, setError, setException, setSession, setUser, validateAttribute } from './chunk-DDXIUZEG.js';
4
4
  export { httpRequestHeaderAttribute, httpResponseHeaderAttribute } from './chunk-7552UTQW.js';
5
5
  export { HTTPAttributes, ServiceAttributes, URLAttributes } from './chunk-4A53YIAX.js';
6
6
  export { parseError } from './chunk-J7VGRIAJ.js';
7
- export { traceConsumer, traceProducer } from './chunk-TFRZOUTV.js';
7
+ export { traceConsumer, traceProducer } from './chunk-34X3TKHA.js';
8
8
  import { emitCorrelatedEvent } from './chunk-KIL5CUN6.js';
9
9
  export { BusinessBaggage, createSafeBaggageSchema } from './chunk-4IFSYQVX.js';
10
10
  import { resetMetrics } from './chunk-7SAWIN74.js';
11
11
  export { Metric, getMetrics, resetMetrics } from './chunk-7SAWIN74.js';
12
12
  import './chunk-5ZN622AO.js';
13
13
  export { createCounter, createHistogram, createObservableGauge, createUpDownCounter, getMeter } from './chunk-TQ5UWA7S.js';
14
- export { traceDB, traceHTTP, traceLLM, traceMessaging } from './chunk-52PUSFC2.js';
15
- import { trace as trace$1 } from './chunk-PMRWMRXY.js';
16
- export { ctx, instrument, span, withBaggage, withNewContext, withTracing } from './chunk-PMRWMRXY.js';
14
+ export { traceDB, traceHTTP, traceLLM, traceMessaging } from './chunk-HBLWOI6P.js';
15
+ import { trace as trace$1 } from './chunk-F3TNRW2P.js';
16
+ export { ctx, instrument, span, withBaggage, withNewContext, withTracing } from './chunk-F3TNRW2P.js';
17
17
  export { createDeterministicTraceId, enrichWithTraceContext, finalizeSpan, flattenMetadata, getActiveContext, getActiveSpan, getTraceContext, getTracer, isTracing, resolveTraceUrl, runWithSpan } from './chunk-DSMSIVTG.js';
18
18
  import { resetEvents } from './chunk-OM4OSBOP.js';
19
19
  export { Event, getEvents, resetEvents } from './chunk-OM4OSBOP.js';
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkHKZHUGGN_cjs = require('./chunk-HKZHUGGN.cjs');
3
+ var chunkLMFPZHI4_cjs = require('./chunk-LMFPZHI4.cjs');
4
4
  require('./chunk-4P6ZOARG.cjs');
5
- require('./chunk-QPH5ZKP5.cjs');
5
+ require('./chunk-WSGAHSZQ.cjs');
6
6
  require('./chunk-NCSMD3TK.cjs');
7
7
  require('./chunk-VQTCQKHQ.cjs');
8
8
  require('./chunk-KKGM42RQ.cjs');
@@ -25,15 +25,15 @@ require('./chunk-JEQ2X3Z6.cjs');
25
25
 
26
26
  Object.defineProperty(exports, "clearOrderingState", {
27
27
  enumerable: true,
28
- get: function () { return chunkHKZHUGGN_cjs.clearOrderingState; }
28
+ get: function () { return chunkLMFPZHI4_cjs.clearOrderingState; }
29
29
  });
30
30
  Object.defineProperty(exports, "traceConsumer", {
31
31
  enumerable: true,
32
- get: function () { return chunkHKZHUGGN_cjs.traceConsumer; }
32
+ get: function () { return chunkLMFPZHI4_cjs.traceConsumer; }
33
33
  });
34
34
  Object.defineProperty(exports, "traceProducer", {
35
35
  enumerable: true,
36
- get: function () { return chunkHKZHUGGN_cjs.traceProducer; }
36
+ get: function () { return chunkLMFPZHI4_cjs.traceProducer; }
37
37
  });
38
38
  //# sourceMappingURL=messaging.cjs.map
39
39
  //# sourceMappingURL=messaging.cjs.map
package/dist/messaging.js CHANGED
@@ -1,6 +1,6 @@
1
- export { clearOrderingState, traceConsumer, traceProducer } from './chunk-TFRZOUTV.js';
1
+ export { clearOrderingState, traceConsumer, traceProducer } from './chunk-34X3TKHA.js';
2
2
  import './chunk-KIL5CUN6.js';
3
- import './chunk-PMRWMRXY.js';
3
+ import './chunk-F3TNRW2P.js';
4
4
  import './chunk-DSMSIVTG.js';
5
5
  import './chunk-SEO6NAQT.js';
6
6
  import './chunk-Z7VAOK5X.js';
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk7SMNC4LS_cjs = require('./chunk-7SMNC4LS.cjs');
4
- require('./chunk-QPH5ZKP5.cjs');
3
+ var chunkAAYCDHH6_cjs = require('./chunk-AAYCDHH6.cjs');
4
+ require('./chunk-WSGAHSZQ.cjs');
5
5
  require('./chunk-NCSMD3TK.cjs');
6
6
  require('./chunk-VQTCQKHQ.cjs');
7
7
  require('./chunk-KKGM42RQ.cjs');
@@ -24,19 +24,19 @@ require('./chunk-JEQ2X3Z6.cjs');
24
24
 
25
25
  Object.defineProperty(exports, "traceDB", {
26
26
  enumerable: true,
27
- get: function () { return chunk7SMNC4LS_cjs.traceDB; }
27
+ get: function () { return chunkAAYCDHH6_cjs.traceDB; }
28
28
  });
29
29
  Object.defineProperty(exports, "traceHTTP", {
30
30
  enumerable: true,
31
- get: function () { return chunk7SMNC4LS_cjs.traceHTTP; }
31
+ get: function () { return chunkAAYCDHH6_cjs.traceHTTP; }
32
32
  });
33
33
  Object.defineProperty(exports, "traceLLM", {
34
34
  enumerable: true,
35
- get: function () { return chunk7SMNC4LS_cjs.traceLLM; }
35
+ get: function () { return chunkAAYCDHH6_cjs.traceLLM; }
36
36
  });
37
37
  Object.defineProperty(exports, "traceMessaging", {
38
38
  enumerable: true,
39
- get: function () { return chunk7SMNC4LS_cjs.traceMessaging; }
39
+ get: function () { return chunkAAYCDHH6_cjs.traceMessaging; }
40
40
  });
41
41
  //# sourceMappingURL=semantic-helpers.cjs.map
42
42
  //# sourceMappingURL=semantic-helpers.cjs.map
@@ -1,5 +1,5 @@
1
- export { traceDB, traceHTTP, traceLLM, traceMessaging } from './chunk-52PUSFC2.js';
2
- import './chunk-PMRWMRXY.js';
1
+ export { traceDB, traceHTTP, traceLLM, traceMessaging } from './chunk-HBLWOI6P.js';
2
+ import './chunk-F3TNRW2P.js';
3
3
  import './chunk-DSMSIVTG.js';
4
4
  import './chunk-SEO6NAQT.js';
5
5
  import './chunk-Z7VAOK5X.js';
package/dist/webhook.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunk4P6ZOARG_cjs = require('./chunk-4P6ZOARG.cjs');
4
- var chunkQPH5ZKP5_cjs = require('./chunk-QPH5ZKP5.cjs');
4
+ var chunkWSGAHSZQ_cjs = require('./chunk-WSGAHSZQ.cjs');
5
5
  require('./chunk-NCSMD3TK.cjs');
6
6
  require('./chunk-VQTCQKHQ.cjs');
7
7
  var chunkKKGM42RQ_cjs = require('./chunk-KKGM42RQ.cjs');
@@ -158,7 +158,7 @@ function createParkingLot(config) {
158
158
  },
159
159
  traceCallback(callbackConfig) {
160
160
  return (fnFactory) => {
161
- return chunkQPH5ZKP5_cjs.trace(
161
+ return chunkWSGAHSZQ_cjs.trace(
162
162
  {
163
163
  name: callbackConfig.name,
164
164
  spanKind: api.SpanKind.SERVER
package/dist/webhook.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { emitCorrelatedEvent } from './chunk-KIL5CUN6.js';
2
- import { trace } from './chunk-PMRWMRXY.js';
2
+ import { trace } from './chunk-F3TNRW2P.js';
3
3
  import './chunk-DSMSIVTG.js';
4
4
  import './chunk-SEO6NAQT.js';
5
5
  import { recordStructuredError } from './chunk-Z7VAOK5X.js';
@@ -2,7 +2,7 @@
2
2
 
3
3
  var chunk4P6ZOARG_cjs = require('./chunk-4P6ZOARG.cjs');
4
4
  var chunkINJD3G4K_cjs = require('./chunk-INJD3G4K.cjs');
5
- var chunkQPH5ZKP5_cjs = require('./chunk-QPH5ZKP5.cjs');
5
+ var chunkWSGAHSZQ_cjs = require('./chunk-WSGAHSZQ.cjs');
6
6
  require('./chunk-NCSMD3TK.cjs');
7
7
  require('./chunk-VQTCQKHQ.cjs');
8
8
  require('./chunk-KKGM42RQ.cjs');
@@ -59,7 +59,7 @@ var WorkflowBaggage = chunkINJD3G4K_cjs.createSafeBaggageSchema(workflowBaggageF
59
59
  function traceDistributedWorkflow(config) {
60
60
  const spanName = `workflow.${config.name}`;
61
61
  return (fnFactory) => {
62
- return chunkQPH5ZKP5_cjs.trace(
62
+ return chunkWSGAHSZQ_cjs.trace(
63
63
  { name: spanName, spanKind: api.SpanKind.INTERNAL },
64
64
  (baseCtx) => {
65
65
  return async (...args) => {
@@ -158,7 +158,7 @@ function traceDistributedWorkflow(config) {
158
158
  function traceDistributedStep(config) {
159
159
  const spanName = `workflow.step.${config.name}`;
160
160
  return (fnFactory) => {
161
- return chunkQPH5ZKP5_cjs.trace(
161
+ return chunkWSGAHSZQ_cjs.trace(
162
162
  { name: spanName, spanKind: api.SpanKind.INTERNAL },
163
163
  (baseCtx) => {
164
164
  return async (...args) => {
@@ -1,6 +1,6 @@
1
1
  import { emitCorrelatedEvent } from './chunk-KIL5CUN6.js';
2
2
  import { createSafeBaggageSchema } from './chunk-4IFSYQVX.js';
3
- import { trace } from './chunk-PMRWMRXY.js';
3
+ import { trace } from './chunk-F3TNRW2P.js';
4
4
  import './chunk-DSMSIVTG.js';
5
5
  import './chunk-SEO6NAQT.js';
6
6
  import './chunk-Z7VAOK5X.js';
package/dist/workflow.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkMOO75VE4_cjs = require('./chunk-MOO75VE4.cjs');
3
+ var chunkAY2SY3MO_cjs = require('./chunk-AY2SY3MO.cjs');
4
4
  require('./chunk-4P6ZOARG.cjs');
5
- require('./chunk-QPH5ZKP5.cjs');
5
+ require('./chunk-WSGAHSZQ.cjs');
6
6
  require('./chunk-NCSMD3TK.cjs');
7
7
  require('./chunk-VQTCQKHQ.cjs');
8
8
  require('./chunk-KKGM42RQ.cjs');
@@ -25,19 +25,19 @@ require('./chunk-JEQ2X3Z6.cjs');
25
25
 
26
26
  Object.defineProperty(exports, "getCurrentWorkflowContext", {
27
27
  enumerable: true,
28
- get: function () { return chunkMOO75VE4_cjs.getCurrentWorkflowContext; }
28
+ get: function () { return chunkAY2SY3MO_cjs.getCurrentWorkflowContext; }
29
29
  });
30
30
  Object.defineProperty(exports, "isInWorkflow", {
31
31
  enumerable: true,
32
- get: function () { return chunkMOO75VE4_cjs.isInWorkflow; }
32
+ get: function () { return chunkAY2SY3MO_cjs.isInWorkflow; }
33
33
  });
34
34
  Object.defineProperty(exports, "traceStep", {
35
35
  enumerable: true,
36
- get: function () { return chunkMOO75VE4_cjs.traceStep; }
36
+ get: function () { return chunkAY2SY3MO_cjs.traceStep; }
37
37
  });
38
38
  Object.defineProperty(exports, "traceWorkflow", {
39
39
  enumerable: true,
40
- get: function () { return chunkMOO75VE4_cjs.traceWorkflow; }
40
+ get: function () { return chunkAY2SY3MO_cjs.traceWorkflow; }
41
41
  });
42
42
  //# sourceMappingURL=workflow.cjs.map
43
43
  //# sourceMappingURL=workflow.cjs.map
package/dist/workflow.js CHANGED
@@ -1,6 +1,6 @@
1
- export { getCurrentWorkflowContext, isInWorkflow, traceStep, traceWorkflow } from './chunk-K7HSRLP5.js';
1
+ export { getCurrentWorkflowContext, isInWorkflow, traceStep, traceWorkflow } from './chunk-4LF6FV2V.js';
2
2
  import './chunk-KIL5CUN6.js';
3
- import './chunk-PMRWMRXY.js';
3
+ import './chunk-F3TNRW2P.js';
4
4
  import './chunk-DSMSIVTG.js';
5
5
  import './chunk-SEO6NAQT.js';
6
6
  import './chunk-Z7VAOK5X.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autotel",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "Write Once, Observe Anywhere",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -62,6 +62,24 @@ describe('Functional API', () => {
62
62
  expect(promise).toBeInstanceOf(Promise);
63
63
  await expect(promise).resolves.toBe(84);
64
64
  });
65
+
66
+ it('accepts a string name as first argument (sync)', () => {
67
+ const result = span('sync-name-shorthand', () => 'ok');
68
+ expect(result).toBe('ok');
69
+ });
70
+
71
+ it('accepts a string name as first argument (async)', async () => {
72
+ await expect(
73
+ span('async-name-shorthand', async () => 'ok'),
74
+ ).resolves.toBe('ok');
75
+ });
76
+
77
+ it('records spans created via the string-name shorthand', async () => {
78
+ const collector = createTraceCollector();
79
+ await span('shorthand.recorded', async () => undefined);
80
+ const names = collector.getSpans().map((s) => s.name);
81
+ expect(names).toContain('shorthand.recorded');
82
+ });
65
83
  });
66
84
 
67
85
  describe('trace()', () => {
package/src/functional.ts CHANGED
@@ -2124,44 +2124,56 @@ export interface SpanOptions {
2124
2124
  * Useful for adding tracing to specific code blocks without wrapping
2125
2125
  * the entire function. Supports both synchronous and asynchronous functions.
2126
2126
  *
2127
+ * Mirrors `trace()`: pass a span name as the first argument for the common
2128
+ * case, or full `SpanOptions` when you need to attach attributes.
2129
+ *
2127
2130
  * @example
2128
2131
  * ```typescript
2129
- * // Async function
2130
- * async function processOrder(order: Order) {
2131
- * await span({
2132
- * name: 'payment.charge',
2133
- * attributes: { amount: order.total }
2134
- * }, async (span) => {
2132
+ * // Name shorthand
2133
+ * await span('payment.charge', async (span) => {
2134
+ * await chargeCustomer(order);
2135
+ * })
2136
+ *
2137
+ * // Full options when attributes are needed
2138
+ * await span(
2139
+ * { name: 'payment.charge', attributes: { amount: order.total } },
2140
+ * async (span) => {
2135
2141
  * await chargeCustomer(order);
2136
- * })
2137
- * }
2142
+ * },
2143
+ * )
2138
2144
  *
2139
- * // Sync function
2140
- * function calculateTotal(items: Item[]) {
2141
- * return span({
2142
- * name: 'calculateTotal',
2143
- * attributes: { itemCount: items.length }
2144
- * }, (span) => {
2145
- * return items.reduce((sum, item) => sum + item.price, 0);
2146
- * })
2147
- * }
2145
+ * // Sync
2146
+ * const total = span('calculateTotal', (span) => {
2147
+ * return items.reduce((sum, item) => sum + item.price, 0);
2148
+ * })
2148
2149
  * ```
2149
2150
  */
2150
- // Overload for sync functions (more specific - should come first)
2151
+ // Overloads sync first (more specific match), then async.
2152
+ // Each shape is offered with a string name OR a full SpanOptions object so
2153
+ // span() aligns with trace()'s argument flexibility.
2154
+ export function span<T = unknown>(
2155
+ name: string,
2156
+ fn: (span: Span) => T,
2157
+ ): T;
2158
+ export function span<T = unknown>(
2159
+ name: string,
2160
+ fn: (span: Span) => Promise<T>,
2161
+ ): Promise<T>;
2151
2162
  export function span<T = unknown>(
2152
2163
  options: SpanOptions,
2153
2164
  fn: (span: Span) => T,
2154
2165
  ): T;
2155
- // Overload for async functions
2156
2166
  export function span<T = unknown>(
2157
2167
  options: SpanOptions,
2158
2168
  fn: (span: Span) => Promise<T>,
2159
2169
  ): Promise<T>;
2160
2170
  // Implementation
2161
2171
  export function span<T = unknown>(
2162
- options: SpanOptions,
2172
+ nameOrOptions: string | SpanOptions,
2163
2173
  fn: (span: Span) => T | Promise<T>,
2164
2174
  ): T | Promise<T> {
2175
+ const options: SpanOptions =
2176
+ typeof nameOrOptions === 'string' ? { name: nameOrOptions } : nameOrOptions;
2165
2177
  const config = getConfig();
2166
2178
  const tracer = config.tracer;
2167
2179
  const { name, attributes } = options;