@zimic/http 1.3.9-canary.0 → 1.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ var color__default = /*#__PURE__*/_interopDefault(color);
12
12
  var yargs__default = /*#__PURE__*/_interopDefault(yargs);
13
13
 
14
14
  // package.json
15
- var version = "1.3.9-canary.0";
15
+ var version = "1.3.9";
16
16
 
17
17
  // src/utils/time.ts
18
18
  async function usingElapsedTime(callback) {
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../package.json","../src/utils/time.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["yargs","hideBin","generate_default","color","logger"],"mappings":";;;;;;;;;;;;;;AAcE,IAAA,OAAA,GAAW,gBAAA;;;ACZb,eAAsB,iBAA6B,QAAA,EAA6C;AAC9F,EAAA,MAAM,uBAAA,GAA0B,YAAY,GAAA,EAAI;AAEhD,EAAA,MAAM,MAAA,GAAS,MAAM,QAAA,EAAS;AAE9B,EAAA,MAAM,qBAAA,GAAwB,YAAY,GAAA,EAAI;AAC9C,EAAA,MAAM,4BAA4B,qBAAA,GAAwB,uBAAA;AAE1D,EAAA,OAAO;AAAA,IACL,SAAA,EAAW,uBAAA;AAAA,IACX,WAAA,EAAa,yBAAA;AAAA,IACb,OAAA,EAAS,qBAAA;AAAA,IACT;AAAA,GACF;AACF;AAEO,SAAS,kBAAkB,yBAAA,EAAmC;AACnE,EAAA,IAAI,4BAA4B,GAAA,EAAM;AACpC,IAAA,OAAO,CAAA,EAAG,yBAAA,CAA0B,OAAA,CAAQ,CAAC,CAAC,CAAA,EAAA,CAAA;AAAA,EAChD,CAAA,MAAO;AACL,IAAA,OAAO,CAAA,EAAA,CAAI,yBAAA,GAA4B,GAAA,EAAM,OAAA,CAAQ,CAAC,CAAC,CAAA,CAAA,CAAA;AAAA,EACzD;AACF;;;ACdA,eAAe,MAAA,GAAS;AACtB,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F,IAGD,KAAA,EAAM;AACX;AAEA,IAAO,WAAA,GAAQ,MAAA;;;AC9Gf,KAAK,WAAA,EAAO","file":"cli.js","sourcesContent":["{\n \"name\": \"@zimic/http\",\n \"description\": \"Next-gen TypeScript-first HTTP utilities\",\n \"keywords\": [\n \"zimic\",\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"api\",\n \"static\"\n ],\n \"version\": \"1.3.9-canary.0\",\n \"homepage\": \"https://zimic.dev/docs/http\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/zimicjs/zimic.git\",\n \"directory\": \"packages/zimic-http\"\n },\n \"author\": {\n \"name\": \"Diego Aquino\",\n \"url\": \"https://github.com/diego-aquino\"\n },\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/zimicjs\"\n },\n \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"license\": \"MIT\",\n \"files\": [\n \"package.json\",\n \"README.md\",\n \"LICENSE.md\",\n \"src\",\n \"!src/**/tests\",\n \"!src/**/__tests__\",\n \"!src/**/*.test.ts\",\n \"dist\",\n \"index.d.ts\",\n \"typegen.d.ts\"\n ],\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"index.d.ts\",\n \"bin\": {\n \"zimic-http\": \"./dist/cli.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./typegen\": {\n \"types\": \"./typegen.d.ts\",\n \"import\": \"./dist/typegen.mjs\",\n \"require\": \"./dist/typegen.js\",\n \"default\": \"./dist/typegen.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"setup\": \"playwright install chromium\",\n \"dev\": \"tsup --watch\",\n \"cli\": \"node --enable-source-maps ./dist/cli.js\",\n \"build\": \"tsup\",\n \"lint\": \"eslint --cache --no-error-on-unmatched-pattern --no-warn-ignored --fix\",\n \"lint:turbo\": \"pnpm lint . --max-warnings 0\",\n \"style\": \"prettier --log-level warn --ignore-unknown --no-error-on-unmatched-pattern --cache\",\n \"style:check\": \"pnpm style --check\",\n \"style:format\": \"pnpm style --write\",\n \"test\": \"dotenv -v NODE_ENV=test -v FORCE_COLOR=1 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test --coverage --reporter tree\",\n \"types:check\": \"tsc --noEmit\",\n \"typegen:fixtures\": \"tsx ./scripts/typegen/generateFixtureTypes.ts\"\n },\n \"dependencies\": {\n \"openapi-typescript\": \"7.10.1\",\n \"picocolors\": \"^1.1.1\",\n \"yargs\": \"18.0.0\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^25.0.9\",\n \"@types/yargs\": \"^17.0.35\",\n \"@vitest/browser\": \"^4.0.17\",\n \"@vitest/browser-playwright\": \"^4.0.17\",\n \"@vitest/coverage-istanbul\": \"^4.0.17\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/interceptor\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"@zimic/utils\": \"workspace:*\",\n \"dotenv-cli\": \"^11.0.0\",\n \"eslint\": \"^9.39.2\",\n \"js-yaml\": \"^4.1.1\",\n \"playwright\": \"^1.57.0\",\n \"prettier\": \"^3.8.0\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.21.0\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.17\"\n },\n \"peerDependencies\": {\n \"typescript\": \">=5.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"typescript\": {\n \"optional\": true\n }\n }\n}\n","import { PossiblePromise } from '@zimic/utils/types';\n\nexport async function usingElapsedTime<ReturnType>(callback: () => PossiblePromise<ReturnType>) {\n const startTimeInMilliseconds = performance.now();\n\n const result = await callback();\n\n const endTimeInMilliseconds = performance.now();\n const elapsedTimeInMilliseconds = endTimeInMilliseconds - startTimeInMilliseconds;\n\n return {\n startTime: startTimeInMilliseconds,\n elapsedTime: elapsedTimeInMilliseconds,\n endTime: endTimeInMilliseconds,\n result,\n };\n}\n\nexport function formatElapsedTime(elapsedTimeInMilliseconds: number) {\n if (elapsedTimeInMilliseconds < 1000) {\n return `${elapsedTimeInMilliseconds.toFixed(0)}ms`;\n } else {\n return `${(elapsedTimeInMilliseconds / 1000).toFixed(2)}s`;\n }\n}\n","import color from 'picocolors';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport { generateTypesFromOpenAPI } from '@/typegen';\nimport { logger } from '@/utils/logging';\nimport { usingElapsedTime, formatElapsedTime } from '@/utils/time';\n\nasync function runCLI() {\n await yargs(hideBin(process.argv))\n .scriptName('zimic-http')\n .version(version)\n .showHelpOnFail(false)\n .strict()\n\n .command('typegen', 'Generate types from schema sources.', (yargs) =>\n yargs.demandCommand().command(\n 'openapi <input>',\n 'Generate types from an OpenAPI schema.',\n (yargs) =>\n yargs\n .positional('input', {\n type: 'string',\n description:\n 'The path to a local OpenAPI schema file or an URL to fetch it. ' +\n 'Version 3 is supported as YAML or JSON.',\n demandOption: true,\n })\n .option('output', {\n type: 'string',\n description:\n 'The path to write the generated types to. If not provided, the types will be written to stdout.',\n alias: 'o',\n })\n .option('service-name', {\n type: 'string',\n description: 'The name of the service to use in the generated types.',\n alias: 's',\n demandOption: true,\n })\n .option('comments', {\n type: 'boolean',\n description: 'Whether to include comments in the generated types.',\n alias: 'c',\n default: true,\n })\n .option('prune', {\n type: 'boolean',\n description:\n 'Whether to remove unused operations and components from the generated types. This is useful for ' +\n 'reducing the size of the output file.',\n alias: 'p',\n default: true,\n })\n .option('filter', {\n type: 'string',\n array: true,\n description: [\n 'One or more expressions filtering which endpoints to include. Filters must follow the format `<method> ' +\n '<path>`, where:',\n '- `<method>`: one HTTP method, a list of HTTP methods separated by commas, or `*` to match any HTTP ' +\n 'method;',\n '- `<path>`: a literal path or a glob. `*` matches zero or more characters in a segment (except `/`), ' +\n 'while `**` matches zero or more characters across segments (may include `/`). For example, ' +\n '`GET /users` matches a single method and path, while `* /users` matches any method to the `/users` ' +\n 'path; `GET /users*` matches any `GET` request whose path starts with `/users`, and `GET /users/**/*` ' +\n 'matches any `GET` request to any sub-path of `/users`.',\n\n 'Negative filters can be created by prefixing the expression with `!`. For example, `!GET /users` will ' +\n 'exclude paths matching `GET /users`.',\n ].join('\\n'),\n alias: 'f',\n })\n .option('filter-file', {\n type: 'string',\n description:\n 'A path to a file containing filter expressions. One expression is expected per line and the format ' +\n 'is the same as used in a `--filter` option. Comments are prefixed with `#`. A filter file can be ' +\n 'used alongside additional `--filter` expressions.',\n alias: 'F',\n }),\n async (cliArguments) => {\n const executionSummary = await usingElapsedTime(async () => {\n await generateTypesFromOpenAPI({\n input: cliArguments.input,\n output: cliArguments.output,\n serviceName: cliArguments.serviceName,\n includeComments: cliArguments.comments,\n prune: cliArguments.prune,\n filters: cliArguments.filter,\n filterFile: cliArguments.filterFile,\n });\n });\n\n const outputFilePath = cliArguments.output;\n\n const successMessage =\n `${color.green(color.bold('✔'))} Generated ` +\n `${outputFilePath ? color.green(outputFilePath) : `to ${color.yellow('stdout')}`} ${color.dim(\n `(${formatElapsedTime(executionSummary.elapsedTime)})`,\n )}`;\n\n const hasWrittenToStdout = outputFilePath === undefined;\n logger[hasWrittenToStdout ? 'warn' : 'info'](successMessage);\n },\n ),\n )\n\n .parse();\n}\n\nexport default runCLI;\n","#!/usr/bin/env node\nimport runCLI from './cli';\n\nvoid runCLI();\n"]}
1
+ {"version":3,"sources":["../package.json","../src/utils/time.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["yargs","hideBin","generate_default","color","logger"],"mappings":";;;;;;;;;;;;;;AAcE,IAAA,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AA,CAAa,QAAA;AAAA,YAC9B,OAAO,YAAA,CAAa,KAAA;AAAA,YACpB,SAAS,YAAA,CAAa,MAAA;AAAA,YACtB,YAAY,YAAA,CAAa;AAAA,WAC1B,CAAA;AAAA,QACH,CAAC,CAAA;AAED,QAAA,MAAM,iBAAiB,YAAA,CAAa,MAAA;AAEpC,QAAA,MAAM,cAAA,GACJ,GAAGC,sBAAA,CAAM,KAAA,CAAMA,uBAAM,IAAA,CAAK,QAAG,CAAC,CAAC,CAAA,WAAA,EAC5B,cAAA,GAAiBA,uBAAM,KAAA,CAAM,cAAc,IAAI,CAAA,GAAA,EAAMA,sBAAA,CAAM,OAAO,QAAQ,CAAC,CAAA,CAAE,CAAA,CAAA,EAAIA,sBAAA,CAAM,GAAA;AAAA,UACxF,CAAA,CAAA,EAAI,iBAAA,CAAkB,gBAAA,CAAiB,WAAW,CAAC,CAAA,CAAA;AAAA,SACpD,CAAA,CAAA;AAEH,QAAA,MAAM,qBAAqB,cAAA,KAAmB,MAAA;AAC9C,QAAAC,uBAAA,CAAO,kBAAA,GAAqB,MAAA,GAAS,MAAM,CAAA,CAAE,cAAc,CAAA;AAAA,MAC7D;AAAA;AACF,IAGD,KAAA,EAAM;AACX;AAEA,IAAO,WAAA,GAAQ,MAAA;;;AC9Gf,KAAK,WAAA,EAAO","file":"cli.js","sourcesContent":["{\n \"name\": \"@zimic/http\",\n \"description\": \"Next-gen TypeScript-first HTTP utilities\",\n \"keywords\": [\n \"zimic\",\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"api\",\n \"static\"\n ],\n \"version\": \"1.3.9\",\n \"homepage\": \"https://zimic.dev/docs/http\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/zimicjs/zimic.git\",\n \"directory\": \"packages/zimic-http\"\n },\n \"author\": {\n \"name\": \"Diego Aquino\",\n \"url\": \"https://github.com/diego-aquino\"\n },\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/zimicjs\"\n },\n \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"license\": \"MIT\",\n \"files\": [\n \"package.json\",\n \"README.md\",\n \"LICENSE.md\",\n \"src\",\n \"!src/**/tests\",\n \"!src/**/__tests__\",\n \"!src/**/*.test.ts\",\n \"dist\",\n \"index.d.ts\",\n \"typegen.d.ts\"\n ],\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"index.d.ts\",\n \"bin\": {\n \"zimic-http\": \"./dist/cli.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./typegen\": {\n \"types\": \"./typegen.d.ts\",\n \"import\": \"./dist/typegen.mjs\",\n \"require\": \"./dist/typegen.js\",\n \"default\": \"./dist/typegen.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"setup\": \"playwright install chromium\",\n \"dev\": \"tsup --watch\",\n \"cli\": \"node --enable-source-maps ./dist/cli.js\",\n \"build\": \"tsup\",\n \"lint\": \"eslint --cache --no-error-on-unmatched-pattern --no-warn-ignored --fix\",\n \"lint:turbo\": \"pnpm lint . --max-warnings 0\",\n \"style\": \"prettier --log-level warn --ignore-unknown --no-error-on-unmatched-pattern --cache\",\n \"style:check\": \"pnpm style --check\",\n \"style:format\": \"pnpm style --write\",\n \"test\": \"dotenv -v NODE_ENV=test -v FORCE_COLOR=1 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test --coverage --reporter tree\",\n \"types:check\": \"tsc --noEmit\",\n \"typegen:fixtures\": \"tsx ./scripts/typegen/generateFixtureTypes.ts\"\n },\n \"dependencies\": {\n \"openapi-typescript\": \"7.10.1\",\n \"picocolors\": \"^1.1.1\",\n \"yargs\": \"18.0.0\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^25.0.9\",\n \"@types/yargs\": \"^17.0.35\",\n \"@vitest/browser\": \"^4.0.17\",\n \"@vitest/browser-playwright\": \"^4.0.17\",\n \"@vitest/coverage-istanbul\": \"^4.0.17\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/interceptor\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"@zimic/utils\": \"workspace:*\",\n \"dotenv-cli\": \"^11.0.0\",\n \"eslint\": \"^9.39.2\",\n \"js-yaml\": \"^4.1.1\",\n \"playwright\": \"^1.57.0\",\n \"prettier\": \"^3.8.0\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.21.0\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.17\"\n },\n \"peerDependencies\": {\n \"typescript\": \">=5.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"typescript\": {\n \"optional\": true\n }\n }\n}\n","import { PossiblePromise } from '@zimic/utils/types';\n\nexport async function usingElapsedTime<ReturnType>(callback: () => PossiblePromise<ReturnType>) {\n const startTimeInMilliseconds = performance.now();\n\n const result = await callback();\n\n const endTimeInMilliseconds = performance.now();\n const elapsedTimeInMilliseconds = endTimeInMilliseconds - startTimeInMilliseconds;\n\n return {\n startTime: startTimeInMilliseconds,\n elapsedTime: elapsedTimeInMilliseconds,\n endTime: endTimeInMilliseconds,\n result,\n };\n}\n\nexport function formatElapsedTime(elapsedTimeInMilliseconds: number) {\n if (elapsedTimeInMilliseconds < 1000) {\n return `${elapsedTimeInMilliseconds.toFixed(0)}ms`;\n } else {\n return `${(elapsedTimeInMilliseconds / 1000).toFixed(2)}s`;\n }\n}\n","import color from 'picocolors';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport { generateTypesFromOpenAPI } from '@/typegen';\nimport { logger } from '@/utils/logging';\nimport { usingElapsedTime, formatElapsedTime } from '@/utils/time';\n\nasync function runCLI() {\n await yargs(hideBin(process.argv))\n .scriptName('zimic-http')\n .version(version)\n .showHelpOnFail(false)\n .strict()\n\n .command('typegen', 'Generate types from schema sources.', (yargs) =>\n yargs.demandCommand().command(\n 'openapi <input>',\n 'Generate types from an OpenAPI schema.',\n (yargs) =>\n yargs\n .positional('input', {\n type: 'string',\n description:\n 'The path to a local OpenAPI schema file or an URL to fetch it. ' +\n 'Version 3 is supported as YAML or JSON.',\n demandOption: true,\n })\n .option('output', {\n type: 'string',\n description:\n 'The path to write the generated types to. If not provided, the types will be written to stdout.',\n alias: 'o',\n })\n .option('service-name', {\n type: 'string',\n description: 'The name of the service to use in the generated types.',\n alias: 's',\n demandOption: true,\n })\n .option('comments', {\n type: 'boolean',\n description: 'Whether to include comments in the generated types.',\n alias: 'c',\n default: true,\n })\n .option('prune', {\n type: 'boolean',\n description:\n 'Whether to remove unused operations and components from the generated types. This is useful for ' +\n 'reducing the size of the output file.',\n alias: 'p',\n default: true,\n })\n .option('filter', {\n type: 'string',\n array: true,\n description: [\n 'One or more expressions filtering which endpoints to include. Filters must follow the format `<method> ' +\n '<path>`, where:',\n '- `<method>`: one HTTP method, a list of HTTP methods separated by commas, or `*` to match any HTTP ' +\n 'method;',\n '- `<path>`: a literal path or a glob. `*` matches zero or more characters in a segment (except `/`), ' +\n 'while `**` matches zero or more characters across segments (may include `/`). For example, ' +\n '`GET /users` matches a single method and path, while `* /users` matches any method to the `/users` ' +\n 'path; `GET /users*` matches any `GET` request whose path starts with `/users`, and `GET /users/**/*` ' +\n 'matches any `GET` request to any sub-path of `/users`.',\n\n 'Negative filters can be created by prefixing the expression with `!`. For example, `!GET /users` will ' +\n 'exclude paths matching `GET /users`.',\n ].join('\\n'),\n alias: 'f',\n })\n .option('filter-file', {\n type: 'string',\n description:\n 'A path to a file containing filter expressions. One expression is expected per line and the format ' +\n 'is the same as used in a `--filter` option. Comments are prefixed with `#`. A filter file can be ' +\n 'used alongside additional `--filter` expressions.',\n alias: 'F',\n }),\n async (cliArguments) => {\n const executionSummary = await usingElapsedTime(async () => {\n await generateTypesFromOpenAPI({\n input: cliArguments.input,\n output: cliArguments.output,\n serviceName: cliArguments.serviceName,\n includeComments: cliArguments.comments,\n prune: cliArguments.prune,\n filters: cliArguments.filter,\n filterFile: cliArguments.filterFile,\n });\n });\n\n const outputFilePath = cliArguments.output;\n\n const successMessage =\n `${color.green(color.bold('✔'))} Generated ` +\n `${outputFilePath ? color.green(outputFilePath) : `to ${color.yellow('stdout')}`} ${color.dim(\n `(${formatElapsedTime(executionSummary.elapsedTime)})`,\n )}`;\n\n const hasWrittenToStdout = outputFilePath === undefined;\n logger[hasWrittenToStdout ? 'warn' : 'info'](successMessage);\n },\n ),\n )\n\n .parse();\n}\n\nexport default runCLI;\n","#!/usr/bin/env node\nimport runCLI from './cli';\n\nvoid runCLI();\n"]}
package/dist/cli.mjs CHANGED
@@ -5,7 +5,7 @@ import yargs from 'yargs';
5
5
  import { hideBin } from 'yargs/helpers';
6
6
 
7
7
  // package.json
8
- var version = "1.3.9-canary.0";
8
+ var version = "1.3.9";
9
9
 
10
10
  // src/utils/time.ts
11
11
  async function usingElapsedTime(callback) {
package/dist/cli.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../package.json","../src/utils/time.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["yargs"],"mappings":";;;;;;;AAcE,IAAA,OAAA,GAAW,gBAAA;;;ACZb,eAAsB,iBAA6B,QAAA,EAA6C;AAC9F,EAAA,MAAM,uBAAA,GAA0B,YAAY,GAAA,EAAI;AAEhD,EAAA,MAAM,MAAA,GAAS,MAAM,QAAA,EAAS;AAE9B,EAAA,MAAM,qBAAA,GAAwB,YAAY,GAAA,EAAI;AAC9C,EAAA,MAAM,4BAA4B,qBAAA,GAAwB,uBAAA;AAE1D,EAAA,OAAO;AAAA,IACL,SAAA,EAAW,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AAA,WAAA,EAC5B,cAAA,GAAiB,MAAM,KAAA,CAAM,cAAc,IAAI,CAAA,GAAA,EAAM,KAAA,CAAM,OAAO,QAAQ,CAAC,CAAA,CAAE,CAAA,CAAA,EAAI,KAAA,CAAM,GAAA;AAAA,UACxF,CAAA,CAAA,EAAI,iBAAA,CAAkB,gBAAA,CAAiB,WAAW,CAAC,CAAA,CAAA;AAAA,SACpD,CAAA,CAAA;AAEH,QAAA,MAAM,qBAAqB,cAAA,KAAmB,MAAA;AAC9C,QAAA,MAAA,CAAO,kBAAA,GAAqB,MAAA,GAAS,MAAM,CAAA,CAAE,cAAc,CAAA;AAAA,MAC7D;AAAA;AACF,IAGD,KAAA,EAAM;AACX;AAEA,IAAO,WAAA,GAAQ,MAAA;;;AC9Gf,KAAK,WAAA,EAAO","file":"cli.mjs","sourcesContent":["{\n \"name\": \"@zimic/http\",\n \"description\": \"Next-gen TypeScript-first HTTP utilities\",\n \"keywords\": [\n \"zimic\",\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"api\",\n \"static\"\n ],\n \"version\": \"1.3.9-canary.0\",\n \"homepage\": \"https://zimic.dev/docs/http\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/zimicjs/zimic.git\",\n \"directory\": \"packages/zimic-http\"\n },\n \"author\": {\n \"name\": \"Diego Aquino\",\n \"url\": \"https://github.com/diego-aquino\"\n },\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/zimicjs\"\n },\n \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"license\": \"MIT\",\n \"files\": [\n \"package.json\",\n \"README.md\",\n \"LICENSE.md\",\n \"src\",\n \"!src/**/tests\",\n \"!src/**/__tests__\",\n \"!src/**/*.test.ts\",\n \"dist\",\n \"index.d.ts\",\n \"typegen.d.ts\"\n ],\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"index.d.ts\",\n \"bin\": {\n \"zimic-http\": \"./dist/cli.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./typegen\": {\n \"types\": \"./typegen.d.ts\",\n \"import\": \"./dist/typegen.mjs\",\n \"require\": \"./dist/typegen.js\",\n \"default\": \"./dist/typegen.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"setup\": \"playwright install chromium\",\n \"dev\": \"tsup --watch\",\n \"cli\": \"node --enable-source-maps ./dist/cli.js\",\n \"build\": \"tsup\",\n \"lint\": \"eslint --cache --no-error-on-unmatched-pattern --no-warn-ignored --fix\",\n \"lint:turbo\": \"pnpm lint . --max-warnings 0\",\n \"style\": \"prettier --log-level warn --ignore-unknown --no-error-on-unmatched-pattern --cache\",\n \"style:check\": \"pnpm style --check\",\n \"style:format\": \"pnpm style --write\",\n \"test\": \"dotenv -v NODE_ENV=test -v FORCE_COLOR=1 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test --coverage --reporter tree\",\n \"types:check\": \"tsc --noEmit\",\n \"typegen:fixtures\": \"tsx ./scripts/typegen/generateFixtureTypes.ts\"\n },\n \"dependencies\": {\n \"openapi-typescript\": \"7.10.1\",\n \"picocolors\": \"^1.1.1\",\n \"yargs\": \"18.0.0\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^25.0.9\",\n \"@types/yargs\": \"^17.0.35\",\n \"@vitest/browser\": \"^4.0.17\",\n \"@vitest/browser-playwright\": \"^4.0.17\",\n \"@vitest/coverage-istanbul\": \"^4.0.17\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/interceptor\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"@zimic/utils\": \"workspace:*\",\n \"dotenv-cli\": \"^11.0.0\",\n \"eslint\": \"^9.39.2\",\n \"js-yaml\": \"^4.1.1\",\n \"playwright\": \"^1.57.0\",\n \"prettier\": \"^3.8.0\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.21.0\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.17\"\n },\n \"peerDependencies\": {\n \"typescript\": \">=5.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"typescript\": {\n \"optional\": true\n }\n }\n}\n","import { PossiblePromise } from '@zimic/utils/types';\n\nexport async function usingElapsedTime<ReturnType>(callback: () => PossiblePromise<ReturnType>) {\n const startTimeInMilliseconds = performance.now();\n\n const result = await callback();\n\n const endTimeInMilliseconds = performance.now();\n const elapsedTimeInMilliseconds = endTimeInMilliseconds - startTimeInMilliseconds;\n\n return {\n startTime: startTimeInMilliseconds,\n elapsedTime: elapsedTimeInMilliseconds,\n endTime: endTimeInMilliseconds,\n result,\n };\n}\n\nexport function formatElapsedTime(elapsedTimeInMilliseconds: number) {\n if (elapsedTimeInMilliseconds < 1000) {\n return `${elapsedTimeInMilliseconds.toFixed(0)}ms`;\n } else {\n return `${(elapsedTimeInMilliseconds / 1000).toFixed(2)}s`;\n }\n}\n","import color from 'picocolors';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport { generateTypesFromOpenAPI } from '@/typegen';\nimport { logger } from '@/utils/logging';\nimport { usingElapsedTime, formatElapsedTime } from '@/utils/time';\n\nasync function runCLI() {\n await yargs(hideBin(process.argv))\n .scriptName('zimic-http')\n .version(version)\n .showHelpOnFail(false)\n .strict()\n\n .command('typegen', 'Generate types from schema sources.', (yargs) =>\n yargs.demandCommand().command(\n 'openapi <input>',\n 'Generate types from an OpenAPI schema.',\n (yargs) =>\n yargs\n .positional('input', {\n type: 'string',\n description:\n 'The path to a local OpenAPI schema file or an URL to fetch it. ' +\n 'Version 3 is supported as YAML or JSON.',\n demandOption: true,\n })\n .option('output', {\n type: 'string',\n description:\n 'The path to write the generated types to. If not provided, the types will be written to stdout.',\n alias: 'o',\n })\n .option('service-name', {\n type: 'string',\n description: 'The name of the service to use in the generated types.',\n alias: 's',\n demandOption: true,\n })\n .option('comments', {\n type: 'boolean',\n description: 'Whether to include comments in the generated types.',\n alias: 'c',\n default: true,\n })\n .option('prune', {\n type: 'boolean',\n description:\n 'Whether to remove unused operations and components from the generated types. This is useful for ' +\n 'reducing the size of the output file.',\n alias: 'p',\n default: true,\n })\n .option('filter', {\n type: 'string',\n array: true,\n description: [\n 'One or more expressions filtering which endpoints to include. Filters must follow the format `<method> ' +\n '<path>`, where:',\n '- `<method>`: one HTTP method, a list of HTTP methods separated by commas, or `*` to match any HTTP ' +\n 'method;',\n '- `<path>`: a literal path or a glob. `*` matches zero or more characters in a segment (except `/`), ' +\n 'while `**` matches zero or more characters across segments (may include `/`). For example, ' +\n '`GET /users` matches a single method and path, while `* /users` matches any method to the `/users` ' +\n 'path; `GET /users*` matches any `GET` request whose path starts with `/users`, and `GET /users/**/*` ' +\n 'matches any `GET` request to any sub-path of `/users`.',\n\n 'Negative filters can be created by prefixing the expression with `!`. For example, `!GET /users` will ' +\n 'exclude paths matching `GET /users`.',\n ].join('\\n'),\n alias: 'f',\n })\n .option('filter-file', {\n type: 'string',\n description:\n 'A path to a file containing filter expressions. One expression is expected per line and the format ' +\n 'is the same as used in a `--filter` option. Comments are prefixed with `#`. A filter file can be ' +\n 'used alongside additional `--filter` expressions.',\n alias: 'F',\n }),\n async (cliArguments) => {\n const executionSummary = await usingElapsedTime(async () => {\n await generateTypesFromOpenAPI({\n input: cliArguments.input,\n output: cliArguments.output,\n serviceName: cliArguments.serviceName,\n includeComments: cliArguments.comments,\n prune: cliArguments.prune,\n filters: cliArguments.filter,\n filterFile: cliArguments.filterFile,\n });\n });\n\n const outputFilePath = cliArguments.output;\n\n const successMessage =\n `${color.green(color.bold('✔'))} Generated ` +\n `${outputFilePath ? color.green(outputFilePath) : `to ${color.yellow('stdout')}`} ${color.dim(\n `(${formatElapsedTime(executionSummary.elapsedTime)})`,\n )}`;\n\n const hasWrittenToStdout = outputFilePath === undefined;\n logger[hasWrittenToStdout ? 'warn' : 'info'](successMessage);\n },\n ),\n )\n\n .parse();\n}\n\nexport default runCLI;\n","#!/usr/bin/env node\nimport runCLI from './cli';\n\nvoid runCLI();\n"]}
1
+ {"version":3,"sources":["../package.json","../src/utils/time.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["yargs"],"mappings":";;;;;;;AAcE,IAAA,OAAA,GAAW,OAAA;;;ACZb,eAAsB,iBAA6B,QAAA,EAA6C;AAC9F,EAAA,MAAM,uBAAA,GAA0B,YAAY,GAAA,EAAI;AAEhD,EAAA,MAAM,MAAA,GAAS,MAAM,QAAA,EAAS;AAE9B,EAAA,MAAM,qBAAA,GAAwB,YAAY,GAAA,EAAI;AAC9C,EAAA,MAAM,4BAA4B,qBAAA,GAAwB,uBAAA;AAE1D,EAAA,OAAO;AAAA,IACL,SAAA,EAAW,uBAAA;AAAA,IACX,WAAA,EAAa,yBAAA;AAAA,IACb,OAAA,EAAS,qBAAA;AAAA,IACT;AAAA,GACF;AACF;AAEO,SAAS,kBAAkB,yBAAA,EAAmC;AACnE,EAAA,IAAI,4BAA4B,GAAA,EAAM;AACpC,IAAA,OAAO,CAAA,EAAG,yBAAA,CAA0B,OAAA,CAAQ,CAAC,CAAC,CAAA,EAAA,CAAA;AAAA,EAChD,CAAA,MAAO;AACL,IAAA,OAAO,CAAA,EAAA,CAAI,yBAAA,GAA4B,GAAA,EAAM,OAAA,CAAQ,CAAC,CAAC,CAAA,CAAA,CAAA;AAAA,EACzD;AACF;;;ACdA,eAAe,MAAA,GAAS;AACtB,EAAA,MAAM,MAAM,OAAA,CAAQ,OAAA,CAAQ,IAAI,CAAC,EAC9B,UAAA,CAAW,YAAY,CAAA,CACvB,OAAA,CAAQ,O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\",\n \"description\": \"Next-gen TypeScript-first HTTP utilities\",\n \"keywords\": [\n \"zimic\",\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"api\",\n \"static\"\n ],\n \"version\": \"1.3.9\",\n \"homepage\": \"https://zimic.dev/docs/http\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/zimicjs/zimic.git\",\n \"directory\": \"packages/zimic-http\"\n },\n \"author\": {\n \"name\": \"Diego Aquino\",\n \"url\": \"https://github.com/diego-aquino\"\n },\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/zimicjs\"\n },\n \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"license\": \"MIT\",\n \"files\": [\n \"package.json\",\n \"README.md\",\n \"LICENSE.md\",\n \"src\",\n \"!src/**/tests\",\n \"!src/**/__tests__\",\n \"!src/**/*.test.ts\",\n \"dist\",\n \"index.d.ts\",\n \"typegen.d.ts\"\n ],\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"index.d.ts\",\n \"bin\": {\n \"zimic-http\": \"./dist/cli.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./typegen\": {\n \"types\": \"./typegen.d.ts\",\n \"import\": \"./dist/typegen.mjs\",\n \"require\": \"./dist/typegen.js\",\n \"default\": \"./dist/typegen.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"setup\": \"playwright install chromium\",\n \"dev\": \"tsup --watch\",\n \"cli\": \"node --enable-source-maps ./dist/cli.js\",\n \"build\": \"tsup\",\n \"lint\": \"eslint --cache --no-error-on-unmatched-pattern --no-warn-ignored --fix\",\n \"lint:turbo\": \"pnpm lint . --max-warnings 0\",\n \"style\": \"prettier --log-level warn --ignore-unknown --no-error-on-unmatched-pattern --cache\",\n \"style:check\": \"pnpm style --check\",\n \"style:format\": \"pnpm style --write\",\n \"test\": \"dotenv -v NODE_ENV=test -v FORCE_COLOR=1 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test --coverage --reporter tree\",\n \"types:check\": \"tsc --noEmit\",\n \"typegen:fixtures\": \"tsx ./scripts/typegen/generateFixtureTypes.ts\"\n },\n \"dependencies\": {\n \"openapi-typescript\": \"7.10.1\",\n \"picocolors\": \"^1.1.1\",\n \"yargs\": \"18.0.0\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^25.0.9\",\n \"@types/yargs\": \"^17.0.35\",\n \"@vitest/browser\": \"^4.0.17\",\n \"@vitest/browser-playwright\": \"^4.0.17\",\n \"@vitest/coverage-istanbul\": \"^4.0.17\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/interceptor\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"@zimic/utils\": \"workspace:*\",\n \"dotenv-cli\": \"^11.0.0\",\n \"eslint\": \"^9.39.2\",\n \"js-yaml\": \"^4.1.1\",\n \"playwright\": \"^1.57.0\",\n \"prettier\": \"^3.8.0\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.21.0\",\n \"typescript\": \"^5.9.3\",\n \"vitest\": \"^4.0.17\"\n },\n \"peerDependencies\": {\n \"typescript\": \">=5.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"typescript\": {\n \"optional\": true\n }\n }\n}\n","import { PossiblePromise } from '@zimic/utils/types';\n\nexport async function usingElapsedTime<ReturnType>(callback: () => PossiblePromise<ReturnType>) {\n const startTimeInMilliseconds = performance.now();\n\n const result = await callback();\n\n const endTimeInMilliseconds = performance.now();\n const elapsedTimeInMilliseconds = endTimeInMilliseconds - startTimeInMilliseconds;\n\n return {\n startTime: startTimeInMilliseconds,\n elapsedTime: elapsedTimeInMilliseconds,\n endTime: endTimeInMilliseconds,\n result,\n };\n}\n\nexport function formatElapsedTime(elapsedTimeInMilliseconds: number) {\n if (elapsedTimeInMilliseconds < 1000) {\n return `${elapsedTimeInMilliseconds.toFixed(0)}ms`;\n } else {\n return `${(elapsedTimeInMilliseconds / 1000).toFixed(2)}s`;\n }\n}\n","import color from 'picocolors';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport { generateTypesFromOpenAPI } from '@/typegen';\nimport { logger } from '@/utils/logging';\nimport { usingElapsedTime, formatElapsedTime } from '@/utils/time';\n\nasync function runCLI() {\n await yargs(hideBin(process.argv))\n .scriptName('zimic-http')\n .version(version)\n .showHelpOnFail(false)\n .strict()\n\n .command('typegen', 'Generate types from schema sources.', (yargs) =>\n yargs.demandCommand().command(\n 'openapi <input>',\n 'Generate types from an OpenAPI schema.',\n (yargs) =>\n yargs\n .positional('input', {\n type: 'string',\n description:\n 'The path to a local OpenAPI schema file or an URL to fetch it. ' +\n 'Version 3 is supported as YAML or JSON.',\n demandOption: true,\n })\n .option('output', {\n type: 'string',\n description:\n 'The path to write the generated types to. If not provided, the types will be written to stdout.',\n alias: 'o',\n })\n .option('service-name', {\n type: 'string',\n description: 'The name of the service to use in the generated types.',\n alias: 's',\n demandOption: true,\n })\n .option('comments', {\n type: 'boolean',\n description: 'Whether to include comments in the generated types.',\n alias: 'c',\n default: true,\n })\n .option('prune', {\n type: 'boolean',\n description:\n 'Whether to remove unused operations and components from the generated types. This is useful for ' +\n 'reducing the size of the output file.',\n alias: 'p',\n default: true,\n })\n .option('filter', {\n type: 'string',\n array: true,\n description: [\n 'One or more expressions filtering which endpoints to include. Filters must follow the format `<method> ' +\n '<path>`, where:',\n '- `<method>`: one HTTP method, a list of HTTP methods separated by commas, or `*` to match any HTTP ' +\n 'method;',\n '- `<path>`: a literal path or a glob. `*` matches zero or more characters in a segment (except `/`), ' +\n 'while `**` matches zero or more characters across segments (may include `/`). For example, ' +\n '`GET /users` matches a single method and path, while `* /users` matches any method to the `/users` ' +\n 'path; `GET /users*` matches any `GET` request whose path starts with `/users`, and `GET /users/**/*` ' +\n 'matches any `GET` request to any sub-path of `/users`.',\n\n 'Negative filters can be created by prefixing the expression with `!`. For example, `!GET /users` will ' +\n 'exclude paths matching `GET /users`.',\n ].join('\\n'),\n alias: 'f',\n })\n .option('filter-file', {\n type: 'string',\n description:\n 'A path to a file containing filter expressions. One expression is expected per line and the format ' +\n 'is the same as used in a `--filter` option. Comments are prefixed with `#`. A filter file can be ' +\n 'used alongside additional `--filter` expressions.',\n alias: 'F',\n }),\n async (cliArguments) => {\n const executionSummary = await usingElapsedTime(async () => {\n await generateTypesFromOpenAPI({\n input: cliArguments.input,\n output: cliArguments.output,\n serviceName: cliArguments.serviceName,\n includeComments: cliArguments.comments,\n prune: cliArguments.prune,\n filters: cliArguments.filter,\n filterFile: cliArguments.filterFile,\n });\n });\n\n const outputFilePath = cliArguments.output;\n\n const successMessage =\n `${color.green(color.bold('✔'))} Generated ` +\n `${outputFilePath ? color.green(outputFilePath) : `to ${color.yellow('stdout')}`} ${color.dim(\n `(${formatElapsedTime(executionSummary.elapsedTime)})`,\n )}`;\n\n const hasWrittenToStdout = outputFilePath === undefined;\n logger[hasWrittenToStdout ? 'warn' : 'info'](successMessage);\n },\n ),\n )\n\n .parse();\n}\n\nexport default runCLI;\n","#!/usr/bin/env node\nimport runCLI from './cli';\n\nvoid runCLI();\n"]}
package/dist/index.d.ts CHANGED
@@ -189,7 +189,7 @@ declare class HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFo
189
189
  has<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): boolean;
