@bleedingdev/modern-js-create-request 3.2.0-ultramodern.0 → 3.2.0-ultramodern.1

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/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.2.0-ultramodern.0",
20
+ "version": "3.2.0-ultramodern.1",
21
21
  "modern:source": "./src/node.ts",
22
22
  "types": "./dist/types/browser.d.ts",
23
23
  "main": "./dist/cjs/node.js",
@@ -61,8 +61,8 @@
61
61
  "encoding": "^0.1.13",
62
62
  "path-to-regexp": "^8.4.2",
63
63
  "qs": "^6.15.1",
64
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.0",
65
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.0"
64
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.1",
65
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.1"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@rslib/core": "0.21.5",
@@ -70,7 +70,7 @@
70
70
  "@types/qs": "^6.15.1",
71
71
  "@typescript/native-preview": "7.0.0-dev.20260516.1",
72
72
  "nock": "^14.0.15",
73
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.0",
73
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.1",
74
74
  "@scripts/rstest-config": "2.66.0"
75
75
  },
76
76
  "sideEffects": false,
@@ -1,28 +0,0 @@
1
- import type { IdentityBindingViolation, IOptions, OperationContractViolation, RequestCreator, UploadCreator } from './types';
2
- export declare class ProducerClientNotInitializedError extends Error {
3
- readonly code = "BFF_PRODUCER_CLIENT_NOT_INITIALIZED";
4
- constructor(requestId: string);
5
- }
6
- export declare class ProducerDomainNotConfiguredError extends Error {
7
- readonly code = "BFF_PRODUCER_DOMAIN_NOT_CONFIGURED";
8
- constructor(requestId: string);
9
- }
10
- export declare class CrossOriginEnvelopePolicyError extends Error {
11
- readonly code = "BFF_CROSS_ORIGIN_ENVELOPE_NOT_ALLOWED";
12
- constructor(requestId: string, sourceOrigin?: string, targetOrigin?: string);
13
- }
14
- export declare class IdentityBindingViolationError extends Error {
15
- readonly code = "BFF_IDENTITY_BINDING_VIOLATION";
16
- readonly violation: IdentityBindingViolation;
17
- constructor(violation: IdentityBindingViolation);
18
- }
19
- export declare class OperationContractViolationError extends Error {
20
- readonly code = "BFF_OPERATION_CONTRACT_VIOLATION";
21
- readonly violation: OperationContractViolation;
22
- constructor(violation: OperationContractViolation);
23
- }
24
- export declare const configure: (options: IOptions) => void;
25
- export declare const createRequest: RequestCreator;
26
- export declare const createUploader: UploadCreator;
27
- export * from './requestContext';
28
- export * from './types';
@@ -1,2 +0,0 @@
1
- declare const handleRes: (res: Response) => Promise<any>;
2
- export { handleRes };
@@ -1,29 +0,0 @@
1
- import type { IdentityBindingViolation, IOptions, OperationContractViolation, RequestCreator, UploadCreator } from './types';
2
- type Fetch = typeof fetch;
3
- export declare class ProducerClientNotInitializedError extends Error {
4
- readonly code = "BFF_PRODUCER_CLIENT_NOT_INITIALIZED";
5
- constructor(requestId: string);
6
- }
7
- export declare class ProducerDomainNotConfiguredError extends Error {
8
- readonly code = "BFF_PRODUCER_DOMAIN_NOT_CONFIGURED";
9
- constructor(requestId: string);
10
- }
11
- export declare class CrossOriginEnvelopePolicyError extends Error {
12
- readonly code = "BFF_CROSS_ORIGIN_ENVELOPE_NOT_ALLOWED";
13
- constructor(requestId: string, sourceOrigin?: string, targetOrigin?: string);
14
- }
15
- export declare class IdentityBindingViolationError extends Error {
16
- readonly code = "BFF_IDENTITY_BINDING_VIOLATION";
17
- readonly violation: IdentityBindingViolation;
18
- constructor(violation: IdentityBindingViolation);
19
- }
20
- export declare class OperationContractViolationError extends Error {
21
- readonly code = "BFF_OPERATION_CONTRACT_VIOLATION";
22
- readonly violation: OperationContractViolation;
23
- constructor(violation: OperationContractViolation);
24
- }
25
- export declare const configure: (options: IOptions<Fetch>) => void;
26
- export declare const createRequest: RequestCreator<Fetch>;
27
- export declare const createUploader: UploadCreator;
28
- export * from './requestContext';
29
- export * from './types';
@@ -1 +0,0 @@
1
- export { parse, stringify } from 'qs';
@@ -1,18 +0,0 @@
1
- import type { OperationContext } from './types';
2
- export declare const BFF_LOCALE_HEADER = "accept-language";
3
- export declare const BFF_TRACEPARENT_HEADER = "traceparent";
4
- export type RequestContextInput = {
5
- headers?: Record<string, unknown>;
6
- locale?: string;
7
- traceparent?: string;
8
- operationContext?: Pick<OperationContext, 'traceparent' | 'traceId' | 'spanId'>;
9
- };
10
- export type RequestContextSnapshot = {
11
- headers: Record<string, string>;
12
- locale?: string;
13
- traceparent?: string;
14
- traceId?: string;
15
- spanId?: string;
16
- };
17
- export declare function createRequestContextSnapshot(input?: RequestContextInput): RequestContextSnapshot;
18
- export declare function createRequestContextHeaders(input?: RequestContextInput): Record<string, string>;
@@ -1,12 +0,0 @@
1
- import type { TransportResilienceOptions, TransportTarget } from './types';
2
- type ExecuteWithResilienceOptions = {
3
- requestId: string;
4
- target: TransportTarget;
5
- method: string;
6
- url: string;
7
- init: Record<string, any>;
8
- fetcher: (...args: any[]) => Promise<any>;
9
- transport?: TransportResilienceOptions;
10
- };
11
- export declare const executeWithResilience: ({ requestId, target, method, url, init, fetcher, transport, }: ExecuteWithResilienceOptions) => Promise<any>;
12
- export {};
@@ -1,167 +0,0 @@
1
- import type { HttpMethodDecider } from '@modern-js/types';
2
- export declare const BFF_ENVELOPE_HEADER = "x-modernjs-bff-envelope";
3
- export declare const BFF_OPERATION_CONTEXT_HEADER = "x-operation-id";
4
- export declare const BFF_OPERATION_CONTEXT_DETAIL_HEADER = "x-modernjs-bff-operation-context";
5
- export declare const BFF_DEFAULT_PROTECTED_IDENTITY_HEADERS: readonly ["x-tenant-id", "x-subject-id", "x-user-id", "x-operation-id"];
6
- export type BFFRequestPayload = {
7
- params?: Record<string, any>;
8
- query?: Record<string, any>;
9
- body?: string;
10
- formUrlencoded?: string | Record<string, any> | URLSearchParams;
11
- formData?: FormData;
12
- data?: Record<string, any>;
13
- headers?: Record<string, any>;
14
- cookies?: Record<string, any>;
15
- files?: Record<string, any>;
16
- };
17
- export type Sender<F = typeof fetch> = ((...args: any[]) => Promise<any>) & {
18
- fetch?: F;
19
- };
20
- export type ResolveHeadersOptions = {
21
- requestId: string;
22
- allowedHeaders: string[];
23
- incomingHeaders: Record<string, any>;
24
- };
25
- export type ResolveHeaders = (options: ResolveHeadersOptions) => Record<string, any> | void;
26
- export type AllowCrossOriginEnvelopeOptions = {
27
- requestId: string;
28
- sourceOrigin?: string;
29
- targetOrigin?: string;
30
- target: 'server' | 'browser';
31
- };
32
- export type AllowCrossOriginEnvelope = boolean | ((options: AllowCrossOriginEnvelopeOptions) => boolean);
33
- export type TransportTarget = 'server' | 'browser';
34
- export type RetryDecisionContext = {
35
- requestId: string;
36
- target: TransportTarget;
37
- method: string;
38
- url: string;
39
- attempt: number;
40
- maxAttempts: number;
41
- error: unknown;
42
- statusCode?: number;
43
- };
44
- export type RetryBackoffOptions = {
45
- retries?: number;
46
- baseDelayMs?: number;
47
- maxDelayMs?: number;
48
- jitterRatio?: number;
49
- retryableStatusCodes?: number[];
50
- shouldRetry?: (context: RetryDecisionContext) => boolean;
51
- };
52
- export type DegradedModeReason = 'timeout' | 'retry' | 'retry_exhausted';
53
- export type DegradedModeEvent = {
54
- requestId: string;
55
- target: TransportTarget;
56
- method: string;
57
- url: string;
58
- reason: DegradedModeReason;
59
- attempt: number;
60
- maxAttempts: number;
61
- timeoutMs?: number;
62
- backoffMs?: number;
63
- statusCode?: number;
64
- error?: unknown;
65
- };
66
- export type TransportResilienceOptions = {
67
- timeoutMs?: number;
68
- retry?: RetryBackoffOptions;
69
- onDegraded?: (event: DegradedModeEvent) => void;
70
- };
71
- export type IdentityBindingViolationReason = 'client_override_blocked' | 'client_override_rejected';
72
- export type IdentityBindingViolation = {
73
- requestId: string;
74
- target: TransportTarget;
75
- header: string;
76
- reason: IdentityBindingViolationReason;
77
- attemptedValue?: unknown;
78
- derivedValue?: unknown;
79
- };
80
- export type DeriveIdentityHeadersOptions = {
81
- requestId: string;
82
- target: TransportTarget;
83
- incomingHeaders: Record<string, any>;
84
- protectedHeaders: string[];
85
- };
86
- export type IdentityBindingOptions = {
87
- enabled?: boolean;
88
- strict?: boolean;
89
- protectedHeaders?: string[];
90
- deriveHeaders?: (options: DeriveIdentityHeadersOptions) => Record<string, any> | void;
91
- onViolation?: (violation: IdentityBindingViolation) => void;
92
- };
93
- export type OperationContractViolationReason = 'missing_schema_hash' | 'missing_operation_version';
94
- export type OperationContractViolation = {
95
- requestId: string;
96
- target: TransportTarget;
97
- operationId: string;
98
- reason: OperationContractViolationReason;
99
- routePath?: string;
100
- method?: string;
101
- schemaHash?: string;
102
- operationVersion?: number;
103
- };
104
- export type CrossProjectOperationContract = {
105
- schemaHash?: string;
106
- operationVersion?: number;
107
- };
108
- export type CrossProjectPolicyViolationReason = 'missing_envelope' | 'invalid_envelope' | 'missing_request_id' | 'namespace_not_allowed' | 'missing_operation_context' | 'operation_context_mismatch' | 'missing_operation_context_details' | 'invalid_operation_context_details' | 'operation_context_details_request_id_mismatch' | 'missing_operation_schema_hash' | 'missing_operation_version' | 'unknown_operation_contract' | 'operation_schema_hash_mismatch' | 'operation_version_mismatch';
109
- export type CrossProjectPolicyViolation = {
110
- code: 'BFF_CROSS_PROJECT_POLICY_DENIED';
111
- reason: CrossProjectPolicyViolationReason;
112
- message: string;
113
- status: number;
114
- };
115
- export type OperationContractOptions = {
116
- enabled?: boolean;
117
- strict?: boolean;
118
- requireSchemaHash?: boolean;
119
- requireOperationVersion?: boolean;
120
- onViolation?: (violation: OperationContractViolation) => void;
121
- };
122
- export type OperationContext = {
123
- operationId?: string;
124
- routePath?: string;
125
- method?: string;
126
- schemaHash?: string;
127
- operationVersion?: number;
128
- traceparent?: string;
129
- traceId?: string;
130
- spanId?: string;
131
- };
132
- export type RequestCreatorOptions<F = typeof fetch> = {
133
- path: string;
134
- method: string;
135
- port: number;
136
- httpMethodDecider?: HttpMethodDecider;
137
- fetch?: F;
138
- domain?: string;
139
- requestId?: string;
140
- operationContext?: OperationContext;
141
- };
142
- export type RequestCreator<F = typeof fetch> = {
143
- (options: RequestCreatorOptions<F>): Sender;
144
- (path: string, method: string, port: number, httpMethodDecider?: HttpMethodDecider, fetch?: F, requestId?: string, operationContext?: OperationContext): Sender;
145
- };
146
- export type UploadCreatorOptions = {
147
- path: string;
148
- domain?: string;
149
- requestId?: string;
150
- };
151
- export type UploadCreator = (options: UploadCreatorOptions) => Sender;
152
- export type IOptions<F = typeof fetch> = {
153
- request?: F;
154
- interceptor?: (request: F) => F;
155
- allowedHeaders?: string[];
156
- resolveHeaders?: ResolveHeaders;
157
- transport?: TransportResilienceOptions;
158
- requireEnvelope?: boolean;
159
- allowCrossOriginEnvelope?: AllowCrossOriginEnvelope;
160
- identityBinding?: IdentityBindingOptions;
161
- operationContract?: OperationContractOptions;
162
- setDomain?: (ops?: {
163
- target: 'server' | 'browser';
164
- requestId?: string;
165
- }) => string;
166
- requestId?: string;
167
- };
@@ -1,5 +0,0 @@
1
- export declare const getUploadPayload: (args: any) => {
2
- body: any;
3
- headers: Record<string, any> | undefined;
4
- params: Record<string, any> | undefined;
5
- };