@zimic/http 0.6.1 → 0.7.0

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 = "0.6.1";
15
+ var version = "0.7.0";
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":["__name","yargs","hideBin","generate_default","color","logger"],"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;AAdsBA,uBAAA,CAAA,gBAAA,EAAA,kBAAA,CAAA;AAgBf,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,GAChD,MAAO;AACL,IAAA,OAAO,CAAA,EAAA,CAAI,yBAAA,GAA4B,GAAA,EAAM,OAAA,CAAQ,CAAC,CAAC,CAAA,CAAA,CAAA;AAAA;AAE3D;AAN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eL,uBAAA,CAAA,MAAA,EAAA,QAAA,CAAA;AAiGf,IAAO,WAAA,GAAQ,MAAA;;;ACxGf,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\": \"0.6.1\",\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 \"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 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test run --coverage\",\n \"types:check\": \"tsc --noEmit\",\n \"typegen:fixtures\": \"tsx ./scripts/typegen/generateFixtureTypes.ts\",\n \"deps:prepare\": \"playwright install chromium\"\n },\n \"dependencies\": {\n \"openapi-typescript\": \"7.8.0\",\n \"picocolors\": \"^1.1.1\",\n \"yargs\": \"18.0.0\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^24.0.7\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.2.4\",\n \"@vitest/coverage-istanbul\": \"^3.2.4\",\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\": \"^8.0.0\",\n \"eslint\": \"^9.30.0\",\n \"execa\": \"9.6.0\",\n \"js-yaml\": \"^4.1.0\",\n \"playwright\": \"^1.53.1\",\n \"prettier\": \"^3.6.2\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.4\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.2.4\"\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 to filter the types to generate. Filters must follow the format ' +\n '`<method> <path>`, where `<method>` is an HTTP method or `*`, and `<path>` is a literal path or a ' +\n 'glob. Filters are case-sensitive regarding paths. For example, `GET /users`, `* /users`, ' +\n '`GET /users/*`, and `GET /users/**/*` are valid filters. Negative filters can be created by ' +\n 'prefixing the expression with `!`. For example, `!GET /users` will exclude paths matching ' +\n '`GET /users`. If more than one positive filter is provided, they will be combined with OR, while ' +\n 'negative filters will be combined with AND.',\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":["__name","yargs","hideBin","generate_default","color","logger"],"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,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A,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;AAC7D;AACF,IAGD,KAAA,EAAM;AACX;AA/FeL,uBAAA,CAAA,MAAA,EAAA,QAAA,CAAA;AAiGf,IAAO,WAAA,GAAQ,MAAA;;;ACxGf,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\": \"0.7.0\",\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 \"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 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test run --coverage\",\n \"types:check\": \"tsc --noEmit\",\n \"typegen:fixtures\": \"tsx ./scripts/typegen/generateFixtureTypes.ts\",\n \"deps:prepare\": \"playwright install chromium\"\n },\n \"dependencies\": {\n \"openapi-typescript\": \"7.8.0\",\n \"picocolors\": \"^1.1.1\",\n \"yargs\": \"18.0.0\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^24.0.7\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.2.4\",\n \"@vitest/coverage-istanbul\": \"^3.2.4\",\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\": \"^8.0.0\",\n \"eslint\": \"^9.30.0\",\n \"execa\": \"9.6.0\",\n \"js-yaml\": \"^4.1.0\",\n \"playwright\": \"^1.53.1\",\n \"prettier\": \"^3.6.2\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.4\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.2.4\"\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 to filter the types to generate. Filters must follow the format ' +\n '`<method> <path>`, where `<method>` is an HTTP method or `*`, and `<path>` is a literal path or a ' +\n 'glob. Filters are case-sensitive regarding paths. For example, `GET /users`, `* /users`, ' +\n '`GET /users/*`, and `GET /users/**/*` are valid filters. Negative filters can be created by ' +\n 'prefixing the expression with `!`. For example, `!GET /users` will exclude paths matching ' +\n '`GET /users`. If more than one positive filter is provided, they will be combined with OR, while ' +\n 'negative filters will be combined with AND.',\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 = "0.6.1";
8
+ var version = "0.7.0";
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,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;AAdsB,MAAA,CAAA,gBAAA,EAAA,kBAAA,CAAA;AAgBf,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,GAChD,MAAO;AACL,IAAA,OAAO,CAAA,EAA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AM,CAAA,CAAE,cAAc,CAAA;AAAA;AAC7D;AACF,IAGD,KAAA,EAAM;AACX;AA/Fe,MAAA,CAAA,MAAA,EAAA,QAAA,CAAA;AAiGf,IAAO,WAAA,GAAQ,MAAA;;;ACxGf,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\": \"0.6.1\",\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 \"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 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test run --coverage\",\n \"types:check\": \"tsc --noEmit\",\n \"typegen:fixtures\": \"tsx ./scripts/typegen/generateFixtureTypes.ts\",\n \"deps:prepare\": \"playwright install chromium\"\n },\n \"dependencies\": {\n \"openapi-typescript\": \"7.8.0\",\n \"picocolors\": \"^1.1.1\",\n \"yargs\": \"18.0.0\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^24.0.7\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.2.4\",\n \"@vitest/coverage-istanbul\": \"^3.2.4\",\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\": \"^8.0.0\",\n \"eslint\": \"^9.30.0\",\n \"execa\": \"9.6.0\",\n \"js-yaml\": \"^4.1.0\",\n \"playwright\": \"^1.53.1\",\n \"prettier\": \"^3.6.2\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.4\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.2.4\"\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 to filter the types to generate. Filters must follow the format ' +\n '`<method> <path>`, where `<method>` is an HTTP method or `*`, and `<path>` is a literal path or a ' +\n 'glob. Filters are case-sensitive regarding paths. For example, `GET /users`, `* /users`, ' +\n '`GET /users/*`, and `GET /users/**/*` are valid filters. Negative filters can be created by ' +\n 'prefixing the expression with `!`. For example, `!GET /users` will exclude paths matching ' +\n '`GET /users`. If more than one positive filter is provided, they will be combined with OR, while ' +\n 'negative filters will be combined with AND.',\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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,CAAA;AAED,QAAA,MAAM,iBAAiB,YAAA,CAAa,MAAA;AAEpC,QAAA,MAAM,cAAA,GACJ,GAAG,KAAA,CAAM,KAAA,CAAM,MAAM,IAAA,CAAK,QAAG,CAAC,CAAC,CAAA,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;AAC7D;AACF,IAGD,KAAA,EAAM;AACX;AA/Fe,MAAA,CAAA,MAAA,EAAA,QAAA,CAAA;AAiGf,IAAO,WAAA,GAAQ,MAAA;;;ACxGf,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\": \"0.7.0\",\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 \"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 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test run --coverage\",\n \"types:check\": \"tsc --noEmit\",\n \"typegen:fixtures\": \"tsx ./scripts/typegen/generateFixtureTypes.ts\",\n \"deps:prepare\": \"playwright install chromium\"\n },\n \"dependencies\": {\n \"openapi-typescript\": \"7.8.0\",\n \"picocolors\": \"^1.1.1\",\n \"yargs\": \"18.0.0\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^24.0.7\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.2.4\",\n \"@vitest/coverage-istanbul\": \"^3.2.4\",\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\": \"^8.0.0\",\n \"eslint\": \"^9.30.0\",\n \"execa\": \"9.6.0\",\n \"js-yaml\": \"^4.1.0\",\n \"playwright\": \"^1.53.1\",\n \"prettier\": \"^3.6.2\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.4\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.2.4\"\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 to filter the types to generate. Filters must follow the format ' +\n '`<method> <path>`, where `<method>` is an HTTP method or `*`, and `<path>` is a literal path or a ' +\n 'glob. Filters are case-sensitive regarding paths. For example, `GET /users`, `* /users`, ' +\n '`GET /users/*`, and `GET /users/**/*` are valid filters. Negative filters can be created by ' +\n 'prefixing the expression with `!`. For example, `!GET /users` will exclude paths matching ' +\n '`GET /users`. If more than one positive filter is provided, they will be combined with OR, while ' +\n 'negative filters will be combined with AND.',\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
@@ -613,7 +613,7 @@ type MergeHttpResponsesByStatusCode<Schemas extends HttpResponseSchemaByStatusCo
613
613
  ] ? RestSchemas extends NonEmptyArray<HttpResponseSchemaByStatusCode> ? OmitPastHttpStatusCodes<FirstSchema, PastSchemas> & MergeHttpResponsesByStatusCode<RestSchemas, [...PastSchemas, FirstSchema]> : OmitPastHttpStatusCodes<FirstSchema, PastSchemas> : never;