190
190
  /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatadelete `formData.delete()` API reference} */
191
191
  delete<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): void;
192
- /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforEach `formData.forEach()` API reference} */
192
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforeach `formData.forEach()` API reference} */
193
193
  forEach<This extends HttpFormData<this['_schema']>>(callback: <Key extends HttpFormDataSchemaName<this['_schema']>>(value: Replace<ArrayItemIfArray<NonNullable<this['_schema'][Key]>>, Blob, File>, key: Key, formData: HttpFormData<this['_schema']>) => void, thisArg?: This): void;
194
194
  /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatakeys `formData.keys()` API reference} */
195
195
  keys(): FormDataIterator<HttpFormDataSchemaName<this['_schema']>>;
@@ -305,13 +305,13 @@ declare class HttpHeaders<LooseSchema extends HttpHeadersSchema.Loose = HttpHead
305
305
  append<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name, value: NonNullable<LooseSchema[Name]>): void;
306
306
  /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersget `headers.get()` API reference} */
307
307
  get<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): Replace<this['_schema'][Name], undefined, null>;
308
- /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetSetCookie `headers.getSetCookie()` API reference} */
308
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetsetcookie `headers.getSetCookie()` API reference} */
309
309
  getSetCookie(): NonNullable<Default<this['_schema']['Set-Cookie'], string>>[];
