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.
- package/README.md +30 -23
- package/dist/{attribute-redacting-processor-Pk7lAzWd.d.cts → attribute-redacting-processor-CvBE0z1p.d.cts} +33 -1
- package/dist/{attribute-redacting-processor-Pk7lAzWd.d.ts → attribute-redacting-processor-CvBE0z1p.d.ts} +33 -1
- package/dist/attribute-redacting-processor.cjs +34 -32
- package/dist/attribute-redacting-processor.d.cts +1 -1
- package/dist/attribute-redacting-processor.d.ts +1 -1
- package/dist/attribute-redacting-processor.js +35 -32
- package/dist/{attributes-aDmJYral.cjs → attributes-Cxys8tgr.cjs} +34 -35
- package/dist/{attributes-B7wix2VG.js → attributes-Dt4YUYbP.js} +34 -35
- package/dist/attributes.cjs +1 -1
- package/dist/attributes.d.cts +1 -1
- package/dist/attributes.d.ts +1 -1
- package/dist/attributes.js +1 -1
- package/dist/auto.cjs +1 -1
- package/dist/auto.js +1 -1
- package/dist/business-baggage.cjs +19 -12
- package/dist/business-baggage.d.cts +8 -3
- package/dist/business-baggage.d.ts +8 -3
- package/dist/business-baggage.js +19 -12
- package/dist/{canonical-log-line-processor-DxtBGZIi.cjs → canonical-log-line-processor-DolzdawH.cjs} +43 -32
- package/dist/{canonical-log-line-processor-B4WgG-VS.d.cts → canonical-log-line-processor-cPB4Axk-.d.ts} +4 -3
- package/dist/{canonical-log-line-processor-B0vq_QR6.js → canonical-log-line-processor-hFUmS__K.js} +43 -32
- package/dist/{canonical-log-line-processor-CL_J7gb5.d.ts → canonical-log-line-processor-l0Aqe6yp.d.cts} +4 -3
- package/dist/config.d.cts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/{correlated-events-kSwLo3mi.cjs → correlated-events-CcuknWnU.cjs} +2 -1
- package/dist/{correlated-events-Bzh5y-UB.js → correlated-events-DwMMbItg.js} +3 -1
- package/dist/correlation-id.cjs +1 -1
- package/dist/correlation-id.js +1 -1
- package/dist/db.cjs +34 -19
- package/dist/db.js +34 -19
- package/dist/decorators.cjs +4 -2
- package/dist/decorators.d.cts +16 -11
- package/dist/decorators.d.ts +16 -11
- package/dist/decorators.js +4 -2
- package/dist/{define-event-CGG048HE.d.cts → define-event-BNeuKUPv.d.cts} +1 -1
- package/dist/{define-event-B2z1SBe7.d.ts → define-event-Bd8f8mST.d.ts} +1 -1
- package/dist/diagnostics.cjs +18 -16
- package/dist/diagnostics.d.cts +14 -10
- package/dist/diagnostics.d.ts +14 -10
- package/dist/diagnostics.js +18 -16
- package/dist/{event-subscriber-CWh8sTGh.d.cts → event-subscriber-DMACQA-1.d.cts} +19 -9
- package/dist/{event-subscriber-CWh8sTGh.d.ts → event-subscriber-DMACQA-1.d.ts} +19 -9
- package/dist/event-subscriber.d.cts +2 -2
- package/dist/event-subscriber.d.ts +2 -2
- package/dist/{event-testing-D0qWfqAy.d.cts → event-testing-CBtnJXE5.d.cts} +1 -1
- package/dist/{event-testing-CA2mIx1E.d.ts → event-testing-CkPgV3Ii.d.ts} +1 -1
- package/dist/event-testing.d.cts +1 -1
- package/dist/event-testing.d.ts +1 -1
- package/dist/event.cjs +1 -1
- package/dist/event.d.cts +5 -5
- package/dist/event.d.ts +5 -5
- package/dist/event.js +1 -1
- package/dist/exception-fingerprint.cjs +133 -0
- package/dist/exception-fingerprint.d.cts +51 -0
- package/dist/exception-fingerprint.d.ts +51 -0
- package/dist/exception-fingerprint.js +126 -0
- package/dist/{functional-e6jw5zQj.d.cts → functional-CJn2zY4o.d.cts} +96 -39
- package/dist/{functional-AT22vCw6.d.ts → functional-DXy1cHFF.d.ts} +96 -39
- package/dist/{functional-C0uAZq2X.cjs → functional-Da6Yv64r.cjs} +27 -15
- package/dist/{functional-DX7Zvag0.js → functional-uSbNnnxK.js} +27 -15
- package/dist/functional.cjs +1 -1
- package/dist/functional.d.cts +2 -2
- package/dist/functional.d.ts +2 -2
- package/dist/functional.js +1 -1
- package/dist/http.cjs +11 -8
- package/dist/http.js +11 -8
- package/dist/{index-DolOVX6F.d.ts → index-CwrNAsgk.d.ts} +22 -26
- package/dist/{index-BPcxVucm.d.cts → index-DQHf4cNl.d.cts} +22 -26
- package/dist/index.cjs +41 -35
- package/dist/index.d.cts +45 -30
- package/dist/index.d.ts +45 -30
- package/dist/index.js +41 -35
- package/dist/{init-pPI3JRRf.d.ts → init-BgnYi2sm.d.ts} +6 -6
- package/dist/{init-CTtHITlX.cjs → init-D4m5rCmD.cjs} +110 -84
- package/dist/{init-ncTMKZ-s.d.cts → init-DrlL1eis.d.cts} +6 -6
- package/dist/{init-WHYwyItd.js → init-JtX-KKz_.js} +105 -85
- package/dist/instrumentation.cjs +2 -2
- package/dist/instrumentation.js +2 -2
- package/dist/{logger-D3Ej3DII.js → logger-DdPp__xW.js} +63 -54
- package/dist/{logger-CN4xpzMd.d.cts → logger-S1Fgl0g3.d.cts} +0 -20
- package/dist/{logger-CN4xpzMd.d.ts → logger-S1Fgl0g3.d.ts} +0 -20
- package/dist/{logger-thMPLpOG.cjs → logger-Sm66cjKl.cjs} +63 -54
- package/dist/logger.cjs +1 -1
- package/dist/logger.d.cts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +1 -1
- package/dist/messaging-adapters.cjs +26 -12
- package/dist/messaging-adapters.d.cts +0 -30
- package/dist/messaging-adapters.d.ts +0 -30
- package/dist/messaging-adapters.js +26 -12
- package/dist/messaging.cjs +37 -34
- package/dist/messaging.d.cts +21 -62
- package/dist/messaging.d.ts +21 -62
- package/dist/messaging.js +37 -34
- package/dist/{metric-testing-CpvP3ZIa.d.cts → metric-testing-86WO1wan.d.cts} +1 -1
- package/dist/{metric-testing-CWm6UhaR.d.ts → metric-testing-CbCxdPBp.d.ts} +1 -1
- package/dist/metric-testing.d.cts +1 -1
- package/dist/metric-testing.d.ts +1 -1
- package/dist/metric.d.cts +3 -3
- package/dist/metric.d.ts +3 -3
- package/dist/{node-require-vROmTeJ8.js → node-require-DSPjaw_l.js} +3 -2
- package/dist/{node-require-PFqDihze.cjs → node-require-EifOMikz.cjs} +3 -2
- package/dist/parse-error.cjs +18 -12
- package/dist/parse-error.d.cts +2 -1
- package/dist/parse-error.d.ts +2 -1
- package/dist/parse-error.js +19 -12
- package/dist/policy.cjs +0 -0
- package/dist/policy.js +0 -0
- package/dist/processors.cjs +1 -1
- package/dist/processors.d.cts +1 -1
- package/dist/processors.d.ts +1 -1
- package/dist/processors.js +1 -1
- package/dist/{sampling-BR9fkSwx.d.cts → sampling-CM5S2Lp3.d.ts} +5 -6
- package/dist/{sampling-CP3e7-Yr.d.ts → sampling-CmRdnXUi.d.cts} +5 -6
- package/dist/sampling.cjs +3 -2
- package/dist/sampling.d.cts +1 -1
- package/dist/sampling.d.ts +1 -1
- package/dist/sampling.js +3 -2
- package/dist/semantic-helpers.cjs +9 -9
- package/dist/semantic-helpers.d.cts +1 -1
- package/dist/semantic-helpers.d.ts +1 -1
- package/dist/semantic-helpers.js +9 -9
- package/dist/{stable-hash-ChFBIhNt.js → stable-hash-BkoAYVks.js} +4 -3
- package/dist/{stable-hash-CS9BxvVQ.cjs → stable-hash-C0pOegH_.cjs} +4 -3
- package/dist/{structured-error-CHg7DoIQ.cjs → structured-error--_wXpd_C.cjs} +34 -25
- package/dist/{structured-error-9--cxBay.js → structured-error-YIuka-FE.js} +34 -25
- package/dist/test-span-collector.cjs +15 -8
- package/dist/test-span-collector.js +15 -8
- package/dist/testing.cjs +16 -18
- package/dist/testing.d.cts +7 -6
- package/dist/testing.d.ts +7 -6
- package/dist/testing.js +16 -18
- package/dist/{trace-context-IuyoPyNq.d.cts → trace-context-C1Cn1q0y.d.cts} +8 -7
- package/dist/{trace-context-IuyoPyNq.d.ts → trace-context-f89xPJbK.d.ts} +8 -7
- package/dist/trace-helpers.cjs +16 -13
- package/dist/trace-helpers.d.cts +9 -4
- package/dist/trace-helpers.d.ts +9 -4
- package/dist/trace-helpers.js +16 -13
- package/dist/tracer-provider.cjs +8 -12
- package/dist/tracer-provider.js +8 -12
- package/dist/validate.cjs +22 -20
- package/dist/validate.d.cts +3 -2
- package/dist/validate.d.ts +3 -2
- package/dist/validate.js +22 -20
- package/dist/values-BenyvWKz.js +141 -0
- package/dist/values-CeMH-mYG.d.cts +8 -0
- package/dist/values-CeMH-mYG.d.ts +8 -0
- package/dist/values-DApyq53y.cjs +267 -0
- package/dist/webhook.cjs +3 -3
- package/dist/webhook.d.cts +1 -1
- package/dist/webhook.d.ts +1 -1
- package/dist/webhook.js +3 -3
- package/dist/workflow-distributed.cjs +9 -7
- package/dist/workflow-distributed.d.cts +9 -8
- package/dist/workflow-distributed.d.ts +9 -8
- package/dist/workflow-distributed.js +9 -7
- package/dist/workflow.cjs +26 -17
- package/dist/workflow.d.cts +1 -28
- package/dist/workflow.d.ts +1 -28
- package/dist/workflow.js +26 -17
- package/dist/yaml-config.cjs +26 -11
- package/dist/yaml-config.d.cts +9 -3
- package/dist/yaml-config.d.ts +9 -3
- package/dist/yaml-config.js +26 -11
- package/package.json +6 -1
package/dist/messaging.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as TraceContext } from "./trace-context-
|
|
1
|
+
import { n as TraceContext } from "./trace-context-C1Cn1q0y.cjs";
|
|
2
2
|
import { Attributes, Link, SpanContext } from "@opentelemetry/api";
|
|
3
3
|
//#region src/messaging.d.ts
|
|
4
4
|
/**
|
|
@@ -83,7 +83,7 @@ interface ProducerConfig {
|
|
|
83
83
|
/**
|
|
84
84
|
* Configuration for consumer tracing
|
|
85
85
|
*/
|
|
86
|
-
interface ConsumerConfig {
|
|
86
|
+
interface ConsumerConfig<TMessage = unknown> {
|
|
87
87
|
/** Messaging system (kafka, rabbitmq, sqs, etc.) */
|
|
88
88
|
system: MessagingSystem;
|
|
89
89
|
/** Destination name (topic/queue) */
|
|
@@ -91,7 +91,7 @@ interface ConsumerConfig {
|
|
|
91
91
|
/** Consumer group name */
|
|
92
92
|
consumerGroup?: string;
|
|
93
93
|
/** Extract headers from message for link creation */
|
|
94
|
-
headersFrom?: string | ((msg:
|
|
94
|
+
headersFrom?: string | ((msg: TMessage) => Record<string, string> | undefined);
|
|
95
95
|
/** Enable batch mode - extract links from all messages */
|
|
96
96
|
batchMode?: boolean;
|
|
97
97
|
/** Extract baggage from message headers */
|
|
@@ -99,7 +99,7 @@ interface ConsumerConfig {
|
|
|
99
99
|
/** Additional attributes to set on span */
|
|
100
100
|
attributes?: Attributes;
|
|
101
101
|
/** Consumer lag metrics extraction */
|
|
102
|
-
lagMetrics?: LagMetricsConfig
|
|
102
|
+
lagMetrics?: LagMetricsConfig<TMessage>;
|
|
103
103
|
/** Callback when message goes to DLQ */
|
|
104
104
|
onDLQ?: (ctx: ConsumerContext, reason: string) => void;
|
|
105
105
|
/** Callback on error */
|
|
@@ -121,7 +121,7 @@ interface ConsumerConfig {
|
|
|
121
121
|
* }
|
|
122
122
|
* ```
|
|
123
123
|
*/
|
|
124
|
-
ordering?: OrderingConfig
|
|
124
|
+
ordering?: OrderingConfig<TMessage>;
|
|
125
125
|
/**
|
|
126
126
|
* Consumer group tracking configuration
|
|
127
127
|
*
|
|
@@ -168,7 +168,7 @@ interface ConsumerConfig {
|
|
|
168
168
|
* })
|
|
169
169
|
* ```
|
|
170
170
|
*/
|
|
171
|
-
customAttributes?: (ctx: ConsumerContext, msg:
|
|
171
|
+
customAttributes?: (ctx: ConsumerContext, msg: TMessage) => Attributes;
|
|
172
172
|
/**
|
|
173
173
|
* Hook for custom context extraction (beyond W3C traceparent)
|
|
174
174
|
*
|
|
@@ -209,20 +209,20 @@ interface ConsumerConfig {
|
|
|
209
209
|
/**
|
|
210
210
|
* Configuration for consumer lag metrics
|
|
211
211
|
*/
|
|
212
|
-
interface LagMetricsConfig {
|
|
212
|
+
interface LagMetricsConfig<TMessage = unknown> {
|
|
213
213
|
/** Get current message offset */
|
|
214
|
-
getCurrentOffset?: (msg:
|
|
214
|
+
getCurrentOffset?: (msg: TMessage) => number | undefined;
|
|
215
215
|
/** Get end offset (high watermark) - can be async */
|
|
216
216
|
getEndOffset?: () => number | Promise<number>;
|
|
217
217
|
/** Get committed offset - can be async */
|
|
218
218
|
getCommittedOffset?: () => number | Promise<number>;
|
|
219
219
|
/** Get partition from message */
|
|
220
|
-
getPartition?: (msg:
|
|
220
|
+
getPartition?: (msg: TMessage) => number | undefined;
|
|
221
221
|
}
|
|
222
222
|
/**
|
|
223
223
|
* Configuration for message ordering tracking
|
|
224
224
|
*/
|
|
225
|
-
interface OrderingConfig {
|
|
225
|
+
interface OrderingConfig<TMessage = unknown> {
|
|
226
226
|
/**
|
|
227
227
|
* Extract sequence number from message
|
|
228
228
|
*
|
|
@@ -233,7 +233,7 @@ interface OrderingConfig {
|
|
|
233
233
|
* sequenceFrom: (msg) => msg.offset
|
|
234
234
|
* ```
|
|
235
235
|
*/
|
|
236
|
-
sequenceFrom?: (msg:
|
|
236
|
+
sequenceFrom?: (msg: TMessage) => number | undefined;
|
|
237
237
|
/**
|
|
238
238
|
* Extract partition key from message
|
|
239
239
|
*
|
|
@@ -244,7 +244,7 @@ interface OrderingConfig {
|
|
|
244
244
|
* partitionKeyFrom: (msg) => msg.key
|
|
245
245
|
* ```
|
|
246
246
|
*/
|
|
247
|
-
partitionKeyFrom?: (msg:
|
|
247
|
+
partitionKeyFrom?: (msg: TMessage) => string | undefined;
|
|
248
248
|
/**
|
|
249
249
|
* Extract message ID for deduplication
|
|
250
250
|
*
|
|
@@ -255,7 +255,7 @@ interface OrderingConfig {
|
|
|
255
255
|
* messageIdFrom: (msg) => msg.headers['idempotency-key']
|
|
256
256
|
* ```
|
|
257
257
|
*/
|
|
258
|
-
messageIdFrom?: (msg:
|
|
258
|
+
messageIdFrom?: (msg: TMessage) => string | undefined;
|
|
259
259
|
/**
|
|
260
260
|
* Enable out-of-order detection
|
|
261
261
|
*
|
|
@@ -499,6 +499,11 @@ interface DLQReplayOptions {
|
|
|
499
499
|
/**
|
|
500
500
|
* Extended trace context for producers with header injection
|
|
501
501
|
*/
|
|
502
|
+
/** The W3C trace context headers a producer attaches to a message. */
|
|
503
|
+
interface TraceHeaders {
|
|
504
|
+
traceparent: string;
|
|
505
|
+
tracestate?: string;
|
|
506
|
+
}
|
|
502
507
|
interface ProducerContext extends TraceContext {
|
|
503
508
|
/**
|
|
504
509
|
* Get W3C trace context headers to inject into message
|
|
@@ -514,10 +519,7 @@ interface ProducerContext extends TraceContext {
|
|
|
514
519
|
* });
|
|
515
520
|
* ```
|
|
516
521
|
*/
|
|
517
|
-
getTraceHeaders():
|
|
518
|
-
traceparent: string;
|
|
519
|
-
tracestate?: string;
|
|
520
|
-
};
|
|
522
|
+
getTraceHeaders(): TraceHeaders;
|
|
521
523
|
/**
|
|
522
524
|
* Get all propagation headers including baggage if enabled
|
|
523
525
|
*
|
|
@@ -700,49 +702,6 @@ interface ConsumerContext extends TraceContext {
|
|
|
700
702
|
*/
|
|
701
703
|
getAssignedPartitions(): PartitionAssignment[];
|
|
702
704
|
}
|
|
703
|
-
/**
|
|
704
|
-
* Create a traced message producer function
|
|
705
|
-
*
|
|
706
|
-
* Sets SpanKind.PRODUCER, OTel messaging semantic attributes,
|
|
707
|
-
* and provides context injection helpers.
|
|
708
|
-
*
|
|
709
|
-
* @param config - Producer configuration
|
|
710
|
-
* @returns Factory function that wraps your producer logic
|
|
711
|
-
*
|
|
712
|
-
* @example Kafka producer
|
|
713
|
-
* ```typescript
|
|
714
|
-
* export const publishUserEvent = traceProducer({
|
|
715
|
-
* system: 'kafka',
|
|
716
|
-
* destination: 'user-events',
|
|
717
|
-
* messageIdFrom: (args) => args[0]?.eventId,
|
|
718
|
-
* })(ctx => async (event: UserEvent) => {
|
|
719
|
-
* const headers = ctx.getTraceHeaders();
|
|
720
|
-
* await producer.send({
|
|
721
|
-
* topic: 'user-events',
|
|
722
|
-
* messages: [{
|
|
723
|
-
* key: event.userId,
|
|
724
|
-
* value: JSON.stringify(event),
|
|
725
|
-
* headers,
|
|
726
|
-
* }]
|
|
727
|
-
* });
|
|
728
|
-
* });
|
|
729
|
-
* ```
|
|
730
|
-
*
|
|
731
|
-
* @example SQS producer
|
|
732
|
-
* ```typescript
|
|
733
|
-
* export const sendToSQS = traceProducer({
|
|
734
|
-
* system: 'sqs',
|
|
735
|
-
* destination: 'orders-queue',
|
|
736
|
-
* })(ctx => async (order: Order) => {
|
|
737
|
-
* const headers = ctx.getAllPropagationHeaders();
|
|
738
|
-
* await sqs.sendMessage({
|
|
739
|
-
* QueueUrl: QUEUE_URL,
|
|
740
|
-
* MessageBody: JSON.stringify(order),
|
|
741
|
-
* MessageAttributes: headersToSQSAttributes(headers),
|
|
742
|
-
* });
|
|
743
|
-
* });
|
|
744
|
-
* ```
|
|
745
|
-
*/
|
|
746
705
|
declare function traceProducer(config: ProducerConfig): <TArgs extends unknown[], TReturn>(fnFactory: (ctx: ProducerContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
|
|
747
706
|
/**
|
|
748
707
|
* Create a traced message consumer function
|
|
@@ -812,10 +771,10 @@ declare function traceProducer(config: ProducerConfig): <TArgs extends unknown[]
|
|
|
812
771
|
* });
|
|
813
772
|
* ```
|
|
814
773
|
*/
|
|
815
|
-
declare function traceConsumer(
|
|
774
|
+
declare function traceConsumer<TMessage = unknown>(typedConfig: ConsumerConfig<TMessage>): <TArgs extends unknown[], TReturn>(fnFactory: (ctx: ConsumerContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
|
|
816
775
|
/**
|
|
817
776
|
* Clear sequence tracking state (useful for testing)
|
|
818
777
|
*/
|
|
819
778
|
declare function clearOrderingState(): void;
|
|
820
779
|
//#endregion
|
|
821
|
-
export { ConsumerConfig, ConsumerContext, ConsumerGroupState, ConsumerGroupTrackingConfig, DLQOptions, DLQReasonCategory, DLQReplayOptions, LagMetricsConfig, MessagingOperation, MessagingSystem, OrderingConfig, OutOfOrderInfo, PartitionAssignment, PartitionLag, ProducerConfig, ProducerContext, RebalanceEvent, RebalanceType, clearOrderingState, traceConsumer, traceProducer };
|
|
780
|
+
export { ConsumerConfig, ConsumerContext, ConsumerGroupState, ConsumerGroupTrackingConfig, DLQOptions, DLQReasonCategory, DLQReplayOptions, LagMetricsConfig, MessagingOperation, MessagingSystem, OrderingConfig, OutOfOrderInfo, PartitionAssignment, PartitionLag, ProducerConfig, ProducerContext, RebalanceEvent, RebalanceType, TraceHeaders, clearOrderingState, traceConsumer, traceProducer };
|
package/dist/messaging.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as TraceContext } from "./trace-context-
|
|
1
|
+
import { n as TraceContext } from "./trace-context-f89xPJbK.js";
|
|
2
2
|
import { Attributes, Link, SpanContext } from "@opentelemetry/api";
|
|
3
3
|
//#region src/messaging.d.ts
|
|
4
4
|
/**
|
|
@@ -83,7 +83,7 @@ interface ProducerConfig {
|
|
|
83
83
|
/**
|
|
84
84
|
* Configuration for consumer tracing
|
|
85
85
|
*/
|
|
86
|
-
interface ConsumerConfig {
|
|
86
|
+
interface ConsumerConfig<TMessage = unknown> {
|
|
87
87
|
/** Messaging system (kafka, rabbitmq, sqs, etc.) */
|
|
88
88
|
system: MessagingSystem;
|
|
89
89
|
/** Destination name (topic/queue) */
|
|
@@ -91,7 +91,7 @@ interface ConsumerConfig {
|
|
|
91
91
|
/** Consumer group name */
|
|
92
92
|
consumerGroup?: string;
|
|
93
93
|
/** Extract headers from message for link creation */
|
|
94
|
-
headersFrom?: string | ((msg:
|
|
94
|
+
headersFrom?: string | ((msg: TMessage) => Record<string, string> | undefined);
|
|
95
95
|
/** Enable batch mode - extract links from all messages */
|
|
96
96
|
batchMode?: boolean;
|
|
97
97
|
/** Extract baggage from message headers */
|
|
@@ -99,7 +99,7 @@ interface ConsumerConfig {
|
|
|
99
99
|
/** Additional attributes to set on span */
|
|
100
100
|
attributes?: Attributes;
|
|
101
101
|
/** Consumer lag metrics extraction */
|
|
102
|
-
lagMetrics?: LagMetricsConfig
|
|
102
|
+
lagMetrics?: LagMetricsConfig<TMessage>;
|
|
103
103
|
/** Callback when message goes to DLQ */
|
|
104
104
|
onDLQ?: (ctx: ConsumerContext, reason: string) => void;
|
|
105
105
|
/** Callback on error */
|
|
@@ -121,7 +121,7 @@ interface ConsumerConfig {
|
|
|
121
121
|
* }
|
|
122
122
|
* ```
|
|
123
123
|
*/
|
|
124
|
-
ordering?: OrderingConfig
|
|
124
|
+
ordering?: OrderingConfig<TMessage>;
|
|
125
125
|
/**
|
|
126
126
|
* Consumer group tracking configuration
|
|
127
127
|
*
|
|
@@ -168,7 +168,7 @@ interface ConsumerConfig {
|
|
|
168
168
|
* })
|
|
169
169
|
* ```
|
|
170
170
|
*/
|
|
171
|
-
customAttributes?: (ctx: ConsumerContext, msg:
|
|
171
|
+
customAttributes?: (ctx: ConsumerContext, msg: TMessage) => Attributes;
|
|
172
172
|
/**
|
|
173
173
|
* Hook for custom context extraction (beyond W3C traceparent)
|
|
174
174
|
*
|
|
@@ -209,20 +209,20 @@ interface ConsumerConfig {
|
|
|
209
209
|
/**
|
|
210
210
|
* Configuration for consumer lag metrics
|
|
211
211
|
*/
|
|
212
|
-
interface LagMetricsConfig {
|
|
212
|
+
interface LagMetricsConfig<TMessage = unknown> {
|
|
213
213
|
/** Get current message offset */
|
|
214
|
-
getCurrentOffset?: (msg:
|
|
214
|
+
getCurrentOffset?: (msg: TMessage) => number | undefined;
|
|
215
215
|
/** Get end offset (high watermark) - can be async */
|
|
216
216
|
getEndOffset?: () => number | Promise<number>;
|
|
217
217
|
/** Get committed offset - can be async */
|
|
218
218
|
getCommittedOffset?: () => number | Promise<number>;
|
|
219
219
|
/** Get partition from message */
|
|
220
|
-
getPartition?: (msg:
|
|
220
|
+
getPartition?: (msg: TMessage) => number | undefined;
|
|
221
221
|
}
|
|
222
222
|
/**
|
|
223
223
|
* Configuration for message ordering tracking
|
|
224
224
|
*/
|
|
225
|
-
interface OrderingConfig {
|
|
225
|
+
interface OrderingConfig<TMessage = unknown> {
|
|
226
226
|
/**
|
|
227
227
|
* Extract sequence number from message
|
|
228
228
|
*
|
|
@@ -233,7 +233,7 @@ interface OrderingConfig {
|
|
|
233
233
|
* sequenceFrom: (msg) => msg.offset
|
|
234
234
|
* ```
|
|
235
235
|
*/
|
|
236
|
-
sequenceFrom?: (msg:
|
|
236
|
+
sequenceFrom?: (msg: TMessage) => number | undefined;
|
|
237
237
|
/**
|
|
238
238
|
* Extract partition key from message
|
|
239
239
|
*
|
|
@@ -244,7 +244,7 @@ interface OrderingConfig {
|
|
|
244
244
|
* partitionKeyFrom: (msg) => msg.key
|
|
245
245
|
* ```
|
|
246
246
|
*/
|
|
247
|
-
partitionKeyFrom?: (msg:
|
|
247
|
+
partitionKeyFrom?: (msg: TMessage) => string | undefined;
|
|
248
248
|
/**
|
|
249
249
|
* Extract message ID for deduplication
|
|
250
250
|
*
|
|
@@ -255,7 +255,7 @@ interface OrderingConfig {
|
|
|
255
255
|
* messageIdFrom: (msg) => msg.headers['idempotency-key']
|
|
256
256
|
* ```
|
|
257
257
|
*/
|
|
258
|
-
messageIdFrom?: (msg:
|
|
258
|
+
messageIdFrom?: (msg: TMessage) => string | undefined;
|
|
259
259
|
/**
|
|
260
260
|
* Enable out-of-order detection
|
|
261
261
|
*
|
|
@@ -499,6 +499,11 @@ interface DLQReplayOptions {
|
|
|
499
499
|
/**
|
|
500
500
|
* Extended trace context for producers with header injection
|
|
501
501
|
*/
|
|
502
|
+
/** The W3C trace context headers a producer attaches to a message. */
|
|
503
|
+
interface TraceHeaders {
|
|
504
|
+
traceparent: string;
|
|
505
|
+
tracestate?: string;
|
|
506
|
+
}
|
|
502
507
|
interface ProducerContext extends TraceContext {
|
|
503
508
|
/**
|
|
504
509
|
* Get W3C trace context headers to inject into message
|
|
@@ -514,10 +519,7 @@ interface ProducerContext extends TraceContext {
|
|
|
514
519
|
* });
|
|
515
520
|
* ```
|
|
516
521
|
*/
|
|
517
|
-
getTraceHeaders():
|
|
518
|
-
traceparent: string;
|
|
519
|
-
tracestate?: string;
|
|
520
|
-
};
|
|
522
|
+
getTraceHeaders(): TraceHeaders;
|
|
521
523
|
/**
|
|
522
524
|
* Get all propagation headers including baggage if enabled
|
|
523
525
|
*
|
|
@@ -700,49 +702,6 @@ interface ConsumerContext extends TraceContext {
|
|
|
700
702
|
*/
|
|
701
703
|
getAssignedPartitions(): PartitionAssignment[];
|
|
702
704
|
}
|
|
703
|
-
/**
|
|
704
|
-
* Create a traced message producer function
|
|
705
|
-
*
|
|
706
|
-
* Sets SpanKind.PRODUCER, OTel messaging semantic attributes,
|
|
707
|
-
* and provides context injection helpers.
|
|
708
|
-
*
|
|
709
|
-
* @param config - Producer configuration
|
|
710
|
-
* @returns Factory function that wraps your producer logic
|
|
711
|
-
*
|
|
712
|
-
* @example Kafka producer
|
|
713
|
-
* ```typescript
|
|
714
|
-
* export const publishUserEvent = traceProducer({
|
|
715
|
-
* system: 'kafka',
|
|
716
|
-
* destination: 'user-events',
|
|
717
|
-
* messageIdFrom: (args) => args[0]?.eventId,
|
|
718
|
-
* })(ctx => async (event: UserEvent) => {
|
|
719
|
-
* const headers = ctx.getTraceHeaders();
|
|
720
|
-
* await producer.send({
|
|
721
|
-
* topic: 'user-events',
|
|
722
|
-
* messages: [{
|
|
723
|
-
* key: event.userId,
|
|
724
|
-
* value: JSON.stringify(event),
|
|
725
|
-
* headers,
|
|
726
|
-
* }]
|
|
727
|
-
* });
|
|
728
|
-
* });
|
|
729
|
-
* ```
|
|
730
|
-
*
|
|
731
|
-
* @example SQS producer
|
|
732
|
-
* ```typescript
|
|
733
|
-
* export const sendToSQS = traceProducer({
|
|
734
|
-
* system: 'sqs',
|
|
735
|
-
* destination: 'orders-queue',
|
|
736
|
-
* })(ctx => async (order: Order) => {
|
|
737
|
-
* const headers = ctx.getAllPropagationHeaders();
|
|
738
|
-
* await sqs.sendMessage({
|
|
739
|
-
* QueueUrl: QUEUE_URL,
|
|
740
|
-
* MessageBody: JSON.stringify(order),
|
|
741
|
-
* MessageAttributes: headersToSQSAttributes(headers),
|
|
742
|
-
* });
|
|
743
|
-
* });
|
|
744
|
-
* ```
|
|
745
|
-
*/
|
|
746
705
|
declare function traceProducer(config: ProducerConfig): <TArgs extends unknown[], TReturn>(fnFactory: (ctx: ProducerContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
|
|
747
706
|
/**
|
|
748
707
|
* Create a traced message consumer function
|
|
@@ -812,10 +771,10 @@ declare function traceProducer(config: ProducerConfig): <TArgs extends unknown[]
|
|
|
812
771
|
* });
|
|
813
772
|
* ```
|
|
814
773
|
*/
|
|
815
|
-
declare function traceConsumer(
|
|
774
|
+
declare function traceConsumer<TMessage = unknown>(typedConfig: ConsumerConfig<TMessage>): <TArgs extends unknown[], TReturn>(fnFactory: (ctx: ConsumerContext) => (...args: TArgs) => Promise<TReturn>) => ((...args: TArgs) => Promise<TReturn>);
|
|
816
775
|
/**
|
|
817
776
|
* Clear sequence tracking state (useful for testing)
|
|
818
777
|
*/
|
|
819
778
|
declare function clearOrderingState(): void;
|
|
820
779
|
//#endregion
|
|
821
|
-
export { ConsumerConfig, ConsumerContext, ConsumerGroupState, ConsumerGroupTrackingConfig, DLQOptions, DLQReasonCategory, DLQReplayOptions, LagMetricsConfig, MessagingOperation, MessagingSystem, OrderingConfig, OutOfOrderInfo, PartitionAssignment, PartitionLag, ProducerConfig, ProducerContext, RebalanceEvent, RebalanceType, clearOrderingState, traceConsumer, traceProducer };
|
|
780
|
+
export { ConsumerConfig, ConsumerContext, ConsumerGroupState, ConsumerGroupTrackingConfig, DLQOptions, DLQReasonCategory, DLQReplayOptions, LagMetricsConfig, MessagingOperation, MessagingSystem, OrderingConfig, OutOfOrderInfo, PartitionAssignment, PartitionLag, ProducerConfig, ProducerContext, RebalanceEvent, RebalanceType, TraceHeaders, clearOrderingState, traceConsumer, traceProducer };
|
package/dist/messaging.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { _ as readProperty, b as toAttributeValue, c as asScalar, g as nonEmptyString, h as isFunction, s as asRecord, v as resolveValue, y as splitNameOrOptions } from "./values-BenyvWKz.js";
|
|
1
2
|
import { createLinkFromHeaders, extractLinksFromBatch } from "./sampling.js";
|
|
2
|
-
import { c as withTracing } from "./functional-
|
|
3
|
-
import { t as emitCorrelatedEvent } from "./correlated-events-
|
|
3
|
+
import { c as withTracing } from "./functional-uSbNnnxK.js";
|
|
4
|
+
import { t as emitCorrelatedEvent } from "./correlated-events-DwMMbItg.js";
|
|
4
5
|
import { t as assertTraceFactory } from "./trace-factory-validation-BjVAinz6.js";
|
|
5
6
|
import { SpanKind, context, propagation } from "@opentelemetry/api";
|
|
6
7
|
|
|
@@ -90,10 +91,22 @@ import { SpanKind, context, propagation } from "@opentelemetry/api";
|
|
|
90
91
|
* });
|
|
91
92
|
* ```
|
|
92
93
|
*/
|
|
94
|
+
/** The Error an onError callback expects, wrapping a non-Error rejection. */
|
|
95
|
+
function toError(cause) {
|
|
96
|
+
return cause instanceof Error ? cause : new Error(String(cause));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Check a config a JavaScript caller may have built by hand. TypeScript has
|
|
100
|
+
* already checked it for everyone else, so this only has to catch the shapes
|
|
101
|
+
* that reach here untyped.
|
|
102
|
+
*/
|
|
103
|
+
function assertMessagingConfig(fn, config) {
|
|
104
|
+
const record = asRecord(config);
|
|
105
|
+
if (!record) throw new TypeError(`${fn}: config must be an object`);
|
|
106
|
+
for (const field of ["system", "destination"]) if (nonEmptyString(record[field]) === void 0) throw new TypeError(`${fn}: config.${field} must be a non-empty string`);
|
|
107
|
+
}
|
|
93
108
|
function traceProducer(config) {
|
|
94
|
-
|
|
95
|
-
if (typeof config.system !== "string" || config.system.trim() === "") throw new TypeError("traceProducer: config.system must be a non-empty string");
|
|
96
|
-
if (typeof config.destination !== "string" || config.destination.trim() === "") throw new TypeError("traceProducer: config.destination must be a non-empty string");
|
|
109
|
+
assertMessagingConfig("traceProducer", config);
|
|
97
110
|
const spanName = `publish ${config.destination}`;
|
|
98
111
|
return (fnFactory) => {
|
|
99
112
|
assertTraceFactory("traceProducer", fnFactory);
|
|
@@ -113,7 +126,7 @@ function traceProducer(config) {
|
|
|
113
126
|
const userFn = fnFactory(ctx);
|
|
114
127
|
assertTraceFactory("traceProducer", userFn, "result");
|
|
115
128
|
return Promise.resolve(userFn(...args)).catch((error) => {
|
|
116
|
-
if (config.onError) config.onError(error, ctx);
|
|
129
|
+
if (config.onError) config.onError(toError(error), ctx);
|
|
117
130
|
throw error;
|
|
118
131
|
});
|
|
119
132
|
};
|
|
@@ -188,10 +201,9 @@ function traceProducer(config) {
|
|
|
188
201
|
* });
|
|
189
202
|
* ```
|
|
190
203
|
*/
|
|
191
|
-
function traceConsumer(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (typeof config.destination !== "string" || config.destination.trim() === "") throw new TypeError("traceConsumer: config.destination must be a non-empty string");
|
|
204
|
+
function traceConsumer(typedConfig) {
|
|
205
|
+
const config = typedConfig;
|
|
206
|
+
assertMessagingConfig("traceConsumer", config);
|
|
195
207
|
const spanName = `${config.batchMode ? "receive" : "process"} ${config.destination}`;
|
|
196
208
|
return (fnFactory) => {
|
|
197
209
|
assertTraceFactory("traceConsumer", fnFactory);
|
|
@@ -208,15 +220,16 @@ function traceConsumer(config) {
|
|
|
208
220
|
outOfOrderInfo: null
|
|
209
221
|
};
|
|
210
222
|
const groupTracking = config.consumerGroupTracking;
|
|
211
|
-
const
|
|
212
|
-
memberId:
|
|
213
|
-
groupInstanceId:
|
|
223
|
+
const groupState = {
|
|
224
|
+
memberId: resolveValue(groupTracking?.memberId) ?? null,
|
|
225
|
+
groupInstanceId: resolveValue(groupTracking?.groupInstanceId) ?? null,
|
|
214
226
|
assignedPartitions: [],
|
|
215
227
|
generation: null,
|
|
216
228
|
isActive: true,
|
|
217
229
|
lastHeartbeat: null,
|
|
218
230
|
state: null
|
|
219
|
-
}
|
|
231
|
+
};
|
|
232
|
+
const ctx = extendContextForConsumer(baseCtx, config, linkStorage, orderingState, groupState);
|
|
220
233
|
setConsumerAttributes(ctx, config);
|
|
221
234
|
return async (...args) => {
|
|
222
235
|
await extractAndAddLinks(ctx, config, args, linkStorage);
|
|
@@ -233,7 +246,7 @@ function traceConsumer(config) {
|
|
|
233
246
|
const userFn = fnFactory(ctx);
|
|
234
247
|
assertTraceFactory("traceConsumer", userFn, "result");
|
|
235
248
|
return Promise.resolve(userFn(...args)).catch((error) => {
|
|
236
|
-
if (config.onError) config.onError(error, ctx);
|
|
249
|
+
if (config.onError) config.onError(toError(error), ctx);
|
|
237
250
|
throw error;
|
|
238
251
|
});
|
|
239
252
|
};
|
|
@@ -306,12 +319,8 @@ function extendContextForConsumer(baseCtx, config, linkStorage, orderingState, g
|
|
|
306
319
|
const consumerCtx = {
|
|
307
320
|
...baseCtx,
|
|
308
321
|
recordDLQ(reason, dlqNameOrOptions, optionsParam) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (typeof dlqNameOrOptions === "string") {
|
|
312
|
-
dlqName = dlqNameOrOptions;
|
|
313
|
-
options = optionsParam;
|
|
314
|
-
} else if (typeof dlqNameOrOptions === "object") options = dlqNameOrOptions;
|
|
322
|
+
const { name: dlqName, options: inlineOptions } = splitNameOrOptions(dlqNameOrOptions);
|
|
323
|
+
const options = dlqName === void 0 ? inlineOptions : optionsParam;
|
|
315
324
|
const linkToProducer = options?.linkToProducer ?? true;
|
|
316
325
|
baseCtx.setAttribute("messaging.dlq.reason", reason);
|
|
317
326
|
if (dlqName) baseCtx.setAttribute("messaging.dlq.name", dlqName);
|
|
@@ -604,29 +613,23 @@ async function extractLagMetrics(ctx, lagConfig, args) {
|
|
|
604
613
|
* Extract headers from message using config
|
|
605
614
|
*/
|
|
606
615
|
function extractHeaders(headersFrom, msg) {
|
|
607
|
-
if (
|
|
608
|
-
|
|
609
|
-
const value = msg[headersFrom];
|
|
610
|
-
if (typeof value === "object" && value !== null) return value;
|
|
611
|
-
}
|
|
616
|
+
if (isFunction(headersFrom)) return headersFrom(msg);
|
|
617
|
+
return asRecord(readProperty(msg, headersFrom));
|
|
612
618
|
}
|
|
613
619
|
/**
|
|
614
620
|
* Extract value from arguments using config
|
|
615
621
|
*/
|
|
616
622
|
function extractValue(extractor, args) {
|
|
617
|
-
|
|
618
|
-
const firstArg = args[0];
|
|
619
|
-
if (typeof firstArg === "object" && firstArg !== null) return firstArg[extractor];
|
|
623
|
+
return isFunction(extractor) ? extractor(args) : asScalar(readProperty(args[0], extractor));
|
|
620
624
|
}
|
|
621
625
|
/**
|
|
622
626
|
* Set custom attributes on context, handling non-primitive values
|
|
623
627
|
*/
|
|
624
628
|
function setCustomAttributes(ctx, attributes) {
|
|
625
|
-
for (const [key, value] of Object.entries(attributes))
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
} else ctx.setAttribute(key, JSON.stringify(value));
|
|
629
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
630
|
+
const attribute = toAttributeValue(value);
|
|
631
|
+
if (attribute !== void 0) ctx.setAttribute(key, attribute);
|
|
632
|
+
}
|
|
630
633
|
}
|
|
631
634
|
/**
|
|
632
635
|
* Extract and process ordering information from message
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { c as FunnelStatus, l as OutcomeStatus, r as EventAttributes } from "./event-subscriber-DMACQA-1.cjs";
|
|
2
2
|
//#region src/metric-testing.d.ts
|
|
3
3
|
interface MetricsEvent {
|
|
4
4
|
event: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { c as FunnelStatus, l as OutcomeStatus, r as EventAttributes } from "./event-subscriber-DMACQA-1.js";
|
|
2
2
|
//#region src/metric-testing.d.ts
|
|
3
3
|
interface MetricsEvent {
|
|
4
4
|
event: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MetricsValue, c as createMetricsCollector, i as MetricsOutcome, n as MetricsEvent, o as assertEventTracked, r as MetricsFunnelStep, s as assertOutcomeTracked, t as MetricsCollector } from "./metric-testing-
|
|
1
|
+
import { a as MetricsValue, c as createMetricsCollector, i as MetricsOutcome, n as MetricsEvent, o as assertEventTracked, r as MetricsFunnelStep, s as assertOutcomeTracked, t as MetricsCollector } from "./metric-testing-86WO1wan.cjs";
|
|
2
2
|
export { MetricsCollector, MetricsEvent, MetricsFunnelStep, MetricsOutcome, MetricsValue, assertEventTracked, assertOutcomeTracked, createMetricsCollector };
|
package/dist/metric-testing.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MetricsValue, c as createMetricsCollector, i as MetricsOutcome, n as MetricsEvent, o as assertEventTracked, r as MetricsFunnelStep, s as assertOutcomeTracked, t as MetricsCollector } from "./metric-testing-
|
|
1
|
+
import { a as MetricsValue, c as createMetricsCollector, i as MetricsOutcome, n as MetricsEvent, o as assertEventTracked, r as MetricsFunnelStep, s as assertOutcomeTracked, t as MetricsCollector } from "./metric-testing-CbCxdPBp.js";
|
|
2
2
|
export { MetricsCollector, MetricsEvent, MetricsFunnelStep, MetricsOutcome, MetricsValue, assertEventTracked, assertOutcomeTracked, createMetricsCollector };
|
package/dist/metric.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { s as Logger } from "./logger-
|
|
2
|
-
import { c as
|
|
3
|
-
import { t as MetricsCollector } from "./metric-testing-
|
|
1
|
+
import { s as Logger } from "./logger-S1Fgl0g3.cjs";
|
|
2
|
+
import { c as FunnelStatus, l as OutcomeStatus, r as EventAttributes } from "./event-subscriber-DMACQA-1.cjs";
|
|
3
|
+
import { t as MetricsCollector } from "./metric-testing-86WO1wan.cjs";
|
|
4
4
|
//#region src/metric.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Metrics class for tracking business metrics in OpenTelemetry
|
package/dist/metric.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { s as Logger } from "./logger-
|
|
2
|
-
import { c as
|
|
3
|
-
import { t as MetricsCollector } from "./metric-testing-
|
|
1
|
+
import { s as Logger } from "./logger-S1Fgl0g3.js";
|
|
2
|
+
import { c as FunnelStatus, l as OutcomeStatus, r as EventAttributes } from "./event-subscriber-DMACQA-1.js";
|
|
3
|
+
import { t as MetricsCollector } from "./metric-testing-CbCxdPBp.js";
|
|
4
4
|
//#region src/metric.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Metrics class for tracking business metrics in OpenTelemetry
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ as readProperty, l as asString } from "./values-BenyvWKz.js";
|
|
1
2
|
import * as nodeModule from "node:module";
|
|
2
3
|
|
|
3
4
|
//#region src/node-require.ts
|
|
@@ -14,7 +15,7 @@ import * as nodeModule from "node:module";
|
|
|
14
15
|
let cachedRequire;
|
|
15
16
|
function getNodeRequire() {
|
|
16
17
|
if (cachedRequire) return cachedRequire;
|
|
17
|
-
const base =
|
|
18
|
+
const base = asString(globalThis.__filename) ?? import.meta.url;
|
|
18
19
|
if (!base) throw Object.assign(/* @__PURE__ */ new Error("node require() is unavailable in this runtime"), { code: "MODULE_NOT_FOUND" });
|
|
19
20
|
cachedRequire = nodeModule.createRequire(base);
|
|
20
21
|
return cachedRequire;
|
|
@@ -40,7 +41,7 @@ function safeRequire(id) {
|
|
|
40
41
|
try {
|
|
41
42
|
return getNodeRequire()(id);
|
|
42
43
|
} catch (error) {
|
|
43
|
-
if (error
|
|
44
|
+
if (asString(readProperty(error, "code")) === "MODULE_NOT_FOUND") return;
|
|
44
45
|
throw error;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./rolldown-runtime-C_NdSu1c.cjs');
|
|
2
|
+
const require_values = require('./values-DApyq53y.cjs');
|
|
2
3
|
let node_module = require("node:module");
|
|
3
4
|
node_module = require_rolldown_runtime.__toESM(node_module, 1);
|
|
4
5
|
|
|
@@ -16,7 +17,7 @@ node_module = require_rolldown_runtime.__toESM(node_module, 1);
|
|
|
16
17
|
let cachedRequire;
|
|
17
18
|
function getNodeRequire() {
|
|
18
19
|
if (cachedRequire) return cachedRequire;
|
|
19
|
-
const base =
|
|
20
|
+
const base = require_values.asString(globalThis.__filename) ?? require("url").pathToFileURL(__filename).href;
|
|
20
21
|
if (!base) throw Object.assign(/* @__PURE__ */ new Error("node require() is unavailable in this runtime"), { code: "MODULE_NOT_FOUND" });
|
|
21
22
|
cachedRequire = node_module.createRequire(base);
|
|
22
23
|
return cachedRequire;
|
|
@@ -42,7 +43,7 @@ function safeRequire(id) {
|
|
|
42
43
|
try {
|
|
43
44
|
return getNodeRequire()(id);
|
|
44
45
|
} catch (error) {
|
|
45
|
-
if (error
|
|
46
|
+
if (require_values.asString(require_values.readProperty(error, "code")) === "MODULE_NOT_FOUND") return;
|
|
46
47
|
throw error;
|
|
47
48
|
}
|
|
48
49
|
}
|
package/dist/parse-error.cjs
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_values = require('./values-DApyq53y.cjs');
|
|
2
3
|
|
|
3
4
|
//#region src/parse-error.ts
|
|
5
|
+
/** An HTTP-ish status, however the library that threw chose to spell it. */
|
|
4
6
|
function toStatus(value) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const n = Number(value);
|
|
8
|
-
if (Number.isFinite(n)) return n;
|
|
9
|
-
}
|
|
7
|
+
const text = require_values.asString(value);
|
|
8
|
+
return text === void 0 ? require_values.asNumber(value) : require_values.asNumber(Number(text)) ?? void 0;
|
|
10
9
|
}
|
|
11
10
|
function pickString(value) {
|
|
12
|
-
|
|
11
|
+
const text = require_values.asString(value);
|
|
12
|
+
return text !== void 0 && text.length > 0 ? text : void 0;
|
|
13
13
|
}
|
|
14
14
|
function pickCode(value) {
|
|
15
|
-
|
|
15
|
+
return require_values.asString(value) ?? require_values.asNumber(value);
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* A plain object of extra fields. Only a plain one: an Error, a Response or a
|
|
19
|
+
* class instance carries behaviour, and copying it onto a log line as details
|
|
20
|
+
* would serialise something the thrower never meant to publish.
|
|
21
|
+
*/
|
|
17
22
|
function pickDetails(value) {
|
|
18
|
-
|
|
23
|
+
const record = require_values.asRecord(value);
|
|
24
|
+
return record?.constructor === Object ? record : void 0;
|
|
19
25
|
}
|
|
20
26
|
function parseError(error) {
|
|
21
27
|
if (error instanceof Error) {
|
|
@@ -31,10 +37,10 @@ function parseError(error) {
|
|
|
31
37
|
raw: error
|
|
32
38
|
};
|
|
33
39
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const data =
|
|
37
|
-
const payload = (
|
|
40
|
+
const err = require_values.asRecord(error);
|
|
41
|
+
if (err) {
|
|
42
|
+
const data = require_values.asRecord(err.data);
|
|
43
|
+
const payload = require_values.asRecord(require_values.readProperty(data, "data")) ?? data;
|
|
38
44
|
return {
|
|
39
45
|
message: pickString(data?.statusText) || pickString(data?.statusMessage) || pickString(data?.message) || pickString(payload?.statusText) || pickString(payload?.statusMessage) || pickString(payload?.message) || pickString(err.message) || "An error occurred",
|
|
40
46
|
status: toStatus(payload?.status) || toStatus(payload?.statusCode) || toStatus(err.status) || toStatus(err.statusCode) || 500,
|