614
614
 
615
615
  /** The body type for HTTP requests and responses. */
616
- type HttpBody = JSONValue | HttpFormData<any> | HttpSearchParams<any> | Blob | ArrayBuffer;
616
+ type HttpBody = JSONValue | HttpFormData<any> | HttpSearchParams<any> | Blob | ArrayBuffer | ReadableStream;
617
617
  declare namespace HttpBody {
618
618
  /** A loose version of the HTTP body type. JSON values are not strictly typed. */
619
619
  type Loose = ReplaceBy<HttpBody, JSONValue, JSONValue.Loose>;
@@ -664,13 +664,13 @@ type HttpRequestHeadersSchemaFromBody<RequestSchema extends HttpRequestSchema, D
664
664
  } : DefaultHeadersSchema : DefaultHeadersSchema;
665
665
  type HttpRequestHeadersSchema<MethodSchema extends HttpMethodSchema> = 'headers' extends keyof MethodSchema['request'] ? [MethodSchema['request']['headers']] extends [never] ? HttpRequestHeadersSchemaFromBody<Default<MethodSchema['request']>, never> : (MethodSchema['request']['headers'] & HttpRequestHeadersSchemaFromBody<Default<MethodSchema['request']>, {}>) | Extract<MethodSchema['request']['headers'], undefined> : HttpRequestHeadersSchemaFromBody<Default<MethodSchema['request']>, never>;
