@zimic/http 0.4.0-canary.0 → 0.4.0-canary.2
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/README.md +1 -1
- package/dist/{chunk-IJVT4RDC.mjs → chunk-KVTV4E5K.mjs} +26 -100
- package/dist/chunk-KVTV4E5K.mjs.map +1 -0
- package/dist/{chunk-DIZB36SQ.js → chunk-LOHINQWU.js} +26 -100
- package/dist/chunk-LOHINQWU.js.map +1 -0
- package/dist/cli.js +7 -7
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.ts +140 -195
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -3
- package/dist/index.mjs.map +1 -1
- package/dist/typegen.js +2 -2
- package/dist/typegen.mjs +1 -1
- package/package.json +2 -2
- package/src/formData/HttpFormData.ts +44 -54
- package/src/formData/types.ts +36 -42
- package/src/headers/HttpHeaders.ts +38 -35
- package/src/headers/types.ts +2 -2
- package/src/pathParams/types.ts +29 -40
- package/src/searchParams/HttpSearchParams.ts +57 -49
- package/src/searchParams/types.ts +39 -45
- package/src/typegen/openapi/transform/components.ts +1 -11
- package/src/typegen/openapi/transform/context.ts +0 -3
- package/src/typegen/openapi/transform/methods.ts +23 -88
- package/src/typegen/openapi/transform/operations.ts +1 -11
- package/src/typegen/openapi/transform/paths.ts +1 -17
- package/src/types/requests.ts +60 -19
- package/src/types/schema.ts +50 -134
- package/dist/chunk-DIZB36SQ.js.map +0 -1
- package/dist/chunk-IJVT4RDC.mjs.map +0 -1
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../zimic-utils/dist/chunk-6IEM75FG.mjs","../../zimic-utils/src/data/blobEquals.ts","../../zimic-utils/src/data/fileEquals.ts","../src/formData/HttpFormData.ts","../src/headers/HttpHeaders.ts","../src/searchParams/HttpSearchParams.ts","../src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K,CAAA,WAAA,EAAa,GAAG,CAAE,CAAA,MAAA;AACrF,MAAA,IAAI,CAAC,sBAAwB,EAAA;AAC3B,QAAO,OAAA,KAAA;AAAA;AAGT,MAAM,MAAA,WAAA,GAAc,MAAO,CAAA,QAAA,CAAS,UAAU,CAAA;AAC9C,MAAA,IAAI,CAAC,WAAa,EAAA;AAChB,QAAO,OAAA,KAAA;AAAA;AACT;AAGF,IAAO,OAAA,IAAA;AAAA;AACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBA,QAAW,GAAA;AACT,IAAA,MAAM,SAAS,EAAC;AAIhB,IAAA,KAAA,MAAW,CAAC,GAAK,EAAA,KAAK,CAAK,IAAA,IAAA,CAAK,SAAW,EAAA;AACzC,MAAA,IAAI,OAAO,MAAQ,EAAA;AACjB,QAAM,MAAA,aAAA,GAAgB,OAAO,GAAG,CAAA;AAEhC,QAAI,IAAA,KAAA,CAAM,OAAqB,CAAA,aAAa,CAAG,EAAA;AAC7C,UAAA,aAAA,CAAc,KAAK,KAAoB,CAAA;AAAA,SAClC,MAAA;AACL,UAAA,MAAA,CAAO,GAAG,CAAA,GAAI,CAAC,aAAA,EAAe,KAAK,CAAA;AAAA;AACrC,OACK,MAAA;AACL,QAAA,MAAA,CAAO,GAAG,CAAI,GAAA,KAAA;AAAA;AAChB;AAGF,IAAO,OAAA,MAAA;AAAA;AAEX,CAAA;AAEA,IAAO,wBAAQ,GAAA;;;AC3OF,IAAA,YAAA,GAAe,MAAO,CAAA,MAAA,CAAO,CAAC,KAAA,EAAO,MAAQ,EAAA,KAAA,EAAO,OAAS,EAAA,QAAA,EAAU,MAAQ,EAAA,SAAS,CAAU","file":"index.mjs","sourcesContent":["var __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __name = (target, value) => __defProp(target, \"name\", { value, configurable: true });\nvar __require = /* @__PURE__ */ ((x) => typeof require !== \"undefined\" ? require : typeof Proxy !== \"undefined\" ? new Proxy(x, {\n get: (a, b) => (typeof require !== \"undefined\" ? require : a)[b]\n}) : x)(function(x) {\n if (typeof require !== \"undefined\") return require.apply(this, arguments);\n throw Error('Dynamic require of \"' + x + '\" is not supported');\n});\nvar __commonJS = (cb, mod) => function __require2() {\n return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\n\nexport { __commonJS, __name, __require, __toESM };\n//# sourceMappingURL=chunk-6IEM75FG.mjs.map\n//# sourceMappingURL=chunk-6IEM75FG.mjs.map","async function blobEquals(blob: Blob, otherBlob: Blob) {\n if (blob.type !== otherBlob.type || blob.size !== otherBlob.size) {\n return false;\n }\n\n const reader = blob.stream().getReader();\n const otherReader = otherBlob.stream().getReader();\n\n let buffer: Uint8Array = new Uint8Array(0);\n let otherBuffer: Uint8Array = new Uint8Array(0);\n\n try {\n while (true) {\n await Promise.all([\n buffer.length === 0 &&\n reader.read().then((result) => {\n if (!result.done) {\n buffer = result.value;\n }\n }),\n\n otherBuffer.length === 0 &&\n otherReader.read().then((result) => {\n if (!result.done) {\n otherBuffer = result.value;\n }\n }),\n ]);\n\n const streamsEndedTogether = buffer.length === 0 && otherBuffer.length === 0;\n\n if (streamsEndedTogether) {\n return true;\n }\n\n const oneStreamEndedBeforeTheOther =\n (buffer.length === 0 && otherBuffer.length > 0) || (buffer.length > 0 && otherBuffer.length === 0);\n\n if (oneStreamEndedBeforeTheOther) {\n return false;\n }\n\n const minimumByteLength = Math.min(buffer.length, otherBuffer.length);\n\n for (let byteIndex = 0; byteIndex < minimumByteLength; byteIndex++) {\n if (buffer[byteIndex] !== otherBuffer[byteIndex]) {\n return false;\n }\n }\n\n buffer = buffer.slice(minimumByteLength);\n otherBuffer = otherBuffer.slice(minimumByteLength);\n }\n } finally {\n reader.releaseLock();\n otherReader.releaseLock();\n }\n}\n\nexport default blobEquals;\n","import blobEquals from './blobEquals';\n\nasync function fileEquals(file: File, otherFile: File) {\n return file.name === otherFile.name && (await blobEquals(file, otherFile));\n}\n\nexport default fileEquals;\n","import fileEquals from '@zimic/utils/data/fileEquals';\nimport { ArrayItemIfArray, ReplaceBy } from '@zimic/utils/types';\n\nimport { HttpFormDataSchema, HttpFormDataSchemaName } from './types';\n\n/**\n * An extended HTTP form data object with a strictly-typed schema. Fully compatible with the built-in\n * {@link https://developer.mozilla.org/docs/Web/API/FormData `FormData`} class.\n *\n * **IMPORTANT**: the input of `HttpFormData` and all of its internal types must be declared inline or as a type aliases\n * (`type`). They cannot be interfaces.\n *\n * @example\n * import { HttpFormData } from '@zimic/http';\n *\n * const formData = new HttpFormData<{\n * files: File[];\n * description?: string;\n * }>();\n *\n * formData.append('file', new File(['content'], 'file.txt', { type: 'text/plain' }));\n * formData.append('description', 'My file');\n *\n * const files = formData.getAll('file');\n * console.log(files); // [File { name: 'file.txt', type: 'text/plain' }]\n *\n * const description = formData.get('description');\n * console.log(description); // 'My file'\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpformdata `HttpFormData` API reference}\n */\nclass HttpFormData<Schema extends HttpFormDataSchema = HttpFormDataSchema> extends FormData {\n /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/set MDN Reference} */\n set<Name extends HttpFormDataSchemaName<Schema>>(\n name: Name,\n value: Exclude<ArrayItemIfArray<NonNullable<Schema[Name]>>, Blob>,\n ): void;\n set<Name extends HttpFormDataSchemaName<Schema>>(\n name: Name,\n blob: Exclude<ArrayItemIfArray<NonNullable<Schema[Name]>>, string>,\n fileName?: string,\n ): void;\n set<Name extends HttpFormDataSchemaName<Schema>>(\n name: Name,\n blobOrValue: ArrayItemIfArray<NonNullable<Schema[Name]>>,\n fileName?: string,\n ): void {\n if (fileName === undefined) {\n super.set(name, blobOrValue as Blob);\n } else {\n super.set(name, blobOrValue as Blob, fileName);\n }\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/append MDN Reference} */\n append<Name extends HttpFormDataSchemaName<Schema>>(\n name: Name,\n value: Exclude<ArrayItemIfArray<NonNullable<Schema[Name]>>, Blob>,\n ): void;\n append<Name extends HttpFormDataSchemaName<Schema>>(\n name: Name,\n blob: Exclude<ArrayItemIfArray<NonNullable<Schema[Name]>>, string>,\n fileName?: string,\n ): void;\n append<Name extends HttpFormDataSchemaName<Schema>>(\n name: Name,\n blobOrValue: ArrayItemIfArray<NonNullable<Schema[Name]>>,\n fileName?: string,\n ): void {\n if (fileName === undefined) {\n super.append(name, blobOrValue as Blob);\n } else {\n super.append(name, blobOrValue as Blob, fileName);\n }\n }\n\n /**\n * Get the value of the entry associated to a key name.\n *\n * If the key might have multiple values, use {@link HttpFormData#getAll} instead.\n *\n * @param name The name of the key to get the value of.\n * @returns The value associated with the key name, or `null` if the key does not exist.\n * @see {@link https://developer.mozilla.org/docs/Web/API/FormData/get MDN Reference}\n */\n get<Name extends HttpFormDataSchemaName.NonArray<Schema>>(\n name: Name,\n ): ReplaceBy<ReplaceBy<ArrayItemIfArray<Schema[Name]>, undefined, null>, Blob, File> {\n return super.get(name) as ReplaceBy<ReplaceBy<ArrayItemIfArray<Schema[Name]>, undefined, null>, Blob, File>;\n }\n\n /**\n * Get all the values of the entry associated with a key name.\n *\n * If the key has at most a single value, use {@link HttpFormData#get} instead.\n *\n * @param name The name of the key to get the values of.\n * @returns An array of values associated with the key name, or an empty array if the key does not exist.\n * @see {@link https://developer.mozilla.org/docs/Web/API/FormData/getAll MDN Reference}\n */\n getAll<Name extends HttpFormDataSchemaName.Array<Schema>>(\n name: Name,\n ): ReplaceBy<ArrayItemIfArray<NonNullable<Schema[Name]>>, Blob, File>[] {\n return super.getAll(name) as ReplaceBy<ArrayItemIfArray<NonNullable<Schema[Name]>>, Blob, File>[];\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/has MDN Reference} */\n has<Name extends HttpFormDataSchemaName<Schema>>(name: Name): boolean {\n return super.has(name);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/delete MDN Reference} */\n delete<Name extends HttpFormDataSchemaName<Schema>>(name: Name): void {\n super.delete(name);\n }\n\n forEach<This extends HttpFormData<Schema>>(\n callback: <Key extends HttpFormDataSchemaName<Schema>>(\n value: ReplaceBy<ArrayItemIfArray<NonNullable<Schema[Key]>>, Blob, File>,\n key: Key,\n parent: HttpFormData<Schema>,\n ) => void,\n thisArg?: This,\n ): void {\n super.forEach(callback as (value: FormDataEntryValue, key: string, parent: FormData) => void, thisArg);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/keys MDN Reference} */\n keys(): FormDataIterator<HttpFormDataSchemaName<Schema>> {\n return super.keys() as FormDataIterator<HttpFormDataSchemaName<Schema>>;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/values MDN Reference} */\n values(): FormDataIterator<\n ReplaceBy<ArrayItemIfArray<NonNullable<Schema[HttpFormDataSchemaName<Schema>]>>, Blob, File>\n > {\n return super.values() as FormDataIterator<\n ReplaceBy<ArrayItemIfArray<NonNullable<Schema[HttpFormDataSchemaName<Schema>]>>, Blob, File>\n >;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/entries MDN Reference} */\n entries(): FormDataIterator<\n [\n HttpFormDataSchemaName<Schema>,\n ReplaceBy<ArrayItemIfArray<NonNullable<Schema[HttpFormDataSchemaName<Schema>]>>, Blob, File>,\n ]\n > {\n return super.entries() as FormDataIterator<\n [\n HttpFormDataSchemaName<Schema>,\n ReplaceBy<ArrayItemIfArray<NonNullable<Schema[HttpFormDataSchemaName<Schema>]>>, Blob, File>,\n ]\n >;\n }\n\n [Symbol.iterator](): FormDataIterator<\n [\n HttpFormDataSchemaName<Schema>,\n ReplaceBy<ArrayItemIfArray<NonNullable<Schema[HttpFormDataSchemaName<Schema>]>>, Blob, File>,\n ]\n > {\n return super[Symbol.iterator]() as FormDataIterator<\n [\n HttpFormDataSchemaName<Schema>,\n ReplaceBy<ArrayItemIfArray<NonNullable<Schema[HttpFormDataSchemaName<Schema>]>>, Blob, File>,\n ]\n >;\n }\n\n /**\n * Checks if the data is equal to the other data. Equality is defined as having the same keys and values, regardless\n * of the order of keys.\n *\n * @param otherData The other data to compare.\n * @returns A promise that resolves with `true` if the data is equal to the other data, or `false` otherwise.\n * Important: both form data might be read while comparing.\n */\n async equals<OtherSchema extends Schema>(otherData: HttpFormData<OtherSchema>): Promise<boolean> {\n if (!(await this.contains(otherData))) {\n return false;\n }\n\n for (const key of this.keys()) {\n const otherHasKey = super.has.call(otherData, key);\n if (!otherHasKey) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Checks if the data contains the other data. This method is less strict than {@link HttpFormData#equals} and only\n * requires that all keys and values in the other data are present in this data.\n *\n * @param otherData The other data to compare.\n * @returns A promise that resolves with `true` if this data contains the other data, or `false` otherwise. Important:\n * both form data might be read while comparing.\n */\n async contains<OtherSchema extends Schema>(otherData: HttpFormData<OtherSchema>): Promise<boolean> {\n for (const [otherKey, otherValue] of otherData.entries()) {\n const values = super.getAll.call(this, otherKey);\n\n const haveSameNumberOfValues = values.length === super.getAll.call(otherData, otherKey).length;\n if (!haveSameNumberOfValues) {\n return false;\n }\n\n let valueExists = false;\n\n for (const value of values) {\n if (\n value === otherValue ||\n (value instanceof Blob && otherValue instanceof Blob && (await fileEquals(value, otherValue)))\n ) {\n valueExists = true;\n break;\n }\n }\n\n if (!valueExists) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Converts this form data into a plain object. This method is useful for serialization and debugging purposes.\n *\n * **NOTE**: If a key has multiple values, the object will contain an array of values for that key. If the key has\n * only one value, the object will contain its value directly, without an array, regardless of how the value was\n * initialized when creating the form data.\n *\n * @example\n * const formData = new HttpFormData<{\n * title: string;\n * descriptions: string[];\n * content: Blob;\n * }>();\n *\n * formData.set('title', 'My title');\n * formData.append('descriptions', 'Description 1');\n * formData.append('descriptions', 'Description 2');\n * formData.set('content', new Blob(['content'], { type: 'text/plain' }));\n *\n * const object = formData.toObject();\n * console.log(object); // { title: 'My title', descriptions: ['Description 1', 'Description 2'], content: Blob { type: 'text/plain' } }\n *\n * @returns A plain object representation of this form data.\n */\n toObject() {\n const object = {} as Schema;\n\n type SchemaValue = Schema[HttpFormDataSchemaName<Schema>];\n\n for (const [key, value] of this.entries()) {\n if (key in object) {\n const existingValue = object[key];\n\n if (Array.isArray<SchemaValue>(existingValue)) {\n existingValue.push(value as SchemaValue);\n } else {\n object[key] = [existingValue, value] as SchemaValue;\n }\n } else {\n object[key] = value as SchemaValue;\n }\n }\n\n return object;\n }\n}\n\nexport default HttpFormData;\n","import { Default, ReplaceBy } from '@zimic/utils/types';\n\nimport { HttpHeadersSchema, HttpHeadersInit, HttpHeadersSchemaName } from './types';\n\nfunction pickPrimitiveProperties<Schema extends HttpHeadersSchema>(schema: Schema) {\n return Object.entries(schema).reduce<Record<string, string>>((accumulated, [key, value]) => {\n if (value !== undefined) {\n accumulated[key] = value;\n }\n return accumulated;\n }, {});\n}\n\n/**\n * An extended HTTP headers object with a strictly-typed schema. Fully compatible with the built-in\n * {@link https://developer.mozilla.org/docs/Web/API/Headers `Headers`} class.\n *\n * **IMPORTANT**: the input of `HttpHeaders` and all of its internal types must be declared inline or as a type aliases\n * (`type`). They cannot be interfaces.\n *\n * @example\n * import { HttpHeaders } from '@zimic/http';\n *\n * const headers = new HttpHeaders<{\n * accept?: string;\n * 'content-type'?: string;\n * }>({\n * accept: '*',\n * 'content-type': 'application/json',\n * });\n *\n * const contentType = headers.get('content-type');\n * console.log(contentType); // 'application/json'\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpheaders `HttpHeaders` API reference}\n */\nclass HttpHeaders<Schema extends HttpHeadersSchema = HttpHeadersSchema> extends Headers {\n constructor(init?: HttpHeadersInit<Schema>) {\n if (init instanceof Headers || Array.isArray(init) || !init) {\n super(init);\n } else {\n super(pickPrimitiveProperties(init));\n }\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/set MDN Reference} */\n set<Name extends HttpHeadersSchemaName<Schema>>(name: Name, value: NonNullable<Schema[Name]> & string): void {\n super.set(name, value);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/append MDN Reference} */\n append<Name extends HttpHeadersSchemaName<Schema>>(name: Name, value: NonNullable<Schema[Name]> & string): void {\n super.append(name, value);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/get MDN Reference} */\n get<Name extends HttpHeadersSchemaName<Schema>>(name: Name): ReplaceBy<Schema[Name], undefined, null> {\n return super.get(name) as ReplaceBy<Schema[Name], undefined, null>;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/has MDN Reference} */\n getSetCookie(): NonNullable<Default<Schema['Set-Cookie'], string>>[] {\n return super.getSetCookie() as NonNullable<Default<Schema['Set-Cookie'], string>>[];\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/has MDN Reference} */\n has<Name extends HttpHeadersSchemaName<Schema>>(name: Name): boolean {\n return super.has(name);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/delete MDN Reference} */\n delete<Name extends HttpHeadersSchemaName<Schema>>(name: Name): void {\n super.delete(name);\n }\n\n forEach<This extends HttpHeaders<Schema>>(\n callback: <Key extends HttpHeadersSchemaName<Schema>>(\n value: NonNullable<Schema[Key]> & string,\n key: Key,\n parent: Headers,\n ) => void,\n thisArg?: This,\n ): void {\n super.forEach(callback as (value: string, key: string, parent: Headers) => void, thisArg);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/keys MDN Reference} */\n keys(): HeadersIterator<HttpHeadersSchemaName<Schema>> {\n return super.keys() as HeadersIterator<HttpHeadersSchemaName<Schema>>;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/values MDN Reference} */\n values(): HeadersIterator<NonNullable<Schema[HttpHeadersSchemaName<Schema>]> & string> {\n return super.values() as HeadersIterator<NonNullable<Schema[HttpHeadersSchemaName<Schema>]> & string>;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/entries MDN Reference} */\n entries(): HeadersIterator<\n [HttpHeadersSchemaName<Schema>, NonNullable<Schema[HttpHeadersSchemaName<Schema>]> & string]\n > {\n return super.entries() as HeadersIterator<\n [HttpHeadersSchemaName<Schema>, NonNullable<Schema[HttpHeadersSchemaName<Schema>]> & string]\n >;\n }\n\n [Symbol.iterator](): HeadersIterator<\n [HttpHeadersSchemaName<Schema>, NonNullable<Schema[HttpHeadersSchemaName<Schema>]> & string]\n > {\n return super[Symbol.iterator]() as HeadersIterator<\n [HttpHeadersSchemaName<Schema>, NonNullable<Schema[HttpHeadersSchemaName<Schema>]> & string]\n >;\n }\n\n /**\n * Checks if this headers object is equal to another set of headers. Equality is defined as having the same keys and\n * values, regardless of the order of keys.\n *\n * @param otherHeaders The other headers object to compare against.\n * @returns `true` if the headers are equal, `false` otherwise.\n */\n equals<OtherSchema extends Schema>(otherHeaders: HttpHeaders<OtherSchema>): boolean {\n if (!this.contains(otherHeaders)) {\n return false;\n }\n\n for (const key of this.keys()) {\n const otherHasKey = super.has.call(otherHeaders, key);\n if (!otherHasKey) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Checks if this headers object contains another set of headers. This method is less strict than\n * {@link HttpHeaders#equals} and only requires that all keys and values in the other headers are present in these\n * headers.\n *\n * @param otherHeaders The other headers object to compare against.\n * @returns `true` if these headers contain the other headers, `false` otherwise.\n */\n contains<OtherSchema extends Schema>(otherHeaders: HttpHeaders<OtherSchema>): boolean {\n for (const [key, otherValue] of otherHeaders.entries()) {\n const value = super.get.call(this, key);\n\n if (value === null) {\n return false;\n }\n\n const valueItems = this.splitHeaderValues(value);\n const otherValueItems = this.splitHeaderValues(otherValue);\n\n const haveSameNumberOfValues = valueItems.length === otherValueItems.length;\n if (!haveSameNumberOfValues) {\n return false;\n }\n\n for (const otherValueItem of otherValueItems) {\n if (!valueItems.includes(otherValueItem)) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n /**\n * Converts these headers into a plain object. This method is useful for serialization and debugging purposes.\n *\n * @example\n * const headers = new HttpHeaders({\n * accept: 'application/json',\n * 'content-type': 'application/json',\n * });\n * const object = headers.toObject();\n * console.log(object); // { accept: 'application/json', 'content-type': 'application/json' }\n *\n * @returns A plain object representation of these headers.\n */\n toObject(): Schema {\n const object = {} as Schema;\n\n for (const [key, value] of this.entries()) {\n object[key] = value;\n }\n\n return object;\n }\n\n private splitHeaderValues(value: string) {\n return value\n .split(',')\n .map((item) => item.trim())\n .filter((item) => item.length > 0);\n }\n}\n\nexport default HttpHeaders;\n","import { ReplaceBy, ArrayItemIfArray } from '@zimic/utils/types';\n\nimport { HttpSearchParamsSchema, HttpSearchParamsInit, HttpSearchParamsSchemaName } from './types';\n\nfunction pickPrimitiveProperties<Schema extends HttpSearchParamsSchema>(schema: Schema) {\n const schemaWithPrimitiveProperties = Object.entries(schema).reduce<Record<string, string>>(\n (accumulated, [key, value]) => {\n if (value !== undefined && !Array.isArray(value)) {\n accumulated[key] = value;\n }\n return accumulated;\n },\n {},\n );\n return schemaWithPrimitiveProperties;\n}\n\n/**\n * An extended HTTP search params object with a strictly-typed schema. Fully compatible with the built-in\n * {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams `URLSearchParams`} class.\n *\n * **IMPORTANT**: the input of `HttpSearchParams` and all of its internal types must be declared inline or as a type\n * aliases (`type`). They cannot be interfaces.\n *\n * @example\n * import { HttpSearchParams } from '@zimic/http';\n *\n * const searchParams = new HttpSearchParams<{\n * names?: string[];\n * page?: `${number}`;\n * }>({\n * names: ['user 1', 'user 2'],\n * page: '1',\n * });\n *\n * const names = searchParams.getAll('names');\n * console.log(names); // ['user 1', 'user 2']\n *\n * const page = searchParams.get('page');\n * console.log(page); // '1'\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpsearchparams `HttpSearchParams` API reference}\n */\nclass HttpSearchParams<Schema extends HttpSearchParamsSchema = HttpSearchParamsSchema> extends URLSearchParams {\n constructor(init?: HttpSearchParamsInit<Schema>) {\n if (init instanceof URLSearchParams || Array.isArray(init) || typeof init === 'string' || !init) {\n super(init);\n } else {\n super(pickPrimitiveProperties(init));\n this.populateInitArrayProperties(init);\n }\n }\n\n private populateInitArrayProperties(init: Schema) {\n for (const [key, value] of Object.entries(init)) {\n if (Array.isArray(value)) {\n for (const item of value) {\n super.append(key, item);\n }\n }\n }\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/set MDN Reference} */\n set<Name extends HttpSearchParamsSchemaName<Schema>>(\n name: Name,\n value: ArrayItemIfArray<NonNullable<Schema[Name]>>,\n ): void {\n super.set(name, value);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/append MDN Reference} */\n append<Name extends HttpSearchParamsSchemaName<Schema>>(\n name: Name,\n value: ArrayItemIfArray<NonNullable<Schema[Name]>>,\n ): void {\n super.append(name, value);\n }\n\n /**\n * Get the value of the entry associated to a key name.\n *\n * If the key might have multiple values, use {@link HttpSearchParams#getAll} instead.\n *\n * @param name The name of the key to get the value of.\n * @returns The value associated with the key name, or `null` if the key does not exist.\n * @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/get MDN Reference}\n */\n get<Name extends HttpSearchParamsSchemaName.NonArray<Schema>>(\n name: Name,\n ): ReplaceBy<ArrayItemIfArray<Schema[Name]>, undefined, null> {\n return super.get(name) as ReplaceBy<ArrayItemIfArray<Schema[Name]>, undefined, null>;\n }\n\n /**\n * Get all the values of the entry associated with a key name.\n *\n * If the key has at most one value, use {@link HttpSearchParams#get} instead.\n *\n * @param name The name of the key to get the values of.\n * @returns An array of values associated with the key name, or an empty array if the key does not exist.\n * @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll MDN Reference}\n */\n getAll<Name extends HttpSearchParamsSchemaName.Array<Schema>>(\n name: Name,\n ): ArrayItemIfArray<NonNullable<Schema[Name]>>[] {\n return super.getAll(name) as ArrayItemIfArray<NonNullable<Schema[Name]>>[];\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/has MDN Reference} */\n has<Name extends HttpSearchParamsSchemaName<Schema>>(\n name: Name,\n value?: ArrayItemIfArray<NonNullable<Schema[Name]>>,\n ): boolean {\n return super.has(name, value);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete MDN Reference} */\n delete<Name extends HttpSearchParamsSchemaName<Schema>>(\n name: Name,\n value?: ArrayItemIfArray<NonNullable<Schema[Name]>>,\n ): void {\n super.delete(name, value);\n }\n\n forEach<This extends HttpSearchParams<Schema>>(\n callback: <Key extends HttpSearchParamsSchemaName<Schema>>(\n value: ArrayItemIfArray<NonNullable<Schema[Key]>>,\n key: Key,\n parent: HttpSearchParams<Schema>,\n ) => void,\n thisArg?: This,\n ): void {\n super.forEach(callback as (value: string, key: string, parent: URLSearchParams) => void, thisArg);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/keys MDN Reference} */\n keys(): URLSearchParamsIterator<HttpSearchParamsSchemaName<Schema>> {\n return super.keys() as URLSearchParamsIterator<HttpSearchParamsSchemaName<Schema>>;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/values MDN Reference} */\n values(): URLSearchParamsIterator<ArrayItemIfArray<NonNullable<Schema[HttpSearchParamsSchemaName<Schema>]>>> {\n return super.values() as URLSearchParamsIterator<\n ArrayItemIfArray<NonNullable<Schema[HttpSearchParamsSchemaName<Schema>]>>\n >;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/entries MDN Reference} */\n entries(): URLSearchParamsIterator<\n [HttpSearchParamsSchemaName<Schema>, ArrayItemIfArray<NonNullable<Schema[HttpSearchParamsSchemaName<Schema>]>>]\n > {\n return super.entries() as URLSearchParamsIterator<\n [HttpSearchParamsSchemaName<Schema>, ArrayItemIfArray<NonNullable<Schema[HttpSearchParamsSchemaName<Schema>]>>]\n >;\n }\n\n [Symbol.iterator](): URLSearchParamsIterator<\n [HttpSearchParamsSchemaName<Schema>, ArrayItemIfArray<NonNullable<Schema[HttpSearchParamsSchemaName<Schema>]>>]\n > {\n return super[Symbol.iterator]() as URLSearchParamsIterator<\n [HttpSearchParamsSchemaName<Schema>, ArrayItemIfArray<NonNullable<Schema[HttpSearchParamsSchemaName<Schema>]>>]\n >;\n }\n\n /**\n * Checks if these search params are equal to another set of search parameters. Equality is defined as having the same\n * keys and values, regardless of the order of the keys.\n *\n * @param otherParams The other search parameters to compare against.\n * @returns `true` if the search parameters are equal, `false` otherwise.\n */\n equals<OtherSchema extends Schema>(otherParams: HttpSearchParams<OtherSchema>): boolean {\n return this.contains(otherParams) && this.size === otherParams.size;\n }\n\n /**\n * Checks if these search params contain another set of search parameters. This method is less strict than\n * {@link HttpSearchParams#equals} and only requires that all keys and values in the other search parameters are\n * present in these search parameters.\n *\n * @param otherParams The other search parameters to check for containment.\n * @returns `true` if these search parameters contain the other search parameters, `false` otherwise.\n */\n contains<OtherSchema extends Schema>(otherParams: HttpSearchParams<OtherSchema>): boolean {\n for (const [key, otherValue] of otherParams.entries()) {\n const values = super.getAll.call(this, key);\n\n const haveSameNumberOfValues = values.length === super.getAll.call(otherParams, key).length;\n if (!haveSameNumberOfValues) {\n return false;\n }\n\n const valueExists = values.includes(otherValue);\n if (!valueExists) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Converts these search params into a plain object. This method is useful for serialization and debugging purposes.\n *\n * **NOTE**: If a key has multiple values, the object will contain an array of values for that key. If the key has\n * only one value, the object will contain its value directly, without an array, regardless of how the value was\n * initialized when creating the search params object.\n *\n * @example\n * const searchParams = new HttpSearchParams({\n * names: ['user 1', 'user 2'],\n * name: ['user 3'],\n * page: '1',\n * });\n * const object = searchParams.toObject();\n * console.log(object); // { names: ['user 1', 'user 2'], name: 'user 3', page: '1' }\n *\n * @returns A plain object representation of these search params.\n */\n toObject() {\n const object = {} as Schema;\n\n type SchemaValue = Schema[HttpSearchParamsSchemaName<Schema>];\n\n for (const [key, value] of this.entries()) {\n if (key in object) {\n const existingValue = object[key];\n\n if (Array.isArray<SchemaValue>(existingValue)) {\n existingValue.push(value as SchemaValue);\n } else {\n object[key] = [existingValue, value] as SchemaValue;\n }\n } else {\n object[key] = value as SchemaValue;\n }\n }\n\n return object;\n }\n}\n\nexport default HttpSearchParams;\n","import { IfAny, UnionToIntersection, UnionHasMoreThanOneType, Prettify, NonEmptyArray } from '@zimic/utils/types';\n\nimport { HttpFormDataSchema, HttpFormDataSerialized } from '../formData/types';\nimport { HttpHeadersSchema, HttpHeadersSerialized } from '../headers/types';\nimport { HttpPathParamsSchema, HttpPathParamsSerialized } from '../pathParams/types';\nimport { HttpSearchParamsSchema, HttpSearchParamsSerialized } from '../searchParams/types';\nimport { HttpBody } from './requests';\n\nexport const HTTP_METHODS = Object.freeze(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'] as const);\n/**\n * A type representing the currently supported\n * {@link https://developer.mozilla.org/docs/Web/HTTP/Methods `HTTP methods`}.\n */\nexport type HttpMethod = (typeof HTTP_METHODS)[number];\n\n/**\n * A schema representing the structure of an HTTP request.\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport interface HttpRequestSchema {\n headers?: HttpHeadersSchema.Loose;\n searchParams?: HttpSearchParamsSchema.Loose;\n body?: HttpBody.Loose;\n}\n\nexport namespace HttpRequestSchema {\n /** Convert an HTTP request schema to be strictly typed. */\n export type AsStrict<Schema> = {\n [Key in keyof Schema]: Key extends 'headers'\n ? HttpHeadersSerialized<Schema[Key]>\n : Key extends 'searchParams'\n ? HttpSearchParamsSerialized<Schema[Key]>\n : Key extends 'body'\n ? HttpBody.AsStrict<Schema[Key]>\n : Schema[Key];\n };\n}\n\n/**\n * A schema representing the structure of an HTTP response.\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport interface HttpResponseSchema {\n headers?: HttpHeadersSchema.Loose;\n body?: HttpBody.Loose;\n}\n\nexport namespace HttpResponseSchema {\n /** A schema representing the structure of an HTTP response with no body. */\n export interface NoBody extends Omit<HttpResponseSchema, 'body'> {\n body?: null;\n }\n\n /** Convert an HTTP response schema to be strictly typed. */\n export type AsStrict<Schema> = HttpRequestSchema.AsStrict<Schema>;\n}\n\n/**\n * The status codes used in HTTP responses, as defined by\n * {@link https://httpwg.org/specs/rfc9110.html#overview.of.status.codes RFC-9110}.\n *\n * - `HttpStatusCode.Information`: {@link https://developer.mozilla.org/docs/Web/HTTP/Status#information_responses `1XX`}\n * - `HttpStatusCode.Success`: {@link https://developer.mozilla.org/docs/Web/HTTP/Status#successful_responses `2XX`}\n * - `HttpStatusCode.Redirection`: {@link https://developer.mozilla.org/docs/Web/HTTP/Status#redirection_messages `3XX`}\n * - `HttpStatusCode.ClientError`: {@link https://developer.mozilla.org/docs/Web/HTTP/Status#client_error_responses `4XX`}\n * - `HttpStatusCode.ServerError`: {@link https://developer.mozilla.org/docs/Web/HTTP/Status#server_error_responses `5XX`}\n */\nexport type HttpStatusCode =\n | HttpStatusCode.Information\n | HttpStatusCode.Success\n | HttpStatusCode.Redirection\n | HttpStatusCode.ClientError\n | HttpStatusCode.ServerError;\n\nexport namespace HttpStatusCode {\n /**\n * An HTTP status code in the `1XX` range, representing an informational response.\n *\n * @see {@link https://developer.mozilla.org/docs/Web/HTTP/Status#information_responses `1XX`}\n */\n export type Information =\n | 100 // Continue\n | 101 // Switching Protocols\n | 102 // Processing\n | 103; // Early Hints\n\n /**\n * An HTTP status code in the `2XX` range, representing a successful response.\n *\n * @see {@link https://developer.mozilla.org/docs/Web/HTTP/Status#successful_responses `2XX`}\n */\n export type Success =\n | 200 // OK\n | 201 // Created\n | 202 // Accepted\n | 203 // Non-Authoritative Information\n | 204 // No Content\n | 205 // Reset Content\n | 206 // Partial Content\n | 207 // Multi-Status\n | 208 // Already Reported\n | 226; // IM Used\n\n /**\n * An HTTP status code in the `3XX` range, representing a redirection response.\n *\n * @see {@link https://developer.mozilla.org/docs/Web/HTTP/Status#redirection_messages `3XX`}\n */\n export type Redirection =\n | 300 // Multiple Choices\n | 301 // Moved Permanently\n | 302 // Found\n | 303 // See Other\n | 304 // Not Modified\n | 307 // Temporary Redirect\n | 308; // Permanent Redirect\n\n /**\n * An HTTP status code in the `4XX` range, representing a client error response.\n *\n * @see {@link https://developer.mozilla.org/docs/Web/HTTP/Status#client_error_responses `4XX`}\n */\n export type ClientError =\n | 400 // Bad Request\n | 401 // Unauthorized\n | 402 // Payment Required\n | 403 // Forbidden\n | 404 // Not Found\n | 405 // Method Not Allowed\n | 406 // Not Acceptable\n | 407 // Proxy Authentication Required\n | 408 // Request Timeout\n | 409 // Conflict\n | 410 // Gone\n | 411 // Length Required\n | 412 // Precondition Failed\n | 413 // Content Too Large\n | 414 // URI Too Long\n | 415 // Unsupported Media Type\n | 416 // Range Not Satisfiable\n | 417 // Expectation Failed\n | 418 // I'm a teapot\n | 421 // Misdirected Request\n | 422 // Unprocessable Content\n | 423 // Locked\n | 424 // Failed Dependency\n | 425 // Too Early\n | 426 // Upgrade Required\n | 428 // Precondition Required\n | 429 // Too Many Requests\n | 431 // Request Header Fields Too Large\n | 451; // Unavailable For Legal Reasons\n\n /**\n * An HTTP status code in the `5XX` range, representing a server error response.\n *\n * @see {@link https://developer.mozilla.org/docs/Web/HTTP/Status#server_error_responses `5XX`}\n */\n export type ServerError =\n | 500 // Internal Server Error\n | 501 // Not Implemented\n | 502 // Bad Gateway\n | 503 // Service Unavailable\n | 504 // Gateway Timeout\n | 505 // HTTP Version Not Supported\n | 506 // Variant Also Negotiates\n | 507 // Insufficient Storage\n | 508 // Loop Detected\n | 510 // Not Extended\n | 511; // Network Authentication Required\n}\n\n/**\n * A schema representing the structure of HTTP responses by status code.\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport type HttpResponseSchemaByStatusCode =\n HttpResponseSchemaByStatusCode.AsStrict<HttpResponseSchemaByStatusCode.Loose>;\n\nexport namespace HttpResponseSchemaByStatusCode {\n /** A loose version of HTTP responses by status code. JSON values are not strictly typed. */\n export type Loose = {\n [StatusCode in HttpStatusCode]?: HttpResponseSchema;\n };\n\n /** Converts an HTTP response schema by status code to be strictly typed. */\n export type AsStrict<Schema> = {\n [StatusCode in keyof Schema]: StatusCode extends 204\n ? HttpResponseSchema.NoBody\n : HttpResponseSchema.AsStrict<Schema[StatusCode]>;\n };\n\n /** A schema representing the structure of HTTP responses by status code with no body. */\n export type NoBody = {\n [StatusCode in HttpStatusCode]?: HttpResponseSchema.NoBody;\n };\n}\n\n/**\n * Extracts the status codes used in a response schema by status code.\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport type HttpResponseSchemaStatusCode<ResponseSchemaByStatusCode extends HttpResponseSchemaByStatusCode> =\n keyof ResponseSchemaByStatusCode & HttpStatusCode;\n\n/**\n * A schema representing the structure of an HTTP request and response for a given method.\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport interface HttpMethodSchema {\n request?: HttpRequestSchema;\n response?: HttpResponseSchemaByStatusCode;\n}\n\nexport namespace HttpMethodSchema {\n /** A schema representing the structure of an HTTP request and response for a given method, having no request body. */\n export interface NoRequestBody extends Omit<HttpMethodSchema, 'request'> {\n request?: Omit<HttpRequestSchema, 'body'> & { body?: null };\n }\n\n /**\n * A schema representing the structure of an HTTP request and response for a given method, having no request and\n * response bodies.\n */\n export interface NoBody extends Omit<NoRequestBody, 'response'> {\n response?: HttpResponseSchemaByStatusCode.NoBody;\n }\n\n /** Converts an HTTP method schema to be strictly typed. */\n export type AsStrict<Schema> = {\n [Key in keyof Schema]: Key extends 'request'\n ? HttpRequestSchema.AsStrict<Schema[Key]>\n : Key extends 'response'\n ? HttpResponseSchemaByStatusCode.AsStrict<Schema[Key]>\n : Schema[Key];\n };\n}\n\n/**\n * A schema representing the structure of HTTP request and response by method.\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport interface HttpMethodsSchema {\n GET?: HttpMethodSchema.NoRequestBody;\n POST?: HttpMethodSchema;\n PUT?: HttpMethodSchema;\n PATCH?: HttpMethodSchema;\n DELETE?: HttpMethodSchema;\n HEAD?: HttpMethodSchema.NoBody;\n OPTIONS?: HttpMethodSchema.NoRequestBody;\n}\n\nexport namespace HttpMethodsSchema {\n /** Converts an HTTP methods schema to be strictly typed. */\n export type AsStrict<Schema> = {\n [Method in keyof Schema]: HttpMethodSchema.AsStrict<Schema[Method]>;\n };\n}\n\ninterface BaseHttpSchema {\n [path: string]: HttpMethodsSchema;\n}\n\n/**\n * Declares an HTTP service schema.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * interface UserListHeaders {\n * accept: string;\n * }\n *\n * interface UserListSearchParams {\n * name?: string;\n * limit?: `${number}`;\n * }\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * request: {\n * headers: UserListHeaders;\n * searchParams: UserListSearchParams;\n * };\n * response: {\n * 200: {\n * // Inline headers declaration\n * headers: { 'content-type': string };\n * body: User[];\n * };\n * };\n * };\n * };\n * }>;\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport type HttpSchema<Schema extends BaseHttpSchema = BaseHttpSchema> = HttpSchema.AsStrict<Schema>;\n\nexport namespace HttpSchema {\n /** Converts an HTTP service schema to be strictly typed. */\n export type AsStrict<Schema extends BaseHttpSchema> = {\n [Path in keyof Schema]: HttpMethodsSchema.AsStrict<Schema[Path]>;\n };\n\n /**\n * Declares an HTTP service methods schema.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserMethods = HttpSchema.Methods<{\n * GET: {\n * response: {\n * 200: { body: User[] };\n * };\n * };\n * }>;\n *\n * type Schema = HttpSchema<{\n * '/users': UserMethods;\n * }>;\n */\n export type Methods<Schema extends HttpMethodsSchema> = HttpMethodsSchema.AsStrict<Schema>;\n\n /**\n * Declares an HTTP service method schema.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserListMethod = HttpSchema.Method<{\n * response: {\n * 200: { body: User[] };\n * };\n * }>;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: UserListMethod;\n * };\n * }>;\n */\n export type Method<Schema extends HttpMethodSchema> = HttpMethodSchema.AsStrict<Schema>;\n\n /**\n * Declares an HTTP service request schema.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserCreationRequest = HttpSchema.Request<{\n * headers: { 'content-type': 'application/json' };\n * body: User;\n * }>;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * POST: {\n * request: UserCreationRequest;\n * response: {\n * 201: { body: User };\n * };\n * };\n * };\n * }>;\n */\n export type Request<Schema extends HttpRequestSchema> = HttpRequestSchema.AsStrict<Schema>;\n\n /**\n * Declares an HTTP service response schema by status code.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserListResponseByStatusCode = HttpSchema.ResponseByStatusCode<{\n * 200: { body: User[] };\n * 400: { body: { message: string } };\n * }>;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * response: UserListResponseByStatusCode;\n * };\n * };\n * }>;\n */\n export type ResponseByStatusCode<Schema extends HttpResponseSchemaByStatusCode> =\n HttpResponseSchemaByStatusCode.AsStrict<Schema>;\n\n /**\n * Declares an HTTP service response schema.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserListSuccessResponse = HttpSchema.Response<{\n * body: User[];\n * }>;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * response: {\n * 200: UserListSuccessResponse;\n * };\n * };\n * };\n * }>;\n */\n export type Response<Schema extends HttpResponseSchema> = HttpResponseSchema.AsStrict<Schema>;\n\n /**\n * Declares an HTTP body schema. JSON values are serialized to their strict form using\n * {@link https://github.com/zimicjs/zimic/wiki/api‐zimic#jsonserialized `JSONSerialized`} if necessary.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserListSuccessResponseBody = HttpSchema.Body<User[]>;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * response: {\n * 200: { body: UserListSuccessResponseBody };\n * };\n * };\n * };\n * }>;\n */\n export type Body<Schema extends HttpBody.Loose> = HttpBody.AsStrict<Schema>;\n\n /**\n * Declares an HTTP headers schema. Headers are serialized to their strict form using\n * {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpheadersserialized `HttpHeadersSerialized`} if\n * necessary.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserListHeaders = HttpSchema.Headers<{\n * accept: 'application/json';\n * }>;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * request: {\n * headers: UserListHeaders;\n * };\n * response: {\n * 200: { body: User[] };\n * };\n * };\n * };\n * }>;\n */\n export type Headers<Schema extends HttpHeadersSchema.Loose> = HttpHeadersSerialized<Schema>;\n\n /**\n * Declares an HTTP search params schema. Search params are serialized to their strict form using\n * {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpsearchparamsserialized `HttpSearchParamsSerialized`}\n * if necessary.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserListSearchParams = HttpSchema.SearchParams<{\n * limit: `${number}`;\n * offset: `${number}`;\n * }>;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * request: {\n * searchParams: UserListSearchParams;\n * };\n * response: {\n * 200: { body: User[] };\n * };\n * };\n * };\n * }>;\n */\n export type SearchParams<Schema extends HttpSearchParamsSchema.Loose> = HttpSearchParamsSerialized<Schema>;\n\n /**\n * Declares an HTTP path params schema. Path params are serialized to their strict form using\n * {@link HttpPathParamsSerialized} if necessary.\n *\n * @example\n * import { type HttpSchema, InferPathParams } from '@zimic/http';\n *\n * type Schema = HttpSchema<{\n * '/users/:userId': {\n * GET: {\n * response: {\n * 200: { body: User };\n * };\n * };\n * };\n * }>;\n *\n * type UserByIdPathParams = HttpSchema.PathParams<{\n * userId: string;\n * }>;\n *\n * // Or infer from the path string\n * type UserByIdPathParams = InferPathParams<Schema, '/users/:userId'>;\n */\n export type PathParams<Schema extends HttpPathParamsSchema.Loose> = HttpPathParamsSerialized<Schema>;\n\n /**\n * Declares an HTTP form data schema. Form data is serialized to their strict form using\n * {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpformdataserialized `HttpFormDataSerialized`} if\n * necessary.\n *\n * @example\n * import { HttpFormData, type HttpSchema } from '@zimic/http';\n *\n * type UserCreationFormData = HttpFormData<\n * HttpSchema.FormData<{\n * name: string;\n * email: string;\n * }>\n * >;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * POST: {\n * request: {\n * body: UserCreationFormData;\n * };\n * response: {\n * 201: { body: User };\n * };\n * };\n * };\n * }>;\n */\n export type FormData<Schema extends HttpFormDataSchema.Loose> = HttpFormDataSerialized<Schema>;\n}\n\n/**\n * Extracts the methods from an HTTP service schema.\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport type HttpSchemaMethod<Schema extends HttpSchema> = IfAny<\n Schema,\n any, // eslint-disable-line @typescript-eslint/no-explicit-any\n keyof UnionToIntersection<Schema[keyof Schema]> & HttpMethod\n>;\n\nexport type AllowAnyStringInPathParams<Path extends string> = Path extends `${infer Prefix}:${string}/${infer Suffix}`\n ? `${Prefix}${string}/${AllowAnyStringInPathParams<Suffix>}`\n : Path extends `${infer Prefix}:${string}`\n ? `${Prefix}${string}`\n : Path;\n\n/**\n * Extracts the paths from an HTTP service schema. Optionally receives a second argument with one or more methods to\n * filter the paths with. Only the methods defined in the schema are allowed.\n *\n * @example\n * import { type HttpSchema, type HttpSchemaPath } from '@zimic/http';\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * response: { 200: { body: User[] } };\n * };\n * };\n * '/users/:userId': {\n * DELETE: {\n * response: { 200: { body: User } };\n * };\n * };\n * }>;\n *\n * type Path = HttpSchemaPath<Schema>;\n * // \"/users\" | \"/users/:userId\" | \"/users/${string}\"\n *\n * type GetPath = HttpSchemaPath<Schema, 'GET'>;\n * // \"/users\"\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport namespace HttpSchemaPath {\n type LooseLiteral<Schema extends HttpSchema, Method extends HttpMethod = HttpMethod> = {\n [Path in keyof Schema & string]: Method extends keyof Schema[Path] ? Path : never;\n }[keyof Schema & string];\n\n /**\n * Extracts the literal paths from an HTTP service schema. Optionally receives a second argument with one or more\n * methods to filter the paths with. Only the methods defined in the schema are allowed.\n *\n * @example\n * import { type HttpSchema, type HttpSchemaPath } from '@zimic/http';\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * response: { 200: { body: User[] } };\n * };\n * };\n * '/users/:userId': {\n * DELETE: {\n * response: { 200: { body: User } };\n * };\n * };\n * }>;\n *\n * type LiteralPath = HttpSchemaPath.Literal<Schema>;\n * // \"/users\" | \"/users/:userId\"\n *\n * type LiteralGetPath = HttpSchemaPath.Literal<Schema, 'GET'>;\n * // \"/users\"\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\n export type Literal<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>,\n > = LooseLiteral<Schema, Method>;\n\n /**\n * Extracts the non-literal paths from an HTTP service schema. Optionally receives a second argument with one or more\n * methods to filter the paths with. Only the methods defined in the schema are allowed.\n *\n * @example\n * import { type HttpSchema, type HttpSchemaPath } from '@zimic/http';\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * response: { 200: { body: User[] } };\n * };\n * };\n * '/users/:userId': {\n * DELETE: {\n * response: { 200: { body: User } };\n * };\n * };\n * }>;\n *\n * type NonLiteralPath = HttpSchemaPath.NonLiteral<Schema>;\n * // \"/users\" | \"/users/${string}\"\n *\n * type NonLiteralGetPath = HttpSchemaPath.NonLiteral<Schema, 'GET'>;\n * // \"/users\"\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\n export type NonLiteral<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>,\n > = AllowAnyStringInPathParams<Literal<Schema, Method>>;\n}\n\nexport type HttpSchemaPath<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>,\n> = HttpSchemaPath.Literal<Schema, Method> | HttpSchemaPath.NonLiteral<Schema, Method>;\n\ntype LargestPathPrefix<Path extends string> = Path extends `${infer Prefix}/${infer Suffix}`\n ? `${Prefix}/${Suffix extends `${string}/${string}` ? LargestPathPrefix<Suffix> : ''}`\n : Path;\n\ntype ExcludeNonLiteralPathsSupersededByLiteralPath<Path extends string> =\n Path extends `${LargestPathPrefix<Path>}:${string}` ? never : Path;\n\nexport type PreferMostStaticLiteralPath<Path extends string> =\n UnionHasMoreThanOneType<Path> extends true ? ExcludeNonLiteralPathsSupersededByLiteralPath<Path> : Path;\n\ntype RecursiveInferHttpSchemaPath<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n NonLiteralPath extends string,\n LiteralPath extends HttpSchemaPath.Literal<Schema, Method>,\n> =\n NonLiteralPath extends AllowAnyStringInPathParams<LiteralPath>\n ? NonLiteralPath extends `${AllowAnyStringInPathParams<LiteralPath>}/${string}`\n ? never\n : LiteralPath\n : never;\n\nexport type LiteralHttpSchemaPathFromNonLiteral<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n NonLiteralPath extends string,\n LiteralPath extends HttpSchemaPath.Literal<Schema, Method> = HttpSchemaPath.Literal<Schema, Method>,\n> = PreferMostStaticLiteralPath<\n LiteralPath extends LiteralPath ? RecursiveInferHttpSchemaPath<Schema, Method, NonLiteralPath, LiteralPath> : never\n>;\n\ntype RecursiveInferPathParams<Path extends string> = Path extends `${infer _Prefix}:${infer ParamName}/${infer Suffix}`\n ? { [Name in ParamName]: string } & RecursiveInferPathParams<Suffix>\n : Path extends `${infer _Prefix}:${infer ParamName}`\n ? { [Name in ParamName]: string }\n : {};\n\n/**\n * Infers the path parameters schema from a path string, optionally validating it against an {@link HttpSchema}.\n *\n * If the first argument is a {@link HttpSchema} (recommended), the second argument is checked to be a valid path in that\n * schema.\n *\n * @example\n * import { HttpSchema, InferPathParams } from '@zimic/http';\n *\n * type Schema = HttpSchema<{\n * '/users/:userId': {\n * GET: {\n * response: { 200: { body: User } };\n * };\n * };\n * }>;\n *\n * // Using a schema to validate the path (recommended):\n * type PathParams = InferPathParams<Schema, '/users/:userId'>;\n * // { userId: string }\n *\n * @example\n * import { InferPathParams } from '@zimic/http';\n *\n * // Without using a schema to validate the path (works as `PathParamsSchemaFromPath`):\n * type PathParams = InferPathParams<'/users/:userId'>;\n * // { userId: string }\n */\nexport type InferPathParams<\n PathOrSchema extends string | HttpSchema,\n OptionalPath extends PathOrSchema extends HttpSchema ? HttpSchemaPath.Literal<PathOrSchema> : never = never,\n> = Prettify<\n RecursiveInferPathParams<\n PathOrSchema extends HttpSchema ? OptionalPath : PathOrSchema extends string ? PathOrSchema : never\n >\n>;\n\ntype OmitPastHttpStatusCodes<\n Schema extends HttpResponseSchemaByStatusCode.Loose,\n PastSchemas extends HttpResponseSchemaByStatusCode.Loose[],\n> =\n PastSchemas extends NonEmptyArray<HttpResponseSchemaByStatusCode.Loose>\n ? Omit<Schema, keyof UnionToIntersection<PastSchemas[number]>>\n : Schema;\n\ntype RecursiveMergeHttpResponsesByStatusCode<\n Schemas extends HttpResponseSchemaByStatusCode.Loose[],\n PastSchemas extends HttpResponseSchemaByStatusCode.Loose[] = [],\n> = Schemas extends [\n infer FirstSchema extends HttpResponseSchemaByStatusCode.Loose,\n ...infer RestSchemas extends HttpResponseSchemaByStatusCode.Loose[],\n]\n ? RestSchemas extends NonEmptyArray<HttpResponseSchemaByStatusCode.Loose>\n ? OmitPastHttpStatusCodes<FirstSchema, PastSchemas> &\n RecursiveMergeHttpResponsesByStatusCode<RestSchemas, [...PastSchemas, FirstSchema]>\n : OmitPastHttpStatusCodes<FirstSchema, PastSchemas>\n : never;\n\n/**\n * Merges multiple HTTP response schemas by status code into a single schema. When there are duplicate status codes, the\n * first declaration takes precedence.\n *\n * @example\n * import { type HttpSchema, type HttpStatusCode, MergeHttpResponsesByStatusCode } from '@zimic/http';\n *\n * // Overriding the 400 status code with a more specific schema\n * // and using a generic schema for all other client errors.\n * type MergedResponseByStatusCode = MergeHttpResponsesByStatusCode<\n * [\n * {\n * 400: { body: { message: string; issues: string[] } };\n * },\n * {\n * [StatusCode in HttpStatusCode.ClientError]: { body: { message: string } };\n * },\n * ]\n * >;\n * // {\n * // 400: { body: { message: string; issues: string[] } };\n * // 401: { body: { message: string}; };\n * // 402: { body: { message: string}; };\n * // 403: { body: { message: string}; };\n * // ...\n * // }\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: { response: MergedResponseByStatusCode };\n * };\n * }>;\n */\nexport type MergeHttpResponsesByStatusCode<\n Schemas extends HttpResponseSchemaByStatusCode.Loose[],\n PastSchemas extends HttpResponseSchemaByStatusCode.Loose[] = [],\n> = HttpResponseSchemaByStatusCode.AsStrict<RecursiveMergeHttpResponsesByStatusCode<Schemas, PastSchemas>>;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../zimic-utils/dist/chunk-6IEM75FG.mjs","../../zimic-utils/src/data/blobEquals.ts","../../zimic-utils/src/data/fileEquals.ts","../src/formData/HttpFormData.ts","../src/headers/HttpHeaders.ts","../src/searchParams/HttpSearchParams.ts","../src/types/schema.ts"],"names":["__defProp","__name","pickPrimitiveProperties"],"mappings":";;;;AACA,IAAIA,aAAY,MAAO,CAAA,cAAA;AAKvB,IAAIC,OAAS,mBAAA,MAAA,CAAA,CAAC,MAAQ,EAAA,KAAA,KAAUD,UAAU,CAAA,MAAA,EAAQ,MAAQ,EAAA,EAAE,KAAO,EAAA,YAAA,EAAc,IAAK,EAAC,CAA1E,EAAA,QAAA,CAAA;;;ACNb,eAAe,UAAA,CAAW,MAAY,SAAiB,EAAA;AACrD,EAAA,IAAI,KAAK,IAAS,KAAA,SAAA,CAAU,QAAQ,IAAK,CAAA,IAAA,KAAS,UAAU,IAAM,EAAA;AACzD,IAAA,OAAA,KAAA;AAAA;AAGT,EAAA,MAAM,MAAS,GAAA,IAAA,CAAK,MAAO,EAAA,CAAE,SAAU,EAAA;AACvC,EAAA,MAAM,WAAc,GAAA,SAAA,CAAU,MAAO,EAAA,CAAE,SAAU,EAAA;AAE7C,EAAA,IAAA,MAAA,GAAqB,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K,SAAW,EAAA;AACzC,MAAA,IAAI,OAAO,MAAQ,EAAA;AACjB,QAAM,MAAA,aAAA,GAAgB,OAAO,GAAG,CAAA;AAEhC,QAAI,IAAA,KAAA,CAAM,OAAqB,CAAA,aAAa,CAAG,EAAA;AAC7C,UAAA,aAAA,CAAc,KAAK,KAAoB,CAAA;AAAA,SAClC,MAAA;AACL,UAAA,MAAA,CAAO,GAAG,CAAA,GAAI,CAAC,aAAA,EAAe,KAAK,CAAA;AAAA;AACrC,OACK,MAAA;AACL,QAAA,MAAA,CAAO,GAAG,CAAI,GAAA,KAAA;AAAA;AAChB;AAGF,IAAO,OAAA,MAAA;AAAA;AAEX,CAAA;AAEA,IAAO,wBAAQ,GAAA;;;AC5OF,IAAA,YAAA,GAAe,MAAO,CAAA,MAAA,CAAO,CAAC,KAAA,EAAO,MAAQ,EAAA,KAAA,EAAO,OAAS,EAAA,QAAA,EAAU,MAAQ,EAAA,SAAS,CAAU","file":"index.mjs","sourcesContent":["var __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __name = (target, value) => __defProp(target, \"name\", { value, configurable: true });\nvar __require = /* @__PURE__ */ ((x) => typeof require !== \"undefined\" ? require : typeof Proxy !== \"undefined\" ? new Proxy(x, {\n get: (a, b) => (typeof require !== \"undefined\" ? require : a)[b]\n}) : x)(function(x) {\n if (typeof require !== \"undefined\") return require.apply(this, arguments);\n throw Error('Dynamic require of \"' + x + '\" is not supported');\n});\nvar __commonJS = (cb, mod) => function __require2() {\n return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\n\nexport { __commonJS, __name, __require, __toESM };\n//# sourceMappingURL=chunk-6IEM75FG.mjs.map\n//# sourceMappingURL=chunk-6IEM75FG.mjs.map","async function blobEquals(blob: Blob, otherBlob: Blob) {\n if (blob.type !== otherBlob.type || blob.size !== otherBlob.size) {\n return false;\n }\n\n const reader = blob.stream().getReader();\n const otherReader = otherBlob.stream().getReader();\n\n let buffer: Uint8Array = new Uint8Array(0);\n let otherBuffer: Uint8Array = new Uint8Array(0);\n\n try {\n while (true) {\n await Promise.all([\n buffer.length === 0 &&\n reader.read().then((result) => {\n if (!result.done) {\n buffer = result.value;\n }\n }),\n\n otherBuffer.length === 0 &&\n otherReader.read().then((result) => {\n if (!result.done) {\n otherBuffer = result.value;\n }\n }),\n ]);\n\n const streamsEndedTogether = buffer.length === 0 && otherBuffer.length === 0;\n\n if (streamsEndedTogether) {\n return true;\n }\n\n const oneStreamEndedBeforeTheOther =\n (buffer.length === 0 && otherBuffer.length > 0) || (buffer.length > 0 && otherBuffer.length === 0);\n\n if (oneStreamEndedBeforeTheOther) {\n return false;\n }\n\n const minimumByteLength = Math.min(buffer.length, otherBuffer.length);\n\n for (let byteIndex = 0; byteIndex < minimumByteLength; byteIndex++) {\n if (buffer[byteIndex] !== otherBuffer[byteIndex]) {\n return false;\n }\n }\n\n buffer = buffer.slice(minimumByteLength);\n otherBuffer = otherBuffer.slice(minimumByteLength);\n }\n } finally {\n reader.releaseLock();\n otherReader.releaseLock();\n }\n}\n\nexport default blobEquals;\n","import blobEquals from './blobEquals';\n\nasync function fileEquals(file: File, otherFile: File) {\n return file.name === otherFile.name && (await blobEquals(file, otherFile));\n}\n\nexport default fileEquals;\n","import fileEquals from '@zimic/utils/data/fileEquals';\nimport { ArrayItemIfArray, ReplaceBy } from '@zimic/utils/types';\n\nimport { HttpFormDataSchema, HttpFormDataSchemaName, HttpFormDataSerialized } from './types';\n\n/**\n * An extended HTTP form data object with a strictly-typed schema. Fully compatible with the built-in\n * {@link https://developer.mozilla.org/docs/Web/API/FormData `FormData`} class.\n *\n * **IMPORTANT**: the input of `HttpFormData` and all of its internal types must be declared inline or as a type aliases\n * (`type`). They cannot be interfaces.\n *\n * @example\n * import { HttpFormData } from '@zimic/http';\n *\n * const formData = new HttpFormData<{\n * files: File[];\n * description?: string;\n * }>();\n *\n * formData.append('file', new File(['content'], 'file.txt', { type: 'text/plain' }));\n * formData.append('description', 'My file');\n *\n * const files = formData.getAll('file');\n * console.log(files); // [File { name: 'file.txt', type: 'text/plain' }]\n *\n * const description = formData.get('description');\n * console.log(description); // 'My file'\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpformdata `HttpFormData` API reference}\n */\nclass HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFormDataSchema.Loose> extends FormData {\n readonly _schema!: HttpFormDataSerialized<LooseSchema>;\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/set MDN Reference} */\n set<Name extends HttpFormDataSchemaName<this['_schema']>>(\n name: Name,\n value: Exclude<ArrayItemIfArray<NonNullable<LooseSchema[Name]>>, Blob>,\n ): void;\n set<Name extends HttpFormDataSchemaName<this['_schema']>>(\n name: Name,\n blob: Exclude<ArrayItemIfArray<NonNullable<LooseSchema[Name]>>, string>,\n fileName?: string,\n ): void;\n set<Name extends HttpFormDataSchemaName<this['_schema']>>(\n name: Name,\n blobOrValue: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,\n fileName?: string,\n ): void {\n if (fileName === undefined) {\n super.set(name, blobOrValue as Blob);\n } else {\n super.set(name, blobOrValue as Blob, fileName);\n }\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/append MDN Reference} */\n append<Name extends HttpFormDataSchemaName<this['_schema']>>(\n name: Name,\n value: Exclude<ArrayItemIfArray<NonNullable<LooseSchema[Name]>>, Blob>,\n ): void;\n append<Name extends HttpFormDataSchemaName<this['_schema']>>(\n name: Name,\n blob: Exclude<ArrayItemIfArray<NonNullable<LooseSchema[Name]>>, string>,\n fileName?: string,\n ): void;\n append<Name extends HttpFormDataSchemaName<this['_schema']>>(\n name: Name,\n blobOrValue: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,\n fileName?: string,\n ): void {\n if (fileName === undefined) {\n super.append(name, blobOrValue as Blob);\n } else {\n super.append(name, blobOrValue as Blob, fileName);\n }\n }\n\n /**\n * Get the value of the entry associated to a key name.\n *\n * If the key might have multiple values, use {@link HttpFormData#getAll} instead.\n *\n * @param name The name of the key to get the value of.\n * @returns The value associated with the key name, or `null` if the key does not exist.\n * @see {@link https://developer.mozilla.org/docs/Web/API/FormData/get MDN Reference}\n */\n get<Name extends HttpFormDataSchemaName.NonArray<this['_schema']>>(\n name: Name,\n ): ReplaceBy<ReplaceBy<ArrayItemIfArray<this['_schema'][Name]>, undefined, null>, Blob, File> {\n return super.get(name) as never;\n }\n\n /**\n * Get all the values of the entry associated with a key name.\n *\n * If the key has at most a single value, use {@link HttpFormData#get} instead.\n *\n * @param name The name of the key to get the values of.\n * @returns An array of values associated with the key name, or an empty array if the key does not exist.\n * @see {@link https://developer.mozilla.org/docs/Web/API/FormData/getAll MDN Reference}\n */\n getAll<Name extends HttpFormDataSchemaName.Array<this['_schema']>>(\n name: Name,\n ): ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][Name]>>, Blob, File>[] {\n return super.getAll(name) as never;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/has MDN Reference} */\n has<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): boolean {\n return super.has(name);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/delete MDN Reference} */\n delete<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): void {\n super.delete(name);\n }\n\n forEach<This extends HttpFormData<this['_schema']>>(\n callback: <Key extends HttpFormDataSchemaName<this['_schema']>>(\n value: ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][Key]>>, Blob, File>,\n key: Key,\n parent: HttpFormData<this['_schema']>,\n ) => void,\n thisArg?: This,\n ): void {\n super.forEach(callback as (value: FormDataEntryValue, key: string, parent: FormData) => void, thisArg);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/keys MDN Reference} */\n keys(): FormDataIterator<HttpFormDataSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/values MDN Reference} */\n values(): FormDataIterator<\n ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>\n > {\n return super.values() as never;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/entries MDN Reference} */\n entries(): FormDataIterator<\n [\n HttpFormDataSchemaName<this['_schema']>,\n ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>,\n ]\n > {\n return super.entries() as never;\n }\n\n [Symbol.iterator](): FormDataIterator<\n [\n HttpFormDataSchemaName<this['_schema']>,\n ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>,\n ]\n > {\n return super[Symbol.iterator]() as never;\n }\n\n /**\n * Checks if the data is equal to the other data. Equality is defined as having the same keys and values, regardless\n * of the order of keys.\n *\n * @param otherData The other data to compare.\n * @returns A promise that resolves with `true` if the data is equal to the other data, or `false` otherwise.\n * Important: both form data might be read while comparing.\n */\n async equals<OtherSchema extends LooseSchema>(otherData: HttpFormData<OtherSchema>): Promise<boolean> {\n if (!(await this.contains(otherData))) {\n return false;\n }\n\n for (const key of this.keys()) {\n const otherHasKey = super.has.call(otherData, key);\n if (!otherHasKey) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Checks if the data contains the other data. This method is less strict than {@link HttpFormData#equals} and only\n * requires that all keys and values in the other data are present in this data.\n *\n * @param otherData The other data to compare.\n * @returns A promise that resolves with `true` if this data contains the other data, or `false` otherwise. Important:\n * both form data might be read while comparing.\n */\n async contains<OtherSchema extends LooseSchema>(otherData: HttpFormData<OtherSchema>): Promise<boolean> {\n for (const [otherKey, otherValue] of otherData.entries()) {\n const values = super.getAll.call(this, otherKey);\n\n const haveSameNumberOfValues = values.length === super.getAll.call(otherData, otherKey).length;\n if (!haveSameNumberOfValues) {\n return false;\n }\n\n let valueExists = false;\n\n for (const value of values) {\n if (\n value === otherValue ||\n (value instanceof Blob && (otherValue as Blob) instanceof Blob && (await fileEquals(value, otherValue)))\n ) {\n valueExists = true;\n break;\n }\n }\n\n if (!valueExists) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Converts this form data into a plain object. This method is useful for serialization and debugging purposes.\n *\n * **NOTE**: If a key has multiple values, the object will contain an array of values for that key. If the key has\n * only one value, the object will contain its value directly, without an array, regardless of how the value was\n * initialized when creating the form data.\n *\n * @example\n * const formData = new HttpFormData<{\n * title: string;\n * descriptions: string[];\n * content: Blob;\n * }>();\n *\n * formData.set('title', 'My title');\n * formData.append('descriptions', 'Description 1');\n * formData.append('descriptions', 'Description 2');\n * formData.set('content', new Blob(['content'], { type: 'text/plain' }));\n *\n * const object = formData.toObject();\n * console.log(object); // { title: 'My title', descriptions: ['Description 1', 'Description 2'], content: Blob { type: 'text/plain' } }\n *\n * @returns A plain object representation of this form data.\n */\n toObject() {\n const object = {} as this['_schema'];\n\n type SchemaValue = this['_schema'][HttpFormDataSchemaName<this['_schema']>];\n\n for (const [key, value] of this.entries()) {\n if (key in object) {\n const existingValue = object[key] as SchemaValue[];\n\n if (Array.isArray<SchemaValue>(existingValue)) {\n existingValue.push(value as SchemaValue);\n } else {\n object[key] = [existingValue, value] as SchemaValue;\n }\n } else {\n object[key] = value as SchemaValue;\n }\n }\n\n return object;\n }\n}\n\nexport default HttpFormData;\n","import { Default, ReplaceBy } from '@zimic/utils/types';\n\nimport { HttpHeadersSchema, HttpHeadersInit, HttpHeadersSchemaName, HttpHeadersSerialized } from './types';\n\nfunction pickPrimitiveProperties<LooseSchema extends HttpHeadersSchema.Loose>(schema: LooseSchema) {\n return Object.entries(schema).reduce<Record<string, string>>((accumulated, [key, value]) => {\n if (value !== undefined) {\n accumulated[key] = String(value);\n }\n return accumulated;\n }, {});\n}\n\n/**\n * An extended HTTP headers object with a strictly-typed schema. Fully compatible with the built-in\n * {@link https://developer.mozilla.org/docs/Web/API/Headers `Headers`} class.\n *\n * @example\n * import { HttpHeaders } from '@zimic/http';\n *\n * const headers = new HttpHeaders<{\n * accept?: string;\n * 'content-type'?: string;\n * }>({\n * accept: '*',\n * 'content-type': 'application/json',\n * });\n *\n * const contentType = headers.get('content-type');\n * console.log(contentType); // 'application/json'\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpheaders `HttpHeaders` API reference}\n */\nclass HttpHeaders<LooseSchema extends HttpHeadersSchema.Loose = HttpHeadersSchema.Loose> extends Headers {\n readonly _schema!: HttpHeadersSerialized<LooseSchema>;\n\n constructor(init?: HttpHeadersInit<LooseSchema>) {\n if (init instanceof Headers || Array.isArray(init) || !init) {\n super(init);\n } else {\n super(pickPrimitiveProperties(init));\n }\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/set MDN Reference} */\n set<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name, value: NonNullable<LooseSchema[Name]>): void {\n super.set(name, value);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/append MDN Reference} */\n append<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name, value: NonNullable<LooseSchema[Name]>): void {\n super.append(name, value);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/get MDN Reference} */\n get<Name extends HttpHeadersSchemaName<this['_schema']>>(\n name: Name,\n ): ReplaceBy<this['_schema'][Name], undefined, null> {\n return super.get(name) as never;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/has MDN Reference} */\n getSetCookie(): NonNullable<Default<this['_schema']['Set-Cookie'], string>>[] {\n return super.getSetCookie() as never;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/has MDN Reference} */\n has<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): boolean {\n return super.has(name);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/delete MDN Reference} */\n delete<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): void {\n super.delete(name);\n }\n\n forEach<This extends HttpHeaders<this['_schema']>>(\n callback: <Key extends HttpHeadersSchemaName<this['_schema']>>(\n value: NonNullable<this['_schema'][Key]> & string,\n key: Key,\n parent: Headers,\n ) => void,\n thisArg?: This,\n ): void {\n super.forEach(callback as (value: string, key: string, parent: Headers) => void, thisArg);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/keys MDN Reference} */\n keys(): HeadersIterator<HttpHeadersSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/values MDN Reference} */\n values(): HeadersIterator<NonNullable<this['_schema'][HttpHeadersSchemaName<this['_schema']>]> & string> {\n return super.values() as never;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/Headers/entries MDN Reference} */\n entries(): HeadersIterator<\n [\n HttpHeadersSchemaName<this['_schema']>,\n NonNullable<this['_schema'][HttpHeadersSchemaName<this['_schema']>]> & string,\n ]\n > {\n return super.entries() as never;\n }\n\n [Symbol.iterator](): HeadersIterator<\n [\n HttpHeadersSchemaName<this['_schema']>,\n NonNullable<this['_schema'][HttpHeadersSchemaName<this['_schema']>]> & string,\n ]\n > {\n return super[Symbol.iterator]() as never;\n }\n\n /**\n * Checks if this headers object is equal to another set of headers. Equality is defined as having the same keys and\n * values, regardless of the order of keys.\n *\n * @param otherHeaders The other headers object to compare against.\n * @returns `true` if the headers are equal, `false` otherwise.\n */\n equals<OtherSchema extends LooseSchema>(otherHeaders: HttpHeaders<OtherSchema>): boolean {\n if (!this.contains(otherHeaders)) {\n return false;\n }\n\n for (const key of this.keys()) {\n const otherHasKey = super.has.call(otherHeaders, key);\n if (!otherHasKey) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Checks if this headers object contains another set of headers. This method is less strict than\n * {@link HttpHeaders#equals} and only requires that all keys and values in the other headers are present in these\n * headers.\n *\n * @param otherHeaders The other headers object to compare against.\n * @returns `true` if these headers contain the other headers, `false` otherwise.\n */\n contains<OtherSchema extends LooseSchema>(otherHeaders: HttpHeaders<OtherSchema>): boolean {\n for (const [key, otherValue] of otherHeaders.entries()) {\n const value = super.get.call(this, key);\n\n if (value === null) {\n return false;\n }\n\n const valueItems = this.splitHeaderValues(value);\n const otherValueItems = this.splitHeaderValues(otherValue);\n\n const haveSameNumberOfValues = valueItems.length === otherValueItems.length;\n if (!haveSameNumberOfValues) {\n return false;\n }\n\n for (const otherValueItem of otherValueItems) {\n if (!valueItems.includes(otherValueItem)) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n /**\n * Converts these headers into a plain object. This method is useful for serialization and debugging purposes.\n *\n * @example\n * const headers = new HttpHeaders({\n * accept: 'application/json',\n * 'content-type': 'application/json',\n * });\n * const object = headers.toObject();\n * console.log(object); // { accept: 'application/json', 'content-type': 'application/json' }\n *\n * @returns A plain object representation of these headers.\n */\n toObject(): this['_schema'] {\n const object = {} as this['_schema'];\n\n for (const [key, value] of this.entries()) {\n object[key] = value;\n }\n\n return object;\n }\n\n private splitHeaderValues(value: string) {\n return value\n .split(',')\n .map((item) => item.trim())\n .filter((item) => item.length > 0);\n }\n}\n\nexport default HttpHeaders;\n","import { ReplaceBy, ArrayItemIfArray } from '@zimic/utils/types';\n\nimport {\n HttpSearchParamsSchema,\n HttpSearchParamsInit,\n HttpSearchParamsSchemaName,\n HttpSearchParamsSerialized,\n} from './types';\n\nfunction pickPrimitiveProperties<Schema extends HttpSearchParamsSchema.Loose>(schema: Schema) {\n const schemaWithPrimitiveProperties = Object.entries(schema).reduce<Record<string, string>>(\n (accumulated, [key, value]) => {\n if (value !== undefined && !Array.isArray(value)) {\n accumulated[key] = String(value);\n }\n return accumulated;\n },\n {},\n );\n return schemaWithPrimitiveProperties;\n}\n\n/**\n * An extended HTTP search params object with a strictly-typed schema. Fully compatible with the built-in\n * {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams `URLSearchParams`} class.\n *\n * @example\n * import { HttpSearchParams } from '@zimic/http';\n *\n * const searchParams = new HttpSearchParams<{\n * names?: string[];\n * page?: `${number}`;\n * }>({\n * names: ['user 1', 'user 2'],\n * page: '1',\n * });\n *\n * const names = searchParams.getAll('names');\n * console.log(names); // ['user 1', 'user 2']\n *\n * const page = searchParams.get('page');\n * console.log(page); // '1'\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpsearchparams `HttpSearchParams` API reference}\n */\nclass HttpSearchParams<\n LooseSchema extends HttpSearchParamsSchema.Loose = HttpSearchParamsSchema.Loose,\n> extends URLSearchParams {\n readonly _schema!: HttpSearchParamsSerialized<LooseSchema>;\n\n constructor(init?: HttpSearchParamsInit<LooseSchema>) {\n if (init instanceof URLSearchParams || Array.isArray(init) || typeof init === 'string' || !init) {\n super(init);\n } else {\n super(pickPrimitiveProperties(init));\n this.populateInitArrayProperties(init);\n }\n }\n\n private populateInitArrayProperties(init: LooseSchema) {\n for (const [key, value] of Object.entries(init)) {\n if (Array.isArray(value)) {\n for (const item of value as unknown[]) {\n super.append(key, String(item));\n }\n }\n }\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/set MDN Reference} */\n set<Name extends HttpSearchParamsSchemaName<this['_schema']>>(\n name: Name,\n value: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,\n ): void {\n super.set(name, value);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/append MDN Reference} */\n append<Name extends HttpSearchParamsSchemaName<this['_schema']>>(\n name: Name,\n value: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,\n ): void {\n super.append(name, value);\n }\n\n /**\n * Get the value of the entry associated to a key name.\n *\n * If the key might have multiple values, use {@link HttpSearchParams#getAll} instead.\n *\n * @param name The name of the key to get the value of.\n * @returns The value associated with the key name, or `null` if the key does not exist.\n * @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/get MDN Reference}\n */\n get<Name extends HttpSearchParamsSchemaName.NonArray<this['_schema']>>(\n name: Name,\n ): ReplaceBy<ArrayItemIfArray<this['_schema'][Name]>, undefined, null> {\n return super.get(name) as never;\n }\n\n /**\n * Get all the values of the entry associated with a key name.\n *\n * If the key has at most one value, use {@link HttpSearchParams#get} instead.\n *\n * @param name The name of the key to get the values of.\n * @returns An array of values associated with the key name, or an empty array if the key does not exist.\n * @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll MDN Reference}\n */\n getAll<Name extends HttpSearchParamsSchemaName.Array<this['_schema']>>(\n name: Name,\n ): ArrayItemIfArray<NonNullable<this['_schema'][Name]>>[] {\n return super.getAll(name) as never;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/has MDN Reference} */\n has<Name extends HttpSearchParamsSchemaName<this['_schema']>>(\n name: Name,\n value?: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,\n ): boolean {\n return super.has(name, value);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete MDN Reference} */\n delete<Name extends HttpSearchParamsSchemaName<this['_schema']>>(\n name: Name,\n value?: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,\n ): void {\n super.delete(name, value);\n }\n\n forEach<This extends HttpSearchParams<this['_schema']>>(\n callback: <Key extends HttpSearchParamsSchemaName<this['_schema']>>(\n value: ArrayItemIfArray<NonNullable<this['_schema'][Key]>>,\n key: Key,\n parent: HttpSearchParams<this['_schema']>,\n ) => void,\n thisArg?: This,\n ): void {\n super.forEach(callback as (value: string, key: string, parent: URLSearchParams) => void, thisArg);\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/keys MDN Reference} */\n keys(): URLSearchParamsIterator<HttpSearchParamsSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/values MDN Reference} */\n values(): URLSearchParamsIterator<\n ArrayItemIfArray<NonNullable<this['_schema'][HttpSearchParamsSchemaName<this['_schema']>]>>\n > {\n return super.values() as never;\n }\n\n /** @see {@link https://developer.mozilla.org/docs/Web/API/URLSearchParams/entries MDN Reference} */\n entries(): URLSearchParamsIterator<\n [\n HttpSearchParamsSchemaName<this['_schema']>,\n ArrayItemIfArray<NonNullable<this['_schema'][HttpSearchParamsSchemaName<this['_schema']>]>>,\n ]\n > {\n return super.entries() as never;\n }\n\n [Symbol.iterator](): URLSearchParamsIterator<\n [\n HttpSearchParamsSchemaName<this['_schema']>,\n ArrayItemIfArray<NonNullable<this['_schema'][HttpSearchParamsSchemaName<this['_schema']>]>>,\n ]\n > {\n return super[Symbol.iterator]() as never;\n }\n\n /**\n * Checks if these search params are equal to another set of search parameters. Equality is defined as having the same\n * keys and values, regardless of the order of the keys.\n *\n * @param otherParams The other search parameters to compare against.\n * @returns `true` if the search parameters are equal, `false` otherwise.\n */\n equals<OtherSchema extends LooseSchema>(otherParams: HttpSearchParams<OtherSchema>): boolean {\n return this.contains(otherParams) && this.size === otherParams.size;\n }\n\n /**\n * Checks if these search params contain another set of search parameters. This method is less strict than\n * {@link HttpSearchParams#equals} and only requires that all keys and values in the other search parameters are\n * present in these search parameters.\n *\n * @param otherParams The other search parameters to check for containment.\n * @returns `true` if these search parameters contain the other search parameters, `false` otherwise.\n */\n contains<OtherSchema extends LooseSchema>(otherParams: HttpSearchParams<OtherSchema>): boolean {\n for (const [key, otherValue] of otherParams.entries()) {\n const values = super.getAll.call(this, key);\n\n const haveSameNumberOfValues = values.length === super.getAll.call(otherParams, key).length;\n if (!haveSameNumberOfValues) {\n return false;\n }\n\n const valueExists = values.includes(otherValue);\n if (!valueExists) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Converts these search params into a plain object. This method is useful for serialization and debugging purposes.\n *\n * **NOTE**: If a key has multiple values, the object will contain an array of values for that key. If the key has\n * only one value, the object will contain its value directly, without an array, regardless of how the value was\n * initialized when creating the search params object.\n *\n * @example\n * const searchParams = new HttpSearchParams({\n * names: ['user 1', 'user 2'],\n * name: ['user 3'],\n * page: '1',\n * });\n * const object = searchParams.toObject();\n * console.log(object); // { names: ['user 1', 'user 2'], name: 'user 3', page: '1' }\n *\n * @returns A plain object representation of these search params.\n */\n toObject() {\n const object = {} as this['_schema'];\n\n type SchemaValue = this['_schema'][HttpSearchParamsSchemaName<this['_schema']>];\n\n for (const [key, value] of this.entries()) {\n if (key in object) {\n const existingValue = object[key] as SchemaValue[];\n\n if (Array.isArray<SchemaValue>(existingValue)) {\n existingValue.push(value as SchemaValue);\n } else {\n object[key] = [existingValue, value] as SchemaValue;\n }\n } else {\n object[key] = value as SchemaValue;\n }\n }\n\n return object;\n }\n}\n\nexport default HttpSearchParams;\n","import {\n IfAny,\n UnionToIntersection,\n UnionHasMoreThanOneType,\n Prettify,\n NonEmptyArray,\n Branded,\n} from '@zimic/utils/types';\n\nimport { HttpFormDataSchema } from '../formData/types';\nimport { HttpHeadersSchema } from '../headers/types';\nimport { HttpPathParamsSchema } from '../pathParams/types';\nimport { HttpSearchParamsSchema } from '../searchParams/types';\nimport { HttpBody } from './requests';\n\nexport const HTTP_METHODS = Object.freeze(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'] as const);\n/**\n * A type representing the currently supported\n * {@link https://developer.mozilla.org/docs/Web/HTTP/Methods `HTTP methods`}.\n */\nexport type HttpMethod = (typeof HTTP_METHODS)[number];\n\n/**\n * A schema representing the structure of an HTTP request.\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport interface HttpRequestSchema {\n headers?: HttpHeadersSchema.Loose;\n searchParams?: HttpSearchParamsSchema.Loose;\n body?: HttpBody.Loose;\n}\n\n/**\n * A schema representing the structure of an HTTP response.\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport interface HttpResponseSchema {\n headers?: HttpHeadersSchema.Loose;\n body?: HttpBody.Loose;\n}\n\n/**\n * The status codes used in HTTP responses, as defined by\n * {@link https://httpwg.org/specs/rfc9110.html#overview.of.status.codes RFC-9110}.\n *\n * - `HttpStatusCode.Information`: {@link https://developer.mozilla.org/docs/Web/HTTP/Status#information_responses `1XX`}\n * - `HttpStatusCode.Success`: {@link https://developer.mozilla.org/docs/Web/HTTP/Status#successful_responses `2XX`}\n * - `HttpStatusCode.Redirection`: {@link https://developer.mozilla.org/docs/Web/HTTP/Status#redirection_messages `3XX`}\n * - `HttpStatusCode.ClientError`: {@link https://developer.mozilla.org/docs/Web/HTTP/Status#client_error_responses `4XX`}\n * - `HttpStatusCode.ServerError`: {@link https://developer.mozilla.org/docs/Web/HTTP/Status#server_error_responses `5XX`}\n */\nexport type HttpStatusCode =\n | HttpStatusCode.Information\n | HttpStatusCode.Success\n | HttpStatusCode.Redirection\n | HttpStatusCode.ClientError\n | HttpStatusCode.ServerError;\n\nexport namespace HttpStatusCode {\n /**\n * An HTTP status code in the `1XX` range, representing an informational response.\n *\n * @see {@link https://developer.mozilla.org/docs/Web/HTTP/Status#information_responses `1XX`}\n */\n export type Information =\n | 100 // Continue\n | 101 // Switching Protocols\n | 102 // Processing\n | 103; // Early Hints\n\n /**\n * An HTTP status code in the `2XX` range, representing a successful response.\n *\n * @see {@link https://developer.mozilla.org/docs/Web/HTTP/Status#successful_responses `2XX`}\n */\n export type Success =\n | 200 // OK\n | 201 // Created\n | 202 // Accepted\n | 203 // Non-Authoritative Information\n | 204 // No Content\n | 205 // Reset Content\n | 206 // Partial Content\n | 207 // Multi-Status\n | 208 // Already Reported\n | 226; // IM Used\n\n /**\n * An HTTP status code in the `3XX` range, representing a redirection response.\n *\n * @see {@link https://developer.mozilla.org/docs/Web/HTTP/Status#redirection_messages `3XX`}\n */\n export type Redirection =\n | 300 // Multiple Choices\n | 301 // Moved Permanently\n | 302 // Found\n | 303 // See Other\n | 304 // Not Modified\n | 307 // Temporary Redirect\n | 308; // Permanent Redirect\n\n /**\n * An HTTP status code in the `4XX` range, representing a client error response.\n *\n * @see {@link https://developer.mozilla.org/docs/Web/HTTP/Status#client_error_responses `4XX`}\n */\n export type ClientError =\n | 400 // Bad Request\n | 401 // Unauthorized\n | 402 // Payment Required\n | 403 // Forbidden\n | 404 // Not Found\n | 405 // Method Not Allowed\n | 406 // Not Acceptable\n | 407 // Proxy Authentication Required\n | 408 // Request Timeout\n | 409 // Conflict\n | 410 // Gone\n | 411 // Length Required\n | 412 // Precondition Failed\n | 413 // Content Too Large\n | 414 // URI Too Long\n | 415 // Unsupported Media Type\n | 416 // Range Not Satisfiable\n | 417 // Expectation Failed\n | 418 // I'm a teapot\n | 421 // Misdirected Request\n | 422 // Unprocessable Content\n | 423 // Locked\n | 424 // Failed Dependency\n | 425 // Too Early\n | 426 // Upgrade Required\n | 428 // Precondition Required\n | 429 // Too Many Requests\n | 431 // Request Header Fields Too Large\n | 451; // Unavailable For Legal Reasons\n\n /**\n * An HTTP status code in the `5XX` range, representing a server error response.\n *\n * @see {@link https://developer.mozilla.org/docs/Web/HTTP/Status#server_error_responses `5XX`}\n */\n export type ServerError =\n | 500 // Internal Server Error\n | 501 // Not Implemented\n | 502 // Bad Gateway\n | 503 // Service Unavailable\n | 504 // Gateway Timeout\n | 505 // HTTP Version Not Supported\n | 506 // Variant Also Negotiates\n | 507 // Insufficient Storage\n | 508 // Loop Detected\n | 510 // Not Extended\n | 511; // Network Authentication Required\n}\n\n/**\n * A schema representing the structure of HTTP responses by status code.\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport type HttpResponseSchemaByStatusCode = {\n [StatusCode in HttpStatusCode]?: HttpResponseSchema;\n};\n\n/**\n * Extracts the status codes used in a response schema by status code.\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport type HttpResponseSchemaStatusCode<ResponseSchemaByStatusCode extends HttpResponseSchemaByStatusCode> =\n keyof ResponseSchemaByStatusCode & HttpStatusCode;\n\n/**\n * A schema representing the structure of an HTTP request and response for a given method.\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport interface HttpMethodSchema {\n request?: HttpRequestSchema;\n response?: HttpResponseSchemaByStatusCode;\n}\n\n/**\n * A schema representing the structure of HTTP request and response by method.\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport interface HttpMethodsSchema {\n GET?: HttpMethodSchema;\n POST?: HttpMethodSchema;\n PUT?: HttpMethodSchema;\n PATCH?: HttpMethodSchema;\n DELETE?: HttpMethodSchema;\n HEAD?: HttpMethodSchema;\n OPTIONS?: HttpMethodSchema;\n}\n\ninterface BaseHttpSchema {\n [path: string]: HttpMethodsSchema;\n}\n\n/**\n * Declares an HTTP service schema.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * interface UserListHeaders {\n * accept: string;\n * }\n *\n * interface UserListSearchParams {\n * name?: string;\n * limit?: number;\n * }\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * request: {\n * headers: UserListHeaders;\n * searchParams: UserListSearchParams;\n * };\n * response: {\n * 200: {\n * // Inline headers declaration\n * headers: { 'content-type': string };\n * body: User[];\n * };\n * };\n * };\n * };\n * }>;\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport type HttpSchema<Schema extends BaseHttpSchema = BaseHttpSchema> = Branded<Schema, 'HttpSchema'>;\n\nexport namespace HttpSchema {\n /**\n * Declares an HTTP service methods schema.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserMethods = HttpSchema.Methods<{\n * GET: {\n * response: {\n * 200: { body: User[] };\n * };\n * };\n * }>;\n *\n * type Schema = HttpSchema<{\n * '/users': UserMethods;\n * }>;\n */\n export type Methods<Schema extends HttpMethodsSchema> = Schema;\n\n /**\n * Declares an HTTP service method schema.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserListMethod = HttpSchema.Method<{\n * response: {\n * 200: { body: User[] };\n * };\n * }>;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: UserListMethod;\n * };\n * }>;\n */\n export type Method<Schema extends HttpMethodSchema> = Schema;\n\n /**\n * Declares an HTTP service request schema.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserCreationRequest = HttpSchema.Request<{\n * headers: { 'content-type': 'application/json' };\n * body: User;\n * }>;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * POST: {\n * request: UserCreationRequest;\n * response: {\n * 201: { body: User };\n * };\n * };\n * };\n * }>;\n */\n export type Request<Schema extends HttpRequestSchema> = Schema;\n\n /**\n * Declares an HTTP service response schema by status code.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserListResponseByStatusCode = HttpSchema.ResponseByStatusCode<{\n * 200: { body: User[] };\n * 400: { body: { message: string } };\n * }>;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * response: UserListResponseByStatusCode;\n * };\n * };\n * }>;\n */\n export type ResponseByStatusCode<Schema extends HttpResponseSchemaByStatusCode> = Schema;\n\n /**\n * Declares an HTTP service response schema.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserListSuccessResponse = HttpSchema.Response<{\n * body: User[];\n * }>;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * response: {\n * 200: UserListSuccessResponse;\n * };\n * };\n * };\n * }>;\n */\n export type Response<Schema extends HttpResponseSchema> = Schema;\n\n /**\n * Declares an HTTP body schema.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserListSuccessResponseBody = HttpSchema.Body<User[]>;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * response: {\n * 200: { body: UserListSuccessResponseBody };\n * };\n * };\n * };\n * }>;\n */\n export type Body<Schema extends HttpBody.Loose> = Schema;\n\n /**\n * Declares an HTTP headers schema.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserListHeaders = HttpSchema.Headers<{\n * accept: 'application/json';\n * }>;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * request: {\n * headers: UserListHeaders;\n * };\n * response: {\n * 200: { body: User[] };\n * };\n * };\n * };\n * }>;\n */\n export type Headers<Schema extends HttpHeadersSchema.Loose> = Schema;\n\n /**\n * Declares an HTTP search params schema.\n *\n * @example\n * import { type HttpSchema } from '@zimic/http';\n *\n * type UserListSearchParams = HttpSchema.SearchParams<{\n * limit: `${number}`;\n * offset: `${number}`;\n * }>;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * request: {\n * searchParams: UserListSearchParams;\n * };\n * response: {\n * 200: { body: User[] };\n * };\n * };\n * };\n * }>;\n */\n export type SearchParams<Schema extends HttpSearchParamsSchema.Loose> = Schema;\n\n /**\n * Declares an HTTP path params schema.\n *\n * @example\n * import { type HttpSchema, InferPathParams } from '@zimic/http';\n *\n * type Schema = HttpSchema<{\n * '/users/:userId': {\n * GET: {\n * response: {\n * 200: { body: User };\n * };\n * };\n * };\n * }>;\n *\n * type UserByIdPathParams = HttpSchema.PathParams<{\n * userId: string;\n * }>;\n *\n * // Or infer from the path string\n * type UserByIdPathParams = InferPathParams<Schema, '/users/:userId'>;\n */\n export type PathParams<Schema extends HttpPathParamsSchema.Loose> = Schema;\n\n /**\n * Declares an HTTP form data schema.\n *\n * @example\n * import { HttpFormData, type HttpSchema } from '@zimic/http';\n *\n * type UserCreationFormData = HttpFormData<\n * HttpSchema.FormData<{\n * name: string;\n * email: string;\n * }>\n * >;\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * POST: {\n * request: {\n * body: UserCreationFormData;\n * };\n * response: {\n * 201: { body: User };\n * };\n * };\n * };\n * }>;\n */\n export type FormData<Schema extends HttpFormDataSchema.Loose> = Schema;\n}\n\n/**\n * Extracts the methods from an HTTP service schema.\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport type HttpSchemaMethod<Schema extends HttpSchema> = IfAny<\n Schema,\n any, // eslint-disable-line @typescript-eslint/no-explicit-any\n keyof UnionToIntersection<Schema[keyof Schema]> & HttpMethod\n>;\n\nexport type AllowAnyStringInPathParams<Path extends string> = Path extends `${infer Prefix}:${string}/${infer Suffix}`\n ? `${Prefix}${string}/${AllowAnyStringInPathParams<Suffix>}`\n : Path extends `${infer Prefix}:${string}`\n ? `${Prefix}${string}`\n : Path;\n\n/**\n * Extracts the paths from an HTTP service schema. Optionally receives a second argument with one or more methods to\n * filter the paths with. Only the methods defined in the schema are allowed.\n *\n * @example\n * import { type HttpSchema, type HttpSchemaPath } from '@zimic/http';\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * response: { 200: { body: User[] } };\n * };\n * };\n * '/users/:userId': {\n * DELETE: {\n * response: { 200: { body: User } };\n * };\n * };\n * }>;\n *\n * type Path = HttpSchemaPath<Schema>;\n * // \"/users\" | \"/users/:userId\" | \"/users/${string}\"\n *\n * type GetPath = HttpSchemaPath<Schema, 'GET'>;\n * // \"/users\"\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\nexport namespace HttpSchemaPath {\n type LooseLiteral<Schema extends HttpSchema, Method extends HttpMethod = HttpMethod> = {\n [Path in keyof Schema & string]: Method extends keyof Schema[Path] ? Path : never;\n }[keyof Schema & string];\n\n /**\n * Extracts the literal paths from an HTTP service schema. Optionally receives a second argument with one or more\n * methods to filter the paths with. Only the methods defined in the schema are allowed.\n *\n * @example\n * import { type HttpSchema, type HttpSchemaPath } from '@zimic/http';\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * response: { 200: { body: User[] } };\n * };\n * };\n * '/users/:userId': {\n * DELETE: {\n * response: { 200: { body: User } };\n * };\n * };\n * }>;\n *\n * type LiteralPath = HttpSchemaPath.Literal<Schema>;\n * // \"/users\" | \"/users/:userId\"\n *\n * type LiteralGetPath = HttpSchemaPath.Literal<Schema, 'GET'>;\n * // \"/users\"\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\n export type Literal<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>,\n > = LooseLiteral<Schema, Method>;\n\n /**\n * Extracts the non-literal paths from an HTTP service schema. Optionally receives a second argument with one or more\n * methods to filter the paths with. Only the methods defined in the schema are allowed.\n *\n * @example\n * import { type HttpSchema, type HttpSchemaPath } from '@zimic/http';\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: {\n * response: { 200: { body: User[] } };\n * };\n * };\n * '/users/:userId': {\n * DELETE: {\n * response: { 200: { body: User } };\n * };\n * };\n * }>;\n *\n * type NonLiteralPath = HttpSchemaPath.NonLiteral<Schema>;\n * // \"/users\" | \"/users/${string}\"\n *\n * type NonLiteralGetPath = HttpSchemaPath.NonLiteral<Schema, 'GET'>;\n * // \"/users\"\n *\n * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas Declaring HTTP interceptor schemas}\n */\n export type NonLiteral<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>,\n > = AllowAnyStringInPathParams<Literal<Schema, Method>>;\n}\n\nexport type HttpSchemaPath<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>,\n> = HttpSchemaPath.Literal<Schema, Method> | HttpSchemaPath.NonLiteral<Schema, Method>;\n\ntype LargestPathPrefix<Path extends string> = Path extends `${infer Prefix}/${infer Suffix}`\n ? `${Prefix}/${Suffix extends `${string}/${string}` ? LargestPathPrefix<Suffix> : ''}`\n : Path;\n\ntype ExcludeNonLiteralPathsSupersededByLiteralPath<Path extends string> =\n Path extends `${LargestPathPrefix<Path>}:${string}` ? never : Path;\n\nexport type PreferMostStaticLiteralPath<Path extends string> =\n UnionHasMoreThanOneType<Path> extends true ? ExcludeNonLiteralPathsSupersededByLiteralPath<Path> : Path;\n\ntype RecursiveInferHttpSchemaPath<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n NonLiteralPath extends string,\n LiteralPath extends HttpSchemaPath.Literal<Schema, Method>,\n> =\n NonLiteralPath extends AllowAnyStringInPathParams<LiteralPath>\n ? NonLiteralPath extends `${AllowAnyStringInPathParams<LiteralPath>}/${string}`\n ? never\n : LiteralPath\n : never;\n\nexport type LiteralHttpSchemaPathFromNonLiteral<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n NonLiteralPath extends string,\n LiteralPath extends HttpSchemaPath.Literal<Schema, Method> = HttpSchemaPath.Literal<Schema, Method>,\n> = PreferMostStaticLiteralPath<\n LiteralPath extends LiteralPath ? RecursiveInferHttpSchemaPath<Schema, Method, NonLiteralPath, LiteralPath> : never\n>;\n\ntype RecursiveInferPathParams<Path extends string> = Path extends `${infer _Prefix}:${infer ParamName}/${infer Suffix}`\n ? { [Name in ParamName]: string } & RecursiveInferPathParams<Suffix>\n : Path extends `${infer _Prefix}:${infer ParamName}`\n ? { [Name in ParamName]: string }\n : {};\n\n/**\n * Infers the path parameters schema from a path string, optionally validating it against an {@link HttpSchema}.\n *\n * If the first argument is a {@link HttpSchema} (recommended), the second argument is checked to be a valid path in that\n * schema.\n *\n * @example\n * import { HttpSchema, InferPathParams } from '@zimic/http';\n *\n * type Schema = HttpSchema<{\n * '/users/:userId': {\n * GET: {\n * response: { 200: { body: User } };\n * };\n * };\n * }>;\n *\n * // Using a schema to validate the path (recommended):\n * type PathParams = InferPathParams<Schema, '/users/:userId'>;\n * // { userId: string }\n *\n * @example\n * import { InferPathParams } from '@zimic/http';\n *\n * // Without using a schema to validate the path (works as `PathParamsSchemaFromPath`):\n * type PathParams = InferPathParams<'/users/:userId'>;\n * // { userId: string }\n */\nexport type InferPathParams<\n PathOrSchema extends string | HttpSchema,\n OptionalPath extends PathOrSchema extends HttpSchema ? HttpSchemaPath.Literal<PathOrSchema> : never = never,\n> = Prettify<\n RecursiveInferPathParams<\n PathOrSchema extends HttpSchema ? OptionalPath : PathOrSchema extends string ? PathOrSchema : never\n >\n>;\n\ntype OmitPastHttpStatusCodes<\n Schema extends HttpResponseSchemaByStatusCode,\n PastSchemas extends HttpResponseSchemaByStatusCode[],\n> =\n PastSchemas extends NonEmptyArray<HttpResponseSchemaByStatusCode>\n ? Omit<Schema, keyof UnionToIntersection<PastSchemas[number]>>\n : Schema;\n\n/**\n * Merges multiple HTTP response schemas by status code into a single schema. When there are duplicate status codes, the\n * first declaration takes precedence.\n *\n * @example\n * import { type HttpSchema, type HttpStatusCode, MergeHttpResponsesByStatusCode } from '@zimic/http';\n *\n * // Overriding the 400 status code with a more specific schema\n * // and using a generic schema for all other client errors.\n * type MergedResponseByStatusCode = MergeHttpResponsesByStatusCode<\n * [\n * {\n * 400: { body: { message: string; issues: string[] } };\n * },\n * {\n * [StatusCode in HttpStatusCode.ClientError]: { body: { message: string } };\n * },\n * ]\n * >;\n * // {\n * // 400: { body: { message: string; issues: string[] } };\n * // 401: { body: { message: string}; };\n * // 402: { body: { message: string}; };\n * // 403: { body: { message: string}; };\n * // ...\n * // }\n *\n * type Schema = HttpSchema<{\n * '/users': {\n * GET: { response: MergedResponseByStatusCode };\n * };\n * }>;\n */\nexport type MergeHttpResponsesByStatusCode<\n Schemas extends HttpResponseSchemaByStatusCode[],\n PastSchemas extends HttpResponseSchemaByStatusCode[] = [],\n> = Schemas extends [\n infer FirstSchema extends HttpResponseSchemaByStatusCode,\n ...infer RestSchemas extends HttpResponseSchemaByStatusCode[],\n]\n ? RestSchemas extends NonEmptyArray<HttpResponseSchemaByStatusCode>\n ? OmitPastHttpStatusCodes<FirstSchema, PastSchemas> &\n MergeHttpResponsesByStatusCode<RestSchemas, [...PastSchemas, FirstSchema]>\n : OmitPastHttpStatusCodes<FirstSchema, PastSchemas>\n : never;\n"]}
|
package/dist/typegen.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkLOHINQWU_js = require('./chunk-LOHINQWU.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "generateTypesFromOpenAPI", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkLOHINQWU_js.generate_default; }
|
|
10
10
|
});
|
|
11
11
|
//# sourceMappingURL=typegen.js.map
|
|
12
12
|
//# sourceMappingURL=typegen.js.map
|
package/dist/typegen.mjs
CHANGED
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"api",
|
|
13
13
|
"static"
|
|
14
14
|
],
|
|
15
|
-
"version": "0.4.0-canary.
|
|
15
|
+
"version": "0.4.0-canary.2",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
18
|
"url": "https://github.com/zimicjs/zimic.git",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"vitest": "^3.1.2",
|
|
89
89
|
"@zimic/eslint-config-node": "0.0.0",
|
|
90
90
|
"@zimic/lint-staged-config": "0.0.0",
|
|
91
|
-
"@zimic/interceptor": "0.
|
|
91
|
+
"@zimic/interceptor": "0.18.0-canary.1",
|
|
92
92
|
"@zimic/tsconfig": "0.0.0",
|
|
93
93
|
"@zimic/utils": "0.0.0"
|
|
94
94
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fileEquals from '@zimic/utils/data/fileEquals';
|
|
2
2
|
import { ArrayItemIfArray, ReplaceBy } from '@zimic/utils/types';
|
|
3
3
|
|
|
4
|
-
import { HttpFormDataSchema, HttpFormDataSchemaName } from './types';
|
|
4
|
+
import { HttpFormDataSchema, HttpFormDataSchemaName, HttpFormDataSerialized } from './types';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* An extended HTTP form data object with a strictly-typed schema. Fully compatible with the built-in
|
|
@@ -29,20 +29,22 @@ import { HttpFormDataSchema, HttpFormDataSchemaName } from './types';
|
|
|
29
29
|
*
|
|
30
30
|
* @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpformdata `HttpFormData` API reference}
|
|
31
31
|
*/
|
|
32
|
-
class HttpFormData<
|
|
32
|
+
class HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFormDataSchema.Loose> extends FormData {
|
|
33
|
+
readonly _schema!: HttpFormDataSerialized<LooseSchema>;
|
|
34
|
+
|
|
33
35
|
/** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/set MDN Reference} */
|
|
34
|
-
set<Name extends HttpFormDataSchemaName<
|
|
36
|
+
set<Name extends HttpFormDataSchemaName<this['_schema']>>(
|
|
35
37
|
name: Name,
|
|
36
|
-
value: Exclude<ArrayItemIfArray<NonNullable<
|
|
38
|
+
value: Exclude<ArrayItemIfArray<NonNullable<LooseSchema[Name]>>, Blob>,
|
|
37
39
|
): void;
|
|
38
|
-
set<Name extends HttpFormDataSchemaName<
|
|
40
|
+
set<Name extends HttpFormDataSchemaName<this['_schema']>>(
|
|
39
41
|
name: Name,
|
|
40
|
-
blob: Exclude<ArrayItemIfArray<NonNullable<
|
|
42
|
+
blob: Exclude<ArrayItemIfArray<NonNullable<LooseSchema[Name]>>, string>,
|
|
41
43
|
fileName?: string,
|
|
42
44
|
): void;
|
|
43
|
-
set<Name extends HttpFormDataSchemaName<
|
|
45
|
+
set<Name extends HttpFormDataSchemaName<this['_schema']>>(
|
|
44
46
|
name: Name,
|
|
45
|
-
blobOrValue: ArrayItemIfArray<NonNullable<
|
|
47
|
+
blobOrValue: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,
|
|
46
48
|
fileName?: string,
|
|
47
49
|
): void {
|
|
48
50
|
if (fileName === undefined) {
|
|
@@ -53,18 +55,18 @@ class HttpFormData<Schema extends HttpFormDataSchema = HttpFormDataSchema> exten
|
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
/** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/append MDN Reference} */
|
|
56
|
-
append<Name extends HttpFormDataSchemaName<
|
|
58
|
+
append<Name extends HttpFormDataSchemaName<this['_schema']>>(
|
|
57
59
|
name: Name,
|
|
58
|
-
value: Exclude<ArrayItemIfArray<NonNullable<
|
|
60
|
+
value: Exclude<ArrayItemIfArray<NonNullable<LooseSchema[Name]>>, Blob>,
|
|
59
61
|
): void;
|
|
60
|
-
append<Name extends HttpFormDataSchemaName<
|
|
62
|
+
append<Name extends HttpFormDataSchemaName<this['_schema']>>(
|
|
61
63
|
name: Name,
|
|
62
|
-
blob: Exclude<ArrayItemIfArray<NonNullable<
|
|
64
|
+
blob: Exclude<ArrayItemIfArray<NonNullable<LooseSchema[Name]>>, string>,
|
|
63
65
|
fileName?: string,
|
|
64
66
|
): void;
|
|
65
|
-
append<Name extends HttpFormDataSchemaName<
|
|
67
|
+
append<Name extends HttpFormDataSchemaName<this['_schema']>>(
|
|
66
68
|
name: Name,
|
|
67
|
-
blobOrValue: ArrayItemIfArray<NonNullable<
|
|
69
|
+
blobOrValue: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>,
|
|
68
70
|
fileName?: string,
|
|
69
71
|
): void {
|
|
70
72
|
if (fileName === undefined) {
|
|
@@ -83,10 +85,10 @@ class HttpFormData<Schema extends HttpFormDataSchema = HttpFormDataSchema> exten
|
|
|
83
85
|
* @returns The value associated with the key name, or `null` if the key does not exist.
|
|
84
86
|
* @see {@link https://developer.mozilla.org/docs/Web/API/FormData/get MDN Reference}
|
|
85
87
|
*/
|
|
86
|
-
get<Name extends HttpFormDataSchemaName.NonArray<
|
|
88
|
+
get<Name extends HttpFormDataSchemaName.NonArray<this['_schema']>>(
|
|
87
89
|
name: Name,
|
|
88
|
-
): ReplaceBy<ReplaceBy<ArrayItemIfArray<
|
|
89
|
-
return super.get(name) as
|
|
90
|
+
): ReplaceBy<ReplaceBy<ArrayItemIfArray<this['_schema'][Name]>, undefined, null>, Blob, File> {
|
|
91
|
+
return super.get(name) as never;
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
/**
|
|
@@ -98,27 +100,27 @@ class HttpFormData<Schema extends HttpFormDataSchema = HttpFormDataSchema> exten
|
|
|
98
100
|
* @returns An array of values associated with the key name, or an empty array if the key does not exist.
|
|
99
101
|
* @see {@link https://developer.mozilla.org/docs/Web/API/FormData/getAll MDN Reference}
|
|
100
102
|
*/
|
|
101
|
-
getAll<Name extends HttpFormDataSchemaName.Array<
|
|
103
|
+
getAll<Name extends HttpFormDataSchemaName.Array<this['_schema']>>(
|
|
102
104
|
name: Name,
|
|
103
|
-
): ReplaceBy<ArrayItemIfArray<NonNullable<
|
|
104
|
-
return super.getAll(name) as
|
|
105
|
+
): ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][Name]>>, Blob, File>[] {
|
|
106
|
+
return super.getAll(name) as never;
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
/** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/has MDN Reference} */
|
|
108
|
-
has<Name extends HttpFormDataSchemaName<
|
|
110
|
+
has<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): boolean {
|
|
109
111
|
return super.has(name);
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
/** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/delete MDN Reference} */
|
|
113
|
-
delete<Name extends HttpFormDataSchemaName<
|
|
115
|
+
delete<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): void {
|
|
114
116
|
super.delete(name);
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
forEach<This extends HttpFormData<
|
|
118
|
-
callback: <Key extends HttpFormDataSchemaName<
|
|
119
|
-
value: ReplaceBy<ArrayItemIfArray<NonNullable<
|
|
119
|
+
forEach<This extends HttpFormData<this['_schema']>>(
|
|
120
|
+
callback: <Key extends HttpFormDataSchemaName<this['_schema']>>(
|
|
121
|
+
value: ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][Key]>>, Blob, File>,
|
|
120
122
|
key: Key,
|
|
121
|
-
parent: HttpFormData<
|
|
123
|
+
parent: HttpFormData<this['_schema']>,
|
|
122
124
|
) => void,
|
|
123
125
|
thisArg?: This,
|
|
124
126
|
): void {
|
|
@@ -126,46 +128,34 @@ class HttpFormData<Schema extends HttpFormDataSchema = HttpFormDataSchema> exten
|
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
/** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/keys MDN Reference} */
|
|
129
|
-
keys(): FormDataIterator<HttpFormDataSchemaName<
|
|
130
|
-
return super.keys() as
|
|
131
|
+
keys(): FormDataIterator<HttpFormDataSchemaName<this['_schema']>> {
|
|
132
|
+
return super.keys() as never;
|
|
131
133
|
}
|
|
132
134
|
|
|
133
135
|
/** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/values MDN Reference} */
|
|
134
136
|
values(): FormDataIterator<
|
|
135
|
-
ReplaceBy<ArrayItemIfArray<NonNullable<
|
|
137
|
+
ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>
|
|
136
138
|
> {
|
|
137
|
-
return super.values() as
|
|
138
|
-
ReplaceBy<ArrayItemIfArray<NonNullable<Schema[HttpFormDataSchemaName<Schema>]>>, Blob, File>
|
|
139
|
-
>;
|
|
139
|
+
return super.values() as never;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/** @see {@link https://developer.mozilla.org/docs/Web/API/FormData/entries MDN Reference} */
|
|
143
143
|
entries(): FormDataIterator<
|
|
144
144
|
[
|
|
145
|
-
HttpFormDataSchemaName<
|
|
146
|
-
ReplaceBy<ArrayItemIfArray<NonNullable<
|
|
145
|
+
HttpFormDataSchemaName<this['_schema']>,
|
|
146
|
+
ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>,
|
|
147
147
|
]
|
|
148
148
|
> {
|
|
149
|
-
return super.entries() as
|
|
150
|
-
[
|
|
151
|
-
HttpFormDataSchemaName<Schema>,
|
|
152
|
-
ReplaceBy<ArrayItemIfArray<NonNullable<Schema[HttpFormDataSchemaName<Schema>]>>, Blob, File>,
|
|
153
|
-
]
|
|
154
|
-
>;
|
|
149
|
+
return super.entries() as never;
|
|
155
150
|
}
|
|
156
151
|
|
|
157
152
|
[Symbol.iterator](): FormDataIterator<
|
|
158
153
|
[
|
|
159
|
-
HttpFormDataSchemaName<
|
|
160
|
-
ReplaceBy<ArrayItemIfArray<NonNullable<
|
|
154
|
+
HttpFormDataSchemaName<this['_schema']>,
|
|
155
|
+
ReplaceBy<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>,
|
|
161
156
|
]
|
|
162
157
|
> {
|
|
163
|
-
return super[Symbol.iterator]() as
|
|
164
|
-
[
|
|
165
|
-
HttpFormDataSchemaName<Schema>,
|
|
166
|
-
ReplaceBy<ArrayItemIfArray<NonNullable<Schema[HttpFormDataSchemaName<Schema>]>>, Blob, File>,
|
|
167
|
-
]
|
|
168
|
-
>;
|
|
158
|
+
return super[Symbol.iterator]() as never;
|
|
169
159
|
}
|
|
170
160
|
|
|
171
161
|
/**
|
|
@@ -176,7 +166,7 @@ class HttpFormData<Schema extends HttpFormDataSchema = HttpFormDataSchema> exten
|
|
|
176
166
|
* @returns A promise that resolves with `true` if the data is equal to the other data, or `false` otherwise.
|
|
177
167
|
* Important: both form data might be read while comparing.
|
|
178
168
|
*/
|
|
179
|
-
async equals<OtherSchema extends
|
|
169
|
+
async equals<OtherSchema extends LooseSchema>(otherData: HttpFormData<OtherSchema>): Promise<boolean> {
|
|
180
170
|
if (!(await this.contains(otherData))) {
|
|
181
171
|
return false;
|
|
182
172
|
}
|
|
@@ -199,7 +189,7 @@ class HttpFormData<Schema extends HttpFormDataSchema = HttpFormDataSchema> exten
|
|
|
199
189
|
* @returns A promise that resolves with `true` if this data contains the other data, or `false` otherwise. Important:
|
|
200
190
|
* both form data might be read while comparing.
|
|
201
191
|
*/
|
|
202
|
-
async contains<OtherSchema extends
|
|
192
|
+
async contains<OtherSchema extends LooseSchema>(otherData: HttpFormData<OtherSchema>): Promise<boolean> {
|
|
203
193
|
for (const [otherKey, otherValue] of otherData.entries()) {
|
|
204
194
|
const values = super.getAll.call(this, otherKey);
|
|
205
195
|
|
|
@@ -213,7 +203,7 @@ class HttpFormData<Schema extends HttpFormDataSchema = HttpFormDataSchema> exten
|
|
|
213
203
|
for (const value of values) {
|
|
214
204
|
if (
|
|
215
205
|
value === otherValue ||
|
|
216
|
-
(value instanceof Blob && otherValue instanceof Blob && (await fileEquals(value, otherValue)))
|
|
206
|
+
(value instanceof Blob && (otherValue as Blob) instanceof Blob && (await fileEquals(value, otherValue)))
|
|
217
207
|
) {
|
|
218
208
|
valueExists = true;
|
|
219
209
|
break;
|
|
@@ -253,13 +243,13 @@ class HttpFormData<Schema extends HttpFormDataSchema = HttpFormDataSchema> exten
|
|
|
253
243
|
* @returns A plain object representation of this form data.
|
|
254
244
|
*/
|
|
255
245
|
toObject() {
|
|
256
|
-
const object = {} as
|
|
246
|
+
const object = {} as this['_schema'];
|
|
257
247
|
|
|
258
|
-
type SchemaValue =
|
|
248
|
+
type SchemaValue = this['_schema'][HttpFormDataSchemaName<this['_schema']>];
|
|
259
249
|
|
|
260
250
|
for (const [key, value] of this.entries()) {
|
|
261
251
|
if (key in object) {
|
|
262
|
-
const existingValue = object[key];
|
|
252
|
+
const existingValue = object[key] as SchemaValue[];
|
|
263
253
|
|
|
264
254
|
if (Array.isArray<SchemaValue>(existingValue)) {
|
|
265
255
|
existingValue.push(value as SchemaValue);
|