unnbound-logger-sdk 3.0.37 → 3.1.0-beta.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/dist/axios.d.ts CHANGED
@@ -8,18 +8,19 @@ export type OnRequest = (config: AxiosRequestConfig, callback: (config: AxiosReq
8
8
  interface HttpClientOptions extends HttpOptions<GetPayload> {
9
9
  onRequest?: OnRequest;
10
10
  redact?: RedactOptions | boolean;
11
+ /**
12
+ * Propagate correlation headers but emit no request/response logs, in every
13
+ * environment. For internal platform transports whose payloads must never become
14
+ * customer-visible (e.g. AS2 envelopes and MDNs) — unlike the `internal()` payload
15
+ * marker, suppression does not depend on runtime env vars.
16
+ */
17
+ silent?: boolean;
11
18
  }
12
19
  /**
13
- * Wraps an axios instance to add tracing and span tracking.
14
- *
15
- * Idempotent: wrapping an already-wrapped instance returns it unchanged (the second
16
- * call's options are ignored). Wrapping mutates the instance in place, so without the
17
- * guard each call nests another span layer around the previous wrapper — long-lived
18
- * processes that construct clients repeatedly accumulate layers until a single request
19
- * overflows the stack (T-3235).
20
- * @param client - The axios instance to wrap
20
+ * Wraps an axios instance to add tracing and span tracking
21
+ * @param axios - The axios instance to wrap
21
22
  * @param options - Configuration options for HTTP tracing
22
23
  * @returns The wrapped axios instance with span tracking
23
24
  */
24
- export declare const traceAxios: (client: AxiosInstance, { ignoreTraceRoutes, traceHeaderKey, getPayload, onRequest, redact: redactOptions, }?: HttpClientOptions) => AxiosInstance;
25
+ export declare const traceAxios: (client: AxiosInstance, { ignoreTraceRoutes, traceHeaderKey, getPayload, onRequest, redact: redactOptions, silent, }?: HttpClientOptions) => AxiosInstance;
25
26
  export {};
package/dist/axios.js CHANGED
@@ -37,29 +37,18 @@ const buildOutgoingHttpPayload = (config, res, redact) => ({
37
37
  });
38
38
  const getNoopPayload = () => ({});
39
39
  const onNoopRequest = (config, callback) => callback(config);
40
- // Global-registry symbol so the guard holds even when several copies of this SDK
41
- // coexist in one process (e.g. a workflow's own copy plus one nested under another SDK).
42
- const tracedMarker = Symbol.for('unnbound-logger-sdk.traceAxios.traced');
43
40
  /**
44
- * Wraps an axios instance to add tracing and span tracking.
45
- *
46
- * Idempotent: wrapping an already-wrapped instance returns it unchanged (the second
47
- * call's options are ignored). Wrapping mutates the instance in place, so without the
48
- * guard each call nests another span layer around the previous wrapper — long-lived
49
- * processes that construct clients repeatedly accumulate layers until a single request
50
- * overflows the stack (T-3235).
51
- * @param client - The axios instance to wrap
41
+ * Wraps an axios instance to add tracing and span tracking
42
+ * @param axios - The axios instance to wrap
52
43
  * @param options - Configuration options for HTTP tracing
53
44
  * @returns The wrapped axios instance with span tracking
54
45
  */
55
- const traceAxios = (client, { ignoreTraceRoutes = types_1.defaultIgnoreTraceRoutes, traceHeaderKey = types_1.defaultTraceHeaderKey, getPayload = getNoopPayload, onRequest = onNoopRequest, redact: redactOptions, } = {
46
+ const traceAxios = (client, { ignoreTraceRoutes = types_1.defaultIgnoreTraceRoutes, traceHeaderKey = types_1.defaultTraceHeaderKey, getPayload = getNoopPayload, onRequest = onNoopRequest, redact: redactOptions, silent = false, } = {
56
47
  ignoreTraceRoutes: types_1.defaultIgnoreTraceRoutes,
57
48
  traceHeaderKey: types_1.defaultTraceHeaderKey,
58
49
  getPayload: getNoopPayload,
59
50
  onRequest: onNoopRequest,
60
51
  }) => {
61
- if (tracedMarker in client)
62
- return client;
63
52
  const redact = typeof redactOptions === 'boolean' ? { response: redactOptions } : redactOptions;
64
53
  const createSpanWrappedRequest = (originalMethod, method) => {
65
54
  const { headers: defaultHeaders, ...partialDefaultConfig } = client.defaults;
@@ -73,6 +62,8 @@ const traceAxios = (client, { ignoreTraceRoutes = types_1.defaultIgnoreTraceRout
73
62
  return originalMethod(config);
74
63
  const traceId = storage_1.storage.getStore()?.traceId;
75
64
  config = { ...config, headers: { ...config.headers, [traceHeaderKey]: traceId } };
65
+ if (silent)
66
+ return onRequest(config, (config) => originalMethod(config));
76
67
  return onRequest(config, (config) => {
77
68
  // Execute the request within a span
78
69
  return (0, span_1.startSpan)('Outgoing HTTP request', () => originalMethod(config), (options) => {
@@ -102,7 +93,6 @@ const traceAxios = (client, { ignoreTraceRoutes = types_1.defaultIgnoreTraceRout
102
93
  const func = createSpanWrappedRequest(request, method);
103
94
  client[method] = (url, config) => func({ ...config, method, url });
104
95
  });
105
- Object.defineProperty(client, tracedMarker, { value: true });
106
96
  return client;
107
97
  };
108
98
  exports.traceAxios = traceAxios;
package/dist/index.d.ts CHANGED
@@ -15,5 +15,5 @@ export { startSpan } from './span';
15
15
  export type { UnnboundContext } from './storage';
16
16
  export { storage, withStorage } from './storage';
17
17
  export { getTraceId, withTrace } from './trace';
18
- export type { EdiFormat, EdiOperation, EdiPayload, EdiX12Operation, EdiX12Payload, EventSource, HttpMethod, HttpPayload, Log, LogLevel, LogType, Maybe, SftpPayload, } from './types';
18
+ export type { As2Operation, As2Outcome, As2Payload, EdiFormat, EdiOperation, EdiPayload, EdiX12Operation, EdiX12Payload, EventSource, HttpMethod, HttpPayload, Log, LogLevel, LogType, Maybe, SftpPayload, } from './types';
19
19
  export { defaultMessageHeaderKey, defaultTraceHeaderKey } from './types';
package/dist/logger.js CHANGED
@@ -11,6 +11,7 @@ const internal_1 = require("./internal");
11
11
  const storage_1 = require("./storage");
12
12
  const levels = new Set(['debug', 'info', 'warn', 'error']);
13
13
  const workflowEnvironment = process.env.WORKFLOW_ENV ?? process.env.UNNBOUND_ENVIRONMENT ?? process.env.ENVIRONMENT;
14
+ const stackEnvironment = process.env.ENVIRONMENT ?? process.env.APP_ENV;
14
15
  const formatLevel = (level) => ({ level });
15
16
  const formatLog = (log, visited = new WeakSet()) => {
16
17
  // Prevent infinite loops from circular references
@@ -54,10 +55,8 @@ const formatLog = (log, visited = new WeakSet()) => {
54
55
  const loggerOptions = {
55
56
  level: process.env.LOG_LEVEL ?? 'debug',
56
57
  base: {
57
- // The Pulumi stack name is internal platform vocabulary — never stamp it into
58
- // the customer-visible envelope (T-3235). Platform stack attribution flows via
59
- // OTel resource attributes into the ClickHouse `stack` column instead (T-2236).
60
58
  environment: workflowEnvironment,
59
+ stack: stackEnvironment,
61
60
  workflowId: process.env.UNNBOUND_WORKFLOW_ID,
62
61
  serviceId: process.env.UNNBOUND_SERVICE_ID,
63
62
  deploymentId: process.env.UNNBOUND_DEPLOYMENT_ID,
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type LogLevel = 'info' | 'debug' | 'error' | 'warn';
2
- export type LogType = 'general' | 'http' | 'sftp' | 'edi';
2
+ export type LogType = 'general' | 'http' | 'sftp' | 'edi' | 'as2';
3
3
  export type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head';
4
4
  export type EventSource = 'http' | 'queue';
5
5
  export type Maybe<T> = {
@@ -22,6 +22,7 @@ export interface Log<T extends LogType = 'general'> {
22
22
  http: T extends 'http' ? HttpPayload : never;
23
23
  sftp: T extends 'sftp' ? SftpPayload : never;
24
24
  edi: T extends 'edi' ? EdiPayload : never;
25
+ as2: T extends 'as2' ? As2Payload : never;
25
26
  duration?: number;
26
27
  err?: unknown;
27
28
  }
@@ -63,6 +64,39 @@ export interface EdiPayload {
63
64
  type: EdiFormat;
64
65
  x12?: EdiX12Payload;
65
66
  }
67
+ export type As2Operation = 'send' | 'deliver' | 'receive' | 'acknowledge' | 'mdn-generate' | 'mdn-deliver' | 'mdn-verify';
68
+ export type As2Outcome = 'confirmed' | 'failed' | 'pending' | 'received' | 'duplicate' | 'inFlight' | 'parked' | 'delivered' | 'generated' | 'verified';
69
+ /**
70
+ * Customer-visible AS2 protocol milestone. Metadata only, by contract: AS2 transport
71
+ * bodies are plaintext business documents, sealed envelopes, and signed MDNs, so this
72
+ * payload must never carry bodies, full URLs, tokens, or certificate material.
73
+ */
74
+ export interface As2Payload {
75
+ operation: As2Operation;
76
+ /** AS2 protocol Message-ID. The log root's messageId stays the Temper event identifier. */
77
+ messageId?: string;
78
+ /** Original-Message-ID of the message an MDN settles. */
79
+ originalMessageId?: string;
80
+ /** Customer trace that originated the transaction, linked from async callback traces. */
81
+ originatingTraceId?: string;
82
+ /** Partner config reference (a variable name), never a URL or certificate. */
83
+ partner?: string;
84
+ /** Destination host only — never full URLs or query strings. */
85
+ host?: string;
86
+ byteLength?: number;
87
+ contentType?: string;
88
+ mdnMode?: 'sync' | 'async';
89
+ replayed?: boolean;
90
+ attempt?: number;
91
+ /** HTTP status of a delivery POST. */
92
+ status?: number;
93
+ outcome?: As2Outcome;
94
+ /** Normalized MDN disposition, e.g. "automatic-action/MDN-sent-automatically; processed". */
95
+ disposition?: string;
96
+ micMatched?: boolean;
97
+ /** Normalized safe error code (As2SdkError.code), never a stack trace. */
98
+ errorCode?: string;
99
+ }
66
100
  export interface HttpOptions<G extends Function> {
67
101
  ignoreTraceRoutes?: string[];
68
102
  traceHeaderKey?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unnbound-logger-sdk",
3
3
  "description": "A structured logging library with TypeScript support using Pino. Provides consistent, well-typed logging with automatic logId, workflowId, traceId, and deploymentId tracking across operational contexts.",
4
- "version": "3.0.37",
4
+ "version": "3.1.0-beta.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "keywords": [