666
666
  type HttpRequestSearchParamsSchema<MethodSchema extends HttpMethodSchema> = 'searchParams' extends keyof MethodSchema['request'] ? Default<MethodSchema['request']>['searchParams'] : never;
667
- type HttpRequestBodySchema<MethodSchema extends HttpMethodSchema> = ReplaceBy<ReplaceBy<IfNever<DefaultNoExclude<Default<MethodSchema['request']>['body']>, null>, undefined, null>, ArrayBuffer, Blob>;
667
+ type HttpRequestBodySchema<MethodSchema extends HttpMethodSchema> = ReplaceBy<IfNever<DefaultNoExclude<Default<MethodSchema['request']>['body']>, null>, undefined, null>;
668
668
  type HttpResponseHeadersSchemaFromBody<ResponseSchema extends HttpResponseSchema, DefaultHeadersSchema> = 'body' extends keyof ResponseSchema ? [ResponseSchema['body']] extends [never] ? DefaultHeadersSchema : [Extract<ResponseSchema['body'], BodyInit | HttpSearchParams | HttpFormData>] extends [never] ? 'headers' extends keyof ResponseSchema ? [ResponseSchema['headers']] extends [never] ? DefaultHeadersSchema : 'content-type' extends keyof Default<ResponseSchema['headers']> ? DefaultHeadersSchema : {
669
669
  'content-type': 'application/json';
670
670
  } : {
671
671
  'content-type': 'application/json';
672
672
  } : DefaultHeadersSchema : DefaultHeadersSchema;
673
673
  type HttpResponseHeadersSchema<MethodSchema extends HttpMethodSchema, StatusCode extends HttpStatusCode> = 'headers' extends keyof Default<MethodSchema['response']>[StatusCode] ? [Default<MethodSchema['response']>[StatusCode]] extends [never] ? HttpResponseHeadersSchemaFromBody<Default<Default<MethodSchema['response']>[StatusCode]>, never> : (Default<Default<MethodSchema['response']>[StatusCode]>['headers'] & HttpResponseHeadersSchemaFromBody<Default<Default<MethodSchema['response']>[StatusCode]>, {}>) | Extract<Default<Default<MethodSchema['response']>[StatusCode]>['headers'], undefined> : HttpResponseHeadersSchemaFromBody<Default<Default<MethodSchema['response']>[StatusCode]>, never>;
674
- type HttpResponseBodySchema<MethodSchema extends HttpMethodSchema, StatusCode extends HttpStatusCode> = ReplaceBy<ReplaceBy<IfNever<DefaultNoExclude<Default<Default<MethodSchema['response']>[StatusCode]>['body']>, null>, undefined, null>, ArrayBuffer, Blob>;
674
+ type HttpResponseBodySchema<MethodSchema extends HttpMethodSchema, StatusCode extends HttpStatusCode> = ReplaceBy<IfNever<DefaultNoExclude<Default<Default<MethodSchema['response']>[StatusCode]>['body']>, null>, undefined, null>;
675
675
 
