@conduit-client/service-fetch-network 5.67.0-dev1

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/LICENSE.txt ADDED
@@ -0,0 +1,27 @@
1
+ *Attorney/Client Privileged + Confidential*
2
+
3
+ Terms of Use for Public Code (Non-OSS)
4
+
5
+ *NOTE:* Before publishing code under this license/these Terms of Use, please review https://salesforce.quip.com/WFfvAMKB18AL and confirm that you’ve completed all prerequisites described therein. *These Terms of Use may not be used or modified without input from IP and Product Legal.*
6
+
7
+ *Terms of Use*
8
+
9
+ Copyright 2022 Salesforce, Inc. All rights reserved.
10
+
11
+ These Terms of Use govern the download, installation, and/or use of this software provided by Salesforce, Inc. (“Salesforce”) (the “Software”), were last updated on April 15, 2022, ** and constitute a legally binding agreement between you and Salesforce. If you do not agree to these Terms of Use, do not install or use the Software.
12
+
13
+ Salesforce grants you a worldwide, non-exclusive, no-charge, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute the Software and derivative works subject to these Terms. These Terms shall be included in all copies or substantial portions of the Software.
14
+
15
+ Subject to the limited rights expressly granted hereunder, Salesforce reserves all rights, title, and interest in and to all intellectual property subsisting in the Software. No rights are granted to you hereunder other than as expressly set forth herein. Users residing in countries on the United States Office of Foreign Assets Control sanction list, or which are otherwise subject to a US export embargo, may not use the Software.
16
+
17
+ Implementation of the Software may require development work, for which you are responsible. The Software may contain bugs, errors and incompatibilities and is made available on an AS IS basis without support, updates, or service level commitments.
18
+
19
+ Salesforce reserves the right at any time to modify, suspend, or discontinue, the Software (or any part thereof) with or without notice. You agree that Salesforce shall not be liable to you or to any third party for any modification, suspension, or discontinuance.
20
+
21
+ You agree to defend Salesforce against any claim, demand, suit or proceeding made or brought against Salesforce by a third party arising out of or accruing from (a) your use of the Software, and (b) any application you develop with the Software that infringes any copyright, trademark, trade secret, trade dress, patent, or other intellectual property right of any person or defames any person or violates their rights of publicity or privacy (each a “Claim Against Salesforce”), and will indemnify Salesforce from any damages, attorney fees, and costs finally awarded against Salesforce as a result of, or for any amounts paid by Salesforce under a settlement approved by you in writing of, a Claim Against Salesforce, provided Salesforce (x) promptly gives you written notice of the Claim Against Salesforce, (y) gives you sole control of the defense and settlement of the Claim Against Salesforce (except that you may not settle any Claim Against Salesforce unless it unconditionally releases Salesforce of all liability), and (z) gives you all reasonable assistance, at your expense.
22
+
23
+ WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE SOFTWARE IS NOT SUPPORTED AND IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA, OR USE, IN CONNECTION WITH THE SOFTWARE, HOWEVER CAUSED AND WHETHER IN CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
24
+
25
+ These Terms of Use shall be governed exclusively by the internal laws of the State of California, without regard to its conflicts of laws rules. Each party hereby consents to the exclusive jurisdiction of the state and federal courts located in San Francisco County, California to adjudicate any dispute arising out of or relating to these Terms of Use and the download, installation, and/or use of the Software. Except as expressly stated herein, these Terms of Use constitute the entire agreement between the parties, and supersede all prior and contemporaneous agreements, proposals, or representations, written or oral, concerning their subject matter. No modification, amendment, or waiver of any provision of these Terms of Use shall be effective unless it is by an update to these Terms of Use that Salesforce makes available, or is in writing and signed by the party against whom the modification, amendment, or waiver is to be asserted.
26
+
27
+ _*Data Privacy*_: Salesforce may collect, process, and store device, system, and other information related to your use of the Software. This information includes, but is not limited to, IP address, user metrics, and other data (“Usage Data”). Salesforce may use Usage Data for analytics, product development, and marketing purposes. You acknowledge that files generated in conjunction with the Software may contain sensitive or confidential data, and you are solely responsible for anonymizing and protecting such data.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ This software is provided as-is with no support provided.
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
File without changes
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import { type NamedService, type ServiceDescriptor } from '@conduit-client/utils';
2
+ import { RetryService } from '@conduit-client/service-retry/v1';
3
+ export type FetchParameters = Parameters<typeof fetch>;
4
+ export type FetchService = (...args: FetchParameters) => PromiseLike<Response>;
5
+ export type IFetchService = FetchService;
6
+ export type FetchServiceDescriptor = ServiceDescriptor<IFetchService, 'fetch', '1.0'>;
7
+ export type NamedFetchService<Name extends string = 'fetch'> = NamedService<Name, IFetchService>;
8
+ export type RequestInterceptor = (fetchArgs: FetchParameters) => PromiseLike<FetchParameters>;
9
+ export type ResponseInterceptor = (response: Response) => PromiseLike<Response>;
10
+ export type Interceptors = {
11
+ request?: RequestInterceptor[];
12
+ response?: ResponseInterceptor[];
13
+ };
14
+ export declare function buildServiceDescriptor(interceptors?: Interceptors, retryService?: RetryService<Response>): FetchServiceDescriptor;
@@ -0,0 +1,4 @@
1
+ export * from './fetch';
2
+ export * from './jwt-interceptor';
3
+ export * from './mock-fetch';
4
+ export * from './utils';
@@ -0,0 +1,11 @@
1
+ import type { JwtManager, JwtToken } from '@conduit-client/jwt-manager';
2
+ import type { FetchParameters } from './fetch';
3
+ /**
4
+ * Sets the Authorization header with a JWT token using the generic setHeader utility
5
+ * @param token - The JWT token to set in the Authorization header
6
+ * @param fetchParams - The fetch parameters [resource, options]
7
+ * @returns Modified fetch parameters with the Authorization header set
8
+ */
9
+ export declare function setHeaderAuthorization<T, E>({ token }: JwtToken<T, E>, fetchParams: FetchParameters): FetchParameters;
10
+ export type JwtRequestModifier = (extraInfo: any, fetchArgs: FetchParameters) => FetchParameters;
11
+ export declare function buildJwtRequestHeaderInterceptor<ExtraInfo>(jwtManager: JwtManager<unknown, ExtraInfo>, jwtRequestModifier?: JwtRequestModifier): (args: FetchParameters) => PromiseLike<[input: string | URL | Request, init?: RequestInit | undefined]>;
@@ -0,0 +1,17 @@
1
+ import { type FetchService } from './fetch';
2
+ import type { ServiceDescriptor } from '@conduit-client/utils';
3
+ export type MockResponse = {
4
+ status?: number;
5
+ statusText?: string;
6
+ ok?: boolean;
7
+ body?: any;
8
+ delay?: number;
9
+ };
10
+ export type MockFetchService = {
11
+ readonly requests: Array<Parameters<FetchService>>;
12
+ readonly availableResponses: number;
13
+ queueResponses: (...newResponses: Array<any>) => void;
14
+ reset: () => void;
15
+ readonly responsesUsed: number;
16
+ } & ((...args: any[]) => Promise<any>);
17
+ export declare function buildMockFetchService(initialResponses?: Array<any>): ServiceDescriptor<MockFetchService, 'fetch', '1.0'>;
@@ -0,0 +1,15 @@
1
+ import { FetchParameters } from './fetch';
2
+ /**
3
+ * Generic utility function to set any header value in fetch parameters
4
+ * @param headerName - The name of the header to set
5
+ * @param headerValue - The value to set for the header
6
+ * @param fetchParams - The fetch parameters [resource, options]
7
+ * @param options - Additional options
8
+ * @param options.throwOnExisting - If true, throws an error when the header already exists
9
+ * @param options.errorMessage - Custom error message to use when header exists
10
+ * @returns Modified fetch parameters with the header set
11
+ */
12
+ export declare function setHeader<T extends string = string>(headerName: T, headerValue: string, [resource, options]: FetchParameters, { throwOnExisting, errorMessage, }?: {
13
+ throwOnExisting?: boolean;
14
+ errorMessage?: string;
15
+ }): FetchParameters;
@@ -0,0 +1,160 @@
1
+ /*!
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+ import { resolvedPromiseLike } from "@conduit-client/utils";
7
+ function buildServiceDescriptor(interceptors = { request: [], response: [] }, retryService) {
8
+ return {
9
+ type: "fetch",
10
+ version: "1.0",
11
+ service: function(...args) {
12
+ const { request: requestInterceptors = [], response: responseInterceptors = [] } = interceptors;
13
+ const pending = requestInterceptors.reduce(
14
+ (previousPromise, interceptor) => previousPromise.then(interceptor),
15
+ resolvedPromiseLike(args)
16
+ );
17
+ return pending.then((args2) => {
18
+ if (retryService) {
19
+ return retryService.applyRetry(() => fetch(...args2));
20
+ }
21
+ return fetch(...args2);
22
+ }).then((response) => {
23
+ return responseInterceptors.reduce(
24
+ (previousPromise, interceptor) => previousPromise.then(interceptor),
25
+ resolvedPromiseLike(response)
26
+ );
27
+ });
28
+ }
29
+ };
30
+ }
31
+ function setHeader(headerName, headerValue, [resource, options = {}], {
32
+ throwOnExisting = false,
33
+ errorMessage = `Unexpected ${headerName} header encountered`
34
+ } = {}) {
35
+ let hasHeaderBeenSet = false;
36
+ if (resource instanceof Request && !(options == null ? void 0 : options.headers)) {
37
+ if (throwOnExisting && resource.headers.has(headerName)) {
38
+ throw new Error(errorMessage);
39
+ }
40
+ resource.headers.set(headerName, headerValue);
41
+ hasHeaderBeenSet = true;
42
+ }
43
+ if ((options == null ? void 0 : options.headers) instanceof Headers) {
44
+ if (throwOnExisting && options.headers.has(headerName)) {
45
+ throw new Error(errorMessage);
46
+ }
47
+ options.headers.set(headerName, headerValue);
48
+ } else {
49
+ if (throwOnExisting && (options == null ? void 0 : options.headers) && Reflect.has(options.headers, headerName)) {
50
+ throw new Error(errorMessage);
51
+ }
52
+ if (!hasHeaderBeenSet) {
53
+ options.headers = {
54
+ ...options == null ? void 0 : options.headers,
55
+ [headerName]: headerValue
56
+ };
57
+ }
58
+ }
59
+ return [resource, options];
60
+ }
61
+ const UNEXPECTED_AUTHORIZATION_HEADER_MESSAGE = "Unexpected Authorization header encountered. To specify a custom Authorization header, use a Fetch service that is not configured with JwtRequestHeaderInterceptor";
62
+ function setHeaderAuthorization({ token }, fetchParams) {
63
+ const authorizationValue = `Bearer ${token}`;
64
+ return setHeader("Authorization", authorizationValue, fetchParams, {
65
+ throwOnExisting: true,
66
+ errorMessage: UNEXPECTED_AUTHORIZATION_HEADER_MESSAGE
67
+ });
68
+ }
69
+ function buildJwtRequestHeaderInterceptor(jwtManager, jwtRequestModifier = (_e, fetchArgs) => fetchArgs) {
70
+ return (args) => {
71
+ return resolvedPromiseLike(jwtManager.getJwt()).then((token) => {
72
+ const fetchArgsWithRequestHeaderAuthorization = setHeaderAuthorization(token, args);
73
+ return token.extraInfo ? jwtRequestModifier(token.extraInfo, fetchArgsWithRequestHeaderAuthorization) : fetchArgsWithRequestHeaderAuthorization;
74
+ });
75
+ };
76
+ }
77
+ class AbortError extends Error {
78
+ constructor(message = "This operation was aborted") {
79
+ super(message);
80
+ this.name = "AbortError";
81
+ }
82
+ }
83
+ function buildMockFetchService(initialResponses = []) {
84
+ let responses = [...initialResponses];
85
+ const networkAdapter = (...args) => {
86
+ var _a;
87
+ const [url, fetchOptions = {}] = args;
88
+ networkAdapter.requests.push(args);
89
+ if ((_a = fetchOptions.signal) == null ? void 0 : _a.aborted) {
90
+ return Promise.reject(new AbortError());
91
+ }
92
+ const result = responses.shift();
93
+ if (result === void 0) {
94
+ throw new Error("No more mock responses queued");
95
+ }
96
+ networkAdapter.availableResponses = responses.length;
97
+ networkAdapter.responsesUsed++;
98
+ if (result instanceof Error) {
99
+ return Promise.reject(result);
100
+ }
101
+ const delay = result.delay || 0;
102
+ return new Promise((resolve, reject) => {
103
+ let abortHandler = null;
104
+ if (fetchOptions.signal) {
105
+ abortHandler = () => {
106
+ reject(new AbortError());
107
+ };
108
+ fetchOptions.signal.addEventListener("abort", abortHandler);
109
+ }
110
+ const completeRequest = () => {
111
+ var _a2;
112
+ if (abortHandler && fetchOptions.signal) {
113
+ fetchOptions.signal.removeEventListener("abort", abortHandler);
114
+ }
115
+ if ((_a2 = fetchOptions.signal) == null ? void 0 : _a2.aborted) {
116
+ reject(new AbortError());
117
+ return;
118
+ }
119
+ resolve({
120
+ ok: result.ok !== void 0 ? result.ok : true,
121
+ statusText: result.statusText !== void 0 ? result.statusText : "ok",
122
+ status: result.status !== void 0 ? result.status : 200,
123
+ json: () => Promise.resolve(result.body)
124
+ });
125
+ };
126
+ if (delay > 0) {
127
+ setTimeout(completeRequest, delay);
128
+ } else {
129
+ setTimeout(completeRequest, 0);
130
+ }
131
+ });
132
+ };
133
+ networkAdapter.requests = [];
134
+ networkAdapter.availableResponses = responses.length;
135
+ networkAdapter.queueResponses = (newResponses) => {
136
+ responses = responses.concat(newResponses);
137
+ networkAdapter.availableResponses = responses.length;
138
+ };
139
+ networkAdapter.fetch = (args) => networkAdapter(args);
140
+ networkAdapter.reset = () => {
141
+ networkAdapter.requests = [];
142
+ responses = [];
143
+ networkAdapter.availableResponses = 0;
144
+ networkAdapter.responsesUsed = 0;
145
+ };
146
+ networkAdapter.responsesUsed = 0;
147
+ return {
148
+ type: "fetch",
149
+ version: "1.0",
150
+ service: networkAdapter
151
+ };
152
+ }
153
+ export {
154
+ buildJwtRequestHeaderInterceptor,
155
+ buildMockFetchService,
156
+ buildServiceDescriptor,
157
+ setHeader,
158
+ setHeaderAuthorization
159
+ };
160
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/v1/fetch.ts","../../src/v1/utils.ts","../../src/v1/jwt-interceptor.ts","../../src/v1/mock-fetch.ts"],"sourcesContent":["import {\n resolvedPromiseLike,\n type NamedService,\n type ServiceDescriptor,\n} from '@conduit-client/utils';\nimport { RetryService } from '@conduit-client/service-retry/v1';\n\nexport type FetchParameters = Parameters<typeof fetch>;\nexport type FetchService = (...args: FetchParameters) => PromiseLike<Response>;\nexport type IFetchService = FetchService;\nexport type FetchServiceDescriptor = ServiceDescriptor<IFetchService, 'fetch', '1.0'>;\nexport type NamedFetchService<Name extends string = 'fetch'> = NamedService<Name, IFetchService>;\nexport type RequestInterceptor = (fetchArgs: FetchParameters) => PromiseLike<FetchParameters>;\nexport type ResponseInterceptor = (response: Response) => PromiseLike<Response>;\nexport type Interceptors = {\n request?: RequestInterceptor[];\n response?: ResponseInterceptor[];\n};\nexport function buildServiceDescriptor(\n interceptors: Interceptors = { request: [], response: [] },\n retryService?: RetryService<Response>\n): FetchServiceDescriptor {\n return {\n type: 'fetch',\n version: '1.0',\n service: function (...args: FetchParameters) {\n const { request: requestInterceptors = [], response: responseInterceptors = [] } =\n interceptors;\n const pending = requestInterceptors.reduce(\n (previousPromise, interceptor) => previousPromise.then(interceptor),\n resolvedPromiseLike(args)\n );\n return pending\n .then((args) => {\n if (retryService) {\n return retryService.applyRetry(() => fetch(...args));\n }\n return fetch(...args);\n })\n .then((response) => {\n return responseInterceptors.reduce(\n (previousPromise, interceptor) => previousPromise.then(interceptor),\n resolvedPromiseLike(response)\n );\n });\n },\n };\n}\n","import { FetchParameters } from './fetch';\n\n/**\n * Generic utility function to set any header value in fetch parameters\n * @param headerName - The name of the header to set\n * @param headerValue - The value to set for the header\n * @param fetchParams - The fetch parameters [resource, options]\n * @param options - Additional options\n * @param options.throwOnExisting - If true, throws an error when the header already exists\n * @param options.errorMessage - Custom error message to use when header exists\n * @returns Modified fetch parameters with the header set\n */\nexport function setHeader<T extends string = string>(\n headerName: T,\n headerValue: string,\n [resource, options = {}]: FetchParameters,\n {\n throwOnExisting = false,\n errorMessage = `Unexpected ${headerName} header encountered`,\n }: {\n throwOnExisting?: boolean;\n errorMessage?: string;\n } = {}\n): FetchParameters {\n let hasHeaderBeenSet = false;\n\n // Handle Request instance with Headers\n if (resource instanceof Request && !options?.headers) {\n if (throwOnExisting && resource.headers.has(headerName)) {\n throw new Error(errorMessage);\n }\n resource.headers.set(headerName, headerValue);\n hasHeaderBeenSet = true;\n }\n\n // Handle options with Headers instance\n if (options?.headers instanceof Headers) {\n if (throwOnExisting && options.headers.has(headerName)) {\n throw new Error(errorMessage);\n }\n options.headers.set(headerName, headerValue);\n } else {\n // Handle options with plain object headers\n if (\n throwOnExisting &&\n options?.headers &&\n Reflect.has(options.headers as any, headerName)\n ) {\n throw new Error(errorMessage);\n }\n // Add the header if it hasn't been set on Request\n if (!hasHeaderBeenSet) {\n options.headers = {\n ...options?.headers,\n [headerName]: headerValue,\n };\n }\n }\n\n return [resource, options];\n}\n","import { resolvedPromiseLike } from '@conduit-client/utils';\nimport type { JwtManager, JwtToken } from '@conduit-client/jwt-manager';\nimport type { FetchParameters } from './fetch';\nimport { setHeader } from './utils';\n\nconst UNEXPECTED_AUTHORIZATION_HEADER_MESSAGE =\n 'Unexpected Authorization header encountered. To specify a custom Authorization header, use a Fetch service that is not configured with JwtRequestHeaderInterceptor';\n\n/**\n * Sets the Authorization header with a JWT token using the generic setHeader utility\n * @param token - The JWT token to set in the Authorization header\n * @param fetchParams - The fetch parameters [resource, options]\n * @returns Modified fetch parameters with the Authorization header set\n */\nexport function setHeaderAuthorization<T, E>(\n { token }: JwtToken<T, E>,\n fetchParams: FetchParameters\n): FetchParameters {\n const authorizationValue = `Bearer ${token}`;\n\n return setHeader('Authorization', authorizationValue, fetchParams, {\n throwOnExisting: true,\n errorMessage: UNEXPECTED_AUTHORIZATION_HEADER_MESSAGE,\n });\n}\n\nexport type JwtRequestModifier = (extraInfo: any, fetchArgs: FetchParameters) => FetchParameters;\n\nexport function buildJwtRequestHeaderInterceptor<ExtraInfo>(\n jwtManager: JwtManager<unknown, ExtraInfo>,\n jwtRequestModifier: JwtRequestModifier = (_e, fetchArgs) => fetchArgs\n) {\n return (args: FetchParameters) => {\n return resolvedPromiseLike(jwtManager.getJwt()).then((token) => {\n const fetchArgsWithRequestHeaderAuthorization = setHeaderAuthorization(token, args);\n return token.extraInfo\n ? jwtRequestModifier(token.extraInfo, fetchArgsWithRequestHeaderAuthorization)\n : fetchArgsWithRequestHeaderAuthorization;\n });\n };\n}\n","import { type FetchService } from './fetch';\nimport type { ServiceDescriptor } from '@conduit-client/utils';\n\n// AbortError class that matches the standard AbortError\nclass AbortError extends Error {\n name = 'AbortError';\n constructor(message = 'This operation was aborted') {\n super(message);\n }\n}\n\nexport type MockResponse = {\n status?: number;\n statusText?: string;\n ok?: boolean;\n body?: any;\n delay?: number; // Delay in milliseconds to simulate network latency\n};\n\nexport type MockFetchService = {\n readonly requests: Array<Parameters<FetchService>>;\n readonly availableResponses: number;\n queueResponses: (...newResponses: Array<any>) => void;\n reset: () => void;\n readonly responsesUsed: number;\n} & ((...args: any[]) => Promise<any>);\n\nexport function buildMockFetchService(\n initialResponses: Array<any> = []\n): ServiceDescriptor<MockFetchService, 'fetch', '1.0'> {\n let responses: Array<any> = [...initialResponses];\n\n const networkAdapter = (...args: any[]) => {\n // Capture the full fetch parameters for more realistic testing\n const [url, fetchOptions = {}] = args;\n\n networkAdapter.requests.push(args);\n\n // Immediate abort detection - check if signal is already aborted\n if (fetchOptions.signal?.aborted) {\n return Promise.reject(new AbortError());\n }\n\n const result = responses.shift();\n if (result === undefined) {\n throw new Error('No more mock responses queued');\n }\n networkAdapter.availableResponses = responses.length;\n networkAdapter.responsesUsed++;\n\n if (result instanceof Error) {\n return Promise.reject(result);\n }\n\n // Simulate request delay if specified\n const delay = (result as MockResponse).delay || 0;\n\n // Create a promise that handles both delay simulation and runtime abort\n return new Promise((resolve, reject) => {\n let abortHandler: (() => void) | null = null;\n\n // Set up abort listener for runtime abort detection\n if (fetchOptions.signal) {\n abortHandler = () => {\n reject(new AbortError());\n };\n fetchOptions.signal.addEventListener('abort', abortHandler);\n }\n\n const completeRequest = () => {\n // Clean up abort listener\n if (abortHandler && fetchOptions.signal) {\n fetchOptions.signal.removeEventListener('abort', abortHandler);\n }\n\n // Check one more time if aborted during delay\n if (fetchOptions.signal?.aborted) {\n reject(new AbortError());\n return;\n }\n\n // Return successful response\n resolve({\n ok: result.ok !== undefined ? result.ok : true,\n statusText: result.statusText !== undefined ? result.statusText : 'ok',\n status: result.status !== undefined ? result.status : 200,\n json: () => Promise.resolve(result.body),\n } as Response);\n };\n\n if (delay > 0) {\n setTimeout(completeRequest, delay);\n } else {\n // Always use async behavior to maintain existing test expectations\n // Even without delay, tests expect async behavior for wire adapters\n setTimeout(completeRequest, 0);\n }\n });\n };\n\n networkAdapter.requests = [] as Array<any>;\n networkAdapter.availableResponses = responses.length;\n\n networkAdapter.queueResponses = (newResponses: Array<any>) => {\n responses = responses.concat(newResponses);\n networkAdapter.availableResponses = responses.length;\n };\n\n networkAdapter.fetch = (args: any) => networkAdapter(args);\n\n networkAdapter.reset = () => {\n networkAdapter.requests = [];\n responses = [];\n networkAdapter.availableResponses = 0;\n networkAdapter.responsesUsed = 0;\n };\n\n networkAdapter.responsesUsed = 0;\n return {\n type: 'fetch',\n version: '1.0',\n service: networkAdapter as MockFetchService,\n };\n}\n"],"names":["args","_a"],"mappings":";;;;;;AAkBO,SAAS,uBACZ,eAA6B,EAAE,SAAS,CAAA,GAAI,UAAU,CAAA,EAAC,GACvD,cACsB;AACtB,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS,YAAa,MAAuB;AACzC,YAAM,EAAE,SAAS,sBAAsB,CAAA,GAAI,UAAU,uBAAuB,CAAA,EAAC,IACzE;AACJ,YAAM,UAAU,oBAAoB;AAAA,QAChC,CAAC,iBAAiB,gBAAgB,gBAAgB,KAAK,WAAW;AAAA,QAClE,oBAAoB,IAAI;AAAA,MAAA;AAE5B,aAAO,QACF,KAAK,CAACA,UAAS;AACZ,YAAI,cAAc;AACd,iBAAO,aAAa,WAAW,MAAM,MAAM,GAAGA,KAAI,CAAC;AAAA,QACvD;AACA,eAAO,MAAM,GAAGA,KAAI;AAAA,MACxB,CAAC,EACA,KAAK,CAAC,aAAa;AAChB,eAAO,qBAAqB;AAAA,UACxB,CAAC,iBAAiB,gBAAgB,gBAAgB,KAAK,WAAW;AAAA,UAClE,oBAAoB,QAAQ;AAAA,QAAA;AAAA,MAEpC,CAAC;AAAA,IACT;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Ae,SAAY,OAAO,aAAa;AAAA,UAClE,QAAQ,OAAO,WAAW,SAAY,OAAO,SAAS;AAAA,UACtD,MAAM,MAAM,QAAQ,QAAQ,OAAO,IAAI;AAAA,QAAA,CAC9B;AAAA,MACjB;AAEA,UAAI,QAAQ,GAAG;AACX,mBAAW,iBAAiB,KAAK;AAAA,MACrC,OAAO;AAGH,mBAAW,iBAAiB,CAAC;AAAA,MACjC;AAAA,IACJ,CAAC;AAAA,EACL;AAEA,iBAAe,WAAW,CAAA;AAC1B,iBAAe,qBAAqB,UAAU;AAE9C,iBAAe,iBAAiB,CAAC,iBAA6B;AAC1D,gBAAY,UAAU,OAAO,YAAY;AACzC,mBAAe,qBAAqB,UAAU;AAAA,EAClD;AAEA,iBAAe,QAAQ,CAAC,SAAc,eAAe,IAAI;AAEzD,iBAAe,QAAQ,MAAM;AACzB,mBAAe,WAAW,CAAA;AAC1B,gBAAY,CAAA;AACZ,mBAAe,qBAAqB;AACpC,mBAAe,gBAAgB;AAAA,EACnC;AAEA,iBAAe,gBAAgB;AAC/B,SAAO;AAAA,IACH,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,EAAA;AAEjB;"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@conduit-client/service-fetch-network",
3
+ "version": "5.67.0-dev1",
4
+ "private": false,
5
+ "description": "Luvio Network Service definition",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/salesforce-experience-platform-emu/luvio-next.git",
10
+ "directory": "packages/@conduit-client/services/fetch-network"
11
+ },
12
+ "license": "SEE LICENSE IN LICENSE.txt",
13
+ "exports": {
14
+ "./v1": {
15
+ "import": "./dist/v1/index.js",
16
+ "types": "./dist/types/v1/index.d.ts",
17
+ "require": "./dist/v1/index.js"
18
+ }
19
+ },
20
+ "main": "./dist/main/index.js",
21
+ "module": "./dist/main/index.js",
22
+ "types": "./dist/main/index.d.ts",
23
+ "files": [
24
+ "dist/"
25
+ ],
26
+ "scripts": {
27
+ "build": "vite build && tsc --build --emitDeclarationOnly",
28
+ "clean": "rm -rf dist",
29
+ "test": "vitest run",
30
+ "test:size": "size-limit",
31
+ "watch": "npm run build --watch"
32
+ },
33
+ "dependencies": {
34
+ "@conduit-client/jwt-manager": "5.67.0-dev1",
35
+ "@conduit-client/service-retry": "5.67.0-dev1",
36
+ "@conduit-client/utils": "5.67.0-dev1"
37
+ },
38
+ "volta": {
39
+ "extends": "../../../../package.json"
40
+ },
41
+ "size-limit": [
42
+ {
43
+ "path": "./dist/v1/index.js",
44
+ "limit": "1.8 kB"
45
+ }
46
+ ]
47
+ }