@bleedingdev/modern-js-create-request 3.2.0-ultramodern.9 → 3.2.0-ultramodern.90

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.
@@ -52,6 +52,25 @@ function parseTraceparent(traceparent) {
52
52
  spanId: spanId.toLowerCase()
53
53
  };
54
54
  }
55
+ function createOperationContextSnapshot(operationContext, safeContext) {
56
+ if (!operationContext) return;
57
+ const snapshot = {
58
+ ...operationContext,
59
+ ...safeContext.locale || operationContext?.locale ? {
60
+ locale: safeContext.locale || operationContext?.locale
61
+ } : {},
62
+ ...safeContext.traceparent || operationContext?.traceparent ? {
63
+ traceparent: safeContext.traceparent || operationContext?.traceparent
64
+ } : {},
65
+ ...safeContext.traceId || operationContext?.traceId ? {
66
+ traceId: safeContext.traceId || operationContext?.traceId
67
+ } : {},
68
+ ...safeContext.spanId || operationContext?.spanId ? {
69
+ spanId: safeContext.spanId || operationContext?.spanId
70
+ } : {}
71
+ };
72
+ return Object.keys(snapshot).some((key)=>void 0 !== snapshot[key]) ? snapshot : void 0;
73
+ }
55
74
  function createRequestContextSnapshot(input = {}) {
56
75
  const locale = readString(input.locale) || readString(readHeader(input.headers, BFF_LOCALE_HEADER));
57
76
  const traceparent = readString(input.traceparent) || readString(input.operationContext?.traceparent) || readString(readHeader(input.headers, BFF_TRACEPARENT_HEADER));
@@ -62,6 +81,18 @@ function createRequestContextSnapshot(input = {}) {
62
81
  const headers = {};
63
82
  if (locale) headers[BFF_LOCALE_HEADER] = locale;
64
83
  if (traceparent) headers[BFF_TRACEPARENT_HEADER] = traceparent;
84
+ const operationContext = createOperationContextSnapshot(input.operationContext, {
85
+ ...locale ? {
86
+ locale
87
+ } : {},
88
+ ...traceparent ? {
89
+ traceparent
90
+ } : {},
91
+ ...parsedTraceparent ? {
92
+ traceId: parsedTraceparent.traceId,
93
+ spanId: parsedTraceparent.spanId
94
+ } : {}
95
+ });
65
96
  return {
66
97
  headers,
67
98
  ...locale ? {
@@ -73,6 +104,9 @@ function createRequestContextSnapshot(input = {}) {
73
104
  ...parsedTraceparent ? {
74
105
  traceId: parsedTraceparent.traceId,
75
106
  spanId: parsedTraceparent.spanId
107
+ } : {},
108
+ ...operationContext ? {
109
+ operationContext
76
110
  } : {}
77
111
  };
78
112
  }
@@ -21,6 +21,25 @@ function parseTraceparent(traceparent) {
21
21
  spanId: spanId.toLowerCase()
22
22
  };
23
23
  }
24
+ function createOperationContextSnapshot(operationContext, safeContext) {
25
+ if (!operationContext) return;
26
+ const snapshot = {
27
+ ...operationContext,
28
+ ...safeContext.locale || operationContext?.locale ? {
29
+ locale: safeContext.locale || operationContext?.locale
30
+ } : {},
31
+ ...safeContext.traceparent || operationContext?.traceparent ? {
32
+ traceparent: safeContext.traceparent || operationContext?.traceparent
33
+ } : {},
34
+ ...safeContext.traceId || operationContext?.traceId ? {
35
+ traceId: safeContext.traceId || operationContext?.traceId
36
+ } : {},
37
+ ...safeContext.spanId || operationContext?.spanId ? {
38
+ spanId: safeContext.spanId || operationContext?.spanId
39
+ } : {}
40
+ };
41
+ return Object.keys(snapshot).some((key)=>void 0 !== snapshot[key]) ? snapshot : void 0;
42
+ }
24
43
  function createRequestContextSnapshot(input = {}) {
25
44
  const locale = readString(input.locale) || readString(readHeader(input.headers, BFF_LOCALE_HEADER));
26
45
  const traceparent = readString(input.traceparent) || readString(input.operationContext?.traceparent) || readString(readHeader(input.headers, BFF_TRACEPARENT_HEADER));
@@ -31,6 +50,18 @@ function createRequestContextSnapshot(input = {}) {
31
50
  const headers = {};
32
51
  if (locale) headers[BFF_LOCALE_HEADER] = locale;
33
52
  if (traceparent) headers[BFF_TRACEPARENT_HEADER] = traceparent;
53
+ const operationContext = createOperationContextSnapshot(input.operationContext, {
54
+ ...locale ? {
55
+ locale
56
+ } : {},
57
+ ...traceparent ? {
58
+ traceparent
59
+ } : {},
60
+ ...parsedTraceparent ? {
61
+ traceId: parsedTraceparent.traceId,
62
+ spanId: parsedTraceparent.spanId
63
+ } : {}
64
+ });
34
65
  return {
35
66
  headers,
36
67
  ...locale ? {
@@ -42,6 +73,9 @@ function createRequestContextSnapshot(input = {}) {
42
73
  ...parsedTraceparent ? {
43
74
  traceId: parsedTraceparent.traceId,
44
75
  spanId: parsedTraceparent.spanId
76
+ } : {},
77
+ ...operationContext ? {
78
+ operationContext
45
79
  } : {}
46
80
  };
47
81
  }
@@ -22,6 +22,25 @@ function parseTraceparent(traceparent) {
22
22
  spanId: spanId.toLowerCase()
23
23
  };
24
24
  }
25
+ function createOperationContextSnapshot(operationContext, safeContext) {
26
+ if (!operationContext) return;
27
+ const snapshot = {
28
+ ...operationContext,
29
+ ...safeContext.locale || operationContext?.locale ? {
30
+ locale: safeContext.locale || operationContext?.locale
31
+ } : {},
32
+ ...safeContext.traceparent || operationContext?.traceparent ? {
33
+ traceparent: safeContext.traceparent || operationContext?.traceparent
34
+ } : {},
35
+ ...safeContext.traceId || operationContext?.traceId ? {
36
+ traceId: safeContext.traceId || operationContext?.traceId
37
+ } : {},
38
+ ...safeContext.spanId || operationContext?.spanId ? {
39
+ spanId: safeContext.spanId || operationContext?.spanId
40
+ } : {}
41
+ };
42
+ return Object.keys(snapshot).some((key)=>void 0 !== snapshot[key]) ? snapshot : void 0;
43
+ }
25
44
  function createRequestContextSnapshot(input = {}) {
26
45
  const locale = readString(input.locale) || readString(readHeader(input.headers, BFF_LOCALE_HEADER));
27
46
  const traceparent = readString(input.traceparent) || readString(input.operationContext?.traceparent) || readString(readHeader(input.headers, BFF_TRACEPARENT_HEADER));
@@ -32,6 +51,18 @@ function createRequestContextSnapshot(input = {}) {
32
51
  const headers = {};
33
52
  if (locale) headers[BFF_LOCALE_HEADER] = locale;
34
53
  if (traceparent) headers[BFF_TRACEPARENT_HEADER] = traceparent;
54
+ const operationContext = createOperationContextSnapshot(input.operationContext, {
55
+ ...locale ? {
56
+ locale
57
+ } : {},
58
+ ...traceparent ? {
59
+ traceparent
60
+ } : {},
61
+ ...parsedTraceparent ? {
62
+ traceId: parsedTraceparent.traceId,
63
+ spanId: parsedTraceparent.spanId
64
+ } : {}
65
+ });
35
66
  return {
36
67
  headers,
37
68
  ...locale ? {
@@ -43,6 +74,9 @@ function createRequestContextSnapshot(input = {}) {
43
74
  ...parsedTraceparent ? {
44
75
  traceId: parsedTraceparent.traceId,
45
76
  spanId: parsedTraceparent.spanId
77
+ } : {},
78
+ ...operationContext ? {
79
+ operationContext
46
80
  } : {}
47
81
  };
48
82
  }
@@ -5,7 +5,7 @@ export type RequestContextInput = {
5
5
  headers?: Record<string, unknown>;
6
6
  locale?: string;
7
7
  traceparent?: string;
8
- operationContext?: Pick<OperationContext, 'traceparent' | 'traceId' | 'spanId'>;
8
+ operationContext?: OperationContext;
9
9
  };
10
10
  export type RequestContextSnapshot = {
11
11
  headers: Record<string, string>;
@@ -13,6 +13,7 @@ export type RequestContextSnapshot = {
13
13
  traceparent?: string;
14
14
  traceId?: string;
15
15
  spanId?: string;
16
+ operationContext?: OperationContext;
16
17
  };
17
18
  export declare function createRequestContextSnapshot(input?: RequestContextInput): RequestContextSnapshot;
18
19
  export declare function createRequestContextHeaders(input?: RequestContextInput): Record<string, string>;
@@ -119,15 +119,22 @@ export type OperationContractOptions = {
119
119
  requireOperationVersion?: boolean;
120
120
  onViolation?: (violation: OperationContractViolation) => void;
121
121
  };
122
+ export type OperationContextSource = 'client' | 'server' | 'generated-client' | 'effect-adapter' | 'data-platform' | 'unknown';
122
123
  export type OperationContext = {
124
+ requestId?: string;
123
125
  operationId?: string;
124
126
  routePath?: string;
125
127
  method?: string;
126
128
  schemaHash?: string;
127
129
  operationVersion?: number;
130
+ locale?: string;
128
131
  traceparent?: string;
129
132
  traceId?: string;
130
133
  spanId?: string;
134
+ source?: OperationContextSource;
135
+ scope?: Record<string, unknown>;
136
+ sessionClaims?: Record<string, unknown>;
137
+ attributes?: Record<string, unknown>;
131
138
  };
132
139
  export type RequestCreatorOptions<F = typeof fetch> = {
133
140
  path: string;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.2.0-ultramodern.9",
20
+ "version": "3.2.0-ultramodern.90",
21
21
  "modern:source": "./src/node.ts",
22
22
  "types": "./dist/types/browser.d.ts",
23
23
  "main": "./dist/cjs/node.js",
@@ -57,21 +57,21 @@
57
57
  }
58
58
  },
59
59
  "dependencies": {
60
- "@swc/helpers": "^0.5.21",
60
+ "@swc/helpers": "^0.5.23",
61
61
  "encoding": "^0.1.13",
62
62
  "path-to-regexp": "^8.4.2",
63
- "qs": "^6.15.1",
64
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.9",
65
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.9"
63
+ "qs": "^6.15.2",
64
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.90",
65
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.90"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@rslib/core": "0.21.5",
69
- "@types/node": "^25.8.0",
69
+ "@types/node": "^25.9.1",
70
70
  "@types/qs": "^6.15.1",
71
- "@typescript/native-preview": "7.0.0-dev.20260516.1",
71
+ "@typescript/native-preview": "7.0.0-dev.20260527.2",
72
72
  "nock": "^14.0.15",
73
- "@scripts/rstest-config": "2.66.0",
74
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.9"
73
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.90",
74
+ "@scripts/rstest-config": "2.66.0"
75
75
  },
76
76
  "sideEffects": false,
77
77
  "publishConfig": {