676
676
  export { type AllowAnyStringInPathParams, HTTP_METHODS, HttpBody, HttpFormData, HttpFormDataSchema, HttpFormDataSchemaName, type HttpFormDataSerialized, HttpHeaders, type HttpHeadersInit, HttpHeadersSchema, type HttpHeadersSchemaName, type HttpHeadersSchemaTuple, type HttpHeadersSerialized, type HttpMethod, type HttpMethodSchema, type HttpMethodsSchema, HttpPathParamsSchema, type HttpPathParamsSerialized, type HttpRequest, type HttpRequestBodySchema, type HttpRequestHeadersSchema, type HttpRequestSchema, type HttpRequestSearchParamsSchema, type HttpResponse, type HttpResponseBodySchema, type HttpResponseHeadersSchema, type HttpResponseSchema, type HttpResponseSchemaByStatusCode, type HttpResponseSchemaStatusCode, HttpSchema, type HttpSchemaMethod, HttpSchemaPath, HttpSearchParams, type HttpSearchParamsInit, HttpSearchParamsSchema, HttpSearchParamsSchemaName, type HttpSearchParamsSchemaTuple, type HttpSearchParamsSerialized, HttpStatusCode, type InferPathParams, type JSONSerialized, JSONValue, type LiteralHttpSchemaPathFromNonLiteral, type MergeHttpResponsesByStatusCode, type StrictFormData, type StrictHeaders, type StrictURLSearchParams };
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "api",
13
13
  "static"
14
14
  ],
15
- "version": "0.6.1",
15
+ "version": "0.7.0",
16
16
  "repository": {
17
17
  "type": "git",
18
18
  "url": "https://github.com/zimicjs/zimic.git",
@@ -91,7 +91,7 @@
91
91
  "typescript": "^5.8.3",
92
92
  "vitest": "^3.2.4",
93
93
  "@zimic/eslint-config-node": "0.0.0",
94
- "@zimic/interceptor": "0.20.2-canary.2",
94
+ "@zimic/interceptor": "0.21.0-canary.1",
95
95
  "@zimic/lint-staged-config": "0.0.0",
96
96
  "@zimic/tsconfig": "0.0.0",
97
97
  "@zimic/utils": "0.0.0"
@@ -12,7 +12,7 @@ import { HttpSearchParamsSchema } from '../searchParams/types';
12
12
 
13
13
  /** The body type for HTTP requests and responses. */
14
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- export type HttpBody = JSONValue | HttpFormData<any> | HttpSearchParams<any> | Blob | ArrayBuffer;
15
+ export type HttpBody = JSONValue | HttpFormData<any> | HttpSearchParams<any> | Blob | ArrayBuffer | ReadableStream;
16
16
 
17
17
  export namespace HttpBody {
18
18
  /** A loose version of the HTTP body type. JSON values are not strictly typed. */
@@ -124,9 +124,9 @@ export type HttpRequestSearchParamsSchema<MethodSchema extends HttpMethodSchema>
124
124
  'searchParams' extends keyof MethodSchema['request'] ? Default<MethodSchema['request']>['searchParams'] : never;
125
125
 
126
126
  export type HttpRequestBodySchema<MethodSchema extends HttpMethodSchema> = ReplaceBy<
127
- ReplaceBy<IfNever<DefaultNoExclude<Default<MethodSchema['request']>['body']>, null>, undefined, null>,
128
- ArrayBuffer,
129
- Blob
127
+ IfNever<DefaultNoExclude<Default<MethodSchema['request']>['body']>, null>,
128
+ undefined,
129
+ null
130
130
  >;
131
131
 
132
132
  type HttpResponseHeadersSchemaFromBody<
@@ -162,11 +162,7 @@ export type HttpResponseBodySchema<
162
162
  MethodSchema extends HttpMethodSchema,
163
163
  StatusCode extends HttpStatusCode,
164
164
  > = ReplaceBy<
165
- ReplaceBy<
166
- IfNever<DefaultNoExclude<Default<Default<MethodSchema['response']>[StatusCode]>['body']>, null>,
167
- undefined,
168
- null
169
- >,
170
- ArrayBuffer,
171
- Blob
165
+ IfNever<DefaultNoExclude<Default<Default<MethodSchema['response']>[StatusCode]>['body']>, null>,
166
+ undefined,
167
+ null
172
168
  >;