310
310
  /** @see {@link https://zimic.dev/docs/http/api/http-headers#headershas `headers.has()` API reference} */
311
311
  has<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): boolean;
312
312
  /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersdelete `headers.delete()` API reference} */
313
313
  delete<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): void;
314
- /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforEach `headers.forEach()` API reference} */
314
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforeach `headers.forEach()` API reference} */
315
315
  forEach<This extends HttpHeaders<this['_schema']>>(callback: <Key extends HttpHeadersSchemaName<this['_schema']>>(value: NonNullable<this['_schema'][Key]> & string, key: Key, headers: Headers) => void, thisArg?: This): void;
316
316
  /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerskeys `headers.keys()` API reference} */
317
317
  keys(): HeadersIterator<HttpHeadersSchemaName<this['_schema']>>;
@@ -431,7 +431,7 @@ declare class HttpSearchParams<LooseSchema extends HttpSearchParamsSchema.Loose
431
431
  has<Name extends HttpSearchParamsSchemaName<this['_schema']>>(name: Name, value?: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>): boolean;
432
432
  /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsdelete `searchParams.delete()` API reference} */
433
433
  delete<Name extends HttpSearchParamsSchemaName<this['_schema']>>(name: Name, value?: ArrayItemIfArray<NonNullable<LooseSchema[Name]>>): void;
434
- /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforEach `searchParams.forEach()` API reference} */
434
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforeach `searchParams.forEach()` API reference} */
435
435
  forEach<This extends HttpSearchParams<this['_schema']>>(callback: <Key extends HttpSearchParamsSchemaName<this['_schema']>>(value: ArrayItemIfArray<NonNullable<this['_schema'][Key]>>, key: Key, searchParams: HttpSearchParams<this['_schema']>) => void, thisArg?: This): void;
436
436
  /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamskeys `searchParams.keys()` API reference} */
437
437
  keys(): URLSearchParamsIterator<HttpSearchParamsSchemaName<this['_schema']>>;
package/dist/index.js CHANGED
@@ -92,7 +92,7 @@ var HttpFormData = class extends FormData {
92
92
  delete(name) {
93
93
  super.delete(name);
94
94
  }
95
- /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforEach `formData.forEach()` API reference} */
95
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforeach `formData.forEach()` API reference} */
96
96
  forEach(callback, thisArg) {
97
97
  super.forEach(callback, thisArg);
98
98
  }
@@ -208,7 +208,7 @@ var HttpHeaders = class extends Headers {
208
208
  get(name) {
209
209
  return super.get(name);
210
210
  }
211
- /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetSetCookie `headers.getSetCookie()` API reference} */
211
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetsetcookie `headers.getSetCookie()` API reference} */
212
212
  getSetCookie() {
213
213
  return super.getSetCookie();
214
214
  }
@@ -220,7 +220,7 @@ var HttpHeaders = class extends Headers {
220
220
  delete(name) {
221
221
  super.delete(name);
222
222
  }
223
- /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforEach `headers.forEach()` API reference} */
223
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforeach `headers.forEach()` API reference} */
224
224
  forEach(callback, thisArg) {
225
225
  super.forEach(callback, thisArg);
226
226
  }
