@zimic/http 0.3.1-canary.0 → 0.3.1-canary.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.3.1-canary.0";
15
+ var version = "0.3.1-canary.2";
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,IAAW,OAAA,GAAA,gBAAA;;;ACZb,eAAsB,iBAA6B,QAA6C,EAAA;AAC9F,EAAM,MAAA,uBAAA,GAA0B,YAAY,GAAI,EAAA;AAEhD,EAAM,MAAA,MAAA,GAAS,MAAM,QAAS,EAAA;AAE9B,EAAM,MAAA,qBAAA,GAAwB,YAAY,GAAI,EAAA;AAC9C,EAAA,MAAM,4BAA4B,qBAAwB,GAAA,uBAAA;AAE1D,EAAO,OAAA;AAAA,IACL,SAAW,EAAA,uBAAA;AAAA,IACX,WAAa,EAAA,yBAAA;AAAA,IACb,OAAS,EAAA,qBAAA;AAAA,IACT;AAAA,GACF;AACF;AAdsBA,uBAAA,CAAA,gBAAA,EAAA,kBAAA,CAAA;AAgBf,SAAS,kBAAkB,yBAAmC,EAAA;AACnE,EAAA,IAAI,4BAA4B,GAAM,EAAA;AACpC,IAAA,OAAO,CAAG,EAAA,yBAAA,CAA0B,OAAQ,CAAA,CAAC,CAAC,CAAA,EAAA,CAAA;AAAA,GACzC,MAAA;AACL,IAAA,OAAO,CAAI,EAAA,CAAA,yBAAA,GAA4B,GAAM,EAAA,OAAA,CAAQ,CAAC,CAAC,CAAA,CA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D,KAAM,EAAA;AACX;AA/FeL,uBAAA,CAAA,MAAA,EAAA,QAAA,CAAA;AAiGf,IAAO,WAAQ,GAAA,MAAA;;;ACxGf,KAAK,WAAO,EAAA","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.3.1-canary.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 \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=18.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:init\": \"playwright install chromium\"\n },\n \"dependencies\": {\n \"openapi-typescript\": \"7.6.1\",\n \"picocolors\": \"^1.1.1\",\n \"yargs\": \"17.7.2\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^22.14.0\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.1.1\",\n \"@vitest/coverage-istanbul\": \"^3.1.1\",\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.24.0\",\n \"execa\": \"9.5.2\",\n \"js-yaml\": \"^4.1.0\",\n \"playwright\": \"^1.51.1\",\n \"prettier\": \"^3.5.3\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.1.1\"\n },\n \"peerDependencies\": {\n \"typescript\": \">=4.8.0\"\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,IAAW,OAAA,GAAA,gBAAA;;;ACZb,eAAsB,iBAA6B,QAA6C,EAAA;AAC9F,EAAM,MAAA,uBAAA,GAA0B,YAAY,GAAI,EAAA;AAEhD,EAAM,MAAA,MAAA,GAAS,MAAM,QAAS,EAAA;AAE9B,EAAM,MAAA,qBAAA,GAAwB,YAAY,GAAI,EAAA;AAC9C,EAAA,MAAM,4BAA4B,qBAAwB,GAAA,uBAAA;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AM,IAAK,CAAA,QAAG,CAAC,CAAC,CAC5B,WAAA,EAAA,cAAA,GAAiBA,uBAAM,KAAM,CAAA,cAAc,IAAI,CAAM,GAAA,EAAAA,sBAAA,CAAM,OAAO,QAAQ,CAAC,CAAE,CAAA,CAAA,CAAA,EAAIA,sBAAM,CAAA,GAAA;AAAA,UACxF,CAAI,CAAA,EAAA,iBAAA,CAAkB,gBAAiB,CAAA,WAAW,CAAC,CAAA,CAAA;AAAA,SACpD,CAAA,CAAA;AAEH,QAAA,MAAM,qBAAqB,cAAmB,KAAA,MAAA;AAC9C,QAAAC,uBAAA,CAAO,kBAAqB,GAAA,MAAA,GAAS,MAAM,CAAA,CAAE,cAAc,CAAA;AAAA;AAC7D;AACF,IAGD,KAAM,EAAA;AACX;AA/FeL,uBAAA,CAAA,MAAA,EAAA,QAAA,CAAA;AAiGf,IAAO,WAAQ,GAAA,MAAA;;;ACxGf,KAAK,WAAO,EAAA","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.3.1-canary.2\",\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 \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=18.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:init\": \"playwright install chromium\"\n },\n \"dependencies\": {\n \"openapi-typescript\": \"7.6.1\",\n \"picocolors\": \"^1.1.1\",\n \"yargs\": \"17.7.2\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^22.14.1\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.1.1\",\n \"@vitest/coverage-istanbul\": \"^3.1.1\",\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.24.0\",\n \"execa\": \"9.5.2\",\n \"js-yaml\": \"^4.1.0\",\n \"playwright\": \"^1.51.1\",\n \"prettier\": \"^3.5.3\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.1.1\"\n },\n \"peerDependencies\": {\n \"typescript\": \">=4.8.0\"\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.3.1-canary.0";
8
+ var version = "0.3.1-canary.2";
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,IAAW,OAAA,GAAA,gBAAA;;;ACZb,eAAsB,iBAA6B,QAA6C,EAAA;AAC9F,EAAM,MAAA,uBAAA,GAA0B,YAAY,GAAI,EAAA;AAEhD,EAAM,MAAA,MAAA,GAAS,MAAM,QAAS,EAAA;AAE9B,EAAM,MAAA,qBAAA,GAAwB,YAAY,GAAI,EAAA;AAC9C,EAAA,MAAM,4BAA4B,qBAAwB,GAAA,uBAAA;AAE1D,EAAO,OAAA;AAAA,IACL,SAAW,EAAA,uBAAA;AAAA,IACX,WAAa,EAAA,yBAAA;AAAA,IACb,OAAS,EAAA,qBAAA;AAAA,IACT;AAAA,GACF;AACF;AAdsB,MAAA,CAAA,gBAAA,EAAA,kBAAA,CAAA;AAgBf,SAAS,kBAAkB,yBAAmC,EAAA;AACnE,EAAA,IAAI,4BAA4B,GAAM,EAAA;AACpC,IAAA,OAAO,CAAG,EAAA,yBAAA,CAA0B,OAAQ,CAAA,CAAC,CAAC,CAAA,EAAA,CAAA;AAAA,GACzC,MAAA;AACL,IAAA,OAAO,CAAI,EAAA,CAAA,yBAAA,GAA4B,GAAM,EAAA,OAAA,CAAQ,CAAC,CAAC,CAAA,CAAA,CAAA;AAAA;AAE3D;AANgB,MAAA,CAAA,iBAAA,EAAA,mBAAA,CAAA;;;ACRhB,eAAe,MAAS,GAAA;AACtB,EAAA,M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li.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.3.1-canary.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 \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=18.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:init\": \"playwright install chromium\"\n },\n \"dependencies\": {\n \"openapi-typescript\": \"7.6.1\",\n \"picocolors\": \"^1.1.1\",\n \"yargs\": \"17.7.2\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^22.14.0\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.1.1\",\n \"@vitest/coverage-istanbul\": \"^3.1.1\",\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.24.0\",\n \"execa\": \"9.5.2\",\n \"js-yaml\": \"^4.1.0\",\n \"playwright\": \"^1.51.1\",\n \"prettier\": \"^3.5.3\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.1.1\"\n },\n \"peerDependencies\": {\n \"typescript\": \">=4.8.0\"\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,IAAW,OAAA,GAAA,gBAAA;;;ACZb,eAAsB,iBAA6B,QAA6C,EAAA;AAC9F,EAAM,MAAA,uBAAA,GAA0B,YAAY,GAAI,EAAA;AAEhD,EAAM,MAAA,MAAA,GAAS,MAAM,QAAS,EAAA;AAE9B,EAAM,MAAA,qBAAA,GAAwB,YAAY,GAAI,EAAA;AAC9C,EAAA,MAAM,4BAA4B,qBAAwB,GAAA,uBAAA;AAE1D,EAAO,OAAA;AAAA,IACL,SAAW,EAAA,uBAAA;AAAA,IACX,WAAa,EAAA,yBAAA;AAAA,IACb,OAAS,EAAA,qBAAA;AAAA,IACT;AAAA,GACF;AACF;AAdsB,MAAA,CAAA,gB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AAI,KAAM,CAAA,GAAA;AAAA,UACxF,CAAI,CAAA,EAAA,iBAAA,CAAkB,gBAAiB,CAAA,WAAW,CAAC,CAAA,CAAA;AAAA,SACpD,CAAA,CAAA;AAEH,QAAA,MAAM,qBAAqB,cAAmB,KAAA,MAAA;AAC9C,QAAA,MAAA,CAAO,kBAAqB,GAAA,MAAA,GAAS,MAAM,CAAA,CAAE,cAAc,CAAA;AAAA;AAC7D;AACF,IAGD,KAAM,EAAA;AACX;AA/Fe,MAAA,CAAA,MAAA,EAAA,QAAA,CAAA;AAiGf,IAAO,WAAQ,GAAA,MAAA;;;ACxGf,KAAK,WAAO,EAAA","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.3.1-canary.2\",\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 \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=18.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:init\": \"playwright install chromium\"\n },\n \"dependencies\": {\n \"openapi-typescript\": \"7.6.1\",\n \"picocolors\": \"^1.1.1\",\n \"yargs\": \"17.7.2\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^22.14.1\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.1.1\",\n \"@vitest/coverage-istanbul\": \"^3.1.1\",\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.24.0\",\n \"execa\": \"9.5.2\",\n \"js-yaml\": \"^4.1.0\",\n \"playwright\": \"^1.51.1\",\n \"prettier\": \"^3.5.3\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.1.1\"\n },\n \"peerDependencies\": {\n \"typescript\": \">=4.8.0\"\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.js CHANGED
@@ -7,9 +7,50 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7
7
  var __defProp2 = Object.defineProperty;
