@zimic/http 0.1.0-canary.2 → 0.1.0-canary.3

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 yargs__default = /*#__PURE__*/_interopDefault(yargs);
12
12
  var chalk__default = /*#__PURE__*/_interopDefault(chalk);
13
13
 
14
14
  // package.json
15
- var version = "0.1.0-canary.2";
15
+ var version = "0.1.0-canary.3";
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/typegen/openapi.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["__name","typegen","chalk","logWithPrefix","yargs","hideBin"],"mappings":";;;;;;;;;;;;;;AAYE,IAAW,OAAA,GAAA,gBAAA;;;ACVb,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,O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C1B,iBAAiB,YAAa,CAAA,QAAA;AAAA,UAC9B,OAAO,YAAa,CAAA,KAAA;AAAA,UACpB,SAAS,YAAa,CAAA,MAAA;AAAA,UACtB,YAAY,YAAa,CAAA;AAAA,SAC1B,CAAA;AAAA;AACH;AACF,IAGD,KAAM,EAAA;AACX;AAlFeJ,uBAAA,CAAA,MAAA,EAAA,QAAA,CAAA;AAoFf,IAAO,WAAQ,GAAA,MAAA;;;ACxFf,KAAK,WAAO,EAAA","file":"cli.js","sourcesContent":["{\n \"name\": \"@zimic/http\",\n \"description\": \"TypeScript-first HTTP resources\",\n \"keywords\": [\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"static\"\n ],\n \"version\": \"0.1.0-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 \"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\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./typegen\": {\n \"types\": \"./dist/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 ./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.js\",\n \"deps:init\": \"playwright install chromium\",\n \"prepublish:patch-relative-paths\": \"sed -E -i 's/\\\\]\\\\(\\\\.\\\\/([^\\\\)]+)\\\\)/](..\\\\/..\\\\/\\\\1)/g;s/\\\"\\\\.\\\\/([^\\\"]+)\\\"/\\\"..\\\\/..\\\\/\\\\1\\\"/g'\",\n \"prepublishOnly\": \"cp ../../README.md ../../LICENSE.md . && pnpm prepublish:patch-relative-paths README.md\"\n },\n \"dependencies\": {\n \"chalk\": \"4.1.2\",\n \"openapi-typescript\": \"7.6.1\",\n \"yargs\": \"17.7.2\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^22.13.4\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.0.5\",\n \"@vitest/coverage-istanbul\": \"^3.0.5\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"dotenv-cli\": \"^8.0.0\",\n \"eslint\": \"^9.20.1\",\n \"execa\": \"9.5.2\",\n \"js-yaml\": \"^4.1.0\",\n \"playwright\": \"^1.50.1\",\n \"prettier\": \"^3.5.1\",\n \"tsup\": \"^8.3.6\",\n \"tsx\": \"^4.19.2\",\n \"typescript\": \"^5.7.3\",\n \"vitest\": \"^3.0.5\",\n \"zimic\": \"^0.13.2\"\n },\n \"peerDependencies\": {\n \"typescript\": \">=4.8.0\"\n }\n}\n","import { PossiblePromise } from '@/types/utils';\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 chalk from 'chalk';\n\nimport { OpenAPITypegenOptions, typegen } from '@/typegen';\nimport { logWithPrefix } from '@/utils/console';\nimport { usingElapsedTime, formatElapsedTime } from '@/utils/time';\n\nasync function generateTypesFromOpenAPI(options: OpenAPITypegenOptions) {\n const executionSummary = await usingElapsedTime(async () => {\n await typegen.generateFromOpenAPI(options);\n });\n\n const outputFilePath = options.output;\n\n const successMessage =\n `${chalk.green.bold('✔')} Generated ` +\n `${outputFilePath ? chalk.green(outputFilePath) : `to ${chalk.yellow('stdout')}`} ${chalk.dim(\n `(${formatElapsedTime(executionSummary.elapsedTime)})`,\n )}`;\n\n const hasWrittenToStdout = outputFilePath === undefined;\n logWithPrefix(successMessage, { method: hasWrittenToStdout ? 'warn' : 'log' });\n}\n\nexport default generateTypesFromOpenAPI;\n","import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport generateTypesFromOpenAPI from './typegen/openapi';\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 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 )\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/typegen/openapi.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["__name","typegen","chalk","logWithPrefix","yargs","hideBin"],"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,CAAA,CAAA;AAAA;AAE3D;AANgBA,uBAAA,CAAA,iBAAA,EAAA,mBAAA,CAAA;;;ACZhB,eAAe,yBAAyB,OAAgC,EAAA;AACtE,EAAM,MAAA,gBAAA,GAAmB,MAAM,gBAAA,CAAiB,YAAY;AAC1D,IAAM,MAAAC,wBAAA,CAAQ,oBAAoB,OAAO,CAAA;AAAA,GAC1C,CAAA;AAED,EAAA,MAAM,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AO,EAAA","file":"cli.js","sourcesContent":["{\n \"name\": \"@zimic/http\",\n \"description\": \"TypeScript-first HTTP resources\",\n \"keywords\": [\n \"zimic\",\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"api\",\n \"static\"\n ],\n \"version\": \"0.1.0-canary.3\",\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 \"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\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./typegen\": {\n \"types\": \"./dist/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 ./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.js\",\n \"deps:init\": \"playwright install chromium\",\n \"prepublish:patch-relative-paths\": \"sed -E -i 's/\\\\]\\\\(\\\\.\\\\/([^\\\\)]+)\\\\)/](..\\\\/..\\\\/\\\\1)/g;s/\\\"\\\\.\\\\/([^\\\"]+)\\\"/\\\"..\\\\/..\\\\/\\\\1\\\"/g'\",\n \"prepublishOnly\": \"cp ../../README.md ../../LICENSE.md . && pnpm prepublish:patch-relative-paths README.md\"\n },\n \"dependencies\": {\n \"chalk\": \"4.1.2\",\n \"openapi-typescript\": \"7.6.1\",\n \"yargs\": \"17.7.2\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^22.13.5\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.0.6\",\n \"@vitest/coverage-istanbul\": \"^3.0.6\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"dotenv-cli\": \"^8.0.0\",\n \"eslint\": \"^9.21.0\",\n \"execa\": \"9.5.2\",\n \"js-yaml\": \"^4.1.0\",\n \"playwright\": \"^1.50.1\",\n \"prettier\": \"^3.5.2\",\n \"tsup\": \"^8.3.6\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.7.3\",\n \"vitest\": \"^3.0.6\",\n \"zimic\": \"^0.13.2\"\n },\n \"peerDependencies\": {\n \"typescript\": \">=4.8.0\"\n }\n}\n","import { PossiblePromise } from '@/types/utils';\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 chalk from 'chalk';\n\nimport { OpenAPITypegenOptions, typegen } from '@/typegen';\nimport { logWithPrefix } from '@/utils/console';\nimport { usingElapsedTime, formatElapsedTime } from '@/utils/time';\n\nasync function generateTypesFromOpenAPI(options: OpenAPITypegenOptions) {\n const executionSummary = await usingElapsedTime(async () => {\n await typegen.generateFromOpenAPI(options);\n });\n\n const outputFilePath = options.output;\n\n const successMessage =\n `${chalk.green.bold('✔')} Generated ` +\n `${outputFilePath ? chalk.green(outputFilePath) : `to ${chalk.yellow('stdout')}`} ${chalk.dim(\n `(${formatElapsedTime(executionSummary.elapsedTime)})`,\n )}`;\n\n const hasWrittenToStdout = outputFilePath === undefined;\n logWithPrefix(successMessage, { method: hasWrittenToStdout ? 'warn' : 'log' });\n}\n\nexport default generateTypesFromOpenAPI;\n","import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport generateTypesFromOpenAPI from './typegen/openapi';\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 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 )\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 { hideBin } from 'yargs/helpers';
5
5
  import chalk from 'chalk';
6
6
 
7
7
  // package.json
8
- var version = "0.1.0-canary.2";
8
+ var version = "0.1.0-canary.3";
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/typegen/openapi.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["yargs"],"mappings":";;;;;;;AAYE,IAAW,OAAA,GAAA,gBAAA;;;ACVb,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;;;ACZhB,eAAe,yBAAyB,OAAgC,EAAA;AACtE,EAAM,MAAA,gBAAA,GAAmB,MAAM,gBAAA,CAAiB,YAAY;AAC1D,IAAM,MAAA,OAAA,CAAQ,oBAAoB,OAAO,CAAA;AAAA,GAC1C,CAAA;AAED,EAAA,MAAM,iBAAiB,OAAQ,CAAA,MAAA;AAE/B,EAAM,MAAA,cAAA,GACJ,GAAG,KAAM,CAAA,K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,QACb,KAAO,EAAA,GAAA;AAAA,QACP,YAAc,EAAA;AAAA,OACf,CACA,CAAA,MAAA,CAAO,UAAY,EAAA;AAAA,QAClB,IAAM,EAAA,SAAA;AAAA,QACN,WAAa,EAAA,qDAAA;AAAA,QACb,KAAO,EAAA,GAAA;AAAA,QACP,OAAS,EAAA;AAAA,OACV,CACA,CAAA,MAAA,CAAO,OAAS,EAAA;AAAA,QACf,IAAM,EAAA,SAAA;AAAA,QACN,WACE,EAAA,uIAAA;AAAA,QAEF,KAAO,EAAA,GAAA;AAAA,QACP,OAAS,EAAA;AAAA,OACV,CACA,CAAA,MAAA,CAAO,QAAU,EAAA;AAAA,QAChB,IAAM,EAAA,QAAA;AAAA,QACN,KAAO,EAAA,IAAA;AAAA,QACP,WACE,EAAA,ulBAAA;AAAA,QAOF,KAAO,EAAA;AAAA,OACR,CACA,CAAA,MAAA,CAAO,aAAe,EAAA;AAAA,QACrB,IAAM,EAAA,QAAA;AAAA,QACN,WACE,EAAA,uPAAA;AAAA,QAGF,KAAO,EAAA;AAAA,OACR,CAAA;AAAA,MACL,OAAO,YAAiB,KAAA;AACtB,QAAA,MAAM,eAAyB,CAAA;AAAA,UAC7B,OAAO,YAAa,CAAA,KAAA;AAAA,UACpB,QAAQ,YAAa,CAAA,MAAA;AAAA,UACrB,aAAa,YAAa,CAAA,WAAA;AAAA,UAC1B,iBAAiB,YAAa,CAAA,QAAA;AAAA,UAC9B,OAAO,YAAa,CAAA,KAAA;AAAA,UACpB,SAAS,YAAa,CAAA,MAAA;AAAA,UACtB,YAAY,YAAa,CAAA;AAAA,SAC1B,CAAA;AAAA;AACH;AACF,IAGD,KAAM,EAAA;AACX;AAlFe,MAAA,CAAA,MAAA,EAAA,QAAA,CAAA;AAoFf,IAAO,WAAQ,GAAA,MAAA;;;ACxFf,KAAK,WAAO,EAAA","file":"cli.mjs","sourcesContent":["{\n \"name\": \"@zimic/http\",\n \"description\": \"TypeScript-first HTTP resources\",\n \"keywords\": [\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"static\"\n ],\n \"version\": \"0.1.0-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 \"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\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./typegen\": {\n \"types\": \"./dist/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 ./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.js\",\n \"deps:init\": \"playwright install chromium\",\n \"prepublish:patch-relative-paths\": \"sed -E -i 's/\\\\]\\\\(\\\\.\\\\/([^\\\\)]+)\\\\)/](..\\\\/..\\\\/\\\\1)/g;s/\\\"\\\\.\\\\/([^\\\"]+)\\\"/\\\"..\\\\/..\\\\/\\\\1\\\"/g'\",\n \"prepublishOnly\": \"cp ../../README.md ../../LICENSE.md . && pnpm prepublish:patch-relative-paths README.md\"\n },\n \"dependencies\": {\n \"chalk\": \"4.1.2\",\n \"openapi-typescript\": \"7.6.1\",\n \"yargs\": \"17.7.2\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^22.13.4\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.0.5\",\n \"@vitest/coverage-istanbul\": \"^3.0.5\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"dotenv-cli\": \"^8.0.0\",\n \"eslint\": \"^9.20.1\",\n \"execa\": \"9.5.2\",\n \"js-yaml\": \"^4.1.0\",\n \"playwright\": \"^1.50.1\",\n \"prettier\": \"^3.5.1\",\n \"tsup\": \"^8.3.6\",\n \"tsx\": \"^4.19.2\",\n \"typescript\": \"^5.7.3\",\n \"vitest\": \"^3.0.5\",\n \"zimic\": \"^0.13.2\"\n },\n \"peerDependencies\": {\n \"typescript\": \">=4.8.0\"\n }\n}\n","import { PossiblePromise } from '@/types/utils';\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 chalk from 'chalk';\n\nimport { OpenAPITypegenOptions, typegen } from '@/typegen';\nimport { logWithPrefix } from '@/utils/console';\nimport { usingElapsedTime, formatElapsedTime } from '@/utils/time';\n\nasync function generateTypesFromOpenAPI(options: OpenAPITypegenOptions) {\n const executionSummary = await usingElapsedTime(async () => {\n await typegen.generateFromOpenAPI(options);\n });\n\n const outputFilePath = options.output;\n\n const successMessage =\n `${chalk.green.bold('✔')} Generated ` +\n `${outputFilePath ? chalk.green(outputFilePath) : `to ${chalk.yellow('stdout')}`} ${chalk.dim(\n `(${formatElapsedTime(executionSummary.elapsedTime)})`,\n )}`;\n\n const hasWrittenToStdout = outputFilePath === undefined;\n logWithPrefix(successMessage, { method: hasWrittenToStdout ? 'warn' : 'log' });\n}\n\nexport default generateTypesFromOpenAPI;\n","import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport generateTypesFromOpenAPI from './typegen/openapi';\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 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 )\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/typegen/openapi.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,EAA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,EAAA;AAAA,OACV,CACA,CAAA,MAAA,CAAO,QAAU,EAAA;AAAA,QAChB,IAAM,EAAA,QAAA;AAAA,QACN,KAAO,EAAA,IAAA;AAAA,QACP,WACE,EAAA,ulBAAA;AAAA,QAOF,KAAO,EAAA;AAAA,OACR,CACA,CAAA,MAAA,CAAO,aAAe,EAAA;AAAA,QACrB,IAAM,EAAA,QAAA;AAAA,QACN,WACE,EAAA,uPAAA;AAAA,QAGF,KAAO,EAAA;AAAA,OACR,CAAA;AAAA,MACL,OAAO,YAAiB,KAAA;AACtB,QAAA,MAAM,eAAyB,CAAA;AAAA,UAC7B,OAAO,YAAa,CAAA,KAAA;AAAA,UACpB,QAAQ,YAAa,CAAA,MAAA;AAAA,UACrB,aAAa,YAAa,CAAA,WAAA;AAAA,UAC1B,iBAAiB,YAAa,CAAA,QAAA;AAAA,UAC9B,OAAO,YAAa,CAAA,KAAA;AAAA,UACpB,SAAS,YAAa,CAAA,MAAA;AAAA,UACtB,YAAY,YAAa,CAAA;AAAA,SAC1B,CAAA;AAAA;AACH;AACF,IAGD,KAAM,EAAA;AACX;AAlFe,MAAA,CAAA,MAAA,EAAA,QAAA,CAAA;AAoFf,IAAO,WAAQ,GAAA,MAAA;;;ACxFf,KAAK,WAAO,EAAA","file":"cli.mjs","sourcesContent":["{\n \"name\": \"@zimic/http\",\n \"description\": \"TypeScript-first HTTP resources\",\n \"keywords\": [\n \"zimic\",\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"api\",\n \"static\"\n ],\n \"version\": \"0.1.0-canary.3\",\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 \"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\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./typegen\": {\n \"types\": \"./dist/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 ./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.js\",\n \"deps:init\": \"playwright install chromium\",\n \"prepublish:patch-relative-paths\": \"sed -E -i 's/\\\\]\\\\(\\\\.\\\\/([^\\\\)]+)\\\\)/](..\\\\/..\\\\/\\\\1)/g;s/\\\"\\\\.\\\\/([^\\\"]+)\\\"/\\\"..\\\\/..\\\\/\\\\1\\\"/g'\",\n \"prepublishOnly\": \"cp ../../README.md ../../LICENSE.md . && pnpm prepublish:patch-relative-paths README.md\"\n },\n \"dependencies\": {\n \"chalk\": \"4.1.2\",\n \"openapi-typescript\": \"7.6.1\",\n \"yargs\": \"17.7.2\"\n },\n \"devDependencies\": {\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^22.13.5\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.0.6\",\n \"@vitest/coverage-istanbul\": \"^3.0.6\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"dotenv-cli\": \"^8.0.0\",\n \"eslint\": \"^9.21.0\",\n \"execa\": \"9.5.2\",\n \"js-yaml\": \"^4.1.0\",\n \"playwright\": \"^1.50.1\",\n \"prettier\": \"^3.5.2\",\n \"tsup\": \"^8.3.6\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.7.3\",\n \"vitest\": \"^3.0.6\",\n \"zimic\": \"^0.13.2\"\n },\n \"peerDependencies\": {\n \"typescript\": \">=4.8.0\"\n }\n}\n","import { PossiblePromise } from '@/types/utils';\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 chalk from 'chalk';\n\nimport { OpenAPITypegenOptions, typegen } from '@/typegen';\nimport { logWithPrefix } from '@/utils/console';\nimport { usingElapsedTime, formatElapsedTime } from '@/utils/time';\n\nasync function generateTypesFromOpenAPI(options: OpenAPITypegenOptions) {\n const executionSummary = await usingElapsedTime(async () => {\n await typegen.generateFromOpenAPI(options);\n });\n\n const outputFilePath = options.output;\n\n const successMessage =\n `${chalk.green.bold('✔')} Generated ` +\n `${outputFilePath ? chalk.green(outputFilePath) : `to ${chalk.yellow('stdout')}`} ${chalk.dim(\n `(${formatElapsedTime(executionSummary.elapsedTime)})`,\n )}`;\n\n const hasWrittenToStdout = outputFilePath === undefined;\n logWithPrefix(successMessage, { method: hasWrittenToStdout ? 'warn' : 'log' });\n}\n\nexport default generateTypesFromOpenAPI;\n","import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport generateTypesFromOpenAPI from './typegen/openapi';\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 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 )\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
@@ -66,6 +66,7 @@ type JSONSerialized<Type> = Type extends JSONValue ? Type : Type extends string
66
66
  } : never;
67
67
 
68
68
  type Default<Type, IfEmpty = never> = [undefined | void] extends [Type] ? IfEmpty : Exclude<Type, undefined | void>;
69
+ type DefaultNoExclude<Type, IfEmpty = never> = [undefined | void] extends Type ? IfEmpty : Type;
69
70
  type IfAny<Type, Yes, No = Type> = 0 extends 1 & Type ? Yes : No;
70
71
  type IfNever<Type, Yes, No = Type> = [Type] extends [never] ? Yes : No;
71
72
  type UnionToIntersection<Union> = (Union extends unknown ? (union: Union) => void : never) extends (intersectedUnion: infer IntersectedUnion) => void ? IntersectedUnion : never;
@@ -1302,5 +1303,10 @@ interface HttpResponse<StrictBody extends HttpBody.Loose = HttpBody, StatusCode
1302
1303
  formData: () => Promise<StrictBody extends HttpFormData<infer HttpFormDataSchema> ? StrictFormData<HttpFormDataSchema> : StrictBody extends HttpSearchParams<infer HttpSearchParamsSchema> ? StrictFormData<HttpSearchParamsSchema> : FormData>;
1303
1304
  clone: () => this;
1304
1305
  }
1306
+ type HttpRequestHeadersSchema<MethodSchema extends HttpMethodSchema> = Default<Default<MethodSchema['request']>['headers']>;
1307
+ type HttpRequestSearchParamsSchema<MethodSchema extends HttpMethodSchema> = Default<Default<MethodSchema['request']>['searchParams']>;
1308
+ type HttpRequestBodySchema<MethodSchema extends HttpMethodSchema> = ReplaceBy<ReplaceBy<IfNever<DefaultNoExclude<Default<MethodSchema['request']>['body']>, null>, undefined, null>, ArrayBuffer, Blob>;
1309
+ type HttpResponseHeadersSchema<MethodSchema extends HttpMethodSchema, StatusCode extends HttpStatusCode> = Default<DefaultNoExclude<Default<Default<MethodSchema['response']>[StatusCode]>['headers']>>;
1310
+ type HttpResponseBodySchema<MethodSchema extends HttpMethodSchema, StatusCode extends HttpStatusCode> = ReplaceBy<ReplaceBy<IfNever<DefaultNoExclude<Default<Default<MethodSchema['response']>[StatusCode]>['body']>, null>, undefined, null>, ArrayBuffer, Blob>;
1305
1311
 
1306
- export { type AllowAnyStringInPathParams, HTTP_METHODS, HTTP_METHODS_WITH_REQUEST_BODY, HTTP_METHODS_WITH_RESPONSE_BODY, HttpBody, HttpFormData, HttpFormDataSchema, HttpFormDataSchemaName, type HttpFormDataSerialized, HttpHeaders, type HttpHeadersInit, HttpHeadersSchema, type HttpHeadersSchemaName, type HttpHeadersSchemaTuple, type HttpHeadersSerialized, type HttpMethod, HttpMethodSchema, type HttpMethodWithRequestBody, type HttpMethodWithResponseBody, type HttpMethodsSchema, HttpPathParamsSchema, type HttpPathParamsSerialized, type HttpRequest, type HttpRequestSchema, type HttpResponse, HttpResponseSchema, 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 };
1312
+ export { type AllowAnyStringInPathParams, HTTP_METHODS, HTTP_METHODS_WITH_REQUEST_BODY, HTTP_METHODS_WITH_RESPONSE_BODY, HttpBody, HttpFormData, HttpFormDataSchema, HttpFormDataSchemaName, type HttpFormDataSerialized, HttpHeaders, type HttpHeadersInit, HttpHeadersSchema, type HttpHeadersSchemaName, type HttpHeadersSchemaTuple, type HttpHeadersSerialized, type HttpMethod, HttpMethodSchema, type HttpMethodWithRequestBody, type HttpMethodWithResponseBody, type HttpMethodsSchema, HttpPathParamsSchema, type HttpPathParamsSerialized, type HttpRequest, type HttpRequestBodySchema, type HttpRequestHeadersSchema, type HttpRequestSchema, type HttpRequestSearchParamsSchema, type HttpResponse, type HttpResponseBodySchema, type HttpResponseHeadersSchema, HttpResponseSchema, 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
@@ -2,15 +2,17 @@
2
2
  "name": "@zimic/http",
3
3
  "description": "TypeScript-first HTTP resources",
4
4
  "keywords": [
5
+ "zimic",
5
6
  "typescript",
6
7
  "types",
7
8
  "typegen",
8
9
  "validation",
9
10
  "inference",
10
11
  "http",
12
+ "api",
11
13
  "static"
12
14
  ],
13
- "version": "0.1.0-canary.2",
15
+ "version": "0.1.0-canary.3",
14
16
  "repository": {
15
17
  "type": "git",
16
18
  "url": "https://github.com/zimicjs/zimic.git",
@@ -69,24 +71,24 @@
69
71
  },
70
72
  "devDependencies": {
71
73
  "@types/js-yaml": "^4.0.9",
72
- "@types/node": "^22.13.4",
74
+ "@types/node": "^22.13.5",
73
75
  "@types/yargs": "^17.0.33",
74
- "@vitest/browser": "^3.0.5",
75
- "@vitest/coverage-istanbul": "^3.0.5",
76
+ "@vitest/browser": "^3.0.6",
77
+ "@vitest/coverage-istanbul": "^3.0.6",
76
78
  "dotenv-cli": "^8.0.0",
77
- "eslint": "^9.20.1",
79
+ "eslint": "^9.21.0",
78
80
  "execa": "9.5.2",
79
81
  "js-yaml": "^4.1.0",
80
82
  "playwright": "^1.50.1",
81
- "prettier": "^3.5.1",
83
+ "prettier": "^3.5.2",
82
84
  "tsup": "^8.3.6",
83
- "tsx": "^4.19.2",
85
+ "tsx": "^4.19.3",
84
86
  "typescript": "^5.7.3",
85
- "vitest": "^3.0.5",
87
+ "vitest": "^3.0.6",
86
88
  "zimic": "^0.13.2",
89
+ "@zimic/lint-staged-config": "0.0.0",
87
90
  "@zimic/eslint-config-node": "0.0.0",
88
- "@zimic/tsconfig": "0.0.0",
89
- "@zimic/lint-staged-config": "0.0.0"
91
+ "@zimic/tsconfig": "0.0.0"
90
92
  },
91
93
  "peerDependencies": {
92
94
  "typescript": ">=4.8.0"
package/src/index.ts CHANGED
@@ -30,6 +30,11 @@ export type {
30
30
  StrictHeaders,
31
31
  StrictURLSearchParams,
32
32
  StrictFormData,
33
+ HttpRequestHeadersSchema,
34
+ HttpRequestBodySchema,
35
+ HttpRequestSearchParamsSchema,
36
+ HttpResponseHeadersSchema,
37
+ HttpResponseBodySchema,
33
38
  } from './types/requests';
34
39
 
35
40
  export type {
@@ -1,6 +1,6 @@
1
1
  import { JSONSerialized, JSONValue } from '@/types/json';
2
- import { HttpStatusCode } from '@/types/schema';
3
- import { ReplaceBy } from '@/types/utils';
2
+ import { HttpMethodSchema, HttpStatusCode } from '@/types/schema';
3
+ import { Default, DefaultNoExclude, IfNever, ReplaceBy } from '@/types/utils';
4
4
 
5
5
  import HttpFormData from '../formData/HttpFormData';
6
6
  import { HttpFormDataSchema } from '../formData/types';
@@ -94,3 +94,35 @@ export interface HttpResponse<
94
94
  >;
95
95
  clone: () => this;
96
96
  }
97
+
98
+ export type HttpRequestHeadersSchema<MethodSchema extends HttpMethodSchema> = Default<
99
+ Default<MethodSchema['request']>['headers']
100
+ >;
101
+
102
+ export type HttpRequestSearchParamsSchema<MethodSchema extends HttpMethodSchema> = Default<
103
+ Default<MethodSchema['request']>['searchParams']
104
+ >;
105
+
106
+ export type HttpRequestBodySchema<MethodSchema extends HttpMethodSchema> = ReplaceBy<
107
+ ReplaceBy<IfNever<DefaultNoExclude<Default<MethodSchema['request']>['body']>, null>, undefined, null>,
108
+ ArrayBuffer,
109
+ Blob
110
+ >;
111
+
112
+ export type HttpResponseHeadersSchema<
113
+ MethodSchema extends HttpMethodSchema,
114
+ StatusCode extends HttpStatusCode,
115
+ > = Default<DefaultNoExclude<Default<Default<MethodSchema['response']>[StatusCode]>['headers']>>;
116
+
117
+ export type HttpResponseBodySchema<
118
+ MethodSchema extends HttpMethodSchema,
119
+ StatusCode extends HttpStatusCode,
120
+ > = ReplaceBy<
121
+ ReplaceBy<
122
+ IfNever<DefaultNoExclude<Default<Default<MethodSchema['response']>[StatusCode]>['body']>, null>,
123
+ undefined,
124
+ null
125
+ >,
126
+ ArrayBuffer,
127
+ Blob
128
+ >;
@@ -16,15 +16,6 @@ export type UnionToIntersection<Union> = (Union extends unknown ? (union: Union)
16
16
  ? IntersectedUnion
17
17
  : never;
18
18
 
19
- type LastUnionType<Union> =
20
- UnionToIntersection<Union extends unknown ? (union: Union) => void : never> extends (x: infer LastType) => void
21
- ? LastType
22
- : never;
23
-
24
- export type UnionToTuple<Union, LastType = LastUnionType<Union>> = [Union] extends [never]
25
- ? []
26
- : [...UnionToTuple<Exclude<Union, LastType>>, LastType];
27
-
28
19
  export type UnionHasMoreThanOneType<Union> = [UnionToIntersection<Union>] extends [never] ? true : false;
29
20
 
30
21
  export type Prettify<Type> = {
@@ -46,19 +37,4 @@ export type NonEmptyArray<Type> = [Type, ...Type[]];
46
37
 
47
38
  export type ReplaceBy<Type, Source, Target> = Type extends Source ? Target : Type;
48
39
 
49
- export type Collection<Type> = Type[] | Set<Type>;
50
-
51
- export type DeepPartial<Type> = Type extends (...parameters: never[]) => unknown
52
- ? Type
53
- : Type extends (infer ArrayItem)[]
54
- ? DeepPartial<ArrayItem>[]
55
- : Type extends object
56
- ? { [Key in keyof Type]?: DeepPartial<Type[Key]> }
57
- : Type;
58
-
59
40
  export type Override<Type, OverrideType> = Omit<Type, keyof OverrideType> & OverrideType;
60
-
61
- export interface Range<Value> {
62
- min: Value;
63
- max: Value;
64
- }