@@ -356,7 +356,7 @@ var HttpSearchParams = class extends URLSearchParams {
356
356
  delete(name, value) {
357
357
  super.delete(name, value);
358
358
  }
359
- /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforEach `searchParams.forEach()` API reference} */
359
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforeach `searchParams.forEach()` API reference} */
360
360
  forEach(callback, thisArg) {
361
361
  super.forEach(callback, thisArg);
362
362
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../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","../src/utils/bodies.ts"],"names":["pickPrimitiveProperties"],"mappings":";;;AAAA,eAAe,UAAA,CAAW,MAAY,SAAA,EAAiB;AACrD,EAAA,IAAI,KAAK,IAAA,KAAS,SAAA,CAAU,QAAQ,IAAA,CAAK,IAAA,KAAS,UAAU,IAAA,EAAM;AAChE,IAAA,OAAO,KAAA;AACT,EAAA;AAEA,EAAA,M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vD,EAAA,IAAI,WAAA,EAAa,UAAA,CAAW,kBAAkB,CAAA,EAAG;AAC/C,IAAA,OAAO,oBAA0B,QAAQ,CAAA;AAAA,EAC3C;AAEA,EAAA,IAAI,WAAA,EAAa,UAAA,CAAW,qBAAqB,CAAA,EAAG;AAClD,IAAA,OAAO,wBAA8B,QAAQ,CAAA;AAAA,EAC/C;AAEA,EAAA,IAAI,WAAA,EAAa,UAAA,CAAW,mCAAmC,CAAA,EAAG;AAChE,IAAA,OAAO,4BAAkC,QAAQ,CAAA;AAAA,EACnD;AAEA,EAAA,IAAI,aAAa,UAAA,CAAW,OAAO,KAAK,WAAA,EAAa,UAAA,CAAW,iBAAiB,CAAA,EAAG;AAClF,IAAA,OAAO,oBAA0B,QAAQ,CAAA;AAAA,EAC3C;AAEA,EAAA,IACE,WAAA,EAAa,WAAW,cAAc,CAAA,IACtC,aAAa,UAAA,CAAW,QAAQ,CAAA,IAChC,WAAA,EAAa,UAAA,CAAW,QAAQ,KAChC,WAAA,EAAa,UAAA,CAAW,OAAO,CAAA,IAC/B,WAAA,EAAa,UAAA,CAAW,QAAQ,CAAA,IAChC,WAAA,EAAa,UAAA,CAAW,YAAY,CAAA,EACpC;AACA,IAAA,OAAO,oBAA0B,QAAQ,CAAA;AAAA,EAC3C;AAEA,EAAA,MAAM,aAAA,GAAgB,SAAS,KAAA,EAAM;AAErC,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,oBAA0B,QAAQ,CAAA;AAAA,EACjD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,oBAA0B,aAAa,CAAA;AAAA,EAChD;AACF","file":"index.js","sourcesContent":["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 const bufferReadPromises: Promise<void>[] = [];\n\n if (buffer.length === 0) {\n bufferReadPromises.push(\n reader.read().then((result) => {\n if (!result.done) {\n buffer = result.value;\n }\n }),\n );\n }\n\n if (otherBuffer.length === 0) {\n bufferReadPromises.push(\n otherReader.read().then((result) => {\n if (!result.done) {\n otherBuffer = result.value;\n }\n }),\n );\n }\n\n await Promise.all(bufferReadPromises);\n\n const haveStreamsEndedTogether = buffer.length === 0 && otherBuffer.length === 0;\n\n if (haveStreamsEndedTogether) {\n return true;\n }\n\n const hasOneStreamEndedBeforeTheOther =\n (buffer.length === 0 && otherBuffer.length > 0) || (buffer.length > 0 && otherBuffer.length === 0);\n\n if (hasOneStreamEndedBeforeTheOther) {\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';\nimport { ArrayItemIfArray, Replace } from '@zimic/utils/types';\n\nimport { HttpFormDataSchema, HttpFormDataSchemaName, HttpFormDataSerialized } from './types';\n\n/** @see {@link https://zimic.dev/docs/http/api/http-form-data `HttpFormData` API reference} */\nclass HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFormDataSchema.Loose> extends FormData {\n readonly _schema!: HttpFormDataSerialized<LooseSchema>;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataset `formData.set()` API 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://zimic.dev/docs/http/api/http-form-data#formdataappend `formData.append()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataget `formData.get()` API reference} */\n get<Name extends HttpFormDataSchemaName.NonArray<this['_schema']>>(\n name: Name,\n ): Replace<Replace<ArrayItemIfArray<this['_schema'][Name]>, undefined, null>, Blob, File> {\n return super.get(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatagetall `formData.getAll()` API reference} */\n getAll<Name extends HttpFormDataSchemaName.Array<this['_schema']>>(\n name: Name,\n ): Replace<ArrayItemIfArray<NonNullable<this['_schema'][Name]>>, Blob, File>[] {\n return super.getAll(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatahas `formData.has()` API reference} */\n has<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): boolean {\n return super.has(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatadelete `formData.delete()` API reference} */\n delete<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): void {\n super.delete(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforEach `formData.forEach()` API reference} */\n forEach<This extends HttpFormData<this['_schema']>>(\n callback: <Key extends HttpFormDataSchemaName<this['_schema']>>(\n value: Replace<ArrayItemIfArray<NonNullable<this['_schema'][Key]>>, Blob, File>,\n key: Key,\n formData: 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://zimic.dev/docs/http/api/http-form-data#formdatakeys `formData.keys()` API reference} */\n keys(): FormDataIterator<HttpFormDataSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatavalues `formData.values()` API reference} */\n values(): FormDataIterator<\n Replace<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>\n > {\n return super.values() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataentries `formData.entries()` API reference} */\n entries(): FormDataIterator<\n [\n HttpFormDataSchemaName<this['_schema']>,\n Replace<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 Replace<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>,\n ]\n > {\n return super[Symbol.iterator]() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataequals `formData.equals()` API reference} */\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 fieldName of this.keys()) {\n if (!super.has.call(otherData, fieldName)) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatacontains `formData.contains()` API reference} */\n async contains<OtherSchema extends LooseSchema>(otherData: HttpFormData<OtherSchema>): Promise<boolean> {\n for (const [otherFieldName, otherFieldValue] of otherData.entries()) {\n const fieldValues = super.getAll.call(this, otherFieldName);\n\n const haveSameNumberOfFieldValues = fieldValues.length === super.getAll.call(otherData, otherFieldName).length;\n\n if (!haveSameNumberOfFieldValues) {\n return false;\n }\n\n let fieldValueExists = false;\n\n for (const fieldValue of fieldValues) {\n if (\n fieldValue === otherFieldValue ||\n (fieldValue instanceof Blob &&\n (otherFieldValue as Blob) instanceof Blob &&\n (await fileEquals(fieldValue, otherFieldValue)))\n ) {\n fieldValueExists = true;\n break;\n }\n }\n\n if (!fieldValueExists) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataassign `formData.assign()` API reference} */\n assign<OtherSchema extends LooseSchema>(...otherDataArray: HttpFormData<OtherSchema>[]) {\n for (const otherData of otherDataArray) {\n if (this === (otherData as unknown)) {\n continue;\n }\n\n for (const fieldName of otherData.keys()) {\n super.delete(fieldName);\n }\n\n for (const [fieldName, fieldValue] of otherData.entries()) {\n super.append(fieldName, fieldValue);\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatatoobject `formData.toObject()` API reference} */\n toObject() {\n const object = {} as this['_schema'];\n\n type SchemaValue = this['_schema'][HttpFormDataSchemaName<this['_schema']>];\n\n for (const [fieldName, fieldValue] of this.entries()) {\n if (fieldName in object) {\n const existingFieldValue = object[fieldName] as SchemaValue[];\n\n if (Array.isArray<SchemaValue>(existingFieldValue)) {\n existingFieldValue.push(fieldValue as SchemaValue);\n } else {\n object[fieldName] = [existingFieldValue, fieldValue] as SchemaValue;\n }\n } else {\n object[fieldName] = fieldValue as SchemaValue;\n }\n }\n\n return object;\n }\n}\n\nexport default HttpFormData;\n","import { Default, Replace } 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/** @see {@link https://zimic.dev/docs/http/api/http-headers `HttpHeaders` API reference} */\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://zimic.dev/docs/http/api/http-headers#headersset `headers.set()` API 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://zimic.dev/docs/http/api/http-headers#headersappend `headers.append()` API 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://zimic.dev/docs/http/api/http-headers#headersget `headers.get()` API reference} */\n get<Name extends HttpHeadersSchemaName<this['_schema']>>(\n name: Name,\n ): Replace<this['_schema'][Name], undefined, null> {\n return super.get(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetSetCookie `headers.getSetCookie()` API reference} */\n getSetCookie(): NonNullable<Default<this['_schema']['Set-Cookie'], string>>[] {\n return super.getSetCookie() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headershas `headers.has()` API reference} */\n has<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): boolean {\n return super.has(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersdelete `headers.delete()` API reference} */\n delete<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): void {\n super.delete(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforEach `headers.forEach()` API reference} */\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 headers: 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://zimic.dev/docs/http/api/http-headers#headerskeys `headers.keys()` API reference} */\n keys(): HeadersIterator<HttpHeadersSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersvalues `headers.values()` API reference} */\n values(): HeadersIterator<NonNullable<this['_schema'][HttpHeadersSchemaName<this['_schema']>]> & string> {\n return super.values() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersentries `headers.entries()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersequals `headers.equals()` API reference} */\n equals<OtherSchema extends LooseSchema>(otherHeaders: HttpHeaders<OtherSchema>): boolean {\n if (!this.contains(otherHeaders)) {\n return false;\n }\n\n for (const headerName of this.keys()) {\n if (!super.has.call(otherHeaders, headerName)) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerscontains `headers.contains()` API reference} */\n contains<OtherSchema extends LooseSchema>(otherHeaders: HttpHeaders<OtherSchema>): boolean {\n for (const [headerName, otherHeaderValue] of otherHeaders.entries()) {\n const headerValue = super.get.call(this, headerName);\n\n if (headerValue === null) {\n return false;\n }\n\n const headerValueItems = this.splitHeaderValues(headerValue);\n const otherHeaderValueItems = this.splitHeaderValues(otherHeaderValue);\n\n const haveSameNumberOfHeaderValues = headerValueItems.length === otherHeaderValueItems.length;\n\n if (!haveSameNumberOfHeaderValues) {\n return false;\n }\n\n for (const otherValueItem of otherHeaderValueItems) {\n if (!headerValueItems.includes(otherValueItem)) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersassign `headers.assign()` API reference} */\n assign<OtherSchema extends LooseSchema>(...otherHeadersArray: HttpHeaders<OtherSchema>[]) {\n for (const otherHeaders of otherHeadersArray) {\n if (this === (otherHeaders as unknown)) {\n continue;\n }\n\n for (const headerName of otherHeaders.keys()) {\n super.delete(headerName);\n }\n\n for (const [headerName, headerValue] of otherHeaders.entries()) {\n super.append(headerName, headerValue);\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerstoobject `headers.toObject()` API reference} */\n toObject(): this['_schema'] {\n const object = {} as this['_schema'];\n\n for (const [headerName, headerValue] of this.entries()) {\n object[headerName] = headerValue;\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 { Replace, 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/** @see {@link https://zimic.dev/docs/http/api/http-search-params `HttpSearchParams` API reference} */\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 [paramName, paramValues] of Object.entries(init)) {\n if (Array.isArray(paramValues)) {\n for (const paramValue of paramValues as unknown[]) {\n super.append(paramName, String(paramValue));\n }\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsset `searchParams.set()` API 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://zimic.dev/docs/http/api/http-search-params#searchparamsappend `searchParams.append()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsget `searchParams.get()` API reference} */\n get<Name extends HttpSearchParamsSchemaName.NonArray<this['_schema']>>(\n name: Name,\n ): Replace<ArrayItemIfArray<this['_schema'][Name]>, undefined, null> {\n return super.get(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsgetall `searchParams.getAll()` API reference} */\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://zimic.dev/docs/http/api/http-search-params#searchparamshas `searchParams.has()` API 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://zimic.dev/docs/http/api/http-search-params#searchparamsdelete `searchParams.delete()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforEach `searchParams.forEach()` API reference} */\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 searchParams: 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://zimic.dev/docs/http/api/http-search-params#searchparamskeys `searchParams.keys()` API reference} */\n keys(): URLSearchParamsIterator<HttpSearchParamsSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsvalues `searchParams.values()` API 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://zimic.dev/docs/http/api/http-search-params#searchparamsentries `searchParams.entries()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsequals `searchParams.equals()` API reference} */\n equals<OtherSchema extends LooseSchema>(otherParams: HttpSearchParams<OtherSchema>): boolean {\n return this.contains(otherParams) && this.size === otherParams.size;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamscontains `searchParams.contains()` API reference} */\n contains<OtherSchema extends LooseSchema>(otherParams: HttpSearchParams<OtherSchema>): boolean {\n for (const [paramName, otherParamValue] of otherParams.entries()) {\n const paramValues = super.getAll.call(this, paramName);\n\n const haveSameNumberOfParamValues = paramValues.length === super.getAll.call(otherParams, paramName).length;\n\n if (!haveSameNumberOfParamValues) {\n return false;\n }\n\n const paramValueExists = paramValues.includes(otherParamValue);\n\n if (!paramValueExists) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsassign `searchParams.assign()` API reference} */\n assign<OtherSchema extends LooseSchema>(...otherParamsArray: HttpSearchParams<OtherSchema>[]) {\n for (const otherParams of otherParamsArray) {\n if (this === (otherParams as unknown)) {\n continue;\n }\n\n for (const paramName of otherParams.keys()) {\n super.delete(paramName);\n }\n\n for (const [paramName, paramValue] of otherParams.entries()) {\n super.append(paramName, paramValue);\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamstoobject `searchParams.toObject()` API reference} */\n toObject() {\n const object = {} as this['_schema'];\n\n type SchemaValue = this['_schema'][HttpSearchParamsSchemaName<this['_schema']>];\n\n for (const [paramName, paramValue] of this.entries()) {\n if (paramName in object) {\n const existingParamValue = object[paramName] as SchemaValue[];\n\n if (Array.isArray<SchemaValue>(existingParamValue)) {\n existingParamValue.push(paramValue as SchemaValue);\n } else {\n object[paramName] = [existingParamValue, paramValue] as SchemaValue;\n }\n } else {\n object[paramName] = paramValue 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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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/** @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference} */\nexport type HttpSchema<Schema extends BaseHttpSchema = BaseHttpSchema> = Branded<Schema, 'HttpSchema'>;\n\nexport namespace HttpSchema {\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemamethods `HttpSchema.Methods` API reference} */\n export type Methods<Schema extends HttpMethodsSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemamethod `HttpSchema.Method` API reference} */\n export type Method<Schema extends HttpMethodSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemarequest `HttpSchema.Request` API reference} */\n export type Request<Schema extends HttpRequestSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaresponsebystatuscode `HttpSchema.ResponseByStatusCode` API reference} */\n export type ResponseByStatusCode<Schema extends HttpResponseSchemaByStatusCode> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaresponse `HttpSchema.Response` API reference} */\n export type Response<Schema extends HttpResponseSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemabody `HttpSchema.Body` API reference} */\n export type Body<Schema extends HttpBody.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaheaders `HttpSchema.Headers` API reference} */\n export type Headers<Schema extends HttpHeadersSchema.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemasearchparams `HttpSchema.SearchParams` API reference} */\n export type SearchParams<Schema extends HttpSearchParamsSchema.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapathparams `HttpSchema.PathParams` API reference} */\n export type PathParams<Schema extends HttpPathParamsSchema.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaformdata `HttpSchema.FormData` API reference} */\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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\ntype RepeatingPathParamModifier = '+';\ntype OptionalPathParamModifier = '?' | '*';\n\ntype ConvertPathParamToRecord<PathParam extends string> = PathParam extends `${infer PathParamWithoutSlash}/`\n ? ConvertPathParamToRecord<PathParamWithoutSlash>\n : PathParam extends `${infer PathParamWithoutSlash}\\\\:`\n ? ConvertPathParamToRecord<PathParamWithoutSlash>\n : PathParam extends `${infer PathParamWithoutModifier}${OptionalPathParamModifier}`\n ? { [Name in PathParamWithoutModifier]?: string }\n : PathParam extends `${infer PathParamWithoutModifier}${RepeatingPathParamModifier}`\n ? { [Name in PathParamWithoutModifier]: string }\n : { [Name in PathParam]: string };\n\ntype RecursiveInferPathParams<Path extends string> = Path extends `${infer Prefix}:${infer PathParamWithRemainingPath}`\n ? PathParamWithRemainingPath extends `${infer PathParam}/${infer RemainingPath}`\n ? Prefix extends `${string}\\\\`\n ? RecursiveInferPathParams<RemainingPath>\n : ConvertPathParamToRecord<PathParam> & RecursiveInferPathParams<RemainingPath>\n : PathParamWithRemainingPath extends `${infer PathParam}\\\\:${infer RemainingPath}`\n ? Prefix extends `${string}\\\\`\n ? RecursiveInferPathParams<`\\\\:${RemainingPath}`>\n : ConvertPathParamToRecord<PathParam> & RecursiveInferPathParams<`\\\\:${RemainingPath}`>\n : PathParamWithRemainingPath extends `${infer PathParam}:${infer RemainingPath}`\n ? Prefix extends `${string}\\\\`\n ? RecursiveInferPathParams<RemainingPath>\n : ConvertPathParamToRecord<PathParam> & RecursiveInferPathParams<`:${RemainingPath}`>\n : Prefix extends `${string}\\\\`\n ? {}\n : ConvertPathParamToRecord<PathParamWithRemainingPath>\n : {};\n\n/** @see {@link https://zimic.dev/docs/http/api/http-schema#inferpathparams `InferPathParams` API reference} */\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 WithoutEscapedColons<Path extends string> = Path extends `${infer Prefix}\\\\:${infer Suffix}`\n ? WithoutEscapedColons<`${Prefix}:${Suffix}`>\n : Path;\n\ntype ConvertPathParamToString<PathParam extends string> = PathParam extends `${infer PathParamWithoutSlash}/`\n ? `${ConvertPathParamToString<PathParamWithoutSlash>}/`\n : PathParam extends `${infer PathParamWithoutSlash}\\\\:`\n ? `${ConvertPathParamToString<PathParamWithoutSlash>}:`\n : string;\n\nexport type AllowAnyStringInPathParams<Path extends string> =\n Path extends `${infer Prefix}:${infer PathParamWithRemainingPath}`\n ? PathParamWithRemainingPath extends `${infer PathParam}/${infer RemainingPath}`\n ? Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${AllowAnyStringInPathParams<PathParamWithRemainingPath>}`\n : `${Prefix}${ConvertPathParamToString<PathParam>}/${AllowAnyStringInPathParams<RemainingPath>}`\n : PathParamWithRemainingPath extends `${infer PathParam}\\\\:${infer RemainingPath}`\n ? Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${AllowAnyStringInPathParams<PathParamWithRemainingPath>}`\n : `${Prefix}${ConvertPathParamToString<PathParam>}:${AllowAnyStringInPathParams<RemainingPath>}`\n : PathParamWithRemainingPath extends `${infer PathParam}:${infer RemainingPath}`\n ? Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${AllowAnyStringInPathParams<PathParamWithRemainingPath>}`\n : `${Prefix}${ConvertPathParamToString<PathParam>}${AllowAnyStringInPathParams<`:${RemainingPath}`>}`\n : Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${PathParamWithRemainingPath}`\n : `${Prefix}${ConvertPathParamToString<PathParamWithRemainingPath>}`\n : Path;\n\n/** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapath `HttpSchemaPath` API reference} */\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 /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapathliteral `HttpSchemaPath.Literal` API reference} */\n export type Literal<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>,\n > = LooseLiteral<Schema, Method>;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapathnonliteral `HttpSchemaPath.NonLiteral` API reference} */\n export type NonLiteral<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>,\n > = WithoutEscapedColons<AllowAnyStringInPathParams<LooseLiteral<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 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/** @see {@link https://zimic.dev/docs/http/api/http-schema#mergehttpresponsesbystatuscode `MergeHttpResponsesByStatusCode` API reference} */\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","import HttpFormData from '@/formData/HttpFormData';\nimport HttpSearchParams from '@/searchParams/HttpSearchParams';\nimport { HttpBody } from '@/types/requests';\n\n/**\n * Error thrown when a value is not valid {@link https://developer.mozilla.org/docs/Web/API/FormData FormData}. HTTP\n * interceptors might throw this error when trying to parse the body of a request or response with the header\n * `'content-type': 'multipart/form-data'`, if the content cannot be parsed to form data.\n */\nexport class InvalidFormDataError extends SyntaxError {\n constructor(value: string) {\n super(`Failed to parse value as form data: ${value}`);\n this.name = 'InvalidFormDataError';\n }\n}\n\n/**\n * Error thrown when a value is not valid JSON. HTTP interceptors might throw this error when trying to parse the body\n * of a request or response with the header `'content-type': 'application/json'`, if the content cannot be parsed to\n * JSON.\n */\nexport class InvalidJSONError extends SyntaxError {\n constructor(value: string) {\n super(`Failed to parse value as JSON: ${value}`);\n this.name = 'InvalidJSONError';\n }\n}\n\nasync function parseHttpBodyAsText<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsText = await resource.text();\n return (bodyAsText || null) as Body;\n}\n\nasync function parseHttpBodyAsBlob<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsBlob = await resource.blob();\n return bodyAsBlob as Body;\n}\n\nasync function parseHttpBodyAsFormData<Body extends HttpBody>(resource: Request | Response) {\n const resourceClone = resource.clone();\n\n try {\n const bodyAsRawFormData = await resource.formData();\n const bodyAsFormData = new HttpFormData();\n\n for (const [key, value] of bodyAsRawFormData) {\n bodyAsFormData.append(key, value);\n }\n\n return bodyAsFormData as Body;\n } catch {\n const bodyAsText = await resourceClone.text();\n\n if (!bodyAsText.trim()) {\n return null;\n }\n\n throw new InvalidFormDataError(bodyAsText);\n }\n}\n\nasync function parseHttpBodyAsSearchParams<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsText = await resource.text();\n\n if (!bodyAsText.trim()) {\n return null;\n }\n\n const bodyAsSearchParams = new HttpSearchParams(bodyAsText);\n return bodyAsSearchParams as Body;\n}\n\nasync function parseHttpBodyAsJSON<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsText = await resource.text();\n\n if (!bodyAsText.trim()) {\n return null;\n }\n\n try {\n const bodyAsJSON = JSON.parse(bodyAsText) as Body;\n return bodyAsJSON;\n } catch {\n throw new InvalidJSONError(bodyAsText);\n }\n}\n\n/**\n * Parses the body of a {@link https://developer.mozilla.org/docs/Web/API/Request request} or\n * {@link https://developer.mozilla.org/docs/Web/API/Response response} based on its `content-type` header.\n *\n * If the body is empty, `null` is returned. If the `content-type` header is not present or not recognized, an attempt\n * is made to parse the body as JSON, and if that fails, it is returned as a `Blob`.\n *\n * | `content-type` | Parsed as |\n * | ----------------------------------- | ------------------------------------------------------------------------ |\n * | `application/json` | `JSON` (object) |\n * | `application/xml` | `string` |\n * | `application/x-www-form-urlencoded` | [`HttpSearchParams`](https://zimic.dev/docs/http/api/http-search-params) |\n * | `application/*` (others) | `Blob` |\n * | `multipart/form-data` | [`HttpFormData`](https://zimic.dev/docs/http/api/http-form-data) |\n * | `multipart/*` (others) | `Blob` |\n * | `text/*` | `string` |\n * | `image/*` | `Blob` |\n * | `audio/*` | `Blob` |\n * | `font/*` | `Blob` |\n * | `video/*` | `Blob` |\n * | Others | `JSON` if possible, otherwise `Blob` |\n *\n * @throws {InvalidJSONError} If the `content-type` starts with `application/json` but the body cannot be parsed to\n * JSON.\n * @throws {InvalidFormDataError} If the `content-type` starts with `multipart/form-data` but the body cannot be parsed\n * to form data.\n */\nexport async function parseHttpBody<Body extends HttpBody = HttpBody>(resource: Request | Response) {\n const contentType = resource.headers.get('content-type');\n\n if (contentType?.startsWith('application/json')) {\n return parseHttpBodyAsJSON<Body>(resource);\n }\n\n if (contentType?.startsWith('multipart/form-data')) {\n return parseHttpBodyAsFormData<Body>(resource);\n }\n\n if (contentType?.startsWith('application/x-www-form-urlencoded')) {\n return parseHttpBodyAsSearchParams<Body>(resource);\n }\n\n if (contentType?.startsWith('text/') || contentType?.startsWith('application/xml')) {\n return parseHttpBodyAsText<Body>(resource);\n }\n\n if (\n contentType?.startsWith('application/') ||\n contentType?.startsWith('image/') ||\n contentType?.startsWith('audio/') ||\n contentType?.startsWith('font/') ||\n contentType?.startsWith('video/') ||\n contentType?.startsWith('multipart/')\n ) {\n return parseHttpBodyAsBlob<Body>(resource);\n }\n\n const resourceClone = resource.clone();\n\n try {\n return await parseHttpBodyAsJSON<Body>(resource);\n } catch {\n return parseHttpBodyAsBlob<Body>(resourceClone);\n }\n}\n"]}
1
+ {"version":3,"sources":["../../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","../src/utils/bodies.ts"],"names":["pickPrimitiveProperties"],"mappings":";;;AAAA,eAAe,UAAA,CAAW,MAAY,SAAA,EAAiB;AACrD,EAAA,IAAI,KAAK,IAAA,KAAS,SAAA,CAAU,QAAQ,IAAA,CAAK,IAAA,KAAS,UAAU,IAAA,EAAM;AAChE,IAAA,OAAO,KAAA;AACT,EAAA;AAEA,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,MAAA,EAAA,CAAS,SAAA,EAAA;AAC7B,EAAA,MAAM,WAAA,GAAc,SAAA,CAAU,MAAA,EAAA,CAAS,SAAA,EAAA;AAEvC,EAAA,IAAI,MAAA,GAAqB,IAAI,UAAA,CAAW,CAAC,CAAA;AACzC,EAAA,IAAI,WAAA,GAA0B,IAAI,UAAA,CAAW,CAAC,CAAA;AAE9C,EAAA,IAAI;AACF,IAAA,OAAO,IAAA,EAAM;AACX,MAAA,MAAM,qBAAsC,EAAA;AAE5C,MAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,QAAA,kBAAA,CAAmB,IAAA;AACjB,UAAA,MAAA,CAAO,IAAA,EAAA,CAAO,IAAA,CAAK,CAAC,MAAA,KAAW;AAC7B,YAAA,IAAI,CAAC,OAAO,IAAA,EAAM;AAChB,cAAA,MAAA,GAAS,MAAA,CAAO,KAAA;AAClB,YAAA;UAC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a,UAAA,CAAW,QAAQ,KAChC,WAAA,EAAa,UAAA,CAAW,OAAO,CAAA,IAC/B,WAAA,EAAa,UAAA,CAAW,QAAQ,CAAA,IAChC,WAAA,EAAa,UAAA,CAAW,YAAY,CAAA,EACpC;AACA,IAAA,OAAO,oBAA0B,QAAQ,CAAA;AAAA,EAC3C;AAEA,EAAA,MAAM,aAAA,GAAgB,SAAS,KAAA,EAAM;AAErC,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,oBAA0B,QAAQ,CAAA;AAAA,EACjD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,oBAA0B,aAAa,CAAA;AAAA,EAChD;AACF","file":"index.js","sourcesContent":["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 const bufferReadPromises: Promise<void>[] = [];\n\n if (buffer.length === 0) {\n bufferReadPromises.push(\n reader.read().then((result) => {\n if (!result.done) {\n buffer = result.value;\n }\n }),\n );\n }\n\n if (otherBuffer.length === 0) {\n bufferReadPromises.push(\n otherReader.read().then((result) => {\n if (!result.done) {\n otherBuffer = result.value;\n }\n }),\n );\n }\n\n await Promise.all(bufferReadPromises);\n\n const haveStreamsEndedTogether = buffer.length === 0 && otherBuffer.length === 0;\n\n if (haveStreamsEndedTogether) {\n return true;\n }\n\n const hasOneStreamEndedBeforeTheOther =\n (buffer.length === 0 && otherBuffer.length > 0) || (buffer.length > 0 && otherBuffer.length === 0);\n\n if (hasOneStreamEndedBeforeTheOther) {\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';\nimport { ArrayItemIfArray, Replace } from '@zimic/utils/types';\n\nimport { HttpFormDataSchema, HttpFormDataSchemaName, HttpFormDataSerialized } from './types';\n\n/** @see {@link https://zimic.dev/docs/http/api/http-form-data `HttpFormData` API reference} */\nclass HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFormDataSchema.Loose> extends FormData {\n readonly _schema!: HttpFormDataSerialized<LooseSchema>;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataset `formData.set()` API 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://zimic.dev/docs/http/api/http-form-data#formdataappend `formData.append()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataget `formData.get()` API reference} */\n get<Name extends HttpFormDataSchemaName.NonArray<this['_schema']>>(\n name: Name,\n ): Replace<Replace<ArrayItemIfArray<this['_schema'][Name]>, undefined, null>, Blob, File> {\n return super.get(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatagetall `formData.getAll()` API reference} */\n getAll<Name extends HttpFormDataSchemaName.Array<this['_schema']>>(\n name: Name,\n ): Replace<ArrayItemIfArray<NonNullable<this['_schema'][Name]>>, Blob, File>[] {\n return super.getAll(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatahas `formData.has()` API reference} */\n has<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): boolean {\n return super.has(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatadelete `formData.delete()` API reference} */\n delete<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): void {\n super.delete(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforeach `formData.forEach()` API reference} */\n forEach<This extends HttpFormData<this['_schema']>>(\n callback: <Key extends HttpFormDataSchemaName<this['_schema']>>(\n value: Replace<ArrayItemIfArray<NonNullable<this['_schema'][Key]>>, Blob, File>,\n key: Key,\n formData: 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://zimic.dev/docs/http/api/http-form-data#formdatakeys `formData.keys()` API reference} */\n keys(): FormDataIterator<HttpFormDataSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatavalues `formData.values()` API reference} */\n values(): FormDataIterator<\n Replace<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>\n > {\n return super.values() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataentries `formData.entries()` API reference} */\n entries(): FormDataIterator<\n [\n HttpFormDataSchemaName<this['_schema']>,\n Replace<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 Replace<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>,\n ]\n > {\n return super[Symbol.iterator]() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataequals `formData.equals()` API reference} */\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 fieldName of this.keys()) {\n if (!super.has.call(otherData, fieldName)) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatacontains `formData.contains()` API reference} */\n async contains<OtherSchema extends LooseSchema>(otherData: HttpFormData<OtherSchema>): Promise<boolean> {\n for (const [otherFieldName, otherFieldValue] of otherData.entries()) {\n const fieldValues = super.getAll.call(this, otherFieldName);\n\n const haveSameNumberOfFieldValues = fieldValues.length === super.getAll.call(otherData, otherFieldName).length;\n\n if (!haveSameNumberOfFieldValues) {\n return false;\n }\n\n let fieldValueExists = false;\n\n for (const fieldValue of fieldValues) {\n if (\n fieldValue === otherFieldValue ||\n (fieldValue instanceof Blob &&\n (otherFieldValue as Blob) instanceof Blob &&\n (await fileEquals(fieldValue, otherFieldValue)))\n ) {\n fieldValueExists = true;\n break;\n }\n }\n\n if (!fieldValueExists) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataassign `formData.assign()` API reference} */\n assign<OtherSchema extends LooseSchema>(...otherDataArray: HttpFormData<OtherSchema>[]) {\n for (const otherData of otherDataArray) {\n if (this === (otherData as unknown)) {\n continue;\n }\n\n for (const fieldName of otherData.keys()) {\n super.delete(fieldName);\n }\n\n for (const [fieldName, fieldValue] of otherData.entries()) {\n super.append(fieldName, fieldValue);\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatatoobject `formData.toObject()` API reference} */\n toObject() {\n const object = {} as this['_schema'];\n\n type SchemaValue = this['_schema'][HttpFormDataSchemaName<this['_schema']>];\n\n for (const [fieldName, fieldValue] of this.entries()) {\n if (fieldName in object) {\n const existingFieldValue = object[fieldName] as SchemaValue[];\n\n if (Array.isArray<SchemaValue>(existingFieldValue)) {\n existingFieldValue.push(fieldValue as SchemaValue);\n } else {\n object[fieldName] = [existingFieldValue, fieldValue] as SchemaValue;\n }\n } else {\n object[fieldName] = fieldValue as SchemaValue;\n }\n }\n\n return object;\n }\n}\n\nexport default HttpFormData;\n","import { Default, Replace } 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/** @see {@link https://zimic.dev/docs/http/api/http-headers `HttpHeaders` API reference} */\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://zimic.dev/docs/http/api/http-headers#headersset `headers.set()` API 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://zimic.dev/docs/http/api/http-headers#headersappend `headers.append()` API 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://zimic.dev/docs/http/api/http-headers#headersget `headers.get()` API reference} */\n get<Name extends HttpHeadersSchemaName<this['_schema']>>(\n name: Name,\n ): Replace<this['_schema'][Name], undefined, null> {\n return super.get(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetsetcookie `headers.getSetCookie()` API reference} */\n getSetCookie(): NonNullable<Default<this['_schema']['Set-Cookie'], string>>[] {\n return super.getSetCookie() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headershas `headers.has()` API reference} */\n has<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): boolean {\n return super.has(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersdelete `headers.delete()` API reference} */\n delete<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): void {\n super.delete(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforeach `headers.forEach()` API reference} */\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 headers: 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://zimic.dev/docs/http/api/http-headers#headerskeys `headers.keys()` API reference} */\n keys(): HeadersIterator<HttpHeadersSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersvalues `headers.values()` API reference} */\n values(): HeadersIterator<NonNullable<this['_schema'][HttpHeadersSchemaName<this['_schema']>]> & string> {\n return super.values() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersentries `headers.entries()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersequals `headers.equals()` API reference} */\n equals<OtherSchema extends LooseSchema>(otherHeaders: HttpHeaders<OtherSchema>): boolean {\n if (!this.contains(otherHeaders)) {\n return false;\n }\n\n for (const headerName of this.keys()) {\n if (!super.has.call(otherHeaders, headerName)) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerscontains `headers.contains()` API reference} */\n contains<OtherSchema extends LooseSchema>(otherHeaders: HttpHeaders<OtherSchema>): boolean {\n for (const [headerName, otherHeaderValue] of otherHeaders.entries()) {\n const headerValue = super.get.call(this, headerName);\n\n if (headerValue === null) {\n return false;\n }\n\n const headerValueItems = this.splitHeaderValues(headerValue);\n const otherHeaderValueItems = this.splitHeaderValues(otherHeaderValue);\n\n const haveSameNumberOfHeaderValues = headerValueItems.length === otherHeaderValueItems.length;\n\n if (!haveSameNumberOfHeaderValues) {\n return false;\n }\n\n for (const otherValueItem of otherHeaderValueItems) {\n if (!headerValueItems.includes(otherValueItem)) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersassign `headers.assign()` API reference} */\n assign<OtherSchema extends LooseSchema>(...otherHeadersArray: HttpHeaders<OtherSchema>[]) {\n for (const otherHeaders of otherHeadersArray) {\n if (this === (otherHeaders as unknown)) {\n continue;\n }\n\n for (const headerName of otherHeaders.keys()) {\n super.delete(headerName);\n }\n\n for (const [headerName, headerValue] of otherHeaders.entries()) {\n super.append(headerName, headerValue);\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerstoobject `headers.toObject()` API reference} */\n toObject(): this['_schema'] {\n const object = {} as this['_schema'];\n\n for (const [headerName, headerValue] of this.entries()) {\n object[headerName] = headerValue;\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 { Replace, 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/** @see {@link https://zimic.dev/docs/http/api/http-search-params `HttpSearchParams` API reference} */\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 [paramName, paramValues] of Object.entries(init)) {\n if (Array.isArray(paramValues)) {\n for (const paramValue of paramValues as unknown[]) {\n super.append(paramName, String(paramValue));\n }\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsset `searchParams.set()` API 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://zimic.dev/docs/http/api/http-search-params#searchparamsappend `searchParams.append()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsget `searchParams.get()` API reference} */\n get<Name extends HttpSearchParamsSchemaName.NonArray<this['_schema']>>(\n name: Name,\n ): Replace<ArrayItemIfArray<this['_schema'][Name]>, undefined, null> {\n return super.get(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsgetall `searchParams.getAll()` API reference} */\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://zimic.dev/docs/http/api/http-search-params#searchparamshas `searchParams.has()` API 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://zimic.dev/docs/http/api/http-search-params#searchparamsdelete `searchParams.delete()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforeach `searchParams.forEach()` API reference} */\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 searchParams: 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://zimic.dev/docs/http/api/http-search-params#searchparamskeys `searchParams.keys()` API reference} */\n keys(): URLSearchParamsIterator<HttpSearchParamsSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsvalues `searchParams.values()` API 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://zimic.dev/docs/http/api/http-search-params#searchparamsentries `searchParams.entries()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsequals `searchParams.equals()` API reference} */\n equals<OtherSchema extends LooseSchema>(otherParams: HttpSearchParams<OtherSchema>): boolean {\n return this.contains(otherParams) && this.size === otherParams.size;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamscontains `searchParams.contains()` API reference} */\n contains<OtherSchema extends LooseSchema>(otherParams: HttpSearchParams<OtherSchema>): boolean {\n for (const [paramName, otherParamValue] of otherParams.entries()) {\n const paramValues = super.getAll.call(this, paramName);\n\n const haveSameNumberOfParamValues = paramValues.length === super.getAll.call(otherParams, paramName).length;\n\n if (!haveSameNumberOfParamValues) {\n return false;\n }\n\n const paramValueExists = paramValues.includes(otherParamValue);\n\n if (!paramValueExists) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsassign `searchParams.assign()` API reference} */\n assign<OtherSchema extends LooseSchema>(...otherParamsArray: HttpSearchParams<OtherSchema>[]) {\n for (const otherParams of otherParamsArray) {\n if (this === (otherParams as unknown)) {\n continue;\n }\n\n for (const paramName of otherParams.keys()) {\n super.delete(paramName);\n }\n\n for (const [paramName, paramValue] of otherParams.entries()) {\n super.append(paramName, paramValue);\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamstoobject `searchParams.toObject()` API reference} */\n toObject() {\n const object = {} as this['_schema'];\n\n type SchemaValue = this['_schema'][HttpSearchParamsSchemaName<this['_schema']>];\n\n for (const [paramName, paramValue] of this.entries()) {\n if (paramName in object) {\n const existingParamValue = object[paramName] as SchemaValue[];\n\n if (Array.isArray<SchemaValue>(existingParamValue)) {\n existingParamValue.push(paramValue as SchemaValue);\n } else {\n object[paramName] = [existingParamValue, paramValue] as SchemaValue;\n }\n } else {\n object[paramName] = paramValue 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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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/** @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference} */\nexport type HttpSchema<Schema extends BaseHttpSchema = BaseHttpSchema> = Branded<Schema, 'HttpSchema'>;\n\nexport namespace HttpSchema {\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemamethods `HttpSchema.Methods` API reference} */\n export type Methods<Schema extends HttpMethodsSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemamethod `HttpSchema.Method` API reference} */\n export type Method<Schema extends HttpMethodSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemarequest `HttpSchema.Request` API reference} */\n export type Request<Schema extends HttpRequestSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaresponsebystatuscode `HttpSchema.ResponseByStatusCode` API reference} */\n export type ResponseByStatusCode<Schema extends HttpResponseSchemaByStatusCode> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaresponse `HttpSchema.Response` API reference} */\n export type Response<Schema extends HttpResponseSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemabody `HttpSchema.Body` API reference} */\n export type Body<Schema extends HttpBody.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaheaders `HttpSchema.Headers` API reference} */\n export type Headers<Schema extends HttpHeadersSchema.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemasearchparams `HttpSchema.SearchParams` API reference} */\n export type SearchParams<Schema extends HttpSearchParamsSchema.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapathparams `HttpSchema.PathParams` API reference} */\n export type PathParams<Schema extends HttpPathParamsSchema.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaformdata `HttpSchema.FormData` API reference} */\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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\ntype RepeatingPathParamModifier = '+';\ntype OptionalPathParamModifier = '?' | '*';\n\ntype ConvertPathParamToRecord<PathParam extends string> = PathParam extends `${infer PathParamWithoutSlash}/`\n ? ConvertPathParamToRecord<PathParamWithoutSlash>\n : PathParam extends `${infer PathParamWithoutSlash}\\\\:`\n ? ConvertPathParamToRecord<PathParamWithoutSlash>\n : PathParam extends `${infer PathParamWithoutModifier}${OptionalPathParamModifier}`\n ? { [Name in PathParamWithoutModifier]?: string }\n : PathParam extends `${infer PathParamWithoutModifier}${RepeatingPathParamModifier}`\n ? { [Name in PathParamWithoutModifier]: string }\n : { [Name in PathParam]: string };\n\ntype RecursiveInferPathParams<Path extends string> = Path extends `${infer Prefix}:${infer PathParamWithRemainingPath}`\n ? PathParamWithRemainingPath extends `${infer PathParam}/${infer RemainingPath}`\n ? Prefix extends `${string}\\\\`\n ? RecursiveInferPathParams<RemainingPath>\n : ConvertPathParamToRecord<PathParam> & RecursiveInferPathParams<RemainingPath>\n : PathParamWithRemainingPath extends `${infer PathParam}\\\\:${infer RemainingPath}`\n ? Prefix extends `${string}\\\\`\n ? RecursiveInferPathParams<`\\\\:${RemainingPath}`>\n : ConvertPathParamToRecord<PathParam> & RecursiveInferPathParams<`\\\\:${RemainingPath}`>\n : PathParamWithRemainingPath extends `${infer PathParam}:${infer RemainingPath}`\n ? Prefix extends `${string}\\\\`\n ? RecursiveInferPathParams<RemainingPath>\n : ConvertPathParamToRecord<PathParam> & RecursiveInferPathParams<`:${RemainingPath}`>\n : Prefix extends `${string}\\\\`\n ? {}\n : ConvertPathParamToRecord<PathParamWithRemainingPath>\n : {};\n\n/** @see {@link https://zimic.dev/docs/http/api/http-schema#inferpathparams `InferPathParams` API reference} */\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 WithoutEscapedColons<Path extends string> = Path extends `${infer Prefix}\\\\:${infer Suffix}`\n ? WithoutEscapedColons<`${Prefix}:${Suffix}`>\n : Path;\n\ntype ConvertPathParamToString<PathParam extends string> = PathParam extends `${infer PathParamWithoutSlash}/`\n ? `${ConvertPathParamToString<PathParamWithoutSlash>}/`\n : PathParam extends `${infer PathParamWithoutSlash}\\\\:`\n ? `${ConvertPathParamToString<PathParamWithoutSlash>}:`\n : string;\n\nexport type AllowAnyStringInPathParams<Path extends string> =\n Path extends `${infer Prefix}:${infer PathParamWithRemainingPath}`\n ? PathParamWithRemainingPath extends `${infer PathParam}/${infer RemainingPath}`\n ? Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${AllowAnyStringInPathParams<PathParamWithRemainingPath>}`\n : `${Prefix}${ConvertPathParamToString<PathParam>}/${AllowAnyStringInPathParams<RemainingPath>}`\n : PathParamWithRemainingPath extends `${infer PathParam}\\\\:${infer RemainingPath}`\n ? Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${AllowAnyStringInPathParams<PathParamWithRemainingPath>}`\n : `${Prefix}${ConvertPathParamToString<PathParam>}:${AllowAnyStringInPathParams<RemainingPath>}`\n : PathParamWithRemainingPath extends `${infer PathParam}:${infer RemainingPath}`\n ? Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${AllowAnyStringInPathParams<PathParamWithRemainingPath>}`\n : `${Prefix}${ConvertPathParamToString<PathParam>}${AllowAnyStringInPathParams<`:${RemainingPath}`>}`\n : Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${PathParamWithRemainingPath}`\n : `${Prefix}${ConvertPathParamToString<PathParamWithRemainingPath>}`\n : Path;\n\n/** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapath `HttpSchemaPath` API reference} */\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 /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapathliteral `HttpSchemaPath.Literal` API reference} */\n export type Literal<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>,\n > = LooseLiteral<Schema, Method>;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapathnonliteral `HttpSchemaPath.NonLiteral` API reference} */\n export type NonLiteral<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>,\n > = WithoutEscapedColons<AllowAnyStringInPathParams<LooseLiteral<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 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/** @see {@link https://zimic.dev/docs/http/api/http-schema#mergehttpresponsesbystatuscode `MergeHttpResponsesByStatusCode` API reference} */\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","import HttpFormData from '@/formData/HttpFormData';\nimport HttpSearchParams from '@/searchParams/HttpSearchParams';\nimport { HttpBody } from '@/types/requests';\n\n/**\n * Error thrown when a value is not valid {@link https://developer.mozilla.org/docs/Web/API/FormData FormData}. HTTP\n * interceptors might throw this error when trying to parse the body of a request or response with the header\n * `'content-type': 'multipart/form-data'`, if the content cannot be parsed to form data.\n */\nexport class InvalidFormDataError extends SyntaxError {\n constructor(value: string) {\n super(`Failed to parse value as form data: ${value}`);\n this.name = 'InvalidFormDataError';\n }\n}\n\n/**\n * Error thrown when a value is not valid JSON. HTTP interceptors might throw this error when trying to parse the body\n * of a request or response with the header `'content-type': 'application/json'`, if the content cannot be parsed to\n * JSON.\n */\nexport class InvalidJSONError extends SyntaxError {\n constructor(value: string) {\n super(`Failed to parse value as JSON: ${value}`);\n this.name = 'InvalidJSONError';\n }\n}\n\nasync function parseHttpBodyAsText<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsText = await resource.text();\n return (bodyAsText || null) as Body;\n}\n\nasync function parseHttpBodyAsBlob<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsBlob = await resource.blob();\n return bodyAsBlob as Body;\n}\n\nasync function parseHttpBodyAsFormData<Body extends HttpBody>(resource: Request | Response) {\n const resourceClone = resource.clone();\n\n try {\n const bodyAsRawFormData = await resource.formData();\n const bodyAsFormData = new HttpFormData();\n\n for (const [key, value] of bodyAsRawFormData) {\n bodyAsFormData.append(key, value);\n }\n\n return bodyAsFormData as Body;\n } catch {\n const bodyAsText = await resourceClone.text();\n\n if (!bodyAsText.trim()) {\n return null;\n }\n\n throw new InvalidFormDataError(bodyAsText);\n }\n}\n\nasync function parseHttpBodyAsSearchParams<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsText = await resource.text();\n\n if (!bodyAsText.trim()) {\n return null;\n }\n\n const bodyAsSearchParams = new HttpSearchParams(bodyAsText);\n return bodyAsSearchParams as Body;\n}\n\nasync function parseHttpBodyAsJSON<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsText = await resource.text();\n\n if (!bodyAsText.trim()) {\n return null;\n }\n\n try {\n const bodyAsJSON = JSON.parse(bodyAsText) as Body;\n return bodyAsJSON;\n } catch {\n throw new InvalidJSONError(bodyAsText);\n }\n}\n\n/**\n * Parses the body of a {@link https://developer.mozilla.org/docs/Web/API/Request request} or\n * {@link https://developer.mozilla.org/docs/Web/API/Response response} based on its `content-type` header.\n *\n * If the body is empty, `null` is returned. If the `content-type` header is not present or not recognized, an attempt\n * is made to parse the body as JSON, and if that fails, it is returned as a `Blob`.\n *\n * | `content-type` | Parsed as |\n * | ----------------------------------- | ------------------------------------------------------------------------ |\n * | `application/json` | `JSON` (object) |\n * | `application/xml` | `string` |\n * | `application/x-www-form-urlencoded` | [`HttpSearchParams`](https://zimic.dev/docs/http/api/http-search-params) |\n * | `application/*` (others) | `Blob` |\n * | `multipart/form-data` | [`HttpFormData`](https://zimic.dev/docs/http/api/http-form-data) |\n * | `multipart/*` (others) | `Blob` |\n * | `text/*` | `string` |\n * | `image/*` | `Blob` |\n * | `audio/*` | `Blob` |\n * | `font/*` | `Blob` |\n * | `video/*` | `Blob` |\n * | Others | `JSON` if possible, otherwise `Blob` |\n *\n * @throws {InvalidJSONError} If the `content-type` starts with `application/json` but the body cannot be parsed to\n * JSON.\n * @throws {InvalidFormDataError} If the `content-type` starts with `multipart/form-data` but the body cannot be parsed\n * to form data.\n */\nexport async function parseHttpBody<Body extends HttpBody = HttpBody>(resource: Request | Response) {\n const contentType = resource.headers.get('content-type');\n\n if (contentType?.startsWith('application/json')) {\n return parseHttpBodyAsJSON<Body>(resource);\n }\n\n if (contentType?.startsWith('multipart/form-data')) {\n return parseHttpBodyAsFormData<Body>(resource);\n }\n\n if (contentType?.startsWith('application/x-www-form-urlencoded')) {\n return parseHttpBodyAsSearchParams<Body>(resource);\n }\n\n if (contentType?.startsWith('text/') || contentType?.startsWith('application/xml')) {\n return parseHttpBodyAsText<Body>(resource);\n }\n\n if (\n contentType?.startsWith('application/') ||\n contentType?.startsWith('image/') ||\n contentType?.startsWith('audio/') ||\n contentType?.startsWith('font/') ||\n contentType?.startsWith('video/') ||\n contentType?.startsWith('multipart/')\n ) {\n return parseHttpBodyAsBlob<Body>(resource);\n }\n\n const resourceClone = resource.clone();\n\n try {\n return await parseHttpBodyAsJSON<Body>(resource);\n } catch {\n return parseHttpBodyAsBlob<Body>(resourceClone);\n }\n}\n"]}
package/dist/index.mjs CHANGED
@@ -90,7 +90,7 @@ var HttpFormData = class extends FormData {
90
90
  delete(name) {
91
91
  super.delete(name);
92
92
  }
93
- /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforEach `formData.forEach()` API reference} */
93
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforeach `formData.forEach()` API reference} */
94
94
  forEach(callback, thisArg) {
95
95
  super.forEach(callback, thisArg);
96
96
  }
@@ -206,7 +206,7 @@ var HttpHeaders = class extends Headers {
206
206
  get(name) {
207
207
  return super.get(name);
208
208
  }
209
- /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetSetCookie `headers.getSetCookie()` API reference} */
209
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetsetcookie `headers.getSetCookie()` API reference} */
210
210
  getSetCookie() {
211
211
  return super.getSetCookie();
212
212
  }