8
8
  var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
9
9
 
10
- // ../zimic-utils/dist/chunk-VXSYL3FX.mjs
10
+ // ../zimic-utils/dist/chunk-HBO3G76H.mjs
11
11
  async function blobEquals(blob, otherBlob) {
12
- return blob.type === otherBlob.type && blob.size === otherBlob.size && await blob.text() === await otherBlob.text();
12
+ if (blob.type !== otherBlob.type || blob.size !== otherBlob.size) {
13
+ return false;
14
+ }
15
+ const reader = blob.stream().getReader();
16
+ const otherReader = otherBlob.stream().getReader();
17
+ let buffer = new Uint8Array(0);
18
+ let otherBuffer = new Uint8Array(0);
19
+ try {
20
+ while (true) {
21
+ await Promise.all([
22
+ buffer.length === 0 && reader.read().then((result) => {
23
+ if (!result.done) {
24
+ buffer = result.value;
25
+ }
26
+ }),
27
+ otherBuffer.length === 0 && otherReader.read().then((result) => {
28
+ if (!result.done) {
29
+ otherBuffer = result.value;
30
+ }
31
+ })
32
+ ]);
33
+ const streamsEndedTogether = buffer.length === 0 && otherBuffer.length === 0;
34
+ if (streamsEndedTogether) {
35
+ return true;
36
+ }
37
+ const oneStreamEndedBeforeTheOther = buffer.length === 0 && otherBuffer.length > 0 || buffer.length > 0 && otherBuffer.length === 0;
38
+ if (oneStreamEndedBeforeTheOther) {
39
+ return false;
40
+ }
41
+ const minimumByteLength = Math.min(buffer.length, otherBuffer.length);
42
+ for (let byteIndex = 0; byteIndex < minimumByteLength; byteIndex++) {
43
+ if (buffer[byteIndex] !== otherBuffer[byteIndex]) {
44
+ return false;
45
+ }
46
+ }
47
+ buffer = buffer.slice(minimumByteLength);
48
+ otherBuffer = otherBuffer.slice(minimumByteLength);
49
+ }
50
+ } finally {
51
+ reader.releaseLock();
52
+ otherReader.releaseLock();
53
+ }
13
54
  }
