@zimic/fetch 1.5.0-canary.5 → 1.5.0-canary.7
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/index.d.ts +35 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client/request/FetchRequest.ts +7 -6
- package/src/client/request/types.ts +18 -0
- package/src/client/response/FetchResponse.ts +13 -6
- package/src/client/response/types.ts +18 -0
- package/src/index.ts +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -156,6 +156,21 @@ declare namespace FetchRequestInit {
|
|
|
156
156
|
export type Loose = Partial<Defaults>;
|
|
157
157
|
export { };
|
|
158
158
|
}
|
|
159
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */
|
|
160
|
+
interface FetchRequestObjectOptions {
|
|
161
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */
|
|
162
|
+
includeBody?: boolean;
|
|
163
|
+
}
|
|
164
|
+
declare namespace FetchRequestObjectOptions {
|
|
165
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */
|
|
166
|
+
interface WithBody {
|
|
167
|
+
includeBody: true;
|
|
168
|
+
}
|
|
169
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */
|
|
170
|
+
interface WithoutBody {
|
|
171
|
+
includeBody?: false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
159
174
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()`} */
|
|
160
175
|
type FetchRequestObject = Pick<FetchRequest.Loose, 'url' | 'path' | 'method' | 'cache' | 'destination' | 'credentials' | 'integrity' | 'keepalive' | 'mode' | 'redirect' | 'referrer' | 'referrerPolicy'> & {
|
|
161
176
|
headers: HttpHeadersSerialized<HttpHeadersSchema>;
|
|
@@ -174,13 +189,7 @@ interface FetchRequest<Schema extends HttpSchema, Method extends HttpSchemaMetho
|
|
|
174
189
|
method: Method;
|
|
175
190
|
clone: () => FetchRequest<Schema, Method, Path>;
|
|
176
191
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */
|
|
177
|
-
toObject: ((options:
|
|
178
|
-
includeBody: true;
|
|
179
|
-
}) => Promise<FetchRequestObject>) & ((options?: {
|
|
180
|
-
includeBody?: false;
|
|
181
|
-
}) => FetchRequestObject) & ((options?: {
|
|
182
|
-
includeBody?: boolean;
|
|
183
|
-
}) => PossiblePromise<FetchRequestObject>);
|
|
192
|
+
toObject: ((options: FetchRequestObjectOptions.WithBody) => Promise<FetchRequestObject>) & ((options?: FetchRequestObjectOptions.WithoutBody) => FetchRequestObject) & ((options?: FetchRequestObjectOptions) => PossiblePromise<FetchRequestObject>);
|
|
184
193
|
}
|
|
185
194
|
declare namespace FetchRequest {
|
|
186
195
|
/** A loosely typed version of a {@link FetchRequest `FetchRequest`}. */
|
|
@@ -190,11 +199,7 @@ declare namespace FetchRequest {
|
|
|
190
199
|
method: HttpMethod;
|
|
191
200
|
clone: () => Loose;
|
|
192
201
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */
|
|
193
|
-
toObject: ((options:
|
|
194
|
-
includeBody: true;
|
|
195
|
-
}) => Promise<FetchRequestObject>) & ((options?: {
|
|
196
|
-
includeBody?: false;
|
|
197
|
-
}) => FetchRequestObject);
|
|
202
|
+
toObject: ((options: FetchRequestObjectOptions.WithBody) => Promise<FetchRequestObject>) & ((options?: FetchRequestObjectOptions.WithoutBody) => FetchRequestObject) & ((options?: FetchRequestObjectOptions) => PossiblePromise<FetchRequestObject>);
|
|
198
203
|
}
|
|
199
204
|
}
|
|
200
205
|
declare const FetchRequest: FetchRequestClass;
|
|
@@ -223,6 +228,21 @@ interface FetchResponseConstructor {
|
|
|
223
228
|
ErrorOnly extends boolean = false, Redirect extends RequestRedirect = 'follow', StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> = FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>>(fetchRequest: FetchRequest<Schema, Method, Path>, body?: FetchResponseBodySchema<Default<Default<Default<Schema[Path][Method]>['response']>[StatusCode]>>, init?: FetchResponseInit<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>): FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;
|
|
224
229
|
[Symbol.hasInstance]: (instance: unknown) => boolean;
|
|
225
230
|
}
|
|
231
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */
|
|
232
|
+
interface FetchResponseObjectOptions {
|
|
233
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */
|
|
234
|
+
includeBody?: boolean;
|
|
235
|
+
}
|
|
236
|
+
declare namespace FetchResponseObjectOptions {
|
|
237
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */
|
|
238
|
+
interface WithBody {
|
|
239
|
+
includeBody: true;
|
|
240
|
+
}
|
|
241
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */
|
|
242
|
+
interface WithoutBody {
|
|
243
|
+
includeBody?: false;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
226
246
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()`} */
|
|
227
247
|
type FetchResponseObject = Pick<FetchResponse.Loose, 'url' | 'type' | 'status' | 'statusText' | 'ok' | 'redirected'> & {
|
|
228
248
|
headers: HttpHeadersSerialized<HttpHeadersSchema>;
|
|
@@ -236,13 +256,7 @@ interface FetchResponsePerStatusCode<Schema extends HttpSchema, Method extends H
|
|
|
236
256
|
error: FetchResponseError<Schema, Method, Path>;
|
|
237
257
|
clone: () => FetchResponsePerStatusCode<Schema, Method, Path, StatusCode>;
|
|
238
258
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */
|
|
239
|
-
toObject: ((options:
|
|
240
|
-
includeBody: true;
|
|
241
|
-
}) => Promise<FetchResponseObject>) & ((options?: {
|
|
242
|
-
includeBody?: false;
|
|
243
|
-
}) => FetchResponseObject) & ((options?: {
|
|
244
|
-
includeBody?: boolean;
|
|
245
|
-
}) => PossiblePromise<FetchResponseObject>);
|
|
259
|
+
toObject: ((options: FetchResponseObjectOptions.WithBody) => Promise<FetchResponseObject>) & ((options?: FetchResponseObjectOptions.WithoutBody) => FetchResponseObject) & ((options?: FetchResponseObjectOptions) => PossiblePromise<FetchResponseObject>);
|
|
246
260
|
}
|
|
247
261
|
interface FetchResponseClass {
|
|
248
262
|
new <Schema extends HttpSchema, Method extends HttpSchemaMethod<Schema>, Path extends HttpSchemaPath.Literal<Schema, Method>,
|
|
@@ -266,11 +280,7 @@ declare namespace FetchResponse {
|
|
|
266
280
|
error: FetchResponseError<any, any, any>;
|
|
267
281
|
clone: () => Loose;
|
|
268
282
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */
|
|
269
|
-
toObject: ((options:
|
|
270
|
-
includeBody: true;
|
|
271
|
-
}) => Promise<FetchResponseObject>) & ((options?: {
|
|
272
|
-
includeBody?: false;
|
|
273
|
-
}) => FetchResponseObject);
|
|
283
|
+
toObject: ((options: FetchResponseObjectOptions.WithBody) => Promise<FetchResponseObject>) & ((options?: FetchResponseObjectOptions.WithoutBody) => FetchResponseObject) & ((options?: FetchResponseObjectOptions) => PossiblePromise<FetchResponseObject>);
|
|
274
284
|
}
|
|
275
285
|
}
|
|
276
286
|
declare const FetchResponse: FetchResponseClass;
|
|
@@ -392,4 +402,4 @@ type InferFetchSchema<FetchInstance> = FetchInstance extends Fetch<infer Schema>
|
|
|
392
402
|
/** @see {@link https://zimic.dev/docs/fetch/api/create-fetch `createFetch` API reference} */
|
|
393
403
|
declare function createFetch<Schema extends HttpSchema>(options: FetchOptions<Schema>): Fetch<Schema>;
|
|
394
404
|
|
|
395
|
-
export { Fetch, type FetchDefaults, type FetchInput, type FetchOptions, FetchRequest, type FetchRequestConstructor, FetchRequestInit, type FetchRequestObject, FetchResponse, type FetchResponseConstructor, FetchResponseError, type FetchResponseErrorObject, FetchResponseErrorObjectOptions, type FetchResponseInit, type FetchResponseObject, type FetchResponsePerStatusCode, type FetchResponseStatusCode, type InferFetchSchema, type JSONStringified, createFetch };
|
|
405
|
+
export { Fetch, type FetchDefaults, type FetchInput, type FetchOptions, FetchRequest, type FetchRequestConstructor, FetchRequestInit, type FetchRequestObject, FetchRequestObjectOptions, FetchResponse, type FetchResponseConstructor, FetchResponseError, type FetchResponseErrorObject, FetchResponseErrorObjectOptions, type FetchResponseInit, type FetchResponseObject, FetchResponseObjectOptions, type FetchResponsePerStatusCode, type FetchResponseStatusCode, type InferFetchSchema, type JSONStringified, createFetch };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../zimic-utils/src/url/createRegexFromPath.ts","../../zimic-utils/src/url/excludeNonPathParams.ts","../../zimic-utils/src/url/joinURL.ts","../src/client/utils/objects.ts","../src/client/request/FetchRequest.ts","../src/client/response/error/FetchResponseError.ts","../src/client/response/FetchResponse.ts","../src/client/FetchClient.ts","../src/client/factory.ts"],"names":["parseHttpBody","FetchRequest","HttpHeaders","HttpSearchParams","request","FetchResponse","Request"],"mappings":";;;;;;;AAAO,SAAS,iCAAA,GAAoC;AAClD,EAAA,OAAO,cAAA;AACT;AAEO,SAAS,oBAAoB,IAAA,EAAc;AAGhD,EAAA,MAAM,gBAAgB,CAAA,KAAA,EAAQ,IAAA,CAAK,WAAW,GAAG,CAAA,GAAI,KAAK,GAAG,CAAA,CAAA;AAC7D,EAAA,MAAM,YAAY,IAAI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K,KAAA,CAAM,WAAW,aAAoC,CAAA;AAEpF,MAAA,aAAA,GACE,uBAAuB,aAAA,GAClB,WAAA,GACD,IAAI,aAAA,CAAoC,cAAc,WAAW,CAAA;AAAA,IACzE;AAEA,IAAA,OAAO,aAAA;AAAA,EACT;AAAA,EAEA,SAAA,CACE,OAAA,EACA,MAAA,EACA,IAAA,EAC+C;AAC/C,IAAA,OACE,OAAA,YAAmB,YAAA,IACnB,OAAA,CAAQ,MAAA,KAAW,UACnB,OAAO,OAAA,CAAQ,IAAA,KAAS,QAAA,IACxB,2BAAA,CAAoB,IAAI,CAAA,CAAE,IAAA,CAAK,QAAQ,IAAI,CAAA;AAAA,EAE/C;AAAA,EAEA,UAAA,CACE,QAAA,EACA,MAAA,EACA,IAAA,EACiD;AACjD,IAAA,OAAO,oBAAoB,aAAA,IAAiB,IAAA,CAAK,UAAU,QAAA,CAAS,OAAA,EAAS,QAAQ,IAAI,CAAA;AAAA,EAC3F;AAAA,EAEA,eAAA,CACE,KAAA,EACA,MAAA,EACA,IAAA,EACmD;AACnD,IAAA,OACE,KAAA,YAAiB,0BAAA,IACjB,IAAA,CAAK,SAAA,CAAU,MAAM,OAAA,EAAS,MAAA,EAAQ,IAAI,CAAA,IAC1C,IAAA,CAAK,UAAA,CAAW,KAAA,CAAM,QAAA,EAAU,QAAQ,IAAI,CAAA;AAAA,EAEhD;AACF,CAAA;AAEA,IAAO,mBAAA,GAAQ,WAAA;;;ACxKf,SAAS,YAAuC,OAAA,EAA8C;AAC5F,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,IAAI,oBAAoB,OAAO,CAAA;AACjD,EAAA,OAAO,KAAA;AACT;AAEA,IAAO,eAAA,GAAQ","file":"index.js","sourcesContent":["export function createPathCharactersToEscapeRegex() {\n return /([.(){}+$])/g;\n}\n\nexport function preparePathForRegex(path: string) {\n // We encode the path using the URL API because, differently from encodeURI and encodeURIComponent, URL does not\n // re-encode already encoded characters. Since URL requires a full URL, we use a data scheme and strip it later.\n const pathURLPrefix = `data:${path.startsWith('/') ? '' : '/'}`;\n const pathAsURL = new URL(`${pathURLPrefix}${path}`);\n const encodedPath = pathAsURL.href.replace(pathURLPrefix, '');\n\n return encodedPath.replace(/^\\/+/g, '').replace(/\\/+$/g, '').replace(createPathCharactersToEscapeRegex(), '\\\\$1');\n}\n\n// Path params names must match the JavaScript identifier pattern.\n// See // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers.\nexport function createPathParamRegex() {\n return /(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)(?!\\\\[*+?])/gu;\n}\n\nexport function createRepeatingPathParamRegex() {\n return /(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\\\\\+/gu;\n}\n\nexport function createOptionalPathParamRegex() {\n return /(?<leadingSlash>\\/)?(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\?(?<trailingSlash>\\/)?/gu;\n}\n\nexport function createOptionalRepeatingPathParamRegex() {\n return /(?<leadingSlash>\\/)?(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\*(?<trailingSlash>\\/)?/gu;\n}\n\nfunction createRegexFromPath(path: string) {\n const pathRegexContent = preparePathForRegex(path)\n .replace(\n createOptionalRepeatingPathParamRegex(),\n (\n _match,\n leadingSlash: string | undefined,\n escape: string | undefined,\n identifier: string,\n trailingSlash: string | undefined,\n ) => {\n if (escape) {\n return `${leadingSlash ?? ''}:${identifier}\\\\*${trailingSlash ?? ''}`;\n }\n\n const hasSegmentBeforePrefix = leadingSlash === '/';\n const prefixExpression = hasSegmentBeforePrefix ? '/?' : leadingSlash;\n\n const hasSegmentAfterSuffix = trailingSlash === '/';\n const suffixExpression = hasSegmentAfterSuffix ? '/?' : trailingSlash;\n\n if (prefixExpression && suffixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>.+?)?${suffixExpression})?`;\n } else if (prefixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>.+?))?`;\n } else if (suffixExpression) {\n return `(?:(?<${identifier}>.+?)${suffixExpression})?`;\n } else {\n return `(?<${identifier}>.+?)?`;\n }\n },\n )\n .replace(createRepeatingPathParamRegex(), (_match, escape: string | undefined, identifier: string) => {\n return escape ? `:${identifier}\\\\+` : `(?<${identifier}>.+)`;\n })\n .replace(\n createOptionalPathParamRegex(),\n (\n _match,\n leadingSlash: string | undefined,\n escape: string | undefined,\n identifier: string,\n trailingSlash: string | undefined,\n ) => {\n if (escape) {\n return `${leadingSlash ?? ''}:${identifier}\\\\?${trailingSlash ?? ''}`;\n }\n\n const hasSegmentBeforePrefix = leadingSlash === '/';\n const prefixExpression = hasSegmentBeforePrefix ? '/?' : leadingSlash;\n\n const hasSegmentAfterSuffix = trailingSlash === '/';\n const suffixExpression = hasSegmentAfterSuffix ? '/?' : trailingSlash;\n\n if (prefixExpression && suffixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>[^\\\\/]+?)?${suffixExpression})`;\n } else if (prefixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>[^\\\\/]+?))?`;\n } else if (suffixExpression) {\n return `(?:(?<${identifier}>[^\\\\/]+?)${suffixExpression})?`;\n } else {\n return `(?<${identifier}>[^\\\\/]+?)?`;\n }\n },\n )\n .replace(createPathParamRegex(), (_match, escape: string | undefined, identifier: string) => {\n return escape ? `:${identifier}` : `(?<${identifier}>[^\\\\/]+?)`;\n });\n\n return new RegExp(`^/?${pathRegexContent}/?$`);\n}\n\nexport default createRegexFromPath;\n","function excludeNonPathParams(url: URL) {\n url.hash = '';\n url.search = '';\n url.username = '';\n url.password = '';\n return url;\n}\n\nexport default excludeNonPathParams;\n","function joinURL(...parts: (URL | string)[]) {\n return parts\n .map((part, index) => {\n const isFirstPart = index === 0;\n const isLastPart = index === parts.length - 1;\n\n let partAsString = part.toString();\n\n if (!isFirstPart) {\n partAsString = partAsString.replace(/^\\//, '');\n }\n if (!isLastPart) {\n partAsString = partAsString.replace(/\\/$/, '');\n }\n\n return partAsString;\n })\n .filter((part) => part.length > 0)\n .join('/');\n}\n\nexport default joinURL;\n","import { parseHttpBody } from '@zimic/http';\nimport { PossiblePromise } from '@zimic/utils/types';\n\nimport { FetchRequestObject } from '../request/types';\nimport { FetchResponseObject } from '../response/types';\n\nconst BODY_METHOD = ['json', 'formData', 'text', 'arrayBuffer', 'blob', 'bytes'] satisfies (keyof Body)[];\ntype BodyMethod = (typeof BODY_METHOD)[number];\n\nexport function isBodyMethod(property: string | symbol, value: unknown): value is Body[BodyMethod] {\n return BODY_METHOD.includes(property as BodyMethod) && typeof value === 'function';\n}\n\nexport function getOrSetBoundBodyMethod(\n resource: Request | Response,\n property: string | symbol,\n value: Body[BodyMethod],\n) {\n // We cache the bound function on the proxy instance to avoid re-binding it on every access.\n const isValueAlreadyBound = Object.prototype.hasOwnProperty.call(resource, property);\n\n if (isValueAlreadyBound) {\n return value;\n }\n\n const boundValue = value.bind(resource) as unknown;\n\n Object.defineProperty(resource, property, {\n value: boundValue,\n configurable: true,\n enumerable: false,\n writable: true,\n });\n\n return boundValue;\n}\n\nexport function withIncludedBodyIfAvailable(\n resource: Request,\n resourceObject: FetchRequestObject,\n): PossiblePromise<FetchRequestObject>;\nexport function withIncludedBodyIfAvailable(\n resource: Response,\n resourceObject: FetchResponseObject,\n): PossiblePromise<FetchResponseObject>;\nexport function withIncludedBodyIfAvailable(\n resource: Request | Response,\n resourceObject: FetchRequestObject | FetchResponseObject,\n): PossiblePromise<FetchRequestObject | FetchResponseObject> {\n const resourceType = resource instanceof Request ? 'request' : 'response';\n\n if (resource.bodyUsed) {\n console.warn(\n '[@zimic/fetch]',\n `Could not include the ${resourceType} body because it is already used. ` +\n 'If you access the body before calling `toObject()`, consider reading it from a cloned ' +\n `${resourceType}.\\n\\nLearn more: https://zimic.dev/docs/fetch/api/fetch-response-error#errortoobject`,\n );\n return resourceObject;\n }\n\n return parseHttpBody(resource.clone())\n .then((body) => {\n resourceObject.body = body;\n return resourceObject;\n })\n .catch((error: unknown) => {\n console.error('[@zimic/fetch]', `Failed to parse ${resourceType} body:`, error);\n return resourceObject;\n });\n}\n","import {\n HttpSchema,\n HttpSchemaMethod,\n HttpSchemaPath,\n HttpRequest,\n HttpRequestBodySchema,\n HttpRequestHeadersSchema,\n HttpHeaders,\n HttpSearchParams,\n HttpMethod,\n AllowAnyStringInPathParams,\n LiteralHttpSchemaPathFromNonLiteral,\n HttpHeadersInit,\n HttpSearchParamsInit,\n HttpHeadersSchema,\n} from '@zimic/http';\nimport { Default, PossiblePromise } from '@zimic/utils/types';\nimport { excludeNonPathParams, joinURL } from '@zimic/utils/url';\n\nimport { Fetch, FetchInput } from '../types/public';\nimport { getOrSetBoundBodyMethod, isBodyMethod, withIncludedBodyIfAvailable } from '../utils/objects';\nimport { FetchRequestBodySchema, FetchRequestInit, FetchRequestObject } from './types';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request `FetchRequest` API reference} */\nexport interface FetchRequest<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n> extends HttpRequest<\n HttpRequestBodySchema<Default<Schema[Path][Method]>>,\n Default<HttpRequestHeadersSchema<Default<Schema[Path][Method]>>>\n> {\n raw: Request;\n path: AllowAnyStringInPathParams<Path>;\n method: Method;\n clone: () => FetchRequest<Schema, Method, Path>;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */\n toObject: ((options: { includeBody: true }) => Promise<FetchRequestObject>) &\n ((options?: { includeBody?: false }) => FetchRequestObject) &\n ((options?: { includeBody?: boolean }) => PossiblePromise<FetchRequestObject>);\n}\n\nexport namespace FetchRequest {\n /** A loosely typed version of a {@link FetchRequest `FetchRequest`}. */\n export interface Loose extends Request {\n raw: Request;\n path: string;\n method: HttpMethod;\n clone: () => Loose;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */\n toObject: ((options: { includeBody: true }) => Promise<FetchRequestObject>) &\n ((options?: { includeBody?: false }) => FetchRequestObject);\n }\n}\n\ninterface FetchRequestClass {\n new <\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n >(\n fetch: Fetch<Schema>,\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>,\n ): FetchRequest<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>;\n\n prototype: Request;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [Symbol.hasInstance]: (instance: unknown) => instance is FetchRequest<any, any, any>;\n}\n\nconst FETCH_REQUEST_BRAND = Symbol.for('FetchRequest');\n\nconst FETCH_REQUEST_EXTRA_PROPERTIES = [FETCH_REQUEST_BRAND, 'raw', 'path', 'toObject'] as const;\ntype FetchRequestExtraProperty = (typeof FETCH_REQUEST_EXTRA_PROPERTIES)[number];\n\nfunction createFetchRequestClass() {\n const FetchRequestClass = function FetchRequest<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n >(\n fetch: Fetch<Schema>,\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>> & {\n headers?: HttpHeadersInit<Default<Schema[Path][Method]>>;\n searchParams?: HttpSearchParamsInit<Default<Schema[Path][Method]>>;\n body?: FetchRequestBodySchema<Default<Default<Schema[Path][Method]>['request']>>;\n },\n ) {\n let actualInput: URL | Request;\n\n const actualInit = {\n baseURL: init?.baseURL ?? fetch.baseURL,\n method: init?.method ?? fetch.method,\n headers: new HttpHeaders(fetch.headers),\n searchParams: new HttpSearchParams(fetch.searchParams),\n body: (init?.body ?? fetch.body) as BodyInit | null,\n mode: init?.mode ?? fetch.mode,\n cache: init?.cache ?? fetch.cache,\n credentials: init?.credentials ?? fetch.credentials,\n integrity: init?.integrity ?? fetch.integrity,\n keepalive: init?.keepalive ?? fetch.keepalive,\n priority: init?.priority ?? fetch.priority,\n redirect: init?.redirect ?? fetch.redirect,\n referrer: init?.referrer ?? fetch.referrer,\n referrerPolicy: init?.referrerPolicy ?? fetch.referrerPolicy,\n signal: init?.signal ?? fetch.signal,\n window: init?.window === undefined ? fetch.window : init.window,\n duplex: init?.duplex ?? fetch.duplex,\n };\n\n if (init?.headers !== undefined) {\n actualInit.headers.assign(new HttpHeaders(init.headers));\n }\n\n let url: URL;\n const baseURL = new URL(actualInit.baseURL);\n\n if (input instanceof Request) {\n const request = input as Request;\n\n actualInit.headers.assign(new HttpHeaders<FetchRequestInit.DefaultHeaders<Schema>>(request.headers));\n\n url = new URL(input.url);\n\n actualInput = request instanceof FetchRequestClass ? request.raw : request;\n } else {\n url = new URL(input instanceof URL ? input : joinURL(baseURL, input));\n\n actualInit.searchParams.assign(\n new HttpSearchParams<FetchRequestInit.DefaultSearchParams<Schema>>(url.searchParams),\n );\n\n if (init?.searchParams !== undefined) {\n actualInit.searchParams.assign(new HttpSearchParams(init.searchParams));\n }\n\n url.search = actualInit.searchParams.toString();\n\n actualInput = url;\n }\n\n const request = new Request(actualInput, actualInit);\n\n const baseURLWithoutTrailingSlash = baseURL.toString().replace(/\\/$/, '');\n const path = excludeNonPathParams(url).toString().replace(baseURLWithoutTrailingSlash, '');\n\n function clone() {\n return new FetchRequestClass(fetch, request.clone() as FetchInput<Schema, Method, Path>);\n }\n\n function toObject(options: { includeBody: true }): Promise<FetchRequestObject>;\n function toObject(options?: { includeBody?: false }): FetchRequestObject;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchRequestObject>;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchRequestObject> {\n const requestObject: FetchRequestObject = {\n url: request.url,\n path,\n method: request.method as HttpMethod,\n headers: HttpHeaders.prototype.toObject.call(request.headers) as HttpHeadersSchema,\n cache: request.cache,\n destination: request.destination,\n credentials: request.credentials,\n integrity: request.integrity,\n keepalive: request.keepalive,\n mode: request.mode,\n redirect: request.redirect,\n referrer: request.referrer,\n referrerPolicy: request.referrerPolicy,\n };\n\n if (!options?.includeBody) {\n return requestObject;\n }\n\n return withIncludedBodyIfAvailable(request, requestObject);\n }\n\n type FetchRequestInstance = FetchRequest<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>;\n\n const fetchRequest = new Proxy(request, {\n get(target, property) {\n if (property === FETCH_REQUEST_BRAND) {\n return true;\n }\n\n if (property === ('raw' satisfies keyof FetchRequestInstance)) {\n return request satisfies FetchRequestInstance['raw'];\n }\n\n if (property === ('path' satisfies keyof FetchRequestInstance)) {\n return path as AllowAnyStringInPathParams<\n LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>\n > satisfies FetchRequestInstance['path'];\n }\n\n if (property === ('clone' satisfies keyof FetchRequestInstance)) {\n return clone satisfies FetchRequestInstance['clone'];\n }\n\n if (property === ('toObject' satisfies keyof FetchRequestInstance)) {\n return toObject satisfies FetchRequestInstance['toObject'];\n }\n\n // Fallback other properties to the original `Request` instance.\n const value = Reflect.get(target, property, target) as unknown;\n\n if (isBodyMethod(property, value)) {\n return getOrSetBoundBodyMethod(request, property, value);\n }\n\n return value;\n },\n\n has(target, property) {\n return (\n FETCH_REQUEST_EXTRA_PROPERTIES.includes(property as FetchRequestExtraProperty) ||\n Reflect.has(target, property)\n );\n },\n }) as unknown as FetchRequest<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>;\n\n return fetchRequest;\n } as unknown as FetchRequestClass;\n\n Object.defineProperty(FetchRequestClass, Symbol.hasInstance, {\n value(instance: unknown): boolean {\n return instance instanceof Request && FETCH_REQUEST_BRAND in instance && instance[FETCH_REQUEST_BRAND] === true;\n },\n writable: false,\n enumerable: false,\n configurable: false,\n });\n\n Object.setPrototypeOf(FetchRequestClass.prototype, Request.prototype);\n\n return FetchRequestClass;\n}\n\nexport const FetchRequest = createFetchRequestClass();\n","import { HttpSchema, HttpSchemaMethod, HttpSchemaPath } from '@zimic/http';\nimport { PossiblePromise } from '@zimic/utils/types';\n\nimport { FetchRequest } from '../../request/FetchRequest';\nimport { FetchResponse } from '../FetchResponse';\nimport { FetchResponseErrorObjectOptions, FetchResponseErrorObject } from './types';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response-error `FetchResponseError` API reference} */\nclass FetchResponseError<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n> extends Error {\n constructor(\n public request: FetchRequest<Schema, Method, Path>,\n public response: FetchResponse<Schema, Method, Path>,\n ) {\n super(`${request.method} ${request.url} failed with status ${response.status}.`);\n this.name = 'FetchResponseError';\n }\n\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-response-error#errortoobject `response.error.toObject()` API reference} */\n toObject(options: FetchResponseErrorObjectOptions.WithBody): Promise<FetchResponseErrorObject>;\n toObject(options?: FetchResponseErrorObjectOptions.WithoutBody): FetchResponseErrorObject;\n toObject(options?: FetchResponseErrorObjectOptions): PossiblePromise<FetchResponseErrorObject>;\n toObject(options?: FetchResponseErrorObjectOptions): PossiblePromise<FetchResponseErrorObject> {\n const partialObject = {\n name: this.name,\n message: this.message,\n } satisfies Partial<FetchResponseErrorObject>;\n\n if (!options?.includeRequestBody && !options?.includeResponseBody) {\n return {\n ...partialObject,\n request: this.request.toObject({ includeBody: false }),\n response: this.response.toObject({ includeBody: false }),\n };\n }\n\n return Promise.all([\n Promise.resolve(this.request.toObject({ includeBody: options.includeRequestBody })),\n Promise.resolve(this.response.toObject({ includeBody: options.includeResponseBody })),\n ]).then(([request, response]) => ({ ...partialObject, request, response }));\n }\n}\n\nexport default FetchResponseError;\n","import {\n HttpHeaders,\n HttpHeadersSchema,\n HttpResponse,\n HttpResponseBodySchema,\n HttpResponseHeadersSchema,\n HttpSchema,\n HttpSchemaMethod,\n HttpSchemaPath,\n HttpStatusCode,\n} from '@zimic/http';\nimport { Default, PossiblePromise } from '@zimic/utils/types';\n\nimport { FetchRequest } from '../request/FetchRequest';\nimport { getOrSetBoundBodyMethod, isBodyMethod, withIncludedBodyIfAvailable } from '../utils/objects';\nimport FetchResponseError from './error/FetchResponseError';\nimport { FetchResponseBodySchema, FetchResponseInit, FetchResponseObject, FetchResponseStatusCode } from './types';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response `FetchResponse` API reference} */\nexport interface FetchResponsePerStatusCode<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n StatusCode extends HttpStatusCode = HttpStatusCode,\n> extends HttpResponse<\n HttpResponseBodySchema<Default<Schema[Path][Method]>, StatusCode>,\n Default<HttpResponseHeadersSchema<Default<Schema[Path][Method]>, StatusCode>>,\n StatusCode\n> {\n raw: Response;\n request: FetchRequest<Schema, Method, Path>;\n error: FetchResponseError<Schema, Method, Path>;\n clone: () => FetchResponsePerStatusCode<Schema, Method, Path, StatusCode>;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */\n toObject: ((options: { includeBody: true }) => Promise<FetchResponseObject>) &\n ((options?: { includeBody?: false }) => FetchResponseObject) &\n ((options?: { includeBody?: boolean }) => PossiblePromise<FetchResponseObject>);\n}\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response `FetchResponse` API reference} */\nexport type FetchResponse<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n> = StatusCode extends StatusCode ? FetchResponsePerStatusCode<Schema, Method, Path, StatusCode> : never;\n\nexport namespace FetchResponse {\n /** A loosely typed version of a {@link FetchResponse}. */\n export interface Loose extends Response {\n raw: Response;\n request: FetchRequest.Loose;\n error: FetchResponseError<any, any, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n clone: () => Loose;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */\n toObject: ((options: { includeBody: true }) => Promise<FetchResponseObject>) &\n ((options?: { includeBody?: false }) => FetchResponseObject);\n }\n}\n\ninterface FetchResponseClass {\n new <\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n >(\n fetchRequest: FetchRequest<Schema, Method, Path>,\n response?: Response,\n ): FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n new <\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n >(\n fetchRequest: FetchRequest<Schema, Method, Path>,\n body?: FetchResponseBodySchema<Default<Default<Default<Schema[Path][Method]>['response']>[StatusCode]>>,\n init?: FetchResponseInit<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>,\n ): FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n\n prototype: Response;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [Symbol.hasInstance]: (instance: unknown) => instance is FetchResponse<any, any, any, any, any, any>;\n}\n\nconst FETCH_RESPONSE_BRAND = Symbol.for('FetchResponse');\n\nconst FETCH_RESPONSE_EXTRA_PROPERTIES = [FETCH_RESPONSE_BRAND, 'raw', 'request', 'error', 'toObject'] as const;\ntype FetchResponseExtraProperty = (typeof FETCH_RESPONSE_EXTRA_PROPERTIES)[number];\n\nfunction createFetchResponseClass() {\n const FetchResponseClass = function FetchResponse<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n >(\n fetchRequest: FetchRequest<Schema, Method, Path>,\n responseOrBody?:\n | Response\n | FetchResponseBodySchema<Default<Default<Default<Schema[Path][Method]>['response']>[StatusCode]>>,\n init?: FetchResponseInit<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>,\n ): FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode> {\n const response =\n responseOrBody instanceof Response\n ? responseOrBody\n : new Response(responseOrBody as BodyInit | null, init as ResponseInit);\n\n let error: FetchResponseError<Schema, Method, Path> | null = null;\n\n function clone() {\n return new FetchResponseClass(fetchRequest, response.clone());\n }\n\n function toObject(options: { includeBody: true }): Promise<FetchResponseObject>;\n function toObject(options?: { includeBody?: false }): FetchResponseObject;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchResponseObject>;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchResponseObject> {\n const responseObject: FetchResponseObject = {\n url: response.url,\n type: response.type,\n status: response.status,\n statusText: response.statusText,\n ok: response.ok,\n headers: HttpHeaders.prototype.toObject.call(response.headers) as HttpHeadersSchema,\n redirected: response.redirected,\n };\n\n if (!options?.includeBody) {\n return responseObject;\n }\n\n return withIncludedBodyIfAvailable(response, responseObject);\n }\n\n type FetchResponseInstance = FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n\n const fetchResponse = new Proxy(response, {\n get(target, property, receiver) {\n if (property === FETCH_RESPONSE_BRAND) {\n return true;\n }\n\n if (property === ('raw' satisfies keyof FetchResponseInstance)) {\n return response satisfies FetchResponseInstance['raw'];\n }\n\n if (property === ('request' satisfies keyof FetchResponseInstance)) {\n return fetchRequest satisfies FetchResponseInstance['request'];\n }\n\n if (property === ('error' satisfies keyof FetchResponseInstance)) {\n // We create the error lazily to preserve the stack trace from the point where it was first accessed.\n error ??= new FetchResponseError(fetchRequest, receiver as FetchResponse<Schema, Method, Path>);\n return error satisfies FetchResponseInstance['error'];\n }\n\n if (property === ('clone' satisfies keyof FetchResponseInstance)) {\n // The `clone` method is not compatible with the mapping we do in `FetchResponse`(i.e.\n // `StatusCode extends StatusCode ? ... : ...`), so we need a type assertion here.\n return clone as FetchResponseInstance['clone'];\n }\n\n if (property === ('toObject' satisfies keyof FetchResponseInstance)) {\n return toObject satisfies FetchResponseInstance['toObject'];\n }\n\n // Fallback other properties to the original `Response` instance.\n const value = Reflect.get(target, property, target) as unknown;\n\n if (isBodyMethod(property, value)) {\n return getOrSetBoundBodyMethod(response, property, value);\n }\n\n return value;\n },\n\n has(target, property) {\n return (\n FETCH_RESPONSE_EXTRA_PROPERTIES.includes(property as FetchResponseExtraProperty) ||\n Reflect.has(target, property)\n );\n },\n }) as unknown as FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n\n return fetchResponse;\n } as unknown as FetchResponseClass;\n\n Object.defineProperty(FetchResponseClass, Symbol.hasInstance, {\n value(instance: unknown): boolean {\n return (\n instance instanceof Response && FETCH_RESPONSE_BRAND in instance && instance[FETCH_RESPONSE_BRAND] === true\n );\n },\n writable: false,\n enumerable: false,\n configurable: false,\n });\n\n Object.setPrototypeOf(FetchResponseClass.prototype, Response.prototype);\n\n return FetchResponseClass;\n}\n\nexport const FetchResponse = createFetchResponseClass();\n\nObject.setPrototypeOf(FetchResponse.prototype, Response.prototype);\n","import { HttpSchemaPath, HttpSchemaMethod, LiteralHttpSchemaPathFromNonLiteral, HttpSchema } from '@zimic/http';\nimport { createRegexFromPath } from '@zimic/utils/url';\n\nimport { FetchRequest } from './request/FetchRequest';\nimport { FetchRequestInit } from './request/types';\nimport FetchResponseError from './response/error/FetchResponseError';\nimport { FetchResponse } from './response/FetchResponse';\nimport { FetchInput, FetchOptions, Fetch, FetchDefaults, FetchRequestConstructor } from './types/public';\n\nconst FETCH_OPTIONS_DEFAULT_PROPERTIES = [\n 'baseURL',\n 'onRequest',\n 'onResponse',\n 'body',\n 'cache',\n 'credentials',\n 'integrity',\n 'keepalive',\n 'mode',\n 'priority',\n 'redirect',\n 'referrer',\n 'referrerPolicy',\n 'signal',\n 'window',\n 'duplex',\n] satisfies (keyof FetchOptions<never>)[];\n\nclass FetchClient<Schema extends HttpSchema> implements Omit<Fetch<Schema>, 'loose' | 'Request' | keyof FetchDefaults> {\n fetch: Fetch<Schema>;\n\n constructor(options: FetchOptions<Schema>) {\n this.fetch = this.createFetchFunction();\n this.assignDefaults(this.fetch, options);\n this.fetch.loose = this.fetch as unknown as Fetch.Loose;\n this.fetch.Request = this.createFetchRequestConstructor(this.fetch);\n }\n\n private assignDefaults(\n fetch: Fetch<Schema>,\n { headers = {}, searchParams = {}, ...otherOptions }: FetchOptions<Schema>,\n ) {\n fetch.headers = headers;\n fetch.searchParams = searchParams;\n\n for (const property of FETCH_OPTIONS_DEFAULT_PROPERTIES) {\n const propertyValue = otherOptions[property];\n\n if (propertyValue !== undefined) {\n fetch[property] = propertyValue as never;\n }\n }\n }\n\n get defaults(): FetchDefaults<Schema> {\n return this.fetch;\n }\n\n private createFetchFunction() {\n const fetch = async <\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n Redirect extends RequestRedirect = 'follow',\n >(\n input: FetchInput<Schema, Method, Path>,\n init: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>, Redirect>,\n ) => {\n const fetchRequest = await this.createFetchRequest<Method, Path>(input, init);\n\n const response = await globalThis.fetch(fetchRequest.raw.clone());\n const fetchResponse = await this.createFetchResponse<\n Method,\n LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>\n >(fetchRequest, response);\n\n return fetchResponse;\n };\n\n return Object.setPrototypeOf(fetch, this) as Fetch<Schema>;\n }\n\n private createFetchRequestConstructor<Schema extends HttpSchema>(fetch: Fetch<Schema>) {\n function Request<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n Redirect extends RequestRedirect = 'follow',\n >(\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>, Redirect>,\n ) {\n return new FetchRequest(fetch, input, init);\n }\n\n Object.setPrototypeOf(Request.prototype, FetchRequest.prototype);\n\n return Request as unknown as FetchRequestConstructor<Schema>;\n }\n\n private async createFetchRequest<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n >(\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>,\n ) {\n let fetchRequest = new this.fetch.Request(input, init);\n\n if (this.fetch.onRequest) {\n const newRequest = await this.fetch.onRequest(fetchRequest as FetchRequest.Loose);\n\n if (newRequest !== fetchRequest) {\n if (newRequest instanceof FetchRequest) {\n fetchRequest = newRequest as typeof fetchRequest;\n } else {\n fetchRequest = new this.fetch.Request(newRequest as FetchInput<Schema, Method, Path>, init);\n }\n }\n }\n\n return fetchRequest;\n }\n\n private async createFetchResponse<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n >(fetchRequest: FetchRequest<Schema, Method, Path>, response: Response) {\n let fetchResponse = new FetchResponse<Schema, Method, Path>(fetchRequest, response);\n\n if (this.fetch.onResponse) {\n const newResponse = await this.fetch.onResponse(fetchResponse as FetchResponse.Loose);\n\n fetchResponse =\n newResponse instanceof FetchResponse\n ? (newResponse as typeof fetchResponse)\n : new FetchResponse<Schema, Method, Path>(fetchRequest, newResponse);\n }\n\n return fetchResponse;\n }\n\n isRequest<Path extends HttpSchemaPath.Literal<Schema, Method>, Method extends HttpSchemaMethod<Schema>>(\n request: unknown,\n method: Method,\n path: Path,\n ): request is FetchRequest<Schema, Method, Path> {\n return (\n request instanceof FetchRequest &&\n request.method === method &&\n typeof request.path === 'string' &&\n createRegexFromPath(path).test(request.path)\n );\n }\n\n isResponse<Path extends HttpSchemaPath.Literal<Schema, Method>, Method extends HttpSchemaMethod<Schema>>(\n response: unknown,\n method: Method,\n path: Path,\n ): response is FetchResponse<Schema, Method, Path> {\n return response instanceof FetchResponse && this.isRequest(response.request, method, path);\n }\n\n isResponseError<Path extends HttpSchemaPath.Literal<Schema, Method>, Method extends HttpSchemaMethod<Schema>>(\n error: unknown,\n method: Method,\n path: Path,\n ): error is FetchResponseError<Schema, Method, Path> {\n return (\n error instanceof FetchResponseError &&\n this.isRequest(error.request, method, path) &&\n this.isResponse(error.response, method, path)\n );\n }\n}\n\nexport default FetchClient;\n","import { HttpSchema } from '@zimic/http';\n\nimport FetchClient from './FetchClient';\nimport { FetchOptions, Fetch } from './types/public';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/create-fetch `createFetch` API reference} */\nfunction createFetch<Schema extends HttpSchema>(options: FetchOptions<Schema>): Fetch<Schema> {\n const { fetch } = new FetchClient<Schema>(options);\n return fetch;\n}\n\nexport default createFetch;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../zimic-utils/src/url/createRegexFromPath.ts","../../zimic-utils/src/url/excludeNonPathParams.ts","../../zimic-utils/src/url/joinURL.ts","../src/client/utils/objects.ts","../src/client/request/FetchRequest.ts","../src/client/response/error/FetchResponseError.ts","../src/client/response/FetchResponse.ts","../src/client/FetchClient.ts","../src/client/factory.ts"],"names":["parseHttpBody","FetchRequest","HttpHeaders","HttpSearchParams","request","FetchResponse","Request"],"mappings":";;;;;;;AAAO,SAAS,iCAAA,GAAoC;AAClD,EAAA,OAAO,cAAA;AACT;AAEO,SAAS,oBAAoB,IAAA,EAAc;AAGhD,EAAA,MAAM,gBAAgB,CAAA,KAAA,EAAQ,IAAA,CAAK,WAAW,GAAG,CAAA,GAAI,KAAK,GAAG,CAAA,CAAA;AAC7D,EAAA,MAAM,YAAY,IAAI,GAAA,CAAI,GAAG,aAAa,CAAA,EAAG,IAAI,CAAA,CAAE,CAAA;AACnD,EAAA,MAAM,WAAA,GAAc,SAAA,CAAU,IAAA,CAAK,OAAA,CAAQ,eAAe,EAAE,CAAA;AAE5D,EAAA,OAAO,WAAA,CAAY,OAAA,CAAQ,OAAA,EAAS,EAAE,CAAA,CAAE,OAAA,CAAQ,OAAA,EAAS,EAAE,CAAA,CAAE,OAAA,CAAQ,iCAAA,EAAA,EAAqC,MAAM,CAAA;AAClH;AAIO,SAAS,oBAAA,GAAuB;AACrC,EAAA,OAAO,gFAAA;AACT;AAEO,SAAS,6BAAA,GAAgC;AAC9C,EAAA,OAAO,yEAAA;AACT;AAEO,SAAS,4BAAA,GAA+B;AAC7C,EAAA,OAAO,gHAAA;AACT;AAEO,SAAS,qCAAA,GAAwC;AACtD,EAAA,OAAO,gHAAA;AACT;AAEA,SAAS,oBAAoB,IAAA,EAAc;AACzC,EAAA,MAAM,gBAAA,GAAmB,mBAAA,CAAoB,IAAI,CAAA,CAC9C,OAAA;IACC,qCAAA,EAAA;AACA,IAAA,CACE,MAAA,EACA,YAAA,EACA,MAAA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AAA,CAAU,MAAM,OAAA,EAAS,MAAA,EAAQ,IAAI,CAAA,IAC1C,IAAA,CAAK,UAAA,CAAW,KAAA,CAAM,QAAA,EAAU,QAAQ,IAAI,CAAA;AAAA,EAEhD;AACF,CAAA;AAEA,IAAO,mBAAA,GAAQ,WAAA;;;ACxKf,SAAS,YAAuC,OAAA,EAA8C;AAC5F,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,IAAI,oBAAoB,OAAO,CAAA;AACjD,EAAA,OAAO,KAAA;AACT;AAEA,IAAO,eAAA,GAAQ","file":"index.js","sourcesContent":["export function createPathCharactersToEscapeRegex() {\n return /([.(){}+$])/g;\n}\n\nexport function preparePathForRegex(path: string) {\n // We encode the path using the URL API because, differently from encodeURI and encodeURIComponent, URL does not\n // re-encode already encoded characters. Since URL requires a full URL, we use a data scheme and strip it later.\n const pathURLPrefix = `data:${path.startsWith('/') ? '' : '/'}`;\n const pathAsURL = new URL(`${pathURLPrefix}${path}`);\n const encodedPath = pathAsURL.href.replace(pathURLPrefix, '');\n\n return encodedPath.replace(/^\\/+/g, '').replace(/\\/+$/g, '').replace(createPathCharactersToEscapeRegex(), '\\\\$1');\n}\n\n// Path params names must match the JavaScript identifier pattern.\n// See // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers.\nexport function createPathParamRegex() {\n return /(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)(?!\\\\[*+?])/gu;\n}\n\nexport function createRepeatingPathParamRegex() {\n return /(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\\\\\+/gu;\n}\n\nexport function createOptionalPathParamRegex() {\n return /(?<leadingSlash>\\/)?(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\?(?<trailingSlash>\\/)?/gu;\n}\n\nexport function createOptionalRepeatingPathParamRegex() {\n return /(?<leadingSlash>\\/)?(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\*(?<trailingSlash>\\/)?/gu;\n}\n\nfunction createRegexFromPath(path: string) {\n const pathRegexContent = preparePathForRegex(path)\n .replace(\n createOptionalRepeatingPathParamRegex(),\n (\n _match,\n leadingSlash: string | undefined,\n escape: string | undefined,\n identifier: string,\n trailingSlash: string | undefined,\n ) => {\n if (escape) {\n return `${leadingSlash ?? ''}:${identifier}\\\\*${trailingSlash ?? ''}`;\n }\n\n const hasSegmentBeforePrefix = leadingSlash === '/';\n const prefixExpression = hasSegmentBeforePrefix ? '/?' : leadingSlash;\n\n const hasSegmentAfterSuffix = trailingSlash === '/';\n const suffixExpression = hasSegmentAfterSuffix ? '/?' : trailingSlash;\n\n if (prefixExpression && suffixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>.+?)?${suffixExpression})?`;\n } else if (prefixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>.+?))?`;\n } else if (suffixExpression) {\n return `(?:(?<${identifier}>.+?)${suffixExpression})?`;\n } else {\n return `(?<${identifier}>.+?)?`;\n }\n },\n )\n .replace(createRepeatingPathParamRegex(), (_match, escape: string | undefined, identifier: string) => {\n return escape ? `:${identifier}\\\\+` : `(?<${identifier}>.+)`;\n })\n .replace(\n createOptionalPathParamRegex(),\n (\n _match,\n leadingSlash: string | undefined,\n escape: string | undefined,\n identifier: string,\n trailingSlash: string | undefined,\n ) => {\n if (escape) {\n return `${leadingSlash ?? ''}:${identifier}\\\\?${trailingSlash ?? ''}`;\n }\n\n const hasSegmentBeforePrefix = leadingSlash === '/';\n const prefixExpression = hasSegmentBeforePrefix ? '/?' : leadingSlash;\n\n const hasSegmentAfterSuffix = trailingSlash === '/';\n const suffixExpression = hasSegmentAfterSuffix ? '/?' : trailingSlash;\n\n if (prefixExpression && suffixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>[^\\\\/]+?)?${suffixExpression})`;\n } else if (prefixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>[^\\\\/]+?))?`;\n } else if (suffixExpression) {\n return `(?:(?<${identifier}>[^\\\\/]+?)${suffixExpression})?`;\n } else {\n return `(?<${identifier}>[^\\\\/]+?)?`;\n }\n },\n )\n .replace(createPathParamRegex(), (_match, escape: string | undefined, identifier: string) => {\n return escape ? `:${identifier}` : `(?<${identifier}>[^\\\\/]+?)`;\n });\n\n return new RegExp(`^/?${pathRegexContent}/?$`);\n}\n\nexport default createRegexFromPath;\n","function excludeNonPathParams(url: URL) {\n url.hash = '';\n url.search = '';\n url.username = '';\n url.password = '';\n return url;\n}\n\nexport default excludeNonPathParams;\n","function joinURL(...parts: (URL | string)[]) {\n return parts\n .map((part, index) => {\n const isFirstPart = index === 0;\n const isLastPart = index === parts.length - 1;\n\n let partAsString = part.toString();\n\n if (!isFirstPart) {\n partAsString = partAsString.replace(/^\\//, '');\n }\n if (!isLastPart) {\n partAsString = partAsString.replace(/\\/$/, '');\n }\n\n return partAsString;\n })\n .filter((part) => part.length > 0)\n .join('/');\n}\n\nexport default joinURL;\n","import { parseHttpBody } from '@zimic/http';\nimport { PossiblePromise } from '@zimic/utils/types';\n\nimport { FetchRequestObject } from '../request/types';\nimport { FetchResponseObject } from '../response/types';\n\nconst BODY_METHOD = ['json', 'formData', 'text', 'arrayBuffer', 'blob', 'bytes'] satisfies (keyof Body)[];\ntype BodyMethod = (typeof BODY_METHOD)[number];\n\nexport function isBodyMethod(property: string | symbol, value: unknown): value is Body[BodyMethod] {\n return BODY_METHOD.includes(property as BodyMethod) && typeof value === 'function';\n}\n\nexport function getOrSetBoundBodyMethod(\n resource: Request | Response,\n property: string | symbol,\n value: Body[BodyMethod],\n) {\n // We cache the bound function on the proxy instance to avoid re-binding it on every access.\n const isValueAlreadyBound = Object.prototype.hasOwnProperty.call(resource, property);\n\n if (isValueAlreadyBound) {\n return value;\n }\n\n const boundValue = value.bind(resource) as unknown;\n\n Object.defineProperty(resource, property, {\n value: boundValue,\n configurable: true,\n enumerable: false,\n writable: true,\n });\n\n return boundValue;\n}\n\nexport function withIncludedBodyIfAvailable(\n resource: Request,\n resourceObject: FetchRequestObject,\n): PossiblePromise<FetchRequestObject>;\nexport function withIncludedBodyIfAvailable(\n resource: Response,\n resourceObject: FetchResponseObject,\n): PossiblePromise<FetchResponseObject>;\nexport function withIncludedBodyIfAvailable(\n resource: Request | Response,\n resourceObject: FetchRequestObject | FetchResponseObject,\n): PossiblePromise<FetchRequestObject | FetchResponseObject> {\n const resourceType = resource instanceof Request ? 'request' : 'response';\n\n if (resource.bodyUsed) {\n console.warn(\n '[@zimic/fetch]',\n `Could not include the ${resourceType} body because it is already used. ` +\n 'If you access the body before calling `toObject()`, consider reading it from a cloned ' +\n `${resourceType}.\\n\\nLearn more: https://zimic.dev/docs/fetch/api/fetch-response-error#errortoobject`,\n );\n return resourceObject;\n }\n\n return parseHttpBody(resource.clone())\n .then((body) => {\n resourceObject.body = body;\n return resourceObject;\n })\n .catch((error: unknown) => {\n console.error('[@zimic/fetch]', `Failed to parse ${resourceType} body:`, error);\n return resourceObject;\n });\n}\n","import {\n HttpSchema,\n HttpSchemaMethod,\n HttpSchemaPath,\n HttpRequest,\n HttpRequestBodySchema,\n HttpRequestHeadersSchema,\n HttpHeaders,\n HttpSearchParams,\n HttpMethod,\n AllowAnyStringInPathParams,\n LiteralHttpSchemaPathFromNonLiteral,\n HttpHeadersInit,\n HttpSearchParamsInit,\n HttpHeadersSchema,\n} from '@zimic/http';\nimport { Default, PossiblePromise } from '@zimic/utils/types';\nimport { excludeNonPathParams, joinURL } from '@zimic/utils/url';\n\nimport { Fetch, FetchInput } from '../types/public';\nimport { getOrSetBoundBodyMethod, isBodyMethod, withIncludedBodyIfAvailable } from '../utils/objects';\nimport { FetchRequestBodySchema, FetchRequestInit, FetchRequestObject, FetchRequestObjectOptions } from './types';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request `FetchRequest` API reference} */\nexport interface FetchRequest<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n> extends HttpRequest<\n HttpRequestBodySchema<Default<Schema[Path][Method]>>,\n Default<HttpRequestHeadersSchema<Default<Schema[Path][Method]>>>\n> {\n raw: Request;\n path: AllowAnyStringInPathParams<Path>;\n method: Method;\n clone: () => FetchRequest<Schema, Method, Path>;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */\n toObject: ((options: FetchRequestObjectOptions.WithBody) => Promise<FetchRequestObject>) &\n ((options?: FetchRequestObjectOptions.WithoutBody) => FetchRequestObject) &\n ((options?: FetchRequestObjectOptions) => PossiblePromise<FetchRequestObject>);\n}\n\nexport namespace FetchRequest {\n /** A loosely typed version of a {@link FetchRequest `FetchRequest`}. */\n export interface Loose extends Request {\n raw: Request;\n path: string;\n method: HttpMethod;\n clone: () => Loose;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */\n toObject: ((options: FetchRequestObjectOptions.WithBody) => Promise<FetchRequestObject>) &\n ((options?: FetchRequestObjectOptions.WithoutBody) => FetchRequestObject) &\n ((options?: FetchRequestObjectOptions) => PossiblePromise<FetchRequestObject>);\n }\n}\n\ninterface FetchRequestClass {\n new <\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n >(\n fetch: Fetch<Schema>,\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>,\n ): FetchRequest<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>;\n\n prototype: Request;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [Symbol.hasInstance]: (instance: unknown) => instance is FetchRequest<any, any, any>;\n}\n\nconst FETCH_REQUEST_BRAND = Symbol.for('FetchRequest');\n\nconst FETCH_REQUEST_EXTRA_PROPERTIES = [FETCH_REQUEST_BRAND, 'raw', 'path', 'toObject'] as const;\ntype FetchRequestExtraProperty = (typeof FETCH_REQUEST_EXTRA_PROPERTIES)[number];\n\nfunction createFetchRequestClass() {\n const FetchRequestClass = function FetchRequest<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n >(\n fetch: Fetch<Schema>,\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>> & {\n headers?: HttpHeadersInit<Default<Schema[Path][Method]>>;\n searchParams?: HttpSearchParamsInit<Default<Schema[Path][Method]>>;\n body?: FetchRequestBodySchema<Default<Default<Schema[Path][Method]>['request']>>;\n },\n ) {\n let actualInput: URL | Request;\n\n const actualInit = {\n baseURL: init?.baseURL ?? fetch.baseURL,\n method: init?.method ?? fetch.method,\n headers: new HttpHeaders(fetch.headers),\n searchParams: new HttpSearchParams(fetch.searchParams),\n body: (init?.body ?? fetch.body) as BodyInit | null,\n mode: init?.mode ?? fetch.mode,\n cache: init?.cache ?? fetch.cache,\n credentials: init?.credentials ?? fetch.credentials,\n integrity: init?.integrity ?? fetch.integrity,\n keepalive: init?.keepalive ?? fetch.keepalive,\n priority: init?.priority ?? fetch.priority,\n redirect: init?.redirect ?? fetch.redirect,\n referrer: init?.referrer ?? fetch.referrer,\n referrerPolicy: init?.referrerPolicy ?? fetch.referrerPolicy,\n signal: init?.signal ?? fetch.signal,\n window: init?.window === undefined ? fetch.window : init.window,\n duplex: init?.duplex ?? fetch.duplex,\n };\n\n if (init?.headers !== undefined) {\n actualInit.headers.assign(new HttpHeaders(init.headers));\n }\n\n let url: URL;\n const baseURL = new URL(actualInit.baseURL);\n\n if (input instanceof Request) {\n const request = input as Request;\n\n actualInit.headers.assign(new HttpHeaders<FetchRequestInit.DefaultHeaders<Schema>>(request.headers));\n\n url = new URL(input.url);\n\n actualInput = request instanceof FetchRequestClass ? request.raw : request;\n } else {\n url = new URL(input instanceof URL ? input : joinURL(baseURL, input));\n\n actualInit.searchParams.assign(\n new HttpSearchParams<FetchRequestInit.DefaultSearchParams<Schema>>(url.searchParams),\n );\n\n if (init?.searchParams !== undefined) {\n actualInit.searchParams.assign(new HttpSearchParams(init.searchParams));\n }\n\n url.search = actualInit.searchParams.toString();\n\n actualInput = url;\n }\n\n const request = new Request(actualInput, actualInit);\n\n const baseURLWithoutTrailingSlash = baseURL.toString().replace(/\\/$/, '');\n const path = excludeNonPathParams(url).toString().replace(baseURLWithoutTrailingSlash, '');\n\n function clone() {\n return new FetchRequestClass(fetch, request.clone() as FetchInput<Schema, Method, Path>);\n }\n\n function toObject(options: { includeBody: true }): Promise<FetchRequestObject>;\n function toObject(options?: { includeBody?: false }): FetchRequestObject;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchRequestObject>;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchRequestObject> {\n const requestObject: FetchRequestObject = {\n url: request.url,\n path,\n method: request.method as HttpMethod,\n headers: HttpHeaders.prototype.toObject.call(request.headers) as HttpHeadersSchema,\n cache: request.cache,\n destination: request.destination,\n credentials: request.credentials,\n integrity: request.integrity,\n keepalive: request.keepalive,\n mode: request.mode,\n redirect: request.redirect,\n referrer: request.referrer,\n referrerPolicy: request.referrerPolicy,\n };\n\n if (!options?.includeBody) {\n return requestObject;\n }\n\n return withIncludedBodyIfAvailable(request, requestObject);\n }\n\n type FetchRequestInstance = FetchRequest<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>;\n\n const fetchRequest = new Proxy(request, {\n get(target, property) {\n if (property === FETCH_REQUEST_BRAND) {\n return true;\n }\n\n if (property === ('raw' satisfies keyof FetchRequestInstance)) {\n return request satisfies FetchRequestInstance['raw'];\n }\n\n if (property === ('path' satisfies keyof FetchRequestInstance)) {\n return path as AllowAnyStringInPathParams<\n LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>\n > satisfies FetchRequestInstance['path'];\n }\n\n if (property === ('clone' satisfies keyof FetchRequestInstance)) {\n return clone satisfies FetchRequestInstance['clone'];\n }\n\n if (property === ('toObject' satisfies keyof FetchRequestInstance)) {\n return toObject satisfies FetchRequestInstance['toObject'];\n }\n\n // Fallback other properties to the original `Request` instance.\n const value = Reflect.get(target, property, target) as unknown;\n\n if (isBodyMethod(property, value)) {\n return getOrSetBoundBodyMethod(request, property, value);\n }\n\n return value;\n },\n\n has(target, property) {\n return (\n FETCH_REQUEST_EXTRA_PROPERTIES.includes(property as FetchRequestExtraProperty) ||\n Reflect.has(target, property)\n );\n },\n }) as unknown as FetchRequest<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>;\n\n return fetchRequest;\n } as unknown as FetchRequestClass;\n\n Object.defineProperty(FetchRequestClass, Symbol.hasInstance, {\n value(instance: unknown): boolean {\n return instance instanceof Request && FETCH_REQUEST_BRAND in instance && instance[FETCH_REQUEST_BRAND] === true;\n },\n writable: false,\n enumerable: false,\n configurable: false,\n });\n\n Object.setPrototypeOf(FetchRequestClass.prototype, Request.prototype);\n\n return FetchRequestClass;\n}\n\nexport const FetchRequest = createFetchRequestClass();\n","import { HttpSchema, HttpSchemaMethod, HttpSchemaPath } from '@zimic/http';\nimport { PossiblePromise } from '@zimic/utils/types';\n\nimport { FetchRequest } from '../../request/FetchRequest';\nimport { FetchResponse } from '../FetchResponse';\nimport { FetchResponseErrorObjectOptions, FetchResponseErrorObject } from './types';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response-error `FetchResponseError` API reference} */\nclass FetchResponseError<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n> extends Error {\n constructor(\n public request: FetchRequest<Schema, Method, Path>,\n public response: FetchResponse<Schema, Method, Path>,\n ) {\n super(`${request.method} ${request.url} failed with status ${response.status}.`);\n this.name = 'FetchResponseError';\n }\n\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-response-error#errortoobject `response.error.toObject()` API reference} */\n toObject(options: FetchResponseErrorObjectOptions.WithBody): Promise<FetchResponseErrorObject>;\n toObject(options?: FetchResponseErrorObjectOptions.WithoutBody): FetchResponseErrorObject;\n toObject(options?: FetchResponseErrorObjectOptions): PossiblePromise<FetchResponseErrorObject>;\n toObject(options?: FetchResponseErrorObjectOptions): PossiblePromise<FetchResponseErrorObject> {\n const partialObject = {\n name: this.name,\n message: this.message,\n } satisfies Partial<FetchResponseErrorObject>;\n\n if (!options?.includeRequestBody && !options?.includeResponseBody) {\n return {\n ...partialObject,\n request: this.request.toObject({ includeBody: false }),\n response: this.response.toObject({ includeBody: false }),\n };\n }\n\n return Promise.all([\n Promise.resolve(this.request.toObject({ includeBody: options.includeRequestBody })),\n Promise.resolve(this.response.toObject({ includeBody: options.includeResponseBody })),\n ]).then(([request, response]) => ({ ...partialObject, request, response }));\n }\n}\n\nexport default FetchResponseError;\n","import {\n HttpHeaders,\n HttpHeadersSchema,\n HttpResponse,\n HttpResponseBodySchema,\n HttpResponseHeadersSchema,\n HttpSchema,\n HttpSchemaMethod,\n HttpSchemaPath,\n HttpStatusCode,\n} from '@zimic/http';\nimport { Default, PossiblePromise } from '@zimic/utils/types';\n\nimport { FetchRequest } from '../request/FetchRequest';\nimport { getOrSetBoundBodyMethod, isBodyMethod, withIncludedBodyIfAvailable } from '../utils/objects';\nimport FetchResponseError from './error/FetchResponseError';\nimport {\n FetchResponseBodySchema,\n FetchResponseInit,\n FetchResponseObject,\n FetchResponseObjectOptions,\n FetchResponseStatusCode,\n} from './types';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response `FetchResponse` API reference} */\nexport interface FetchResponsePerStatusCode<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n StatusCode extends HttpStatusCode = HttpStatusCode,\n> extends HttpResponse<\n HttpResponseBodySchema<Default<Schema[Path][Method]>, StatusCode>,\n Default<HttpResponseHeadersSchema<Default<Schema[Path][Method]>, StatusCode>>,\n StatusCode\n> {\n raw: Response;\n request: FetchRequest<Schema, Method, Path>;\n error: FetchResponseError<Schema, Method, Path>;\n clone: () => FetchResponsePerStatusCode<Schema, Method, Path, StatusCode>;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */\n toObject: ((options: FetchResponseObjectOptions.WithBody) => Promise<FetchResponseObject>) &\n ((options?: FetchResponseObjectOptions.WithoutBody) => FetchResponseObject) &\n ((options?: FetchResponseObjectOptions) => PossiblePromise<FetchResponseObject>);\n}\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response `FetchResponse` API reference} */\nexport type FetchResponse<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n> = StatusCode extends StatusCode ? FetchResponsePerStatusCode<Schema, Method, Path, StatusCode> : never;\n\nexport namespace FetchResponse {\n /** A loosely typed version of a {@link FetchResponse}. */\n export interface Loose extends Response {\n raw: Response;\n request: FetchRequest.Loose;\n error: FetchResponseError<any, any, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n clone: () => Loose;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */\n toObject: ((options: FetchResponseObjectOptions.WithBody) => Promise<FetchResponseObject>) &\n ((options?: FetchResponseObjectOptions.WithoutBody) => FetchResponseObject) &\n ((options?: FetchResponseObjectOptions) => PossiblePromise<FetchResponseObject>);\n }\n}\n\ninterface FetchResponseClass {\n new <\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n >(\n fetchRequest: FetchRequest<Schema, Method, Path>,\n response?: Response,\n ): FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n new <\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n >(\n fetchRequest: FetchRequest<Schema, Method, Path>,\n body?: FetchResponseBodySchema<Default<Default<Default<Schema[Path][Method]>['response']>[StatusCode]>>,\n init?: FetchResponseInit<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>,\n ): FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n\n prototype: Response;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [Symbol.hasInstance]: (instance: unknown) => instance is FetchResponse<any, any, any, any, any, any>;\n}\n\nconst FETCH_RESPONSE_BRAND = Symbol.for('FetchResponse');\n\nconst FETCH_RESPONSE_EXTRA_PROPERTIES = [FETCH_RESPONSE_BRAND, 'raw', 'request', 'error', 'toObject'] as const;\ntype FetchResponseExtraProperty = (typeof FETCH_RESPONSE_EXTRA_PROPERTIES)[number];\n\nfunction createFetchResponseClass() {\n const FetchResponseClass = function FetchResponse<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n >(\n fetchRequest: FetchRequest<Schema, Method, Path>,\n responseOrBody?:\n | Response\n | FetchResponseBodySchema<Default<Default<Default<Schema[Path][Method]>['response']>[StatusCode]>>,\n init?: FetchResponseInit<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>,\n ): FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode> {\n const response =\n responseOrBody instanceof Response\n ? responseOrBody\n : new Response(responseOrBody as BodyInit | null, init as ResponseInit);\n\n let error: FetchResponseError<Schema, Method, Path> | null = null;\n\n function clone() {\n return new FetchResponseClass(fetchRequest, response.clone());\n }\n\n function toObject(options: { includeBody: true }): Promise<FetchResponseObject>;\n function toObject(options?: { includeBody?: false }): FetchResponseObject;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchResponseObject>;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchResponseObject> {\n const responseObject: FetchResponseObject = {\n url: response.url,\n type: response.type,\n status: response.status,\n statusText: response.statusText,\n ok: response.ok,\n headers: HttpHeaders.prototype.toObject.call(response.headers) as HttpHeadersSchema,\n redirected: response.redirected,\n };\n\n if (!options?.includeBody) {\n return responseObject;\n }\n\n return withIncludedBodyIfAvailable(response, responseObject);\n }\n\n type FetchResponseInstance = FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n\n const fetchResponse = new Proxy(response, {\n get(target, property, receiver) {\n if (property === FETCH_RESPONSE_BRAND) {\n return true;\n }\n\n if (property === ('raw' satisfies keyof FetchResponseInstance)) {\n return response satisfies FetchResponseInstance['raw'];\n }\n\n if (property === ('request' satisfies keyof FetchResponseInstance)) {\n return fetchRequest satisfies FetchResponseInstance['request'];\n }\n\n if (property === ('error' satisfies keyof FetchResponseInstance)) {\n // We create the error lazily to preserve the stack trace from the point where it was first accessed.\n error ??= new FetchResponseError(fetchRequest, receiver as FetchResponse<Schema, Method, Path>);\n return error satisfies FetchResponseInstance['error'];\n }\n\n if (property === ('clone' satisfies keyof FetchResponseInstance)) {\n // The `clone` method is not compatible with the mapping we do in `FetchResponse`(i.e.\n // `StatusCode extends StatusCode ? ... : ...`), so we need a type assertion here.\n return clone as FetchResponseInstance['clone'];\n }\n\n if (property === ('toObject' satisfies keyof FetchResponseInstance)) {\n return toObject satisfies FetchResponseInstance['toObject'];\n }\n\n // Fallback other properties to the original `Response` instance.\n const value = Reflect.get(target, property, target) as unknown;\n\n if (isBodyMethod(property, value)) {\n return getOrSetBoundBodyMethod(response, property, value);\n }\n\n return value;\n },\n\n has(target, property) {\n return (\n FETCH_RESPONSE_EXTRA_PROPERTIES.includes(property as FetchResponseExtraProperty) ||\n Reflect.has(target, property)\n );\n },\n }) as unknown as FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n\n return fetchResponse;\n } as unknown as FetchResponseClass;\n\n Object.defineProperty(FetchResponseClass, Symbol.hasInstance, {\n value(instance: unknown): boolean {\n return (\n instance instanceof Response && FETCH_RESPONSE_BRAND in instance && instance[FETCH_RESPONSE_BRAND] === true\n );\n },\n writable: false,\n enumerable: false,\n configurable: false,\n });\n\n Object.setPrototypeOf(FetchResponseClass.prototype, Response.prototype);\n\n return FetchResponseClass;\n}\n\nexport const FetchResponse = createFetchResponseClass();\n\nObject.setPrototypeOf(FetchResponse.prototype, Response.prototype);\n","import { HttpSchemaPath, HttpSchemaMethod, LiteralHttpSchemaPathFromNonLiteral, HttpSchema } from '@zimic/http';\nimport { createRegexFromPath } from '@zimic/utils/url';\n\nimport { FetchRequest } from './request/FetchRequest';\nimport { FetchRequestInit } from './request/types';\nimport FetchResponseError from './response/error/FetchResponseError';\nimport { FetchResponse } from './response/FetchResponse';\nimport { FetchInput, FetchOptions, Fetch, FetchDefaults, FetchRequestConstructor } from './types/public';\n\nconst FETCH_OPTIONS_DEFAULT_PROPERTIES = [\n 'baseURL',\n 'onRequest',\n 'onResponse',\n 'body',\n 'cache',\n 'credentials',\n 'integrity',\n 'keepalive',\n 'mode',\n 'priority',\n 'redirect',\n 'referrer',\n 'referrerPolicy',\n 'signal',\n 'window',\n 'duplex',\n] satisfies (keyof FetchOptions<never>)[];\n\nclass FetchClient<Schema extends HttpSchema> implements Omit<Fetch<Schema>, 'loose' | 'Request' | keyof FetchDefaults> {\n fetch: Fetch<Schema>;\n\n constructor(options: FetchOptions<Schema>) {\n this.fetch = this.createFetchFunction();\n this.assignDefaults(this.fetch, options);\n this.fetch.loose = this.fetch as unknown as Fetch.Loose;\n this.fetch.Request = this.createFetchRequestConstructor(this.fetch);\n }\n\n private assignDefaults(\n fetch: Fetch<Schema>,\n { headers = {}, searchParams = {}, ...otherOptions }: FetchOptions<Schema>,\n ) {\n fetch.headers = headers;\n fetch.searchParams = searchParams;\n\n for (const property of FETCH_OPTIONS_DEFAULT_PROPERTIES) {\n const propertyValue = otherOptions[property];\n\n if (propertyValue !== undefined) {\n fetch[property] = propertyValue as never;\n }\n }\n }\n\n get defaults(): FetchDefaults<Schema> {\n return this.fetch;\n }\n\n private createFetchFunction() {\n const fetch = async <\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n Redirect extends RequestRedirect = 'follow',\n >(\n input: FetchInput<Schema, Method, Path>,\n init: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>, Redirect>,\n ) => {\n const fetchRequest = await this.createFetchRequest<Method, Path>(input, init);\n\n const response = await globalThis.fetch(fetchRequest.raw.clone());\n const fetchResponse = await this.createFetchResponse<\n Method,\n LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>\n >(fetchRequest, response);\n\n return fetchResponse;\n };\n\n return Object.setPrototypeOf(fetch, this) as Fetch<Schema>;\n }\n\n private createFetchRequestConstructor<Schema extends HttpSchema>(fetch: Fetch<Schema>) {\n function Request<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n Redirect extends RequestRedirect = 'follow',\n >(\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>, Redirect>,\n ) {\n return new FetchRequest(fetch, input, init);\n }\n\n Object.setPrototypeOf(Request.prototype, FetchRequest.prototype);\n\n return Request as unknown as FetchRequestConstructor<Schema>;\n }\n\n private async createFetchRequest<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n >(\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>,\n ) {\n let fetchRequest = new this.fetch.Request(input, init);\n\n if (this.fetch.onRequest) {\n const newRequest = await this.fetch.onRequest(fetchRequest as FetchRequest.Loose);\n\n if (newRequest !== fetchRequest) {\n if (newRequest instanceof FetchRequest) {\n fetchRequest = newRequest as typeof fetchRequest;\n } else {\n fetchRequest = new this.fetch.Request(newRequest as FetchInput<Schema, Method, Path>, init);\n }\n }\n }\n\n return fetchRequest;\n }\n\n private async createFetchResponse<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n >(fetchRequest: FetchRequest<Schema, Method, Path>, response: Response) {\n let fetchResponse = new FetchResponse<Schema, Method, Path>(fetchRequest, response);\n\n if (this.fetch.onResponse) {\n const newResponse = await this.fetch.onResponse(fetchResponse as FetchResponse.Loose);\n\n fetchResponse =\n newResponse instanceof FetchResponse\n ? (newResponse as typeof fetchResponse)\n : new FetchResponse<Schema, Method, Path>(fetchRequest, newResponse);\n }\n\n return fetchResponse;\n }\n\n isRequest<Path extends HttpSchemaPath.Literal<Schema, Method>, Method extends HttpSchemaMethod<Schema>>(\n request: unknown,\n method: Method,\n path: Path,\n ): request is FetchRequest<Schema, Method, Path> {\n return (\n request instanceof FetchRequest &&\n request.method === method &&\n typeof request.path === 'string' &&\n createRegexFromPath(path).test(request.path)\n );\n }\n\n isResponse<Path extends HttpSchemaPath.Literal<Schema, Method>, Method extends HttpSchemaMethod<Schema>>(\n response: unknown,\n method: Method,\n path: Path,\n ): response is FetchResponse<Schema, Method, Path> {\n return response instanceof FetchResponse && this.isRequest(response.request, method, path);\n }\n\n isResponseError<Path extends HttpSchemaPath.Literal<Schema, Method>, Method extends HttpSchemaMethod<Schema>>(\n error: unknown,\n method: Method,\n path: Path,\n ): error is FetchResponseError<Schema, Method, Path> {\n return (\n error instanceof FetchResponseError &&\n this.isRequest(error.request, method, path) &&\n this.isResponse(error.response, method, path)\n );\n }\n}\n\nexport default FetchClient;\n","import { HttpSchema } from '@zimic/http';\n\nimport FetchClient from './FetchClient';\nimport { FetchOptions, Fetch } from './types/public';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/create-fetch `createFetch` API reference} */\nfunction createFetch<Schema extends HttpSchema>(options: FetchOptions<Schema>): Fetch<Schema> {\n const { fetch } = new FetchClient<Schema>(options);\n return fetch;\n}\n\nexport default createFetch;\n"]}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../zimic-utils/src/url/createRegexFromPath.ts","../../zimic-utils/src/url/excludeNonPathParams.ts","../../zimic-utils/src/url/joinURL.ts","../src/client/utils/objects.ts","../src/client/request/FetchRequest.ts","../src/client/response/error/FetchResponseError.ts","../src/client/response/FetchResponse.ts","../src/client/FetchClient.ts","../src/client/factory.ts"],"names":["FetchRequest","request","FetchResponse","HttpHeaders","Request"],"mappings":";;;;;AAAO,SAAS,iCAAA,GAAoC;AAClD,EAAA,OAAO,cAAA;AACT;AAEO,SAAS,oBAAoB,IAAA,EAAc;AAGhD,EAAA,MAAM,gBAAgB,CAAA,KAAA,EAAQ,IAAA,CAAK,WAAW,G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,UAAA,EAAY;AACzB,MAAA,MAAM,WAAA,GAAc,MAAM,IAAA,CAAK,KAAA,CAAM,WAAW,aAAoC,CAAA;AAEpF,MAAA,aAAA,GACE,uBAAuB,aAAA,GAClB,WAAA,GACD,IAAI,aAAA,CAAoC,cAAc,WAAW,CAAA;AAAA,IACzE;AAEA,IAAA,OAAO,aAAA;AAAA,EACT;AAAA,EAEA,SAAA,CACE,OAAA,EACA,MAAA,EACA,IAAA,EAC+C;AAC/C,IAAA,OACE,OAAA,YAAmB,YAAA,IACnB,OAAA,CAAQ,MAAA,KAAW,UACnB,OAAO,OAAA,CAAQ,IAAA,KAAS,QAAA,IACxB,2BAAA,CAAoB,IAAI,CAAA,CAAE,IAAA,CAAK,QAAQ,IAAI,CAAA;AAAA,EAE/C;AAAA,EAEA,UAAA,CACE,QAAA,EACA,MAAA,EACA,IAAA,EACiD;AACjD,IAAA,OAAO,oBAAoB,aAAA,IAAiB,IAAA,CAAK,UAAU,QAAA,CAAS,OAAA,EAAS,QAAQ,IAAI,CAAA;AAAA,EAC3F;AAAA,EAEA,eAAA,CACE,KAAA,EACA,MAAA,EACA,IAAA,EACmD;AACnD,IAAA,OACE,KAAA,YAAiB,0BAAA,IACjB,IAAA,CAAK,SAAA,CAAU,MAAM,OAAA,EAAS,MAAA,EAAQ,IAAI,CAAA,IAC1C,IAAA,CAAK,UAAA,CAAW,KAAA,CAAM,QAAA,EAAU,QAAQ,IAAI,CAAA;AAAA,EAEhD;AACF,CAAA;AAEA,IAAO,mBAAA,GAAQ,WAAA;;;ACxKf,SAAS,YAAuC,OAAA,EAA8C;AAC5F,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,IAAI,oBAAoB,OAAO,CAAA;AACjD,EAAA,OAAO,KAAA;AACT;AAEA,IAAO,eAAA,GAAQ","file":"index.mjs","sourcesContent":["export function createPathCharactersToEscapeRegex() {\n return /([.(){}+$])/g;\n}\n\nexport function preparePathForRegex(path: string) {\n // We encode the path using the URL API because, differently from encodeURI and encodeURIComponent, URL does not\n // re-encode already encoded characters. Since URL requires a full URL, we use a data scheme and strip it later.\n const pathURLPrefix = `data:${path.startsWith('/') ? '' : '/'}`;\n const pathAsURL = new URL(`${pathURLPrefix}${path}`);\n const encodedPath = pathAsURL.href.replace(pathURLPrefix, '');\n\n return encodedPath.replace(/^\\/+/g, '').replace(/\\/+$/g, '').replace(createPathCharactersToEscapeRegex(), '\\\\$1');\n}\n\n// Path params names must match the JavaScript identifier pattern.\n// See // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers.\nexport function createPathParamRegex() {\n return /(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)(?!\\\\[*+?])/gu;\n}\n\nexport function createRepeatingPathParamRegex() {\n return /(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\\\\\+/gu;\n}\n\nexport function createOptionalPathParamRegex() {\n return /(?<leadingSlash>\\/)?(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\?(?<trailingSlash>\\/)?/gu;\n}\n\nexport function createOptionalRepeatingPathParamRegex() {\n return /(?<leadingSlash>\\/)?(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\*(?<trailingSlash>\\/)?/gu;\n}\n\nfunction createRegexFromPath(path: string) {\n const pathRegexContent = preparePathForRegex(path)\n .replace(\n createOptionalRepeatingPathParamRegex(),\n (\n _match,\n leadingSlash: string | undefined,\n escape: string | undefined,\n identifier: string,\n trailingSlash: string | undefined,\n ) => {\n if (escape) {\n return `${leadingSlash ?? ''}:${identifier}\\\\*${trailingSlash ?? ''}`;\n }\n\n const hasSegmentBeforePrefix = leadingSlash === '/';\n const prefixExpression = hasSegmentBeforePrefix ? '/?' : leadingSlash;\n\n const hasSegmentAfterSuffix = trailingSlash === '/';\n const suffixExpression = hasSegmentAfterSuffix ? '/?' : trailingSlash;\n\n if (prefixExpression && suffixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>.+?)?${suffixExpression})?`;\n } else if (prefixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>.+?))?`;\n } else if (suffixExpression) {\n return `(?:(?<${identifier}>.+?)${suffixExpression})?`;\n } else {\n return `(?<${identifier}>.+?)?`;\n }\n },\n )\n .replace(createRepeatingPathParamRegex(), (_match, escape: string | undefined, identifier: string) => {\n return escape ? `:${identifier}\\\\+` : `(?<${identifier}>.+)`;\n })\n .replace(\n createOptionalPathParamRegex(),\n (\n _match,\n leadingSlash: string | undefined,\n escape: string | undefined,\n identifier: string,\n trailingSlash: string | undefined,\n ) => {\n if (escape) {\n return `${leadingSlash ?? ''}:${identifier}\\\\?${trailingSlash ?? ''}`;\n }\n\n const hasSegmentBeforePrefix = leadingSlash === '/';\n const prefixExpression = hasSegmentBeforePrefix ? '/?' : leadingSlash;\n\n const hasSegmentAfterSuffix = trailingSlash === '/';\n const suffixExpression = hasSegmentAfterSuffix ? '/?' : trailingSlash;\n\n if (prefixExpression && suffixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>[^\\\\/]+?)?${suffixExpression})`;\n } else if (prefixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>[^\\\\/]+?))?`;\n } else if (suffixExpression) {\n return `(?:(?<${identifier}>[^\\\\/]+?)${suffixExpression})?`;\n } else {\n return `(?<${identifier}>[^\\\\/]+?)?`;\n }\n },\n )\n .replace(createPathParamRegex(), (_match, escape: string | undefined, identifier: string) => {\n return escape ? `:${identifier}` : `(?<${identifier}>[^\\\\/]+?)`;\n });\n\n return new RegExp(`^/?${pathRegexContent}/?$`);\n}\n\nexport default createRegexFromPath;\n","function excludeNonPathParams(url: URL) {\n url.hash = '';\n url.search = '';\n url.username = '';\n url.password = '';\n return url;\n}\n\nexport default excludeNonPathParams;\n","function joinURL(...parts: (URL | string)[]) {\n return parts\n .map((part, index) => {\n const isFirstPart = index === 0;\n const isLastPart = index === parts.length - 1;\n\n let partAsString = part.toString();\n\n if (!isFirstPart) {\n partAsString = partAsString.replace(/^\\//, '');\n }\n if (!isLastPart) {\n partAsString = partAsString.replace(/\\/$/, '');\n }\n\n return partAsString;\n })\n .filter((part) => part.length > 0)\n .join('/');\n}\n\nexport default joinURL;\n","import { parseHttpBody } from '@zimic/http';\nimport { PossiblePromise } from '@zimic/utils/types';\n\nimport { FetchRequestObject } from '../request/types';\nimport { FetchResponseObject } from '../response/types';\n\nconst BODY_METHOD = ['json', 'formData', 'text', 'arrayBuffer', 'blob', 'bytes'] satisfies (keyof Body)[];\ntype BodyMethod = (typeof BODY_METHOD)[number];\n\nexport function isBodyMethod(property: string | symbol, value: unknown): value is Body[BodyMethod] {\n return BODY_METHOD.includes(property as BodyMethod) && typeof value === 'function';\n}\n\nexport function getOrSetBoundBodyMethod(\n resource: Request | Response,\n property: string | symbol,\n value: Body[BodyMethod],\n) {\n // We cache the bound function on the proxy instance to avoid re-binding it on every access.\n const isValueAlreadyBound = Object.prototype.hasOwnProperty.call(resource, property);\n\n if (isValueAlreadyBound) {\n return value;\n }\n\n const boundValue = value.bind(resource) as unknown;\n\n Object.defineProperty(resource, property, {\n value: boundValue,\n configurable: true,\n enumerable: false,\n writable: true,\n });\n\n return boundValue;\n}\n\nexport function withIncludedBodyIfAvailable(\n resource: Request,\n resourceObject: FetchRequestObject,\n): PossiblePromise<FetchRequestObject>;\nexport function withIncludedBodyIfAvailable(\n resource: Response,\n resourceObject: FetchResponseObject,\n): PossiblePromise<FetchResponseObject>;\nexport function withIncludedBodyIfAvailable(\n resource: Request | Response,\n resourceObject: FetchRequestObject | FetchResponseObject,\n): PossiblePromise<FetchRequestObject | FetchResponseObject> {\n const resourceType = resource instanceof Request ? 'request' : 'response';\n\n if (resource.bodyUsed) {\n console.warn(\n '[@zimic/fetch]',\n `Could not include the ${resourceType} body because it is already used. ` +\n 'If you access the body before calling `toObject()`, consider reading it from a cloned ' +\n `${resourceType}.\\n\\nLearn more: https://zimic.dev/docs/fetch/api/fetch-response-error#errortoobject`,\n );\n return resourceObject;\n }\n\n return parseHttpBody(resource.clone())\n .then((body) => {\n resourceObject.body = body;\n return resourceObject;\n })\n .catch((error: unknown) => {\n console.error('[@zimic/fetch]', `Failed to parse ${resourceType} body:`, error);\n return resourceObject;\n });\n}\n","import {\n HttpSchema,\n HttpSchemaMethod,\n HttpSchemaPath,\n HttpRequest,\n HttpRequestBodySchema,\n HttpRequestHeadersSchema,\n HttpHeaders,\n HttpSearchParams,\n HttpMethod,\n AllowAnyStringInPathParams,\n LiteralHttpSchemaPathFromNonLiteral,\n HttpHeadersInit,\n HttpSearchParamsInit,\n HttpHeadersSchema,\n} from '@zimic/http';\nimport { Default, PossiblePromise } from '@zimic/utils/types';\nimport { excludeNonPathParams, joinURL } from '@zimic/utils/url';\n\nimport { Fetch, FetchInput } from '../types/public';\nimport { getOrSetBoundBodyMethod, isBodyMethod, withIncludedBodyIfAvailable } from '../utils/objects';\nimport { FetchRequestBodySchema, FetchRequestInit, FetchRequestObject } from './types';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request `FetchRequest` API reference} */\nexport interface FetchRequest<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n> extends HttpRequest<\n HttpRequestBodySchema<Default<Schema[Path][Method]>>,\n Default<HttpRequestHeadersSchema<Default<Schema[Path][Method]>>>\n> {\n raw: Request;\n path: AllowAnyStringInPathParams<Path>;\n method: Method;\n clone: () => FetchRequest<Schema, Method, Path>;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */\n toObject: ((options: { includeBody: true }) => Promise<FetchRequestObject>) &\n ((options?: { includeBody?: false }) => FetchRequestObject) &\n ((options?: { includeBody?: boolean }) => PossiblePromise<FetchRequestObject>);\n}\n\nexport namespace FetchRequest {\n /** A loosely typed version of a {@link FetchRequest `FetchRequest`}. */\n export interface Loose extends Request {\n raw: Request;\n path: string;\n method: HttpMethod;\n clone: () => Loose;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */\n toObject: ((options: { includeBody: true }) => Promise<FetchRequestObject>) &\n ((options?: { includeBody?: false }) => FetchRequestObject);\n }\n}\n\ninterface FetchRequestClass {\n new <\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n >(\n fetch: Fetch<Schema>,\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>,\n ): FetchRequest<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>;\n\n prototype: Request;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [Symbol.hasInstance]: (instance: unknown) => instance is FetchRequest<any, any, any>;\n}\n\nconst FETCH_REQUEST_BRAND = Symbol.for('FetchRequest');\n\nconst FETCH_REQUEST_EXTRA_PROPERTIES = [FETCH_REQUEST_BRAND, 'raw', 'path', 'toObject'] as const;\ntype FetchRequestExtraProperty = (typeof FETCH_REQUEST_EXTRA_PROPERTIES)[number];\n\nfunction createFetchRequestClass() {\n const FetchRequestClass = function FetchRequest<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n >(\n fetch: Fetch<Schema>,\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>> & {\n headers?: HttpHeadersInit<Default<Schema[Path][Method]>>;\n searchParams?: HttpSearchParamsInit<Default<Schema[Path][Method]>>;\n body?: FetchRequestBodySchema<Default<Default<Schema[Path][Method]>['request']>>;\n },\n ) {\n let actualInput: URL | Request;\n\n const actualInit = {\n baseURL: init?.baseURL ?? fetch.baseURL,\n method: init?.method ?? fetch.method,\n headers: new HttpHeaders(fetch.headers),\n searchParams: new HttpSearchParams(fetch.searchParams),\n body: (init?.body ?? fetch.body) as BodyInit | null,\n mode: init?.mode ?? fetch.mode,\n cache: init?.cache ?? fetch.cache,\n credentials: init?.credentials ?? fetch.credentials,\n integrity: init?.integrity ?? fetch.integrity,\n keepalive: init?.keepalive ?? fetch.keepalive,\n priority: init?.priority ?? fetch.priority,\n redirect: init?.redirect ?? fetch.redirect,\n referrer: init?.referrer ?? fetch.referrer,\n referrerPolicy: init?.referrerPolicy ?? fetch.referrerPolicy,\n signal: init?.signal ?? fetch.signal,\n window: init?.window === undefined ? fetch.window : init.window,\n duplex: init?.duplex ?? fetch.duplex,\n };\n\n if (init?.headers !== undefined) {\n actualInit.headers.assign(new HttpHeaders(init.headers));\n }\n\n let url: URL;\n const baseURL = new URL(actualInit.baseURL);\n\n if (input instanceof Request) {\n const request = input as Request;\n\n actualInit.headers.assign(new HttpHeaders<FetchRequestInit.DefaultHeaders<Schema>>(request.headers));\n\n url = new URL(input.url);\n\n actualInput = request instanceof FetchRequestClass ? request.raw : request;\n } else {\n url = new URL(input instanceof URL ? input : joinURL(baseURL, input));\n\n actualInit.searchParams.assign(\n new HttpSearchParams<FetchRequestInit.DefaultSearchParams<Schema>>(url.searchParams),\n );\n\n if (init?.searchParams !== undefined) {\n actualInit.searchParams.assign(new HttpSearchParams(init.searchParams));\n }\n\n url.search = actualInit.searchParams.toString();\n\n actualInput = url;\n }\n\n const request = new Request(actualInput, actualInit);\n\n const baseURLWithoutTrailingSlash = baseURL.toString().replace(/\\/$/, '');\n const path = excludeNonPathParams(url).toString().replace(baseURLWithoutTrailingSlash, '');\n\n function clone() {\n return new FetchRequestClass(fetch, request.clone() as FetchInput<Schema, Method, Path>);\n }\n\n function toObject(options: { includeBody: true }): Promise<FetchRequestObject>;\n function toObject(options?: { includeBody?: false }): FetchRequestObject;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchRequestObject>;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchRequestObject> {\n const requestObject: FetchRequestObject = {\n url: request.url,\n path,\n method: request.method as HttpMethod,\n headers: HttpHeaders.prototype.toObject.call(request.headers) as HttpHeadersSchema,\n cache: request.cache,\n destination: request.destination,\n credentials: request.credentials,\n integrity: request.integrity,\n keepalive: request.keepalive,\n mode: request.mode,\n redirect: request.redirect,\n referrer: request.referrer,\n referrerPolicy: request.referrerPolicy,\n };\n\n if (!options?.includeBody) {\n return requestObject;\n }\n\n return withIncludedBodyIfAvailable(request, requestObject);\n }\n\n type FetchRequestInstance = FetchRequest<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>;\n\n const fetchRequest = new Proxy(request, {\n get(target, property) {\n if (property === FETCH_REQUEST_BRAND) {\n return true;\n }\n\n if (property === ('raw' satisfies keyof FetchRequestInstance)) {\n return request satisfies FetchRequestInstance['raw'];\n }\n\n if (property === ('path' satisfies keyof FetchRequestInstance)) {\n return path as AllowAnyStringInPathParams<\n LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>\n > satisfies FetchRequestInstance['path'];\n }\n\n if (property === ('clone' satisfies keyof FetchRequestInstance)) {\n return clone satisfies FetchRequestInstance['clone'];\n }\n\n if (property === ('toObject' satisfies keyof FetchRequestInstance)) {\n return toObject satisfies FetchRequestInstance['toObject'];\n }\n\n // Fallback other properties to the original `Request` instance.\n const value = Reflect.get(target, property, target) as unknown;\n\n if (isBodyMethod(property, value)) {\n return getOrSetBoundBodyMethod(request, property, value);\n }\n\n return value;\n },\n\n has(target, property) {\n return (\n FETCH_REQUEST_EXTRA_PROPERTIES.includes(property as FetchRequestExtraProperty) ||\n Reflect.has(target, property)\n );\n },\n }) as unknown as FetchRequest<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>;\n\n return fetchRequest;\n } as unknown as FetchRequestClass;\n\n Object.defineProperty(FetchRequestClass, Symbol.hasInstance, {\n value(instance: unknown): boolean {\n return instance instanceof Request && FETCH_REQUEST_BRAND in instance && instance[FETCH_REQUEST_BRAND] === true;\n },\n writable: false,\n enumerable: false,\n configurable: false,\n });\n\n Object.setPrototypeOf(FetchRequestClass.prototype, Request.prototype);\n\n return FetchRequestClass;\n}\n\nexport const FetchRequest = createFetchRequestClass();\n","import { HttpSchema, HttpSchemaMethod, HttpSchemaPath } from '@zimic/http';\nimport { PossiblePromise } from '@zimic/utils/types';\n\nimport { FetchRequest } from '../../request/FetchRequest';\nimport { FetchResponse } from '../FetchResponse';\nimport { FetchResponseErrorObjectOptions, FetchResponseErrorObject } from './types';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response-error `FetchResponseError` API reference} */\nclass FetchResponseError<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n> extends Error {\n constructor(\n public request: FetchRequest<Schema, Method, Path>,\n public response: FetchResponse<Schema, Method, Path>,\n ) {\n super(`${request.method} ${request.url} failed with status ${response.status}.`);\n this.name = 'FetchResponseError';\n }\n\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-response-error#errortoobject `response.error.toObject()` API reference} */\n toObject(options: FetchResponseErrorObjectOptions.WithBody): Promise<FetchResponseErrorObject>;\n toObject(options?: FetchResponseErrorObjectOptions.WithoutBody): FetchResponseErrorObject;\n toObject(options?: FetchResponseErrorObjectOptions): PossiblePromise<FetchResponseErrorObject>;\n toObject(options?: FetchResponseErrorObjectOptions): PossiblePromise<FetchResponseErrorObject> {\n const partialObject = {\n name: this.name,\n message: this.message,\n } satisfies Partial<FetchResponseErrorObject>;\n\n if (!options?.includeRequestBody && !options?.includeResponseBody) {\n return {\n ...partialObject,\n request: this.request.toObject({ includeBody: false }),\n response: this.response.toObject({ includeBody: false }),\n };\n }\n\n return Promise.all([\n Promise.resolve(this.request.toObject({ includeBody: options.includeRequestBody })),\n Promise.resolve(this.response.toObject({ includeBody: options.includeResponseBody })),\n ]).then(([request, response]) => ({ ...partialObject, request, response }));\n }\n}\n\nexport default FetchResponseError;\n","import {\n HttpHeaders,\n HttpHeadersSchema,\n HttpResponse,\n HttpResponseBodySchema,\n HttpResponseHeadersSchema,\n HttpSchema,\n HttpSchemaMethod,\n HttpSchemaPath,\n HttpStatusCode,\n} from '@zimic/http';\nimport { Default, PossiblePromise } from '@zimic/utils/types';\n\nimport { FetchRequest } from '../request/FetchRequest';\nimport { getOrSetBoundBodyMethod, isBodyMethod, withIncludedBodyIfAvailable } from '../utils/objects';\nimport FetchResponseError from './error/FetchResponseError';\nimport { FetchResponseBodySchema, FetchResponseInit, FetchResponseObject, FetchResponseStatusCode } from './types';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response `FetchResponse` API reference} */\nexport interface FetchResponsePerStatusCode<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n StatusCode extends HttpStatusCode = HttpStatusCode,\n> extends HttpResponse<\n HttpResponseBodySchema<Default<Schema[Path][Method]>, StatusCode>,\n Default<HttpResponseHeadersSchema<Default<Schema[Path][Method]>, StatusCode>>,\n StatusCode\n> {\n raw: Response;\n request: FetchRequest<Schema, Method, Path>;\n error: FetchResponseError<Schema, Method, Path>;\n clone: () => FetchResponsePerStatusCode<Schema, Method, Path, StatusCode>;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */\n toObject: ((options: { includeBody: true }) => Promise<FetchResponseObject>) &\n ((options?: { includeBody?: false }) => FetchResponseObject) &\n ((options?: { includeBody?: boolean }) => PossiblePromise<FetchResponseObject>);\n}\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response `FetchResponse` API reference} */\nexport type FetchResponse<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n> = StatusCode extends StatusCode ? FetchResponsePerStatusCode<Schema, Method, Path, StatusCode> : never;\n\nexport namespace FetchResponse {\n /** A loosely typed version of a {@link FetchResponse}. */\n export interface Loose extends Response {\n raw: Response;\n request: FetchRequest.Loose;\n error: FetchResponseError<any, any, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n clone: () => Loose;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */\n toObject: ((options: { includeBody: true }) => Promise<FetchResponseObject>) &\n ((options?: { includeBody?: false }) => FetchResponseObject);\n }\n}\n\ninterface FetchResponseClass {\n new <\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n >(\n fetchRequest: FetchRequest<Schema, Method, Path>,\n response?: Response,\n ): FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n new <\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n >(\n fetchRequest: FetchRequest<Schema, Method, Path>,\n body?: FetchResponseBodySchema<Default<Default<Default<Schema[Path][Method]>['response']>[StatusCode]>>,\n init?: FetchResponseInit<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>,\n ): FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n\n prototype: Response;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [Symbol.hasInstance]: (instance: unknown) => instance is FetchResponse<any, any, any, any, any, any>;\n}\n\nconst FETCH_RESPONSE_BRAND = Symbol.for('FetchResponse');\n\nconst FETCH_RESPONSE_EXTRA_PROPERTIES = [FETCH_RESPONSE_BRAND, 'raw', 'request', 'error', 'toObject'] as const;\ntype FetchResponseExtraProperty = (typeof FETCH_RESPONSE_EXTRA_PROPERTIES)[number];\n\nfunction createFetchResponseClass() {\n const FetchResponseClass = function FetchResponse<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n >(\n fetchRequest: FetchRequest<Schema, Method, Path>,\n responseOrBody?:\n | Response\n | FetchResponseBodySchema<Default<Default<Default<Schema[Path][Method]>['response']>[StatusCode]>>,\n init?: FetchResponseInit<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>,\n ): FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode> {\n const response =\n responseOrBody instanceof Response\n ? responseOrBody\n : new Response(responseOrBody as BodyInit | null, init as ResponseInit);\n\n let error: FetchResponseError<Schema, Method, Path> | null = null;\n\n function clone() {\n return new FetchResponseClass(fetchRequest, response.clone());\n }\n\n function toObject(options: { includeBody: true }): Promise<FetchResponseObject>;\n function toObject(options?: { includeBody?: false }): FetchResponseObject;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchResponseObject>;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchResponseObject> {\n const responseObject: FetchResponseObject = {\n url: response.url,\n type: response.type,\n status: response.status,\n statusText: response.statusText,\n ok: response.ok,\n headers: HttpHeaders.prototype.toObject.call(response.headers) as HttpHeadersSchema,\n redirected: response.redirected,\n };\n\n if (!options?.includeBody) {\n return responseObject;\n }\n\n return withIncludedBodyIfAvailable(response, responseObject);\n }\n\n type FetchResponseInstance = FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n\n const fetchResponse = new Proxy(response, {\n get(target, property, receiver) {\n if (property === FETCH_RESPONSE_BRAND) {\n return true;\n }\n\n if (property === ('raw' satisfies keyof FetchResponseInstance)) {\n return response satisfies FetchResponseInstance['raw'];\n }\n\n if (property === ('request' satisfies keyof FetchResponseInstance)) {\n return fetchRequest satisfies FetchResponseInstance['request'];\n }\n\n if (property === ('error' satisfies keyof FetchResponseInstance)) {\n // We create the error lazily to preserve the stack trace from the point where it was first accessed.\n error ??= new FetchResponseError(fetchRequest, receiver as FetchResponse<Schema, Method, Path>);\n return error satisfies FetchResponseInstance['error'];\n }\n\n if (property === ('clone' satisfies keyof FetchResponseInstance)) {\n // The `clone` method is not compatible with the mapping we do in `FetchResponse`(i.e.\n // `StatusCode extends StatusCode ? ... : ...`), so we need a type assertion here.\n return clone as FetchResponseInstance['clone'];\n }\n\n if (property === ('toObject' satisfies keyof FetchResponseInstance)) {\n return toObject satisfies FetchResponseInstance['toObject'];\n }\n\n // Fallback other properties to the original `Response` instance.\n const value = Reflect.get(target, property, target) as unknown;\n\n if (isBodyMethod(property, value)) {\n return getOrSetBoundBodyMethod(response, property, value);\n }\n\n return value;\n },\n\n has(target, property) {\n return (\n FETCH_RESPONSE_EXTRA_PROPERTIES.includes(property as FetchResponseExtraProperty) ||\n Reflect.has(target, property)\n );\n },\n }) as unknown as FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n\n return fetchResponse;\n } as unknown as FetchResponseClass;\n\n Object.defineProperty(FetchResponseClass, Symbol.hasInstance, {\n value(instance: unknown): boolean {\n return (\n instance instanceof Response && FETCH_RESPONSE_BRAND in instance && instance[FETCH_RESPONSE_BRAND] === true\n );\n },\n writable: false,\n enumerable: false,\n configurable: false,\n });\n\n Object.setPrototypeOf(FetchResponseClass.prototype, Response.prototype);\n\n return FetchResponseClass;\n}\n\nexport const FetchResponse = createFetchResponseClass();\n\nObject.setPrototypeOf(FetchResponse.prototype, Response.prototype);\n","import { HttpSchemaPath, HttpSchemaMethod, LiteralHttpSchemaPathFromNonLiteral, HttpSchema } from '@zimic/http';\nimport { createRegexFromPath } from '@zimic/utils/url';\n\nimport { FetchRequest } from './request/FetchRequest';\nimport { FetchRequestInit } from './request/types';\nimport FetchResponseError from './response/error/FetchResponseError';\nimport { FetchResponse } from './response/FetchResponse';\nimport { FetchInput, FetchOptions, Fetch, FetchDefaults, FetchRequestConstructor } from './types/public';\n\nconst FETCH_OPTIONS_DEFAULT_PROPERTIES = [\n 'baseURL',\n 'onRequest',\n 'onResponse',\n 'body',\n 'cache',\n 'credentials',\n 'integrity',\n 'keepalive',\n 'mode',\n 'priority',\n 'redirect',\n 'referrer',\n 'referrerPolicy',\n 'signal',\n 'window',\n 'duplex',\n] satisfies (keyof FetchOptions<never>)[];\n\nclass FetchClient<Schema extends HttpSchema> implements Omit<Fetch<Schema>, 'loose' | 'Request' | keyof FetchDefaults> {\n fetch: Fetch<Schema>;\n\n constructor(options: FetchOptions<Schema>) {\n this.fetch = this.createFetchFunction();\n this.assignDefaults(this.fetch, options);\n this.fetch.loose = this.fetch as unknown as Fetch.Loose;\n this.fetch.Request = this.createFetchRequestConstructor(this.fetch);\n }\n\n private assignDefaults(\n fetch: Fetch<Schema>,\n { headers = {}, searchParams = {}, ...otherOptions }: FetchOptions<Schema>,\n ) {\n fetch.headers = headers;\n fetch.searchParams = searchParams;\n\n for (const property of FETCH_OPTIONS_DEFAULT_PROPERTIES) {\n const propertyValue = otherOptions[property];\n\n if (propertyValue !== undefined) {\n fetch[property] = propertyValue as never;\n }\n }\n }\n\n get defaults(): FetchDefaults<Schema> {\n return this.fetch;\n }\n\n private createFetchFunction() {\n const fetch = async <\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n Redirect extends RequestRedirect = 'follow',\n >(\n input: FetchInput<Schema, Method, Path>,\n init: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>, Redirect>,\n ) => {\n const fetchRequest = await this.createFetchRequest<Method, Path>(input, init);\n\n const response = await globalThis.fetch(fetchRequest.raw.clone());\n const fetchResponse = await this.createFetchResponse<\n Method,\n LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>\n >(fetchRequest, response);\n\n return fetchResponse;\n };\n\n return Object.setPrototypeOf(fetch, this) as Fetch<Schema>;\n }\n\n private createFetchRequestConstructor<Schema extends HttpSchema>(fetch: Fetch<Schema>) {\n function Request<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n Redirect extends RequestRedirect = 'follow',\n >(\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>, Redirect>,\n ) {\n return new FetchRequest(fetch, input, init);\n }\n\n Object.setPrototypeOf(Request.prototype, FetchRequest.prototype);\n\n return Request as unknown as FetchRequestConstructor<Schema>;\n }\n\n private async createFetchRequest<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n >(\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>,\n ) {\n let fetchRequest = new this.fetch.Request(input, init);\n\n if (this.fetch.onRequest) {\n const newRequest = await this.fetch.onRequest(fetchRequest as FetchRequest.Loose);\n\n if (newRequest !== fetchRequest) {\n if (newRequest instanceof FetchRequest) {\n fetchRequest = newRequest as typeof fetchRequest;\n } else {\n fetchRequest = new this.fetch.Request(newRequest as FetchInput<Schema, Method, Path>, init);\n }\n }\n }\n\n return fetchRequest;\n }\n\n private async createFetchResponse<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n >(fetchRequest: FetchRequest<Schema, Method, Path>, response: Response) {\n let fetchResponse = new FetchResponse<Schema, Method, Path>(fetchRequest, response);\n\n if (this.fetch.onResponse) {\n const newResponse = await this.fetch.onResponse(fetchResponse as FetchResponse.Loose);\n\n fetchResponse =\n newResponse instanceof FetchResponse\n ? (newResponse as typeof fetchResponse)\n : new FetchResponse<Schema, Method, Path>(fetchRequest, newResponse);\n }\n\n return fetchResponse;\n }\n\n isRequest<Path extends HttpSchemaPath.Literal<Schema, Method>, Method extends HttpSchemaMethod<Schema>>(\n request: unknown,\n method: Method,\n path: Path,\n ): request is FetchRequest<Schema, Method, Path> {\n return (\n request instanceof FetchRequest &&\n request.method === method &&\n typeof request.path === 'string' &&\n createRegexFromPath(path).test(request.path)\n );\n }\n\n isResponse<Path extends HttpSchemaPath.Literal<Schema, Method>, Method extends HttpSchemaMethod<Schema>>(\n response: unknown,\n method: Method,\n path: Path,\n ): response is FetchResponse<Schema, Method, Path> {\n return response instanceof FetchResponse && this.isRequest(response.request, method, path);\n }\n\n isResponseError<Path extends HttpSchemaPath.Literal<Schema, Method>, Method extends HttpSchemaMethod<Schema>>(\n error: unknown,\n method: Method,\n path: Path,\n ): error is FetchResponseError<Schema, Method, Path> {\n return (\n error instanceof FetchResponseError &&\n this.isRequest(error.request, method, path) &&\n this.isResponse(error.response, method, path)\n );\n }\n}\n\nexport default FetchClient;\n","import { HttpSchema } from '@zimic/http';\n\nimport FetchClient from './FetchClient';\nimport { FetchOptions, Fetch } from './types/public';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/create-fetch `createFetch` API reference} */\nfunction createFetch<Schema extends HttpSchema>(options: FetchOptions<Schema>): Fetch<Schema> {\n const { fetch } = new FetchClient<Schema>(options);\n return fetch;\n}\n\nexport default createFetch;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../zimic-utils/src/url/createRegexFromPath.ts","../../zimic-utils/src/url/excludeNonPathParams.ts","../../zimic-utils/src/url/joinURL.ts","../src/client/utils/objects.ts","../src/client/request/FetchRequest.ts","../src/client/response/error/FetchResponseError.ts","../src/client/response/FetchResponse.ts","../src/client/FetchClient.ts","../src/client/factory.ts"],"names":["FetchRequest","request","FetchResponse","HttpHeaders","Request"],"mappings":";;;;;AAAO,SAAS,iCAAA,GAAoC;AAClD,EAAA,OAAO,cAAA;AACT;AAEO,SAAS,oBAAoB,IAAA,EAAc;AAGhD,EAAA,MAAM,gBAAgB,CAAA,KAAA,EAAQ,IAAA,CAAK,WAAW,GAAG,CAAA,GAAI,KAAK,GAAG,CAAA,CAAA;AAC7D,EAAA,MAAM,YAAY,IAAI,GAAA,CAAI,GAAG,aAAa,CAAA,EAAG,IAAI,CAAA,CAAE,CAAA;AACnD,EAAA,MAAM,WAAA,GAAc,SAAA,CAAU,IAAA,CAAK,OAAA,CAAQ,eAAe,EAAE,CAAA;AAE5D,EAAA,OAAO,WAAA,CAAY,OAAA,CAAQ,OAAA,EAAS,EAAE,CAAA,CAAE,OAAA,CAAQ,OAAA,EAAS,EAAE,CAAA,CAAE,OAAA,CAAQ,iCAAA,EAAA,EAAqC,MAAM,CAAA;AAClH;AAIO,SAAS,oBAAA,GAAuB;AACrC,EAAA,OAAO,gFAAA;AACT;AAEO,SAAS,6BAAA,GAAgC;AAC9C,EAAA,OAAO,yEAAA;AACT;AAEO,SAAS,4BAAA,GAA+B;AAC7C,EAAA,OAAO,gHAAA;AACT;AAEO,SAAS,qCAAA,GAAwC;AACtD,EAAA,OAAO,gHAAA;AACT;AAEA,SAAS,oBAAoB,IAAA,EAAc;AACzC,EAAA,MAAM,gBAAA,GAAmB,mBAAA,CAAoB,IAAI,CAAA,CAC9C,OAAA;IACC,qCAAA,EAAA;AACA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0BAAA,IACjB,IAAA,CAAK,SAAA,CAAU,MAAM,OAAA,EAAS,MAAA,EAAQ,IAAI,CAAA,IAC1C,IAAA,CAAK,UAAA,CAAW,KAAA,CAAM,QAAA,EAAU,QAAQ,IAAI,CAAA;AAAA,EAEhD;AACF,CAAA;AAEA,IAAO,mBAAA,GAAQ,WAAA;;;ACxKf,SAAS,YAAuC,OAAA,EAA8C;AAC5F,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,IAAI,oBAAoB,OAAO,CAAA;AACjD,EAAA,OAAO,KAAA;AACT;AAEA,IAAO,eAAA,GAAQ","file":"index.mjs","sourcesContent":["export function createPathCharactersToEscapeRegex() {\n return /([.(){}+$])/g;\n}\n\nexport function preparePathForRegex(path: string) {\n // We encode the path using the URL API because, differently from encodeURI and encodeURIComponent, URL does not\n // re-encode already encoded characters. Since URL requires a full URL, we use a data scheme and strip it later.\n const pathURLPrefix = `data:${path.startsWith('/') ? '' : '/'}`;\n const pathAsURL = new URL(`${pathURLPrefix}${path}`);\n const encodedPath = pathAsURL.href.replace(pathURLPrefix, '');\n\n return encodedPath.replace(/^\\/+/g, '').replace(/\\/+$/g, '').replace(createPathCharactersToEscapeRegex(), '\\\\$1');\n}\n\n// Path params names must match the JavaScript identifier pattern.\n// See // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers.\nexport function createPathParamRegex() {\n return /(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)(?!\\\\[*+?])/gu;\n}\n\nexport function createRepeatingPathParamRegex() {\n return /(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\\\\\+/gu;\n}\n\nexport function createOptionalPathParamRegex() {\n return /(?<leadingSlash>\\/)?(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\?(?<trailingSlash>\\/)?/gu;\n}\n\nexport function createOptionalRepeatingPathParamRegex() {\n return /(?<leadingSlash>\\/)?(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\*(?<trailingSlash>\\/)?/gu;\n}\n\nfunction createRegexFromPath(path: string) {\n const pathRegexContent = preparePathForRegex(path)\n .replace(\n createOptionalRepeatingPathParamRegex(),\n (\n _match,\n leadingSlash: string | undefined,\n escape: string | undefined,\n identifier: string,\n trailingSlash: string | undefined,\n ) => {\n if (escape) {\n return `${leadingSlash ?? ''}:${identifier}\\\\*${trailingSlash ?? ''}`;\n }\n\n const hasSegmentBeforePrefix = leadingSlash === '/';\n const prefixExpression = hasSegmentBeforePrefix ? '/?' : leadingSlash;\n\n const hasSegmentAfterSuffix = trailingSlash === '/';\n const suffixExpression = hasSegmentAfterSuffix ? '/?' : trailingSlash;\n\n if (prefixExpression && suffixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>.+?)?${suffixExpression})?`;\n } else if (prefixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>.+?))?`;\n } else if (suffixExpression) {\n return `(?:(?<${identifier}>.+?)${suffixExpression})?`;\n } else {\n return `(?<${identifier}>.+?)?`;\n }\n },\n )\n .replace(createRepeatingPathParamRegex(), (_match, escape: string | undefined, identifier: string) => {\n return escape ? `:${identifier}\\\\+` : `(?<${identifier}>.+)`;\n })\n .replace(\n createOptionalPathParamRegex(),\n (\n _match,\n leadingSlash: string | undefined,\n escape: string | undefined,\n identifier: string,\n trailingSlash: string | undefined,\n ) => {\n if (escape) {\n return `${leadingSlash ?? ''}:${identifier}\\\\?${trailingSlash ?? ''}`;\n }\n\n const hasSegmentBeforePrefix = leadingSlash === '/';\n const prefixExpression = hasSegmentBeforePrefix ? '/?' : leadingSlash;\n\n const hasSegmentAfterSuffix = trailingSlash === '/';\n const suffixExpression = hasSegmentAfterSuffix ? '/?' : trailingSlash;\n\n if (prefixExpression && suffixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>[^\\\\/]+?)?${suffixExpression})`;\n } else if (prefixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>[^\\\\/]+?))?`;\n } else if (suffixExpression) {\n return `(?:(?<${identifier}>[^\\\\/]+?)${suffixExpression})?`;\n } else {\n return `(?<${identifier}>[^\\\\/]+?)?`;\n }\n },\n )\n .replace(createPathParamRegex(), (_match, escape: string | undefined, identifier: string) => {\n return escape ? `:${identifier}` : `(?<${identifier}>[^\\\\/]+?)`;\n });\n\n return new RegExp(`^/?${pathRegexContent}/?$`);\n}\n\nexport default createRegexFromPath;\n","function excludeNonPathParams(url: URL) {\n url.hash = '';\n url.search = '';\n url.username = '';\n url.password = '';\n return url;\n}\n\nexport default excludeNonPathParams;\n","function joinURL(...parts: (URL | string)[]) {\n return parts\n .map((part, index) => {\n const isFirstPart = index === 0;\n const isLastPart = index === parts.length - 1;\n\n let partAsString = part.toString();\n\n if (!isFirstPart) {\n partAsString = partAsString.replace(/^\\//, '');\n }\n if (!isLastPart) {\n partAsString = partAsString.replace(/\\/$/, '');\n }\n\n return partAsString;\n })\n .filter((part) => part.length > 0)\n .join('/');\n}\n\nexport default joinURL;\n","import { parseHttpBody } from '@zimic/http';\nimport { PossiblePromise } from '@zimic/utils/types';\n\nimport { FetchRequestObject } from '../request/types';\nimport { FetchResponseObject } from '../response/types';\n\nconst BODY_METHOD = ['json', 'formData', 'text', 'arrayBuffer', 'blob', 'bytes'] satisfies (keyof Body)[];\ntype BodyMethod = (typeof BODY_METHOD)[number];\n\nexport function isBodyMethod(property: string | symbol, value: unknown): value is Body[BodyMethod] {\n return BODY_METHOD.includes(property as BodyMethod) && typeof value === 'function';\n}\n\nexport function getOrSetBoundBodyMethod(\n resource: Request | Response,\n property: string | symbol,\n value: Body[BodyMethod],\n) {\n // We cache the bound function on the proxy instance to avoid re-binding it on every access.\n const isValueAlreadyBound = Object.prototype.hasOwnProperty.call(resource, property);\n\n if (isValueAlreadyBound) {\n return value;\n }\n\n const boundValue = value.bind(resource) as unknown;\n\n Object.defineProperty(resource, property, {\n value: boundValue,\n configurable: true,\n enumerable: false,\n writable: true,\n });\n\n return boundValue;\n}\n\nexport function withIncludedBodyIfAvailable(\n resource: Request,\n resourceObject: FetchRequestObject,\n): PossiblePromise<FetchRequestObject>;\nexport function withIncludedBodyIfAvailable(\n resource: Response,\n resourceObject: FetchResponseObject,\n): PossiblePromise<FetchResponseObject>;\nexport function withIncludedBodyIfAvailable(\n resource: Request | Response,\n resourceObject: FetchRequestObject | FetchResponseObject,\n): PossiblePromise<FetchRequestObject | FetchResponseObject> {\n const resourceType = resource instanceof Request ? 'request' : 'response';\n\n if (resource.bodyUsed) {\n console.warn(\n '[@zimic/fetch]',\n `Could not include the ${resourceType} body because it is already used. ` +\n 'If you access the body before calling `toObject()`, consider reading it from a cloned ' +\n `${resourceType}.\\n\\nLearn more: https://zimic.dev/docs/fetch/api/fetch-response-error#errortoobject`,\n );\n return resourceObject;\n }\n\n return parseHttpBody(resource.clone())\n .then((body) => {\n resourceObject.body = body;\n return resourceObject;\n })\n .catch((error: unknown) => {\n console.error('[@zimic/fetch]', `Failed to parse ${resourceType} body:`, error);\n return resourceObject;\n });\n}\n","import {\n HttpSchema,\n HttpSchemaMethod,\n HttpSchemaPath,\n HttpRequest,\n HttpRequestBodySchema,\n HttpRequestHeadersSchema,\n HttpHeaders,\n HttpSearchParams,\n HttpMethod,\n AllowAnyStringInPathParams,\n LiteralHttpSchemaPathFromNonLiteral,\n HttpHeadersInit,\n HttpSearchParamsInit,\n HttpHeadersSchema,\n} from '@zimic/http';\nimport { Default, PossiblePromise } from '@zimic/utils/types';\nimport { excludeNonPathParams, joinURL } from '@zimic/utils/url';\n\nimport { Fetch, FetchInput } from '../types/public';\nimport { getOrSetBoundBodyMethod, isBodyMethod, withIncludedBodyIfAvailable } from '../utils/objects';\nimport { FetchRequestBodySchema, FetchRequestInit, FetchRequestObject, FetchRequestObjectOptions } from './types';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request `FetchRequest` API reference} */\nexport interface FetchRequest<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n> extends HttpRequest<\n HttpRequestBodySchema<Default<Schema[Path][Method]>>,\n Default<HttpRequestHeadersSchema<Default<Schema[Path][Method]>>>\n> {\n raw: Request;\n path: AllowAnyStringInPathParams<Path>;\n method: Method;\n clone: () => FetchRequest<Schema, Method, Path>;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */\n toObject: ((options: FetchRequestObjectOptions.WithBody) => Promise<FetchRequestObject>) &\n ((options?: FetchRequestObjectOptions.WithoutBody) => FetchRequestObject) &\n ((options?: FetchRequestObjectOptions) => PossiblePromise<FetchRequestObject>);\n}\n\nexport namespace FetchRequest {\n /** A loosely typed version of a {@link FetchRequest `FetchRequest`}. */\n export interface Loose extends Request {\n raw: Request;\n path: string;\n method: HttpMethod;\n clone: () => Loose;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */\n toObject: ((options: FetchRequestObjectOptions.WithBody) => Promise<FetchRequestObject>) &\n ((options?: FetchRequestObjectOptions.WithoutBody) => FetchRequestObject) &\n ((options?: FetchRequestObjectOptions) => PossiblePromise<FetchRequestObject>);\n }\n}\n\ninterface FetchRequestClass {\n new <\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n >(\n fetch: Fetch<Schema>,\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>,\n ): FetchRequest<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>;\n\n prototype: Request;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [Symbol.hasInstance]: (instance: unknown) => instance is FetchRequest<any, any, any>;\n}\n\nconst FETCH_REQUEST_BRAND = Symbol.for('FetchRequest');\n\nconst FETCH_REQUEST_EXTRA_PROPERTIES = [FETCH_REQUEST_BRAND, 'raw', 'path', 'toObject'] as const;\ntype FetchRequestExtraProperty = (typeof FETCH_REQUEST_EXTRA_PROPERTIES)[number];\n\nfunction createFetchRequestClass() {\n const FetchRequestClass = function FetchRequest<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n >(\n fetch: Fetch<Schema>,\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>> & {\n headers?: HttpHeadersInit<Default<Schema[Path][Method]>>;\n searchParams?: HttpSearchParamsInit<Default<Schema[Path][Method]>>;\n body?: FetchRequestBodySchema<Default<Default<Schema[Path][Method]>['request']>>;\n },\n ) {\n let actualInput: URL | Request;\n\n const actualInit = {\n baseURL: init?.baseURL ?? fetch.baseURL,\n method: init?.method ?? fetch.method,\n headers: new HttpHeaders(fetch.headers),\n searchParams: new HttpSearchParams(fetch.searchParams),\n body: (init?.body ?? fetch.body) as BodyInit | null,\n mode: init?.mode ?? fetch.mode,\n cache: init?.cache ?? fetch.cache,\n credentials: init?.credentials ?? fetch.credentials,\n integrity: init?.integrity ?? fetch.integrity,\n keepalive: init?.keepalive ?? fetch.keepalive,\n priority: init?.priority ?? fetch.priority,\n redirect: init?.redirect ?? fetch.redirect,\n referrer: init?.referrer ?? fetch.referrer,\n referrerPolicy: init?.referrerPolicy ?? fetch.referrerPolicy,\n signal: init?.signal ?? fetch.signal,\n window: init?.window === undefined ? fetch.window : init.window,\n duplex: init?.duplex ?? fetch.duplex,\n };\n\n if (init?.headers !== undefined) {\n actualInit.headers.assign(new HttpHeaders(init.headers));\n }\n\n let url: URL;\n const baseURL = new URL(actualInit.baseURL);\n\n if (input instanceof Request) {\n const request = input as Request;\n\n actualInit.headers.assign(new HttpHeaders<FetchRequestInit.DefaultHeaders<Schema>>(request.headers));\n\n url = new URL(input.url);\n\n actualInput = request instanceof FetchRequestClass ? request.raw : request;\n } else {\n url = new URL(input instanceof URL ? input : joinURL(baseURL, input));\n\n actualInit.searchParams.assign(\n new HttpSearchParams<FetchRequestInit.DefaultSearchParams<Schema>>(url.searchParams),\n );\n\n if (init?.searchParams !== undefined) {\n actualInit.searchParams.assign(new HttpSearchParams(init.searchParams));\n }\n\n url.search = actualInit.searchParams.toString();\n\n actualInput = url;\n }\n\n const request = new Request(actualInput, actualInit);\n\n const baseURLWithoutTrailingSlash = baseURL.toString().replace(/\\/$/, '');\n const path = excludeNonPathParams(url).toString().replace(baseURLWithoutTrailingSlash, '');\n\n function clone() {\n return new FetchRequestClass(fetch, request.clone() as FetchInput<Schema, Method, Path>);\n }\n\n function toObject(options: { includeBody: true }): Promise<FetchRequestObject>;\n function toObject(options?: { includeBody?: false }): FetchRequestObject;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchRequestObject>;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchRequestObject> {\n const requestObject: FetchRequestObject = {\n url: request.url,\n path,\n method: request.method as HttpMethod,\n headers: HttpHeaders.prototype.toObject.call(request.headers) as HttpHeadersSchema,\n cache: request.cache,\n destination: request.destination,\n credentials: request.credentials,\n integrity: request.integrity,\n keepalive: request.keepalive,\n mode: request.mode,\n redirect: request.redirect,\n referrer: request.referrer,\n referrerPolicy: request.referrerPolicy,\n };\n\n if (!options?.includeBody) {\n return requestObject;\n }\n\n return withIncludedBodyIfAvailable(request, requestObject);\n }\n\n type FetchRequestInstance = FetchRequest<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>;\n\n const fetchRequest = new Proxy(request, {\n get(target, property) {\n if (property === FETCH_REQUEST_BRAND) {\n return true;\n }\n\n if (property === ('raw' satisfies keyof FetchRequestInstance)) {\n return request satisfies FetchRequestInstance['raw'];\n }\n\n if (property === ('path' satisfies keyof FetchRequestInstance)) {\n return path as AllowAnyStringInPathParams<\n LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>\n > satisfies FetchRequestInstance['path'];\n }\n\n if (property === ('clone' satisfies keyof FetchRequestInstance)) {\n return clone satisfies FetchRequestInstance['clone'];\n }\n\n if (property === ('toObject' satisfies keyof FetchRequestInstance)) {\n return toObject satisfies FetchRequestInstance['toObject'];\n }\n\n // Fallback other properties to the original `Request` instance.\n const value = Reflect.get(target, property, target) as unknown;\n\n if (isBodyMethod(property, value)) {\n return getOrSetBoundBodyMethod(request, property, value);\n }\n\n return value;\n },\n\n has(target, property) {\n return (\n FETCH_REQUEST_EXTRA_PROPERTIES.includes(property as FetchRequestExtraProperty) ||\n Reflect.has(target, property)\n );\n },\n }) as unknown as FetchRequest<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>;\n\n return fetchRequest;\n } as unknown as FetchRequestClass;\n\n Object.defineProperty(FetchRequestClass, Symbol.hasInstance, {\n value(instance: unknown): boolean {\n return instance instanceof Request && FETCH_REQUEST_BRAND in instance && instance[FETCH_REQUEST_BRAND] === true;\n },\n writable: false,\n enumerable: false,\n configurable: false,\n });\n\n Object.setPrototypeOf(FetchRequestClass.prototype, Request.prototype);\n\n return FetchRequestClass;\n}\n\nexport const FetchRequest = createFetchRequestClass();\n","import { HttpSchema, HttpSchemaMethod, HttpSchemaPath } from '@zimic/http';\nimport { PossiblePromise } from '@zimic/utils/types';\n\nimport { FetchRequest } from '../../request/FetchRequest';\nimport { FetchResponse } from '../FetchResponse';\nimport { FetchResponseErrorObjectOptions, FetchResponseErrorObject } from './types';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response-error `FetchResponseError` API reference} */\nclass FetchResponseError<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n> extends Error {\n constructor(\n public request: FetchRequest<Schema, Method, Path>,\n public response: FetchResponse<Schema, Method, Path>,\n ) {\n super(`${request.method} ${request.url} failed with status ${response.status}.`);\n this.name = 'FetchResponseError';\n }\n\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-response-error#errortoobject `response.error.toObject()` API reference} */\n toObject(options: FetchResponseErrorObjectOptions.WithBody): Promise<FetchResponseErrorObject>;\n toObject(options?: FetchResponseErrorObjectOptions.WithoutBody): FetchResponseErrorObject;\n toObject(options?: FetchResponseErrorObjectOptions): PossiblePromise<FetchResponseErrorObject>;\n toObject(options?: FetchResponseErrorObjectOptions): PossiblePromise<FetchResponseErrorObject> {\n const partialObject = {\n name: this.name,\n message: this.message,\n } satisfies Partial<FetchResponseErrorObject>;\n\n if (!options?.includeRequestBody && !options?.includeResponseBody) {\n return {\n ...partialObject,\n request: this.request.toObject({ includeBody: false }),\n response: this.response.toObject({ includeBody: false }),\n };\n }\n\n return Promise.all([\n Promise.resolve(this.request.toObject({ includeBody: options.includeRequestBody })),\n Promise.resolve(this.response.toObject({ includeBody: options.includeResponseBody })),\n ]).then(([request, response]) => ({ ...partialObject, request, response }));\n }\n}\n\nexport default FetchResponseError;\n","import {\n HttpHeaders,\n HttpHeadersSchema,\n HttpResponse,\n HttpResponseBodySchema,\n HttpResponseHeadersSchema,\n HttpSchema,\n HttpSchemaMethod,\n HttpSchemaPath,\n HttpStatusCode,\n} from '@zimic/http';\nimport { Default, PossiblePromise } from '@zimic/utils/types';\n\nimport { FetchRequest } from '../request/FetchRequest';\nimport { getOrSetBoundBodyMethod, isBodyMethod, withIncludedBodyIfAvailable } from '../utils/objects';\nimport FetchResponseError from './error/FetchResponseError';\nimport {\n FetchResponseBodySchema,\n FetchResponseInit,\n FetchResponseObject,\n FetchResponseObjectOptions,\n FetchResponseStatusCode,\n} from './types';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response `FetchResponse` API reference} */\nexport interface FetchResponsePerStatusCode<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n StatusCode extends HttpStatusCode = HttpStatusCode,\n> extends HttpResponse<\n HttpResponseBodySchema<Default<Schema[Path][Method]>, StatusCode>,\n Default<HttpResponseHeadersSchema<Default<Schema[Path][Method]>, StatusCode>>,\n StatusCode\n> {\n raw: Response;\n request: FetchRequest<Schema, Method, Path>;\n error: FetchResponseError<Schema, Method, Path>;\n clone: () => FetchResponsePerStatusCode<Schema, Method, Path, StatusCode>;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */\n toObject: ((options: FetchResponseObjectOptions.WithBody) => Promise<FetchResponseObject>) &\n ((options?: FetchResponseObjectOptions.WithoutBody) => FetchResponseObject) &\n ((options?: FetchResponseObjectOptions) => PossiblePromise<FetchResponseObject>);\n}\n\n/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response `FetchResponse` API reference} */\nexport type FetchResponse<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n> = StatusCode extends StatusCode ? FetchResponsePerStatusCode<Schema, Method, Path, StatusCode> : never;\n\nexport namespace FetchResponse {\n /** A loosely typed version of a {@link FetchResponse}. */\n export interface Loose extends Response {\n raw: Response;\n request: FetchRequest.Loose;\n error: FetchResponseError<any, any, any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n clone: () => Loose;\n /** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */\n toObject: ((options: FetchResponseObjectOptions.WithBody) => Promise<FetchResponseObject>) &\n ((options?: FetchResponseObjectOptions.WithoutBody) => FetchResponseObject) &\n ((options?: FetchResponseObjectOptions) => PossiblePromise<FetchResponseObject>);\n }\n}\n\ninterface FetchResponseClass {\n new <\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n >(\n fetchRequest: FetchRequest<Schema, Method, Path>,\n response?: Response,\n ): FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n new <\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n >(\n fetchRequest: FetchRequest<Schema, Method, Path>,\n body?: FetchResponseBodySchema<Default<Default<Default<Schema[Path][Method]>['response']>[StatusCode]>>,\n init?: FetchResponseInit<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>,\n ): FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n\n prototype: Response;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [Symbol.hasInstance]: (instance: unknown) => instance is FetchResponse<any, any, any, any, any, any>;\n}\n\nconst FETCH_RESPONSE_BRAND = Symbol.for('FetchResponse');\n\nconst FETCH_RESPONSE_EXTRA_PROPERTIES = [FETCH_RESPONSE_BRAND, 'raw', 'request', 'error', 'toObject'] as const;\ntype FetchResponseExtraProperty = (typeof FETCH_RESPONSE_EXTRA_PROPERTIES)[number];\n\nfunction createFetchResponseClass() {\n const FetchResponseClass = function FetchResponse<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n /** @deprecated The type parameter `ErrorOnly` will be removed in the next major version. */\n ErrorOnly extends boolean = false,\n Redirect extends RequestRedirect = 'follow',\n StatusCode extends FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect> =\n FetchResponseStatusCode<Default<Schema[Path][Method]>, ErrorOnly, Redirect>,\n >(\n fetchRequest: FetchRequest<Schema, Method, Path>,\n responseOrBody?:\n | Response\n | FetchResponseBodySchema<Default<Default<Default<Schema[Path][Method]>['response']>[StatusCode]>>,\n init?: FetchResponseInit<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>,\n ): FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode> {\n const response =\n responseOrBody instanceof Response\n ? responseOrBody\n : new Response(responseOrBody as BodyInit | null, init as ResponseInit);\n\n let error: FetchResponseError<Schema, Method, Path> | null = null;\n\n function clone() {\n return new FetchResponseClass(fetchRequest, response.clone());\n }\n\n function toObject(options: { includeBody: true }): Promise<FetchResponseObject>;\n function toObject(options?: { includeBody?: false }): FetchResponseObject;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchResponseObject>;\n function toObject(options?: { includeBody?: boolean }): PossiblePromise<FetchResponseObject> {\n const responseObject: FetchResponseObject = {\n url: response.url,\n type: response.type,\n status: response.status,\n statusText: response.statusText,\n ok: response.ok,\n headers: HttpHeaders.prototype.toObject.call(response.headers) as HttpHeadersSchema,\n redirected: response.redirected,\n };\n\n if (!options?.includeBody) {\n return responseObject;\n }\n\n return withIncludedBodyIfAvailable(response, responseObject);\n }\n\n type FetchResponseInstance = FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n\n const fetchResponse = new Proxy(response, {\n get(target, property, receiver) {\n if (property === FETCH_RESPONSE_BRAND) {\n return true;\n }\n\n if (property === ('raw' satisfies keyof FetchResponseInstance)) {\n return response satisfies FetchResponseInstance['raw'];\n }\n\n if (property === ('request' satisfies keyof FetchResponseInstance)) {\n return fetchRequest satisfies FetchResponseInstance['request'];\n }\n\n if (property === ('error' satisfies keyof FetchResponseInstance)) {\n // We create the error lazily to preserve the stack trace from the point where it was first accessed.\n error ??= new FetchResponseError(fetchRequest, receiver as FetchResponse<Schema, Method, Path>);\n return error satisfies FetchResponseInstance['error'];\n }\n\n if (property === ('clone' satisfies keyof FetchResponseInstance)) {\n // The `clone` method is not compatible with the mapping we do in `FetchResponse`(i.e.\n // `StatusCode extends StatusCode ? ... : ...`), so we need a type assertion here.\n return clone as FetchResponseInstance['clone'];\n }\n\n if (property === ('toObject' satisfies keyof FetchResponseInstance)) {\n return toObject satisfies FetchResponseInstance['toObject'];\n }\n\n // Fallback other properties to the original `Response` instance.\n const value = Reflect.get(target, property, target) as unknown;\n\n if (isBodyMethod(property, value)) {\n return getOrSetBoundBodyMethod(response, property, value);\n }\n\n return value;\n },\n\n has(target, property) {\n return (\n FETCH_RESPONSE_EXTRA_PROPERTIES.includes(property as FetchResponseExtraProperty) ||\n Reflect.has(target, property)\n );\n },\n }) as unknown as FetchResponse<Schema, Method, Path, ErrorOnly, Redirect, StatusCode>;\n\n return fetchResponse;\n } as unknown as FetchResponseClass;\n\n Object.defineProperty(FetchResponseClass, Symbol.hasInstance, {\n value(instance: unknown): boolean {\n return (\n instance instanceof Response && FETCH_RESPONSE_BRAND in instance && instance[FETCH_RESPONSE_BRAND] === true\n );\n },\n writable: false,\n enumerable: false,\n configurable: false,\n });\n\n Object.setPrototypeOf(FetchResponseClass.prototype, Response.prototype);\n\n return FetchResponseClass;\n}\n\nexport const FetchResponse = createFetchResponseClass();\n\nObject.setPrototypeOf(FetchResponse.prototype, Response.prototype);\n","import { HttpSchemaPath, HttpSchemaMethod, LiteralHttpSchemaPathFromNonLiteral, HttpSchema } from '@zimic/http';\nimport { createRegexFromPath } from '@zimic/utils/url';\n\nimport { FetchRequest } from './request/FetchRequest';\nimport { FetchRequestInit } from './request/types';\nimport FetchResponseError from './response/error/FetchResponseError';\nimport { FetchResponse } from './response/FetchResponse';\nimport { FetchInput, FetchOptions, Fetch, FetchDefaults, FetchRequestConstructor } from './types/public';\n\nconst FETCH_OPTIONS_DEFAULT_PROPERTIES = [\n 'baseURL',\n 'onRequest',\n 'onResponse',\n 'body',\n 'cache',\n 'credentials',\n 'integrity',\n 'keepalive',\n 'mode',\n 'priority',\n 'redirect',\n 'referrer',\n 'referrerPolicy',\n 'signal',\n 'window',\n 'duplex',\n] satisfies (keyof FetchOptions<never>)[];\n\nclass FetchClient<Schema extends HttpSchema> implements Omit<Fetch<Schema>, 'loose' | 'Request' | keyof FetchDefaults> {\n fetch: Fetch<Schema>;\n\n constructor(options: FetchOptions<Schema>) {\n this.fetch = this.createFetchFunction();\n this.assignDefaults(this.fetch, options);\n this.fetch.loose = this.fetch as unknown as Fetch.Loose;\n this.fetch.Request = this.createFetchRequestConstructor(this.fetch);\n }\n\n private assignDefaults(\n fetch: Fetch<Schema>,\n { headers = {}, searchParams = {}, ...otherOptions }: FetchOptions<Schema>,\n ) {\n fetch.headers = headers;\n fetch.searchParams = searchParams;\n\n for (const property of FETCH_OPTIONS_DEFAULT_PROPERTIES) {\n const propertyValue = otherOptions[property];\n\n if (propertyValue !== undefined) {\n fetch[property] = propertyValue as never;\n }\n }\n }\n\n get defaults(): FetchDefaults<Schema> {\n return this.fetch;\n }\n\n private createFetchFunction() {\n const fetch = async <\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n Redirect extends RequestRedirect = 'follow',\n >(\n input: FetchInput<Schema, Method, Path>,\n init: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>, Redirect>,\n ) => {\n const fetchRequest = await this.createFetchRequest<Method, Path>(input, init);\n\n const response = await globalThis.fetch(fetchRequest.raw.clone());\n const fetchResponse = await this.createFetchResponse<\n Method,\n LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>\n >(fetchRequest, response);\n\n return fetchResponse;\n };\n\n return Object.setPrototypeOf(fetch, this) as Fetch<Schema>;\n }\n\n private createFetchRequestConstructor<Schema extends HttpSchema>(fetch: Fetch<Schema>) {\n function Request<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n Redirect extends RequestRedirect = 'follow',\n >(\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>, Redirect>,\n ) {\n return new FetchRequest(fetch, input, init);\n }\n\n Object.setPrototypeOf(Request.prototype, FetchRequest.prototype);\n\n return Request as unknown as FetchRequestConstructor<Schema>;\n }\n\n private async createFetchRequest<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.NonLiteral<Schema, Method>,\n >(\n input: FetchInput<Schema, Method, Path>,\n init?: FetchRequestInit<Schema, Method, LiteralHttpSchemaPathFromNonLiteral<Schema, Method, Path>>,\n ) {\n let fetchRequest = new this.fetch.Request(input, init);\n\n if (this.fetch.onRequest) {\n const newRequest = await this.fetch.onRequest(fetchRequest as FetchRequest.Loose);\n\n if (newRequest !== fetchRequest) {\n if (newRequest instanceof FetchRequest) {\n fetchRequest = newRequest as typeof fetchRequest;\n } else {\n fetchRequest = new this.fetch.Request(newRequest as FetchInput<Schema, Method, Path>, init);\n }\n }\n }\n\n return fetchRequest;\n }\n\n private async createFetchResponse<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath.Literal<Schema, Method>,\n >(fetchRequest: FetchRequest<Schema, Method, Path>, response: Response) {\n let fetchResponse = new FetchResponse<Schema, Method, Path>(fetchRequest, response);\n\n if (this.fetch.onResponse) {\n const newResponse = await this.fetch.onResponse(fetchResponse as FetchResponse.Loose);\n\n fetchResponse =\n newResponse instanceof FetchResponse\n ? (newResponse as typeof fetchResponse)\n : new FetchResponse<Schema, Method, Path>(fetchRequest, newResponse);\n }\n\n return fetchResponse;\n }\n\n isRequest<Path extends HttpSchemaPath.Literal<Schema, Method>, Method extends HttpSchemaMethod<Schema>>(\n request: unknown,\n method: Method,\n path: Path,\n ): request is FetchRequest<Schema, Method, Path> {\n return (\n request instanceof FetchRequest &&\n request.method === method &&\n typeof request.path === 'string' &&\n createRegexFromPath(path).test(request.path)\n );\n }\n\n isResponse<Path extends HttpSchemaPath.Literal<Schema, Method>, Method extends HttpSchemaMethod<Schema>>(\n response: unknown,\n method: Method,\n path: Path,\n ): response is FetchResponse<Schema, Method, Path> {\n return response instanceof FetchResponse && this.isRequest(response.request, method, path);\n }\n\n isResponseError<Path extends HttpSchemaPath.Literal<Schema, Method>, Method extends HttpSchemaMethod<Schema>>(\n error: unknown,\n method: Method,\n path: Path,\n ): error is FetchResponseError<Schema, Method, Path> {\n return (\n error instanceof FetchResponseError &&\n this.isRequest(error.request, method, path) &&\n this.isResponse(error.response, method, path)\n );\n }\n}\n\nexport default FetchClient;\n","import { HttpSchema } from '@zimic/http';\n\nimport FetchClient from './FetchClient';\nimport { FetchOptions, Fetch } from './types/public';\n\n/** @see {@link https://zimic.dev/docs/fetch/api/create-fetch `createFetch` API reference} */\nfunction createFetch<Schema extends HttpSchema>(options: FetchOptions<Schema>): Fetch<Schema> {\n const { fetch } = new FetchClient<Schema>(options);\n return fetch;\n}\n\nexport default createFetch;\n"]}
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ import { excludeNonPathParams, joinURL } from '@zimic/utils/url';
|
|
|
19
19
|
|
|
20
20
|
import { Fetch, FetchInput } from '../types/public';
|
|
21
21
|
import { getOrSetBoundBodyMethod, isBodyMethod, withIncludedBodyIfAvailable } from '../utils/objects';
|
|
22
|
-
import { FetchRequestBodySchema, FetchRequestInit, FetchRequestObject } from './types';
|
|
22
|
+
import { FetchRequestBodySchema, FetchRequestInit, FetchRequestObject, FetchRequestObjectOptions } from './types';
|
|
23
23
|
|
|
24
24
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request `FetchRequest` API reference} */
|
|
25
25
|
export interface FetchRequest<
|
|
@@ -35,9 +35,9 @@ export interface FetchRequest<
|
|
|
35
35
|
method: Method;
|
|
36
36
|
clone: () => FetchRequest<Schema, Method, Path>;
|
|
37
37
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */
|
|
38
|
-
toObject: ((options:
|
|
39
|
-
((options?:
|
|
40
|
-
((options?:
|
|
38
|
+
toObject: ((options: FetchRequestObjectOptions.WithBody) => Promise<FetchRequestObject>) &
|
|
39
|
+
((options?: FetchRequestObjectOptions.WithoutBody) => FetchRequestObject) &
|
|
40
|
+
((options?: FetchRequestObjectOptions) => PossiblePromise<FetchRequestObject>);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export namespace FetchRequest {
|
|
@@ -48,8 +48,9 @@ export namespace FetchRequest {
|
|
|
48
48
|
method: HttpMethod;
|
|
49
49
|
clone: () => Loose;
|
|
50
50
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */
|
|
51
|
-
toObject: ((options:
|
|
52
|
-
((options?:
|
|
51
|
+
toObject: ((options: FetchRequestObjectOptions.WithBody) => Promise<FetchRequestObject>) &
|
|
52
|
+
((options?: FetchRequestObjectOptions.WithoutBody) => FetchRequestObject) &
|
|
53
|
+
((options?: FetchRequestObjectOptions) => PossiblePromise<FetchRequestObject>);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -122,6 +122,24 @@ export namespace FetchRequestInit {
|
|
|
122
122
|
export type Loose = Partial<Defaults>;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */
|
|
126
|
+
export interface FetchRequestObjectOptions {
|
|
127
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */
|
|
128
|
+
includeBody?: boolean;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export namespace FetchRequestObjectOptions {
|
|
132
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */
|
|
133
|
+
export interface WithBody {
|
|
134
|
+
includeBody: true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()` API reference} */
|
|
138
|
+
export interface WithoutBody {
|
|
139
|
+
includeBody?: false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
125
143
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-request#requesttoobject `request.toObject()`} */
|
|
126
144
|
export type FetchRequestObject = Pick<
|
|
127
145
|
FetchRequest.Loose,
|
|
@@ -14,7 +14,13 @@ import { Default, PossiblePromise } from '@zimic/utils/types';
|
|
|
14
14
|
import { FetchRequest } from '../request/FetchRequest';
|
|
15
15
|
import { getOrSetBoundBodyMethod, isBodyMethod, withIncludedBodyIfAvailable } from '../utils/objects';
|
|
16
16
|
import FetchResponseError from './error/FetchResponseError';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
FetchResponseBodySchema,
|
|
19
|
+
FetchResponseInit,
|
|
20
|
+
FetchResponseObject,
|
|
21
|
+
FetchResponseObjectOptions,
|
|
22
|
+
FetchResponseStatusCode,
|
|
23
|
+
} from './types';
|
|
18
24
|
|
|
19
25
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response `FetchResponse` API reference} */
|
|
20
26
|
export interface FetchResponsePerStatusCode<
|
|
@@ -32,9 +38,9 @@ export interface FetchResponsePerStatusCode<
|
|
|
32
38
|
error: FetchResponseError<Schema, Method, Path>;
|
|
33
39
|
clone: () => FetchResponsePerStatusCode<Schema, Method, Path, StatusCode>;
|
|
34
40
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */
|
|
35
|
-
toObject: ((options:
|
|
36
|
-
((options?:
|
|
37
|
-
((options?:
|
|
41
|
+
toObject: ((options: FetchResponseObjectOptions.WithBody) => Promise<FetchResponseObject>) &
|
|
42
|
+
((options?: FetchResponseObjectOptions.WithoutBody) => FetchResponseObject) &
|
|
43
|
+
((options?: FetchResponseObjectOptions) => PossiblePromise<FetchResponseObject>);
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response `FetchResponse` API reference} */
|
|
@@ -57,8 +63,9 @@ export namespace FetchResponse {
|
|
|
57
63
|
error: FetchResponseError<any, any, any>; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
58
64
|
clone: () => Loose;
|
|
59
65
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */
|
|
60
|
-
toObject: ((options:
|
|
61
|
-
((options?:
|
|
66
|
+
toObject: ((options: FetchResponseObjectOptions.WithBody) => Promise<FetchResponseObject>) &
|
|
67
|
+
((options?: FetchResponseObjectOptions.WithoutBody) => FetchResponseObject) &
|
|
68
|
+
((options?: FetchResponseObjectOptions) => PossiblePromise<FetchResponseObject>);
|
|
62
69
|
}
|
|
63
70
|
}
|
|
64
71
|
|
|
@@ -101,6 +101,24 @@ export interface FetchResponseConstructor {
|
|
|
101
101
|
[Symbol.hasInstance]: (instance: unknown) => boolean;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */
|
|
105
|
+
export interface FetchResponseObjectOptions {
|
|
106
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */
|
|
107
|
+
includeBody?: boolean;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export namespace FetchResponseObjectOptions {
|
|
111
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */
|
|
112
|
+
export interface WithBody {
|
|
113
|
+
includeBody: true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()` API reference} */
|
|
117
|
+
export interface WithoutBody {
|
|
118
|
+
includeBody?: false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
104
122
|
/** @see {@link https://zimic.dev/docs/fetch/api/fetch-response#responsetoobject `response.toObject()`} */
|
|
105
123
|
export type FetchResponseObject = Pick<
|
|
106
124
|
FetchResponse.Loose,
|
package/src/index.ts
CHANGED
|
@@ -10,12 +10,13 @@ export type {
|
|
|
10
10
|
} from './client/types/public';
|
|
11
11
|
|
|
12
12
|
export { FetchRequest } from './client/request/FetchRequest';
|
|
13
|
-
export type { FetchRequestInit, FetchRequestObject } from './client/request/types';
|
|
13
|
+
export type { FetchRequestInit, FetchRequestObject, FetchRequestObjectOptions } from './client/request/types';
|
|
14
14
|
|
|
15
15
|
export { FetchResponse } from './client/response/FetchResponse';
|
|
16
16
|
export type { FetchResponsePerStatusCode } from './client/response/FetchResponse';
|
|
17
17
|
export type {
|
|
18
18
|
FetchResponseObject,
|
|
19
|
+
FetchResponseObjectOptions,
|
|
19
20
|
FetchResponseConstructor,
|
|
20
21
|
FetchResponseInit,
|
|
21
22
|
FetchResponseStatusCode,
|