@@ -218,7 +218,7 @@ var HttpHeaders = class extends Headers {
218
218
  delete(name) {
219
219
  super.delete(name);
220
220
  }
221
- /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforEach `headers.forEach()` API reference} */
221
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforeach `headers.forEach()` API reference} */
222
222
  forEach(callback, thisArg) {
223
223
  super.forEach(callback, thisArg);
224
224
  }
@@ -354,7 +354,7 @@ var HttpSearchParams = class extends URLSearchParams {
354
354
  delete(name, value) {
355
355
  super.delete(name, value);
356
356
  }
357
- /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforEach `searchParams.forEach()` API reference} */
357
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforeach `searchParams.forEach()` API reference} */
358
358
  forEach(callback, thisArg) {
359
359
  super.forEach(callback, thisArg);
360
360
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../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","../src/utils/bodies.ts"],"names":["pickPrimitiveProperties"],"mappings":";AAAA,eAAe,UAAA,CAAW,MAAY,SAAA,EAAiB;AACrD,EAAA,IAAI,KAAK,IAAA,KAAS,SAAA,CAAU,QAAQ,IAAA,CAAK,IAAA,KAAS,UAAU,IAAA,EAAM;AAChE,IAAA,OAAO,KAAA;AACT,EAAA;AAEA,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,MAAA,EAAA,CAAS,SAAA,EAAA;AAC7B,EAAA,MAAM,WAAA,G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B,QAAQ,CAAA;AAAA,EAC3C;AAEA,EAAA,IAAI,WAAA,EAAa,UAAA,CAAW,qBAAqB,CAAA,EAAG;AAClD,IAAA,OAAO,wBAA8B,QAAQ,CAAA;AAAA,EAC/C;AAEA,EAAA,IAAI,WAAA,EAAa,UAAA,CAAW,mCAAmC,CAAA,EAAG;AAChE,IAAA,OAAO,4BAAkC,QAAQ,CAAA;AAAA,EACnD;AAEA,EAAA,IAAI,aAAa,UAAA,CAAW,OAAO,KAAK,WAAA,EAAa,UAAA,CAAW,iBAAiB,CAAA,EAAG;AAClF,IAAA,OAAO,oBAA0B,QAAQ,CAAA;AAAA,EAC3C;AAEA,EAAA,IACE,WAAA,EAAa,WAAW,cAAc,CAAA,IACtC,aAAa,UAAA,CAAW,QAAQ,CAAA,IAChC,WAAA,EAAa,UAAA,CAAW,QAAQ,KAChC,WAAA,EAAa,UAAA,CAAW,OAAO,CAAA,IAC/B,WAAA,EAAa,UAAA,CAAW,QAAQ,CAAA,IAChC,WAAA,EAAa,UAAA,CAAW,YAAY,CAAA,EACpC;AACA,IAAA,OAAO,oBAA0B,QAAQ,CAAA;AAAA,EAC3C;AAEA,EAAA,MAAM,aAAA,GAAgB,SAAS,KAAA,EAAM;AAErC,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,oBAA0B,QAAQ,CAAA;AAAA,EACjD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,oBAA0B,aAAa,CAAA;AAAA,EAChD;AACF","file":"index.mjs","sourcesContent":["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 const bufferReadPromises: Promise<void>[] = [];\n\n if (buffer.length === 0) {\n bufferReadPromises.push(\n reader.read().then((result) => {\n if (!result.done) {\n buffer = result.value;\n }\n }),\n );\n }\n\n if (otherBuffer.length === 0) {\n bufferReadPromises.push(\n otherReader.read().then((result) => {\n if (!result.done) {\n otherBuffer = result.value;\n }\n }),\n );\n }\n\n await Promise.all(bufferReadPromises);\n\n const haveStreamsEndedTogether = buffer.length === 0 && otherBuffer.length === 0;\n\n if (haveStreamsEndedTogether) {\n return true;\n }\n\n const hasOneStreamEndedBeforeTheOther =\n (buffer.length === 0 && otherBuffer.length > 0) || (buffer.length > 0 && otherBuffer.length === 0);\n\n if (hasOneStreamEndedBeforeTheOther) {\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';\nimport { ArrayItemIfArray, Replace } from '@zimic/utils/types';\n\nimport { HttpFormDataSchema, HttpFormDataSchemaName, HttpFormDataSerialized } from './types';\n\n/** @see {@link https://zimic.dev/docs/http/api/http-form-data `HttpFormData` API reference} */\nclass HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFormDataSchema.Loose> extends FormData {\n readonly _schema!: HttpFormDataSerialized<LooseSchema>;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataset `formData.set()` API 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://zimic.dev/docs/http/api/http-form-data#formdataappend `formData.append()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataget `formData.get()` API reference} */\n get<Name extends HttpFormDataSchemaName.NonArray<this['_schema']>>(\n name: Name,\n ): Replace<Replace<ArrayItemIfArray<this['_schema'][Name]>, undefined, null>, Blob, File> {\n return super.get(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatagetall `formData.getAll()` API reference} */\n getAll<Name extends HttpFormDataSchemaName.Array<this['_schema']>>(\n name: Name,\n ): Replace<ArrayItemIfArray<NonNullable<this['_schema'][Name]>>, Blob, File>[] {\n return super.getAll(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatahas `formData.has()` API reference} */\n has<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): boolean {\n return super.has(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatadelete `formData.delete()` API reference} */\n delete<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): void {\n super.delete(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforEach `formData.forEach()` API reference} */\n forEach<This extends HttpFormData<this['_schema']>>(\n callback: <Key extends HttpFormDataSchemaName<this['_schema']>>(\n value: Replace<ArrayItemIfArray<NonNullable<this['_schema'][Key]>>, Blob, File>,\n key: Key,\n formData: 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://zimic.dev/docs/http/api/http-form-data#formdatakeys `formData.keys()` API reference} */\n keys(): FormDataIterator<HttpFormDataSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatavalues `formData.values()` API reference} */\n values(): FormDataIterator<\n Replace<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>\n > {\n return super.values() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataentries `formData.entries()` API reference} */\n entries(): FormDataIterator<\n [\n HttpFormDataSchemaName<this['_schema']>,\n Replace<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 Replace<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>,\n ]\n > {\n return super[Symbol.iterator]() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataequals `formData.equals()` API reference} */\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 fieldName of this.keys()) {\n if (!super.has.call(otherData, fieldName)) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatacontains `formData.contains()` API reference} */\n async contains<OtherSchema extends LooseSchema>(otherData: HttpFormData<OtherSchema>): Promise<boolean> {\n for (const [otherFieldName, otherFieldValue] of otherData.entries()) {\n const fieldValues = super.getAll.call(this, otherFieldName);\n\n const haveSameNumberOfFieldValues = fieldValues.length === super.getAll.call(otherData, otherFieldName).length;\n\n if (!haveSameNumberOfFieldValues) {\n return false;\n }\n\n let fieldValueExists = false;\n\n for (const fieldValue of fieldValues) {\n if (\n fieldValue === otherFieldValue ||\n (fieldValue instanceof Blob &&\n (otherFieldValue as Blob) instanceof Blob &&\n (await fileEquals(fieldValue, otherFieldValue)))\n ) {\n fieldValueExists = true;\n break;\n }\n }\n\n if (!fieldValueExists) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataassign `formData.assign()` API reference} */\n assign<OtherSchema extends LooseSchema>(...otherDataArray: HttpFormData<OtherSchema>[]) {\n for (const otherData of otherDataArray) {\n if (this === (otherData as unknown)) {\n continue;\n }\n\n for (const fieldName of otherData.keys()) {\n super.delete(fieldName);\n }\n\n for (const [fieldName, fieldValue] of otherData.entries()) {\n super.append(fieldName, fieldValue);\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatatoobject `formData.toObject()` API reference} */\n toObject() {\n const object = {} as this['_schema'];\n\n type SchemaValue = this['_schema'][HttpFormDataSchemaName<this['_schema']>];\n\n for (const [fieldName, fieldValue] of this.entries()) {\n if (fieldName in object) {\n const existingFieldValue = object[fieldName] as SchemaValue[];\n\n if (Array.isArray<SchemaValue>(existingFieldValue)) {\n existingFieldValue.push(fieldValue as SchemaValue);\n } else {\n object[fieldName] = [existingFieldValue, fieldValue] as SchemaValue;\n }\n } else {\n object[fieldName] = fieldValue as SchemaValue;\n }\n }\n\n return object;\n }\n}\n\nexport default HttpFormData;\n","import { Default, Replace } 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/** @see {@link https://zimic.dev/docs/http/api/http-headers `HttpHeaders` API reference} */\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://zimic.dev/docs/http/api/http-headers#headersset `headers.set()` API 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://zimic.dev/docs/http/api/http-headers#headersappend `headers.append()` API 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://zimic.dev/docs/http/api/http-headers#headersget `headers.get()` API reference} */\n get<Name extends HttpHeadersSchemaName<this['_schema']>>(\n name: Name,\n ): Replace<this['_schema'][Name], undefined, null> {\n return super.get(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetSetCookie `headers.getSetCookie()` API reference} */\n getSetCookie(): NonNullable<Default<this['_schema']['Set-Cookie'], string>>[] {\n return super.getSetCookie() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headershas `headers.has()` API reference} */\n has<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): boolean {\n return super.has(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersdelete `headers.delete()` API reference} */\n delete<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): void {\n super.delete(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforEach `headers.forEach()` API reference} */\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 headers: 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://zimic.dev/docs/http/api/http-headers#headerskeys `headers.keys()` API reference} */\n keys(): HeadersIterator<HttpHeadersSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersvalues `headers.values()` API reference} */\n values(): HeadersIterator<NonNullable<this['_schema'][HttpHeadersSchemaName<this['_schema']>]> & string> {\n return super.values() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersentries `headers.entries()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersequals `headers.equals()` API reference} */\n equals<OtherSchema extends LooseSchema>(otherHeaders: HttpHeaders<OtherSchema>): boolean {\n if (!this.contains(otherHeaders)) {\n return false;\n }\n\n for (const headerName of this.keys()) {\n if (!super.has.call(otherHeaders, headerName)) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerscontains `headers.contains()` API reference} */\n contains<OtherSchema extends LooseSchema>(otherHeaders: HttpHeaders<OtherSchema>): boolean {\n for (const [headerName, otherHeaderValue] of otherHeaders.entries()) {\n const headerValue = super.get.call(this, headerName);\n\n if (headerValue === null) {\n return false;\n }\n\n const headerValueItems = this.splitHeaderValues(headerValue);\n const otherHeaderValueItems = this.splitHeaderValues(otherHeaderValue);\n\n const haveSameNumberOfHeaderValues = headerValueItems.length === otherHeaderValueItems.length;\n\n if (!haveSameNumberOfHeaderValues) {\n return false;\n }\n\n for (const otherValueItem of otherHeaderValueItems) {\n if (!headerValueItems.includes(otherValueItem)) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersassign `headers.assign()` API reference} */\n assign<OtherSchema extends LooseSchema>(...otherHeadersArray: HttpHeaders<OtherSchema>[]) {\n for (const otherHeaders of otherHeadersArray) {\n if (this === (otherHeaders as unknown)) {\n continue;\n }\n\n for (const headerName of otherHeaders.keys()) {\n super.delete(headerName);\n }\n\n for (const [headerName, headerValue] of otherHeaders.entries()) {\n super.append(headerName, headerValue);\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerstoobject `headers.toObject()` API reference} */\n toObject(): this['_schema'] {\n const object = {} as this['_schema'];\n\n for (const [headerName, headerValue] of this.entries()) {\n object[headerName] = headerValue;\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 { Replace, 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/** @see {@link https://zimic.dev/docs/http/api/http-search-params `HttpSearchParams` API reference} */\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 [paramName, paramValues] of Object.entries(init)) {\n if (Array.isArray(paramValues)) {\n for (const paramValue of paramValues as unknown[]) {\n super.append(paramName, String(paramValue));\n }\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsset `searchParams.set()` API 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://zimic.dev/docs/http/api/http-search-params#searchparamsappend `searchParams.append()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsget `searchParams.get()` API reference} */\n get<Name extends HttpSearchParamsSchemaName.NonArray<this['_schema']>>(\n name: Name,\n ): Replace<ArrayItemIfArray<this['_schema'][Name]>, undefined, null> {\n return super.get(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsgetall `searchParams.getAll()` API reference} */\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://zimic.dev/docs/http/api/http-search-params#searchparamshas `searchParams.has()` API 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://zimic.dev/docs/http/api/http-search-params#searchparamsdelete `searchParams.delete()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforEach `searchParams.forEach()` API reference} */\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 searchParams: 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://zimic.dev/docs/http/api/http-search-params#searchparamskeys `searchParams.keys()` API reference} */\n keys(): URLSearchParamsIterator<HttpSearchParamsSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsvalues `searchParams.values()` API 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://zimic.dev/docs/http/api/http-search-params#searchparamsentries `searchParams.entries()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsequals `searchParams.equals()` API reference} */\n equals<OtherSchema extends LooseSchema>(otherParams: HttpSearchParams<OtherSchema>): boolean {\n return this.contains(otherParams) && this.size === otherParams.size;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamscontains `searchParams.contains()` API reference} */\n contains<OtherSchema extends LooseSchema>(otherParams: HttpSearchParams<OtherSchema>): boolean {\n for (const [paramName, otherParamValue] of otherParams.entries()) {\n const paramValues = super.getAll.call(this, paramName);\n\n const haveSameNumberOfParamValues = paramValues.length === super.getAll.call(otherParams, paramName).length;\n\n if (!haveSameNumberOfParamValues) {\n return false;\n }\n\n const paramValueExists = paramValues.includes(otherParamValue);\n\n if (!paramValueExists) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsassign `searchParams.assign()` API reference} */\n assign<OtherSchema extends LooseSchema>(...otherParamsArray: HttpSearchParams<OtherSchema>[]) {\n for (const otherParams of otherParamsArray) {\n if (this === (otherParams as unknown)) {\n continue;\n }\n\n for (const paramName of otherParams.keys()) {\n super.delete(paramName);\n }\n\n for (const [paramName, paramValue] of otherParams.entries()) {\n super.append(paramName, paramValue);\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamstoobject `searchParams.toObject()` API reference} */\n toObject() {\n const object = {} as this['_schema'];\n\n type SchemaValue = this['_schema'][HttpSearchParamsSchemaName<this['_schema']>];\n\n for (const [paramName, paramValue] of this.entries()) {\n if (paramName in object) {\n const existingParamValue = object[paramName] as SchemaValue[];\n\n if (Array.isArray<SchemaValue>(existingParamValue)) {\n existingParamValue.push(paramValue as SchemaValue);\n } else {\n object[paramName] = [existingParamValue, paramValue] as SchemaValue;\n }\n } else {\n object[paramName] = paramValue 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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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/** @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference} */\nexport type HttpSchema<Schema extends BaseHttpSchema = BaseHttpSchema> = Branded<Schema, 'HttpSchema'>;\n\nexport namespace HttpSchema {\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemamethods `HttpSchema.Methods` API reference} */\n export type Methods<Schema extends HttpMethodsSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemamethod `HttpSchema.Method` API reference} */\n export type Method<Schema extends HttpMethodSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemarequest `HttpSchema.Request` API reference} */\n export type Request<Schema extends HttpRequestSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaresponsebystatuscode `HttpSchema.ResponseByStatusCode` API reference} */\n export type ResponseByStatusCode<Schema extends HttpResponseSchemaByStatusCode> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaresponse `HttpSchema.Response` API reference} */\n export type Response<Schema extends HttpResponseSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemabody `HttpSchema.Body` API reference} */\n export type Body<Schema extends HttpBody.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaheaders `HttpSchema.Headers` API reference} */\n export type Headers<Schema extends HttpHeadersSchema.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemasearchparams `HttpSchema.SearchParams` API reference} */\n export type SearchParams<Schema extends HttpSearchParamsSchema.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapathparams `HttpSchema.PathParams` API reference} */\n export type PathParams<Schema extends HttpPathParamsSchema.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaformdata `HttpSchema.FormData` API reference} */\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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\ntype RepeatingPathParamModifier = '+';\ntype OptionalPathParamModifier = '?' | '*';\n\ntype ConvertPathParamToRecord<PathParam extends string> = PathParam extends `${infer PathParamWithoutSlash}/`\n ? ConvertPathParamToRecord<PathParamWithoutSlash>\n : PathParam extends `${infer PathParamWithoutSlash}\\\\:`\n ? ConvertPathParamToRecord<PathParamWithoutSlash>\n : PathParam extends `${infer PathParamWithoutModifier}${OptionalPathParamModifier}`\n ? { [Name in PathParamWithoutModifier]?: string }\n : PathParam extends `${infer PathParamWithoutModifier}${RepeatingPathParamModifier}`\n ? { [Name in PathParamWithoutModifier]: string }\n : { [Name in PathParam]: string };\n\ntype RecursiveInferPathParams<Path extends string> = Path extends `${infer Prefix}:${infer PathParamWithRemainingPath}`\n ? PathParamWithRemainingPath extends `${infer PathParam}/${infer RemainingPath}`\n ? Prefix extends `${string}\\\\`\n ? RecursiveInferPathParams<RemainingPath>\n : ConvertPathParamToRecord<PathParam> & RecursiveInferPathParams<RemainingPath>\n : PathParamWithRemainingPath extends `${infer PathParam}\\\\:${infer RemainingPath}`\n ? Prefix extends `${string}\\\\`\n ? RecursiveInferPathParams<`\\\\:${RemainingPath}`>\n : ConvertPathParamToRecord<PathParam> & RecursiveInferPathParams<`\\\\:${RemainingPath}`>\n : PathParamWithRemainingPath extends `${infer PathParam}:${infer RemainingPath}`\n ? Prefix extends `${string}\\\\`\n ? RecursiveInferPathParams<RemainingPath>\n : ConvertPathParamToRecord<PathParam> & RecursiveInferPathParams<`:${RemainingPath}`>\n : Prefix extends `${string}\\\\`\n ? {}\n : ConvertPathParamToRecord<PathParamWithRemainingPath>\n : {};\n\n/** @see {@link https://zimic.dev/docs/http/api/http-schema#inferpathparams `InferPathParams` API reference} */\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 WithoutEscapedColons<Path extends string> = Path extends `${infer Prefix}\\\\:${infer Suffix}`\n ? WithoutEscapedColons<`${Prefix}:${Suffix}`>\n : Path;\n\ntype ConvertPathParamToString<PathParam extends string> = PathParam extends `${infer PathParamWithoutSlash}/`\n ? `${ConvertPathParamToString<PathParamWithoutSlash>}/`\n : PathParam extends `${infer PathParamWithoutSlash}\\\\:`\n ? `${ConvertPathParamToString<PathParamWithoutSlash>}:`\n : string;\n\nexport type AllowAnyStringInPathParams<Path extends string> =\n Path extends `${infer Prefix}:${infer PathParamWithRemainingPath}`\n ? PathParamWithRemainingPath extends `${infer PathParam}/${infer RemainingPath}`\n ? Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${AllowAnyStringInPathParams<PathParamWithRemainingPath>}`\n : `${Prefix}${ConvertPathParamToString<PathParam>}/${AllowAnyStringInPathParams<RemainingPath>}`\n : PathParamWithRemainingPath extends `${infer PathParam}\\\\:${infer RemainingPath}`\n ? Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${AllowAnyStringInPathParams<PathParamWithRemainingPath>}`\n : `${Prefix}${ConvertPathParamToString<PathParam>}:${AllowAnyStringInPathParams<RemainingPath>}`\n : PathParamWithRemainingPath extends `${infer PathParam}:${infer RemainingPath}`\n ? Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${AllowAnyStringInPathParams<PathParamWithRemainingPath>}`\n : `${Prefix}${ConvertPathParamToString<PathParam>}${AllowAnyStringInPathParams<`:${RemainingPath}`>}`\n : Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${PathParamWithRemainingPath}`\n : `${Prefix}${ConvertPathParamToString<PathParamWithRemainingPath>}`\n : Path;\n\n/** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapath `HttpSchemaPath` API reference} */\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 /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapathliteral `HttpSchemaPath.Literal` API reference} */\n export type Literal<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>,\n > = LooseLiteral<Schema, Method>;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapathnonliteral `HttpSchemaPath.NonLiteral` API reference} */\n export type NonLiteral<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>,\n > = WithoutEscapedColons<AllowAnyStringInPathParams<LooseLiteral<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 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/** @see {@link https://zimic.dev/docs/http/api/http-schema#mergehttpresponsesbystatuscode `MergeHttpResponsesByStatusCode` API reference} */\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","import HttpFormData from '@/formData/HttpFormData';\nimport HttpSearchParams from '@/searchParams/HttpSearchParams';\nimport { HttpBody } from '@/types/requests';\n\n/**\n * Error thrown when a value is not valid {@link https://developer.mozilla.org/docs/Web/API/FormData FormData}. HTTP\n * interceptors might throw this error when trying to parse the body of a request or response with the header\n * `'content-type': 'multipart/form-data'`, if the content cannot be parsed to form data.\n */\nexport class InvalidFormDataError extends SyntaxError {\n constructor(value: string) {\n super(`Failed to parse value as form data: ${value}`);\n this.name = 'InvalidFormDataError';\n }\n}\n\n/**\n * Error thrown when a value is not valid JSON. HTTP interceptors might throw this error when trying to parse the body\n * of a request or response with the header `'content-type': 'application/json'`, if the content cannot be parsed to\n * JSON.\n */\nexport class InvalidJSONError extends SyntaxError {\n constructor(value: string) {\n super(`Failed to parse value as JSON: ${value}`);\n this.name = 'InvalidJSONError';\n }\n}\n\nasync function parseHttpBodyAsText<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsText = await resource.text();\n return (bodyAsText || null) as Body;\n}\n\nasync function parseHttpBodyAsBlob<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsBlob = await resource.blob();\n return bodyAsBlob as Body;\n}\n\nasync function parseHttpBodyAsFormData<Body extends HttpBody>(resource: Request | Response) {\n const resourceClone = resource.clone();\n\n try {\n const bodyAsRawFormData = await resource.formData();\n const bodyAsFormData = new HttpFormData();\n\n for (const [key, value] of bodyAsRawFormData) {\n bodyAsFormData.append(key, value);\n }\n\n return bodyAsFormData as Body;\n } catch {\n const bodyAsText = await resourceClone.text();\n\n if (!bodyAsText.trim()) {\n return null;\n }\n\n throw new InvalidFormDataError(bodyAsText);\n }\n}\n\nasync function parseHttpBodyAsSearchParams<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsText = await resource.text();\n\n if (!bodyAsText.trim()) {\n return null;\n }\n\n const bodyAsSearchParams = new HttpSearchParams(bodyAsText);\n return bodyAsSearchParams as Body;\n}\n\nasync function parseHttpBodyAsJSON<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsText = await resource.text();\n\n if (!bodyAsText.trim()) {\n return null;\n }\n\n try {\n const bodyAsJSON = JSON.parse(bodyAsText) as Body;\n return bodyAsJSON;\n } catch {\n throw new InvalidJSONError(bodyAsText);\n }\n}\n\n/**\n * Parses the body of a {@link https://developer.mozilla.org/docs/Web/API/Request request} or\n * {@link https://developer.mozilla.org/docs/Web/API/Response response} based on its `content-type` header.\n *\n * If the body is empty, `null` is returned. If the `content-type` header is not present or not recognized, an attempt\n * is made to parse the body as JSON, and if that fails, it is returned as a `Blob`.\n *\n * | `content-type` | Parsed as |\n * | ----------------------------------- | ------------------------------------------------------------------------ |\n * | `application/json` | `JSON` (object) |\n * | `application/xml` | `string` |\n * | `application/x-www-form-urlencoded` | [`HttpSearchParams`](https://zimic.dev/docs/http/api/http-search-params) |\n * | `application/*` (others) | `Blob` |\n * | `multipart/form-data` | [`HttpFormData`](https://zimic.dev/docs/http/api/http-form-data) |\n * | `multipart/*` (others) | `Blob` |\n * | `text/*` | `string` |\n * | `image/*` | `Blob` |\n * | `audio/*` | `Blob` |\n * | `font/*` | `Blob` |\n * | `video/*` | `Blob` |\n * | Others | `JSON` if possible, otherwise `Blob` |\n *\n * @throws {InvalidJSONError} If the `content-type` starts with `application/json` but the body cannot be parsed to\n * JSON.\n * @throws {InvalidFormDataError} If the `content-type` starts with `multipart/form-data` but the body cannot be parsed\n * to form data.\n */\nexport async function parseHttpBody<Body extends HttpBody = HttpBody>(resource: Request | Response) {\n const contentType = resource.headers.get('content-type');\n\n if (contentType?.startsWith('application/json')) {\n return parseHttpBodyAsJSON<Body>(resource);\n }\n\n if (contentType?.startsWith('multipart/form-data')) {\n return parseHttpBodyAsFormData<Body>(resource);\n }\n\n if (contentType?.startsWith('application/x-www-form-urlencoded')) {\n return parseHttpBodyAsSearchParams<Body>(resource);\n }\n\n if (contentType?.startsWith('text/') || contentType?.startsWith('application/xml')) {\n return parseHttpBodyAsText<Body>(resource);\n }\n\n if (\n contentType?.startsWith('application/') ||\n contentType?.startsWith('image/') ||\n contentType?.startsWith('audio/') ||\n contentType?.startsWith('font/') ||\n contentType?.startsWith('video/') ||\n contentType?.startsWith('multipart/')\n ) {\n return parseHttpBodyAsBlob<Body>(resource);\n }\n\n const resourceClone = resource.clone();\n\n try {\n return await parseHttpBodyAsJSON<Body>(resource);\n } catch {\n return parseHttpBodyAsBlob<Body>(resourceClone);\n }\n}\n"]}
1
+ {"version":3,"sources":["../../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","../src/utils/bodies.ts"],"names":["pickPrimitiveProperties"],"mappings":";AAAA,eAAe,UAAA,CAAW,MAAY,SAAA,EAAiB;AACrD,EAAA,IAAI,KAAK,IAAA,KAAS,SAAA,CAAU,QAAQ,IAAA,CAAK,IAAA,KAAS,UAAU,IAAA,EAAM;AAChE,IAAA,OAAO,KAAA;AACT,EAAA;AAEA,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,MAAA,EAAA,CAAS,SAAA,EAAA;AAC7B,EAAA,MAAM,WAAA,GAAc,SAAA,CAAU,MAAA,EAAA,CAAS,SAAA,EAAA;AAEvC,EAAA,IAAI,MAAA,GAAqB,IAAI,UAAA,CAAW,CAAC,CAAA;AACzC,EAAA,IAAI,WAAA,GAA0B,IAAI,UAAA,CAAW,CAAC,CAAA;AAE9C,EAAA,IAAI;AACF,IAAA,OAAO,IAAA,EAAM;AACX,MAAA,MAAM,qBAAsC,EAAA;AAE5C,MAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,QAAA,kBAAA,CAAmB,IAAA;AACjB,UAAA,MAAA,CAAO,IAAA,EAAA,CAAO,IAAA,CAAK,CAAC,MAAA,KAAW;AAC7B,YAAA,IAAI,CAAC,OAAO,IAAA,EAAM;AAChB,cAAA,MAAA,GAAS,MAAA,CAAO,KAAA;AAClB,YAAA;UACF,CAAC;AAAA,SAAA;AAEL,MAAA;AAEA,MAAA,IAAI,WAAA,CAAY,WAAW,CAAA,EAAG;AAC5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AA,CAAW,QAAQ,CAAA,IAChC,WAAA,EAAa,UAAA,CAAW,YAAY,CAAA,EACpC;AACA,IAAA,OAAO,oBAA0B,QAAQ,CAAA;AAAA,EAC3C;AAEA,EAAA,MAAM,aAAA,GAAgB,SAAS,KAAA,EAAM;AAErC,EAAA,IAAI;AACF,IAAA,OAAO,MAAM,oBAA0B,QAAQ,CAAA;AAAA,EACjD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,oBAA0B,aAAa,CAAA;AAAA,EAChD;AACF","file":"index.mjs","sourcesContent":["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 const bufferReadPromises: Promise<void>[] = [];\n\n if (buffer.length === 0) {\n bufferReadPromises.push(\n reader.read().then((result) => {\n if (!result.done) {\n buffer = result.value;\n }\n }),\n );\n }\n\n if (otherBuffer.length === 0) {\n bufferReadPromises.push(\n otherReader.read().then((result) => {\n if (!result.done) {\n otherBuffer = result.value;\n }\n }),\n );\n }\n\n await Promise.all(bufferReadPromises);\n\n const haveStreamsEndedTogether = buffer.length === 0 && otherBuffer.length === 0;\n\n if (haveStreamsEndedTogether) {\n return true;\n }\n\n const hasOneStreamEndedBeforeTheOther =\n (buffer.length === 0 && otherBuffer.length > 0) || (buffer.length > 0 && otherBuffer.length === 0);\n\n if (hasOneStreamEndedBeforeTheOther) {\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';\nimport { ArrayItemIfArray, Replace } from '@zimic/utils/types';\n\nimport { HttpFormDataSchema, HttpFormDataSchemaName, HttpFormDataSerialized } from './types';\n\n/** @see {@link https://zimic.dev/docs/http/api/http-form-data `HttpFormData` API reference} */\nclass HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFormDataSchema.Loose> extends FormData {\n readonly _schema!: HttpFormDataSerialized<LooseSchema>;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataset `formData.set()` API 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://zimic.dev/docs/http/api/http-form-data#formdataappend `formData.append()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataget `formData.get()` API reference} */\n get<Name extends HttpFormDataSchemaName.NonArray<this['_schema']>>(\n name: Name,\n ): Replace<Replace<ArrayItemIfArray<this['_schema'][Name]>, undefined, null>, Blob, File> {\n return super.get(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatagetall `formData.getAll()` API reference} */\n getAll<Name extends HttpFormDataSchemaName.Array<this['_schema']>>(\n name: Name,\n ): Replace<ArrayItemIfArray<NonNullable<this['_schema'][Name]>>, Blob, File>[] {\n return super.getAll(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatahas `formData.has()` API reference} */\n has<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): boolean {\n return super.has(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatadelete `formData.delete()` API reference} */\n delete<Name extends HttpFormDataSchemaName<this['_schema']>>(name: Name): void {\n super.delete(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforeach `formData.forEach()` API reference} */\n forEach<This extends HttpFormData<this['_schema']>>(\n callback: <Key extends HttpFormDataSchemaName<this['_schema']>>(\n value: Replace<ArrayItemIfArray<NonNullable<this['_schema'][Key]>>, Blob, File>,\n key: Key,\n formData: 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://zimic.dev/docs/http/api/http-form-data#formdatakeys `formData.keys()` API reference} */\n keys(): FormDataIterator<HttpFormDataSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatavalues `formData.values()` API reference} */\n values(): FormDataIterator<\n Replace<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>\n > {\n return super.values() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataentries `formData.entries()` API reference} */\n entries(): FormDataIterator<\n [\n HttpFormDataSchemaName<this['_schema']>,\n Replace<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 Replace<ArrayItemIfArray<NonNullable<this['_schema'][HttpFormDataSchemaName<this['_schema']>]>>, Blob, File>,\n ]\n > {\n return super[Symbol.iterator]() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataequals `formData.equals()` API reference} */\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 fieldName of this.keys()) {\n if (!super.has.call(otherData, fieldName)) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatacontains `formData.contains()` API reference} */\n async contains<OtherSchema extends LooseSchema>(otherData: HttpFormData<OtherSchema>): Promise<boolean> {\n for (const [otherFieldName, otherFieldValue] of otherData.entries()) {\n const fieldValues = super.getAll.call(this, otherFieldName);\n\n const haveSameNumberOfFieldValues = fieldValues.length === super.getAll.call(otherData, otherFieldName).length;\n\n if (!haveSameNumberOfFieldValues) {\n return false;\n }\n\n let fieldValueExists = false;\n\n for (const fieldValue of fieldValues) {\n if (\n fieldValue === otherFieldValue ||\n (fieldValue instanceof Blob &&\n (otherFieldValue as Blob) instanceof Blob &&\n (await fileEquals(fieldValue, otherFieldValue)))\n ) {\n fieldValueExists = true;\n break;\n }\n }\n\n if (!fieldValueExists) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataassign `formData.assign()` API reference} */\n assign<OtherSchema extends LooseSchema>(...otherDataArray: HttpFormData<OtherSchema>[]) {\n for (const otherData of otherDataArray) {\n if (this === (otherData as unknown)) {\n continue;\n }\n\n for (const fieldName of otherData.keys()) {\n super.delete(fieldName);\n }\n\n for (const [fieldName, fieldValue] of otherData.entries()) {\n super.append(fieldName, fieldValue);\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdatatoobject `formData.toObject()` API reference} */\n toObject() {\n const object = {} as this['_schema'];\n\n type SchemaValue = this['_schema'][HttpFormDataSchemaName<this['_schema']>];\n\n for (const [fieldName, fieldValue] of this.entries()) {\n if (fieldName in object) {\n const existingFieldValue = object[fieldName] as SchemaValue[];\n\n if (Array.isArray<SchemaValue>(existingFieldValue)) {\n existingFieldValue.push(fieldValue as SchemaValue);\n } else {\n object[fieldName] = [existingFieldValue, fieldValue] as SchemaValue;\n }\n } else {\n object[fieldName] = fieldValue as SchemaValue;\n }\n }\n\n return object;\n }\n}\n\nexport default HttpFormData;\n","import { Default, Replace } 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/** @see {@link https://zimic.dev/docs/http/api/http-headers `HttpHeaders` API reference} */\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://zimic.dev/docs/http/api/http-headers#headersset `headers.set()` API 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://zimic.dev/docs/http/api/http-headers#headersappend `headers.append()` API 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://zimic.dev/docs/http/api/http-headers#headersget `headers.get()` API reference} */\n get<Name extends HttpHeadersSchemaName<this['_schema']>>(\n name: Name,\n ): Replace<this['_schema'][Name], undefined, null> {\n return super.get(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetsetcookie `headers.getSetCookie()` API reference} */\n getSetCookie(): NonNullable<Default<this['_schema']['Set-Cookie'], string>>[] {\n return super.getSetCookie() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headershas `headers.has()` API reference} */\n has<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): boolean {\n return super.has(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersdelete `headers.delete()` API reference} */\n delete<Name extends HttpHeadersSchemaName<this['_schema']>>(name: Name): void {\n super.delete(name);\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforeach `headers.forEach()` API reference} */\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 headers: 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://zimic.dev/docs/http/api/http-headers#headerskeys `headers.keys()` API reference} */\n keys(): HeadersIterator<HttpHeadersSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersvalues `headers.values()` API reference} */\n values(): HeadersIterator<NonNullable<this['_schema'][HttpHeadersSchemaName<this['_schema']>]> & string> {\n return super.values() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersentries `headers.entries()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersequals `headers.equals()` API reference} */\n equals<OtherSchema extends LooseSchema>(otherHeaders: HttpHeaders<OtherSchema>): boolean {\n if (!this.contains(otherHeaders)) {\n return false;\n }\n\n for (const headerName of this.keys()) {\n if (!super.has.call(otherHeaders, headerName)) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerscontains `headers.contains()` API reference} */\n contains<OtherSchema extends LooseSchema>(otherHeaders: HttpHeaders<OtherSchema>): boolean {\n for (const [headerName, otherHeaderValue] of otherHeaders.entries()) {\n const headerValue = super.get.call(this, headerName);\n\n if (headerValue === null) {\n return false;\n }\n\n const headerValueItems = this.splitHeaderValues(headerValue);\n const otherHeaderValueItems = this.splitHeaderValues(otherHeaderValue);\n\n const haveSameNumberOfHeaderValues = headerValueItems.length === otherHeaderValueItems.length;\n\n if (!haveSameNumberOfHeaderValues) {\n return false;\n }\n\n for (const otherValueItem of otherHeaderValueItems) {\n if (!headerValueItems.includes(otherValueItem)) {\n return false;\n }\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersassign `headers.assign()` API reference} */\n assign<OtherSchema extends LooseSchema>(...otherHeadersArray: HttpHeaders<OtherSchema>[]) {\n for (const otherHeaders of otherHeadersArray) {\n if (this === (otherHeaders as unknown)) {\n continue;\n }\n\n for (const headerName of otherHeaders.keys()) {\n super.delete(headerName);\n }\n\n for (const [headerName, headerValue] of otherHeaders.entries()) {\n super.append(headerName, headerValue);\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-headers#headerstoobject `headers.toObject()` API reference} */\n toObject(): this['_schema'] {\n const object = {} as this['_schema'];\n\n for (const [headerName, headerValue] of this.entries()) {\n object[headerName] = headerValue;\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 { Replace, 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/** @see {@link https://zimic.dev/docs/http/api/http-search-params `HttpSearchParams` API reference} */\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 [paramName, paramValues] of Object.entries(init)) {\n if (Array.isArray(paramValues)) {\n for (const paramValue of paramValues as unknown[]) {\n super.append(paramName, String(paramValue));\n }\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsset `searchParams.set()` API 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://zimic.dev/docs/http/api/http-search-params#searchparamsappend `searchParams.append()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsget `searchParams.get()` API reference} */\n get<Name extends HttpSearchParamsSchemaName.NonArray<this['_schema']>>(\n name: Name,\n ): Replace<ArrayItemIfArray<this['_schema'][Name]>, undefined, null> {\n return super.get(name) as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsgetall `searchParams.getAll()` API reference} */\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://zimic.dev/docs/http/api/http-search-params#searchparamshas `searchParams.has()` API 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://zimic.dev/docs/http/api/http-search-params#searchparamsdelete `searchParams.delete()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforeach `searchParams.forEach()` API reference} */\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 searchParams: 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://zimic.dev/docs/http/api/http-search-params#searchparamskeys `searchParams.keys()` API reference} */\n keys(): URLSearchParamsIterator<HttpSearchParamsSchemaName<this['_schema']>> {\n return super.keys() as never;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsvalues `searchParams.values()` API 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://zimic.dev/docs/http/api/http-search-params#searchparamsentries `searchParams.entries()` API 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 /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsequals `searchParams.equals()` API reference} */\n equals<OtherSchema extends LooseSchema>(otherParams: HttpSearchParams<OtherSchema>): boolean {\n return this.contains(otherParams) && this.size === otherParams.size;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamscontains `searchParams.contains()` API reference} */\n contains<OtherSchema extends LooseSchema>(otherParams: HttpSearchParams<OtherSchema>): boolean {\n for (const [paramName, otherParamValue] of otherParams.entries()) {\n const paramValues = super.getAll.call(this, paramName);\n\n const haveSameNumberOfParamValues = paramValues.length === super.getAll.call(otherParams, paramName).length;\n\n if (!haveSameNumberOfParamValues) {\n return false;\n }\n\n const paramValueExists = paramValues.includes(otherParamValue);\n\n if (!paramValueExists) {\n return false;\n }\n }\n\n return true;\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsassign `searchParams.assign()` API reference} */\n assign<OtherSchema extends LooseSchema>(...otherParamsArray: HttpSearchParams<OtherSchema>[]) {\n for (const otherParams of otherParamsArray) {\n if (this === (otherParams as unknown)) {\n continue;\n }\n\n for (const paramName of otherParams.keys()) {\n super.delete(paramName);\n }\n\n for (const [paramName, paramValue] of otherParams.entries()) {\n super.append(paramName, paramValue);\n }\n }\n }\n\n /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamstoobject `searchParams.toObject()` API reference} */\n toObject() {\n const object = {} as this['_schema'];\n\n type SchemaValue = this['_schema'][HttpSearchParamsSchemaName<this['_schema']>];\n\n for (const [paramName, paramValue] of this.entries()) {\n if (paramName in object) {\n const existingParamValue = object[paramName] as SchemaValue[];\n\n if (Array.isArray<SchemaValue>(existingParamValue)) {\n existingParamValue.push(paramValue as SchemaValue);\n } else {\n object[paramName] = [existingParamValue, paramValue] as SchemaValue;\n }\n } else {\n object[paramName] = paramValue 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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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/** @see {@link https://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference} */\nexport type HttpSchema<Schema extends BaseHttpSchema = BaseHttpSchema> = Branded<Schema, 'HttpSchema'>;\n\nexport namespace HttpSchema {\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemamethods `HttpSchema.Methods` API reference} */\n export type Methods<Schema extends HttpMethodsSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemamethod `HttpSchema.Method` API reference} */\n export type Method<Schema extends HttpMethodSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemarequest `HttpSchema.Request` API reference} */\n export type Request<Schema extends HttpRequestSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaresponsebystatuscode `HttpSchema.ResponseByStatusCode` API reference} */\n export type ResponseByStatusCode<Schema extends HttpResponseSchemaByStatusCode> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaresponse `HttpSchema.Response` API reference} */\n export type Response<Schema extends HttpResponseSchema> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemabody `HttpSchema.Body` API reference} */\n export type Body<Schema extends HttpBody.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaheaders `HttpSchema.Headers` API reference} */\n export type Headers<Schema extends HttpHeadersSchema.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemasearchparams `HttpSchema.SearchParams` API reference} */\n export type SearchParams<Schema extends HttpSearchParamsSchema.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapathparams `HttpSchema.PathParams` API reference} */\n export type PathParams<Schema extends HttpPathParamsSchema.Loose> = Schema;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemaformdata `HttpSchema.FormData` API reference} */\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://zimic.dev/docs/http/api/http-schema `HttpSchema` API reference}\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\ntype RepeatingPathParamModifier = '+';\ntype OptionalPathParamModifier = '?' | '*';\n\ntype ConvertPathParamToRecord<PathParam extends string> = PathParam extends `${infer PathParamWithoutSlash}/`\n ? ConvertPathParamToRecord<PathParamWithoutSlash>\n : PathParam extends `${infer PathParamWithoutSlash}\\\\:`\n ? ConvertPathParamToRecord<PathParamWithoutSlash>\n : PathParam extends `${infer PathParamWithoutModifier}${OptionalPathParamModifier}`\n ? { [Name in PathParamWithoutModifier]?: string }\n : PathParam extends `${infer PathParamWithoutModifier}${RepeatingPathParamModifier}`\n ? { [Name in PathParamWithoutModifier]: string }\n : { [Name in PathParam]: string };\n\ntype RecursiveInferPathParams<Path extends string> = Path extends `${infer Prefix}:${infer PathParamWithRemainingPath}`\n ? PathParamWithRemainingPath extends `${infer PathParam}/${infer RemainingPath}`\n ? Prefix extends `${string}\\\\`\n ? RecursiveInferPathParams<RemainingPath>\n : ConvertPathParamToRecord<PathParam> & RecursiveInferPathParams<RemainingPath>\n : PathParamWithRemainingPath extends `${infer PathParam}\\\\:${infer RemainingPath}`\n ? Prefix extends `${string}\\\\`\n ? RecursiveInferPathParams<`\\\\:${RemainingPath}`>\n : ConvertPathParamToRecord<PathParam> & RecursiveInferPathParams<`\\\\:${RemainingPath}`>\n : PathParamWithRemainingPath extends `${infer PathParam}:${infer RemainingPath}`\n ? Prefix extends `${string}\\\\`\n ? RecursiveInferPathParams<RemainingPath>\n : ConvertPathParamToRecord<PathParam> & RecursiveInferPathParams<`:${RemainingPath}`>\n : Prefix extends `${string}\\\\`\n ? {}\n : ConvertPathParamToRecord<PathParamWithRemainingPath>\n : {};\n\n/** @see {@link https://zimic.dev/docs/http/api/http-schema#inferpathparams `InferPathParams` API reference} */\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 WithoutEscapedColons<Path extends string> = Path extends `${infer Prefix}\\\\:${infer Suffix}`\n ? WithoutEscapedColons<`${Prefix}:${Suffix}`>\n : Path;\n\ntype ConvertPathParamToString<PathParam extends string> = PathParam extends `${infer PathParamWithoutSlash}/`\n ? `${ConvertPathParamToString<PathParamWithoutSlash>}/`\n : PathParam extends `${infer PathParamWithoutSlash}\\\\:`\n ? `${ConvertPathParamToString<PathParamWithoutSlash>}:`\n : string;\n\nexport type AllowAnyStringInPathParams<Path extends string> =\n Path extends `${infer Prefix}:${infer PathParamWithRemainingPath}`\n ? PathParamWithRemainingPath extends `${infer PathParam}/${infer RemainingPath}`\n ? Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${AllowAnyStringInPathParams<PathParamWithRemainingPath>}`\n : `${Prefix}${ConvertPathParamToString<PathParam>}/${AllowAnyStringInPathParams<RemainingPath>}`\n : PathParamWithRemainingPath extends `${infer PathParam}\\\\:${infer RemainingPath}`\n ? Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${AllowAnyStringInPathParams<PathParamWithRemainingPath>}`\n : `${Prefix}${ConvertPathParamToString<PathParam>}:${AllowAnyStringInPathParams<RemainingPath>}`\n : PathParamWithRemainingPath extends `${infer PathParam}:${infer RemainingPath}`\n ? Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${AllowAnyStringInPathParams<PathParamWithRemainingPath>}`\n : `${Prefix}${ConvertPathParamToString<PathParam>}${AllowAnyStringInPathParams<`:${RemainingPath}`>}`\n : Prefix extends `${infer PrefixPrefix}\\\\`\n ? `${PrefixPrefix}:${PathParamWithRemainingPath}`\n : `${Prefix}${ConvertPathParamToString<PathParamWithRemainingPath>}`\n : Path;\n\n/** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapath `HttpSchemaPath` API reference} */\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 /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapathliteral `HttpSchemaPath.Literal` API reference} */\n export type Literal<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>,\n > = LooseLiteral<Schema, Method>;\n\n /** @see {@link https://zimic.dev/docs/http/api/http-schema#httpschemapathnonliteral `HttpSchemaPath.NonLiteral` API reference} */\n export type NonLiteral<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema> = HttpSchemaMethod<Schema>,\n > = WithoutEscapedColons<AllowAnyStringInPathParams<LooseLiteral<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 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/** @see {@link https://zimic.dev/docs/http/api/http-schema#mergehttpresponsesbystatuscode `MergeHttpResponsesByStatusCode` API reference} */\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","import HttpFormData from '@/formData/HttpFormData';\nimport HttpSearchParams from '@/searchParams/HttpSearchParams';\nimport { HttpBody } from '@/types/requests';\n\n/**\n * Error thrown when a value is not valid {@link https://developer.mozilla.org/docs/Web/API/FormData FormData}. HTTP\n * interceptors might throw this error when trying to parse the body of a request or response with the header\n * `'content-type': 'multipart/form-data'`, if the content cannot be parsed to form data.\n */\nexport class InvalidFormDataError extends SyntaxError {\n constructor(value: string) {\n super(`Failed to parse value as form data: ${value}`);\n this.name = 'InvalidFormDataError';\n }\n}\n\n/**\n * Error thrown when a value is not valid JSON. HTTP interceptors might throw this error when trying to parse the body\n * of a request or response with the header `'content-type': 'application/json'`, if the content cannot be parsed to\n * JSON.\n */\nexport class InvalidJSONError extends SyntaxError {\n constructor(value: string) {\n super(`Failed to parse value as JSON: ${value}`);\n this.name = 'InvalidJSONError';\n }\n}\n\nasync function parseHttpBodyAsText<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsText = await resource.text();\n return (bodyAsText || null) as Body;\n}\n\nasync function parseHttpBodyAsBlob<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsBlob = await resource.blob();\n return bodyAsBlob as Body;\n}\n\nasync function parseHttpBodyAsFormData<Body extends HttpBody>(resource: Request | Response) {\n const resourceClone = resource.clone();\n\n try {\n const bodyAsRawFormData = await resource.formData();\n const bodyAsFormData = new HttpFormData();\n\n for (const [key, value] of bodyAsRawFormData) {\n bodyAsFormData.append(key, value);\n }\n\n return bodyAsFormData as Body;\n } catch {\n const bodyAsText = await resourceClone.text();\n\n if (!bodyAsText.trim()) {\n return null;\n }\n\n throw new InvalidFormDataError(bodyAsText);\n }\n}\n\nasync function parseHttpBodyAsSearchParams<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsText = await resource.text();\n\n if (!bodyAsText.trim()) {\n return null;\n }\n\n const bodyAsSearchParams = new HttpSearchParams(bodyAsText);\n return bodyAsSearchParams as Body;\n}\n\nasync function parseHttpBodyAsJSON<Body extends HttpBody>(resource: Request | Response) {\n const bodyAsText = await resource.text();\n\n if (!bodyAsText.trim()) {\n return null;\n }\n\n try {\n const bodyAsJSON = JSON.parse(bodyAsText) as Body;\n return bodyAsJSON;\n } catch {\n throw new InvalidJSONError(bodyAsText);\n }\n}\n\n/**\n * Parses the body of a {@link https://developer.mozilla.org/docs/Web/API/Request request} or\n * {@link https://developer.mozilla.org/docs/Web/API/Response response} based on its `content-type` header.\n *\n * If the body is empty, `null` is returned. If the `content-type` header is not present or not recognized, an attempt\n * is made to parse the body as JSON, and if that fails, it is returned as a `Blob`.\n *\n * | `content-type` | Parsed as |\n * | ----------------------------------- | ------------------------------------------------------------------------ |\n * | `application/json` | `JSON` (object) |\n * | `application/xml` | `string` |\n * | `application/x-www-form-urlencoded` | [`HttpSearchParams`](https://zimic.dev/docs/http/api/http-search-params) |\n * | `application/*` (others) | `Blob` |\n * | `multipart/form-data` | [`HttpFormData`](https://zimic.dev/docs/http/api/http-form-data) |\n * | `multipart/*` (others) | `Blob` |\n * | `text/*` | `string` |\n * | `image/*` | `Blob` |\n * | `audio/*` | `Blob` |\n * | `font/*` | `Blob` |\n * | `video/*` | `Blob` |\n * | Others | `JSON` if possible, otherwise `Blob` |\n *\n * @throws {InvalidJSONError} If the `content-type` starts with `application/json` but the body cannot be parsed to\n * JSON.\n * @throws {InvalidFormDataError} If the `content-type` starts with `multipart/form-data` but the body cannot be parsed\n * to form data.\n */\nexport async function parseHttpBody<Body extends HttpBody = HttpBody>(resource: Request | Response) {\n const contentType = resource.headers.get('content-type');\n\n if (contentType?.startsWith('application/json')) {\n return parseHttpBodyAsJSON<Body>(resource);\n }\n\n if (contentType?.startsWith('multipart/form-data')) {\n return parseHttpBodyAsFormData<Body>(resource);\n }\n\n if (contentType?.startsWith('application/x-www-form-urlencoded')) {\n return parseHttpBodyAsSearchParams<Body>(resource);\n }\n\n if (contentType?.startsWith('text/') || contentType?.startsWith('application/xml')) {\n return parseHttpBodyAsText<Body>(resource);\n }\n\n if (\n contentType?.startsWith('application/') ||\n contentType?.startsWith('image/') ||\n contentType?.startsWith('audio/') ||\n contentType?.startsWith('font/') ||\n contentType?.startsWith('video/') ||\n contentType?.startsWith('multipart/')\n ) {\n return parseHttpBodyAsBlob<Body>(resource);\n }\n\n const resourceClone = resource.clone();\n\n try {\n return await parseHttpBodyAsJSON<Body>(resource);\n } catch {\n return parseHttpBodyAsBlob<Body>(resourceClone);\n }\n}\n"]}
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "api",
13
13
  "static"
14
14
  ],
15
- "version": "1.3.9-canary.0",
15
+ "version": "1.3.9",
16
16
  "homepage": "https://zimic.dev/docs/http",
17
17
  "repository": {
18
18
  "type": "git",
@@ -75,7 +75,7 @@ class HttpFormData<LooseSchema extends HttpFormDataSchema.Loose = HttpFormDataSc
75
75
  super.delete(name);
76
76
  }
77
77
 
78
- /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforEach `formData.forEach()` API reference} */
78
+ /** @see {@link https://zimic.dev/docs/http/api/http-form-data#formdataforeach `formData.forEach()` API reference} */
79
79
  forEach<This extends HttpFormData<this['_schema']>>(
80
80
  callback: <Key extends HttpFormDataSchemaName<this['_schema']>>(
81
81
  value: Replace<ArrayItemIfArray<NonNullable<this['_schema'][Key]>>, Blob, File>,
@@ -40,7 +40,7 @@ class HttpHeaders<LooseSchema extends HttpHeadersSchema.Loose = HttpHeadersSchem
40
40
  return super.get(name) as never;
41
41
  }
42
42
 
43
- /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetSetCookie `headers.getSetCookie()` API reference} */
43
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersgetsetcookie `headers.getSetCookie()` API reference} */
44
44
  getSetCookie(): NonNullable<Default<this['_schema']['Set-Cookie'], string>>[] {
45
45
  return super.getSetCookie() as never;
46
46
  }
@@ -55,7 +55,7 @@ class HttpHeaders<LooseSchema extends HttpHeadersSchema.Loose = HttpHeadersSchem
55
55
  super.delete(name);
56
56
  }
57
57
 
58
- /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforEach `headers.forEach()` API reference} */
58
+ /** @see {@link https://zimic.dev/docs/http/api/http-headers#headersforeach `headers.forEach()` API reference} */
59
59
  forEach<This extends HttpHeaders<this['_schema']>>(
60
60
  callback: <Key extends HttpHeadersSchemaName<this['_schema']>>(
61
61
  value: NonNullable<this['_schema'][Key]> & string,
@@ -91,7 +91,7 @@ class HttpSearchParams<
91
91
  super.delete(name, value);
92
92
  }
93
93
 
94
- /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforEach `searchParams.forEach()` API reference} */
94
+ /** @see {@link https://zimic.dev/docs/http/api/http-search-params#searchparamsforeach `searchParams.forEach()` API reference} */
95
95
  forEach<This extends HttpSearchParams<this['_schema']>>(
96
96
  callback: <Key extends HttpSearchParamsSchemaName<this['_schema']>>(
97
97
  value: ArrayItemIfArray<NonNullable<this['_schema'][Key]>>,