14
55
  __name(blobEquals, "blobEquals");
15
56
  __name2(blobEquals, "blobEquals");
@@ -101,22 +142,8 @@ var HttpFormData = class extends FormData {
101
142
  * Important: both form data might be read while comparing.
102
143
  */
103
144
  async equals(otherData) {
104
- for (const [otherKey, otherValue] of otherData.entries()) {
105
- const values = super.getAll.call(this, otherKey);
106
- const haveSameNumberOfValues = values.length === super.getAll.call(otherData, otherKey).length;
107
- if (!haveSameNumberOfValues) {
108
- return false;
109
- }
110
- let valueExists = false;
111
- for (const value of values) {
112
- if (value === otherValue || value instanceof Blob && otherValue instanceof Blob && await fileEquals_default(value, otherValue)) {
113
- valueExists = true;
114
- break;
115
- }
116
- }
117
- if (!valueExists) {
118
- return false;
119
- }
145
+ if (!await this.contains(otherData)) {
146
+ return false;
120
147
  }
121
148
  for (const key of this.keys()) {
122
149
  const otherHasKey = super.has.call(otherData, key);
@@ -137,13 +164,13 @@ var HttpFormData = class extends FormData {
137
164
  async contains(otherData) {
138
165
  for (const [otherKey, otherValue] of otherData.entries()) {
139
166
  const values = super.getAll.call(this, otherKey);
140
- const haveCompatibleNumberOfValues = values.length >= super.getAll.call(otherData, otherKey).length;
141
- if (!haveCompatibleNumberOfValues) {
167
+ const haveSameNumberOfValues = values.length === super.getAll.call(otherData, otherKey).length;
168
+ if (!haveSameNumberOfValues) {
142
169
  return false;
143
170
  }
144
171
  let valueExists = false;
145
172
  for (const value of values) {
146
- if (value === otherValue || typeof value === "string" && typeof otherValue === "string" && value === otherValue || value instanceof Blob && otherValue instanceof Blob && await fileEquals_default(value, otherValue)) {
173
+ if (value === otherValue || value instanceof Blob && otherValue instanceof Blob && await fileEquals_default(value, otherValue)) {
147
174
  valueExists = true;
148
175
  break;
149
176
  }
@@ -268,22 +295,8 @@ var HttpHeaders = class extends Headers {
268
295
  * @returns `true` if the headers are equal, `false` otherwise.
269
296
  */
270
297
  equals(otherHeaders) {
271
- for (const [key, otherValue] of otherHeaders.entries()) {
272
- const value = super.get.call(this, key);
273
- if (value === null) {
274
- return false;
275
- }
276
- const valueItems = this.splitHeaderValues(value);
277
- const otherValueItems = this.splitHeaderValues(otherValue);
278
- const haveCompatibleNumberOfValues = valueItems.length === otherValueItems.length;
279
- if (!haveCompatibleNumberOfValues) {
280
- return false;
281
- }
282
- for (const otherValueItem of otherValueItems) {
283
- if (!valueItems.includes(otherValueItem)) {
284
- return false;
285
- }
286
- }
298
+ if (!this.contains(otherHeaders)) {
299
+ return false;
287
300
  }
288
301
  for (const key of this.keys()) {
289
302
  const otherHasKey = super.has.call(otherHeaders, key);
@@ -309,8 +322,8 @@ var HttpHeaders = class extends Headers {
309
322
  }
310
323
  const valueItems = this.splitHeaderValues(value);
311
324
  const otherValueItems = this.splitHeaderValues(otherValue);
312
- const haveCompatibleNumberOfValues = valueItems.length >= otherValueItems.length;
313
- if (!haveCompatibleNumberOfValues) {
325
+ const haveSameNumberOfValues = valueItems.length === otherValueItems.length;
326
+ if (!haveSameNumberOfValues) {
314
327
  return false;
315
328
  }
316
329
  for (const otherValueItem of otherValueItems) {
@@ -448,18 +461,7 @@ var HttpSearchParams = class extends URLSearchParams {
448
461
  * @returns `true` if the search parameters are equal, `false` otherwise.
449
462
  */
450
463
  equals(otherParams) {
451
- for (const [key, otherValue] of otherParams.entries()) {
452
- const values = super.getAll.call(this, key);
453
- const haveSameNumberOfValues = values.length === super.getAll.call(otherParams, key).length;
454
- if (!haveSameNumberOfValues) {
455
- return false;
456
- }
457
- const valueExists = values.includes(otherValue);
458
- if (!valueExists) {
459
- return false;
460
- }
461
- }
462
- return this.size === otherParams.size;
464
+ return this.contains(otherParams) && this.size === otherParams.size;
463
465
  }
464
466
  /**
465
467
  * Checks if these search params contain another set of search parameters. This method is less strict than
@@ -472,8 +474,8 @@ var HttpSearchParams = class extends URLSearchParams {
472
474
  contains(otherParams) {
473
475
  for (const [key, otherValue] of otherParams.entries()) {
474
476
  const values = super.getAll.call(this, key);
475
- const haveCompatibleNumberOfValues = values.length >= super.getAll.call(otherParams, key).length;
476
- if (!haveCompatibleNumberOfValues) {
477
+ const haveSameNumberOfValues = values.length === super.getAll.call(otherParams, key).length;
478
+ if (!haveSameNumberOfValues) {
477
479
  return false;
478
480
  }
479
481
  const valueExists = values.includes(otherValue);