@zimic/http 0.1.0 → 0.1.1-canary.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/README.md CHANGED
@@ -3,14 +3,16 @@
3
3
  </p>
4
4
 
5
5
  <h1 align="center">
6
- Zimic
6
+ @zimic/http
7
7
  </h1>
8
8
 
9
9
  <p align="center">
10
- TypeScript-first HTTP integrations
10
+ TypeScript-first HTTP intercepting and mocking
11
11
  </p>
12
12
 
13
13
  <p align="center">
14
+ <a href="https://www.npmjs.com/package/@zimic/http">npm</a>
15
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
14
16
  <a href="https://github.com/zimicjs/zimic/wiki">Docs</a>
15
17
  <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
16
18
  <a href="#examples">Examples</a>
@@ -29,39 +31,30 @@
29
31
 
30
32
  [![NPM Downloads - @zimic/http](https://img.shields.io/npm/dm/@zimic/http?style=flat&logo=npm&color=0E69BE&label=%20%40zimic%2Fhttp&labelColor=353C43)](https://www.npmjs.com/package/@zimic/http)&nbsp;
31
33
  [![Bundle size - @zimic/http](https://badgen.net/bundlephobia/minzip/@zimic/http?color=0E69BE&labelColor=353C43&label=@zimic/http%20min%20gzip)](https://bundlephobia.com/package/@zimic/http)<br />
32
- [![NPM Downloads - @zimic/fetch](https://img.shields.io/npm/dm/@zimic/fetch?style=flat&logo=npm&color=0E69BE&label=%20%40zimic%2Ffetch&labelColor=353C43)](https://www.npmjs.com/package/@zimic/fetch)&nbsp;
33
- [![Bundle size - @zimic/fetch](https://badgen.net/bundlephobia/minzip/@zimic/fetch?color=0E69BE&labelColor=353C43&label=@zimic/fetch%20min%20gzip)](https://bundlephobia.com/package/@zimic/fetch)<br />
34
- [![NPM Downloads - @zimic/interceptor](https://img.shields.io/npm/dm/@zimic/interceptor?style=flat&logo=npm&color=0E69BE&label=%20%40zimic%2Finterceptor&labelColor=353C43)](https://www.npmjs.com/package/@zimic/interceptor)&nbsp;
35
- [![Bundle size - @zimic/interceptor](https://badgen.net/bundlephobia/minzip/@zimic/interceptor?color=0E69BE&labelColor=353C43&label=@zimic/interceptor%20min%20gzip)](https://bundlephobia.com/package/@zimic/interceptor)&nbsp;
36
34
 
37
35
  </div>
38
36
 
39
37
  ---
40
38
 
41
- ## Contents <!-- omit from toc -->
42
-
43
- - [Libraries](#libraries)
44
- - [`@zimic/http`](#zimichttp)
45
- - [`@zimic/fetch`](#zimicfetch)
46
- - [`@zimic/interceptor`](#zimicinterceptor)
39
+ - [Features](#features)
40
+ - [Getting started](#getting-started)
41
+ - [Installation](#installation)
42
+ - [Basic usage](#basic-usage)
43
+ - [Documentation](#documentation)
47
44
  - [Examples](#examples)
48
45
  - [Changelog](#changelog)
49
46
  - [Contributing](#contributing)
50
47
 
51
48
  ---
52
49
 
53
- Zimic is a set of lightweight, thoroughly tested, TypeScript-first HTTP integration libraries.
54
-
55
- ## Libraries
56
-
57
- ### `@zimic/http`
50
+ `@zimic/http` is a collection of type-safe utilities to handle HTTP requests and responses, including headers, search
51
+ params, and form data.
58
52
 
59
53
  > [!NOTE]
60
54
  >
61
55
  > :seedling: This library is in **beta**.
62
56
 
63
- [`@zimic/http`](../../packages/zimic-http) is a collection of type-safe utilities to handle HTTP requests and responses,
64
- including headers, search params, and form data.
57
+ ## Features
65
58
 
66
59
  - :star: **HTTP schemas and typegen**: Declare the structure of your HTTP endpoints as a TypeScript
67
60
  [schema](https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas) and use it to type your HTTP requests and
@@ -74,82 +67,149 @@ including headers, search params, and form data.
74
67
  [`FormData`](https://github.com/zimicjs/zimic/wiki/api‐zimic‐http#httpformdata) objects, fully compatible with their
75
68
  native counterparts.
76
69
 
77
- **Learn more**:
70
+ ## Getting started
78
71
 
79
- - [`@zimic/http` - Getting started](https://github.com/zimicjs/zimic/wiki/getting‐started‐http)
80
- - [`@zimic/http` - API reference](https://github.com/zimicjs/zimic/wiki/api‐zimic‐http)
81
- - `@zimic/http` - CLI reference
82
- - [`zimic-http typegen`](https://github.com/zimicjs/zimic/wiki/cli‐zimic‐typegen)
72
+ Check our [getting started guide](https://github.com/zimicjs/zimic/wiki/getting‐started‐http).
73
+
74
+ ### Installation
75
+
76
+ | Manager | Command |
77
+ | :-----: | -------------------------------- |
78
+ | npm | `npm install @zimic/http --save` |
79
+ | yarn | `yarn add @zimic/http` |
80
+ | pnpm | `pnpm add @zimic/http` |
81
+
82
+ ## Basic usage
83
83
 
84
- ### `@zimic/fetch`
84
+ 1. Declare your [schema](https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas):
85
85
 
86
- > [!WARNING]
87
- >
88
- > :construction: This library is **experimental**.
86
+ ```ts
87
+ import { type HttpSchema } from '@zimic/http';
89
88
 
90
- [`@zimic/fetch`](../../packages/zimic-fetch) is a minimal (1 kB minified and gzipped), zero-dependency, and type-safe
91
- `fetch`-like API client.
89
+ interface User {
90
+ username: string;
91
+ }
92
+
93
+ interface RequestError {
94
+ code: string;
95
+ message: string;
96
+ }
92
97
 
93
- - :sparkles: **Type-safe `fetch`**: Create a type-safe
94
- [`fetch`-like](https://developer.mozilla.org/docs/Web/API/Fetch_API) API client. Use your
95
- [`@zimic/http` schema](https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas) and have your requests and
96
- responses fully typed by default.
97
- - :muscle: **Developer experience**: `@zimic/fetch` seeks to be as compatible with the
98
- [native Fetch API](https://developer.mozilla.org/docs/Web/API/Fetch_API) as possible, while providing an ergonomic
99
- interface to improve type safety. Define default options to apply to your requests, such as a base URL, headers,
100
- search parameters, and more. Inspect and modify requests and responses using
101
- [`onRequest`](https://github.com/zimicjs/zimic/wiki/api‐zimic‐fetch#fetchonrequest) and
102
- [`onResponse`](https://github.com/zimicjs/zimic/wiki/api‐zimic‐fetch#fetchonresponse) listeners.
98
+ type Schema = HttpSchema<{
99
+ '/users': {
100
+ POST: {
101
+ request: { body: User };
102
+ response: {
103
+ 201: { body: User };
104
+ 400: { body: RequestError };
105
+ 409: { body: RequestError };
106
+ };
107
+ };
103
108
 
104
- **Learn more**:
109
+ GET: {
110
+ request: {
111
+ headers: { authorization: string };
112
+ searchParams: { query?: string; limit?: `${number}` };
113
+ };
114
+ response: {
115
+ 200: { body: User[] };
116
+ 400: { body: RequestError };
117
+ 401: { body: RequestError };
118
+ };
119
+ };
120
+ };
105
121
 
106
- - [`@zimic/fetch` - Getting started](https://github.com/zimicjs/zimic/wiki/getting‐started‐fetch)
107
- - [`@zimic/fetch` - API reference](https://github.com/zimicjs/zimic/wiki/api‐zimic‐fetch)
122
+ '/users/:userId': {
123
+ PATCH: {
124
+ request: {
125
+ headers: { authorization: string };
126
+ body: Partial<User>;
127
+ };
128
+ response: {
129
+ 204: {};
130
+ 400: { body: RequestError };
131
+ };
132
+ };
133
+ };
134
+ }>;
135
+ ```
108
136
 
109
- ### `@zimic/interceptor`
137
+ 2. Use the types in your code!
110
138
 
111
- > [!NOTE]
112
- >
113
- > :seedling: This library is in **beta**.
139
+ - **Example 1**: Reference the types in your code:
114
140
 
115
- [`@zimic/interceptor`](../../packages/zimic-interceptor) provides a flexible and type-safe way to intercept and mock HTTP
116
- requests.
117
-
118
- - :globe_with_meridians: **HTTP interceptors**: Intercept HTTP requests and return mock responses. Use
119
- [local](https://github.com/zimicjs/zimic/wiki/getting‐started#local-http-interceptors) or
120
- [remote](https://github.com/zimicjs/zimic/wiki/getting‐started#remote-http-interceptors) interceptors to adapt your
121
- mocks to your development and testing workflow.
122
- - :zap: **Fully typed mocks**: Use your
123
- [`@zimic/http` schema](https://github.com/zimicjs/zimic/wiki/api‐zimic‐http‐schemas) and create type-safe mocks for
124
- your HTTP requests.
125
- - :link: **Network-level interceptor**: `@zimic/interceptor` combines [MSW](https://github.com/mswjs/msw) and
126
- [interceptor servers](https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server) to handle real HTTP requests. From you
127
- application's point of view, the mocked responses are indistinguishable from the real ones.
128
- - :wrench: **Flexibility**: Mock external services and reliably test how your application behaves. Simulate success,
129
- loading, and error states with ease using [standard web APIs](https://developer.mozilla.org/docs/Web/API).
130
- - :bulb: **Simplicity**: `@zimic/interceptor` was designed to encourage clarity, simplicity, and robustness in your
131
- mocks.
132
-
133
- > [!TIP]
134
- >
135
- > `@zimic/fetch` and `@zimic/interceptor` are not required to be used together. `@zimic/interceptor` is compatible with
136
- > any HTTP client implementation, as `@zimic/fetch` works with any HTTP interceptor library. With that in mind,
137
- > `@zimic/fetch` and `@zimic/interceptor` work best together, providing a seamless and type-safe experience for
138
- > performing HTTP requests in your application and mocking them during development and testing.
141
+ ```ts
142
+ import { HttpHeaders, HttpSearchParams, HttpFormData } from '@zimic/http';
143
+
144
+ type UserListHeaders = Schema['/users']['GET']['request']['headers'];
145
+
146
+ const headers = new HttpHeaders<UserListHeaders>({
147
+ authorization: 'Bearer token',
148
+ });
149
+
150
+ type UserListSearchParams = Schema['/users']['GET']['request']['searchParams'];
151
+
152
+ const searchParams = new HttpSearchParams<UserListSearchParams>({
153
+ query: 'u',
154
+ limit: '10',
155
+ });
139
156
 
140
- **Learn more**:
157
+ type UserCreateBody = Schema['/users']['POST']['request']['body'];
141
158
 
142
- - [`@zimic/interceptor` - Getting started](https://github.com/zimicjs/zimic/wiki/getting‐started‐interceptor)
143
- - [`@zimic/interceptor` - API reference](https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http)
144
- - `@zimic/interceptor` - CLI reference
145
- - [Browser](https://github.com/zimicjs/zimic/wiki/cli‐zimic‐browser)
146
- - [Server](https://github.com/zimicjs/zimic/wiki/cli‐zimic‐server)
147
- - `@zimic/interceptor` - Guides
148
- - [Testing](https://github.com/zimicjs/zimic/wiki/guides‐testing‐interceptor)
159
+ const formData = new HttpFormData<UserCreateBody>();
160
+ formData.append('username', 'user');
161
+ ```
162
+
163
+ - **Example 2**: Using [`@zimic/fetch`](../zimic-fetch):
164
+
165
+ ```ts
166
+ import { createFetch } from '@zimic/fetch';
167
+
168
+ const fetch = createFetch<Schema>({
169
+ baseURL: 'http://localhost:3000',
170
+ });
171
+
172
+ const response = await fetch('/users', {
173
+ method: 'POST',
174
+ body: { username: 'user' },
175
+ });
176
+
177
+ if (!response.ok) {
178
+ throw response.error;
179
+ }
180
+
181
+ console.log(await response.json()); // { username: 'user' }
182
+ ```
183
+
184
+ - **Example 3**: Using [`@zimic/interceptor`](../zimic-interceptor):
185
+
186
+ ```ts
187
+ import { httpInterceptor } from '@zimic/interceptor/http';
188
+
189
+ const interceptor = httpInterceptor.create<Schema>({
190
+ type: 'local',
191
+ baseURL: 'http://localhost:3000',
192
+ });
193
+
194
+ await interceptor.start();
195
+
196
+ interceptor.post('/users').respond({
197
+ status: 201,
198
+ body: { username: body.username },
199
+ });
200
+ ```
201
+
202
+ ## Documentation
203
+
204
+ - [Getting started](https://github.com/zimicjs/zimic/wiki/getting‐started‐http)
205
+ - [API reference](https://github.com/zimicjs/zimic/wiki/api‐zimic‐http)
206
+ - CLI reference
207
+ - [`zimic-http typegen`](https://github.com/zimicjs/zimic/wiki/cli‐zimic‐typegen)
149
208
 
150
209
  ## Examples
151
210
 
152
- Visit our [examples](../../examples/README.md) to see how to use Zimic with popular frameworks, libraries, and use cases.
211
+ Visit our [examples](../../examples/README.md) to see how to use Zimic with popular frameworks, libraries, and use
212
+ cases.
153
213
 
154
214
  ## Changelog
155
215
 
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";
15
+ var version = "0.1.1-canary.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/typegen/openapi.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["__name","typegen","chalk","logWithPrefix","yargs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AAA;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;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 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.1.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 \"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 ./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 \"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.8\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.0.7\",\n \"@vitest/coverage-istanbul\": \"^3.0.7\",\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.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.4.0\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.8.2\",\n \"vitest\": \"^3.0.7\"\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 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,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AA,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;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 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.1.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 \"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 ./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 \"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.8\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.0.7\",\n \"@vitest/coverage-istanbul\": \"^3.0.7\",\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.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.4.0\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.8.2\",\n \"vitest\": \"^3.0.7\"\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 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";
8
+ var version = "0.1.1-canary.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/typegen/openapi.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["yargs"],"mappings":";;;;;;;AAcE,IAAW,OAAA,GAAA,OAAA;;;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,4B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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 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.1.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 \"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 ./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 \"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.8\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.0.7\",\n \"@vitest/coverage-istanbul\": \"^3.0.7\",\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.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.4.0\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.8.2\",\n \"vitest\": \"^3.0.7\"\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 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,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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B,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 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.1.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 \"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 ./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 \"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.8\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.0.7\",\n \"@vitest/coverage-istanbul\": \"^3.0.7\",\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.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.4.0\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.8.2\",\n \"vitest\": \"^3.0.7\"\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 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/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "api",
13
13
  "static"
14
14
  ],
15
- "version": "0.1.0",
15
+ "version": "0.1.1-canary.0",
16
16
  "repository": {
17
17
  "type": "git",
18
18
  "url": "https://github.com/zimicjs/zimic.git",
@@ -85,8 +85,8 @@
85
85
  "tsx": "^4.19.3",
86
86
  "typescript": "^5.8.2",
87
87
  "vitest": "^3.0.7",
88
+ "@zimic/interceptor": "0.14.0",
88
89
  "@zimic/eslint-config-node": "0.0.0",
89
- "@zimic/interceptor": "0.14.0-canary.26",
90
90
  "@zimic/lint-staged-config": "0.0.0",
91
91
  "@zimic/tsconfig": "0.0.0",
92
92
  "@zimic/utils": "0.0.0"
@@ -107,7 +107,6 @@
107
107
  "test:turbo": "dotenv -v CI=true -- pnpm run test run --coverage",
108
108
  "types:check": "tsc --noEmit",
109
109
  "typegen:fixtures": "tsx ./scripts/typegen/generateFixtureTypes.ts",
110
- "deps:init": "playwright install chromium",
111
- "prepublish:patch-relative-paths": "sed -E -i 's/\\]\\(\\.\\/([^\\)]+)\\)/](..\\/..\\/\\1)/g;s/\"\\.\\/([^\"]+)\"/\"..\\/..\\/\\1\"/g'"
110
+ "deps:init": "playwright install chromium"
112
111
  }
113
112
  }