@hey-api/openapi-ts 0.98.1 → 0.99.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
@@ -7,17 +7,17 @@
7
7
  <p align="center">
8
8
  <a href="https://www.devtrends.dev/trends?c=v1.kZIBIg"><img src="https://api.devtrends.dev/badge/npm/%40hey-api%2Fopenapi-ts?period=month&style=flat&view=value" alt="DevTrends badge for @hey-api/openapi-ts" /></a>
9
9
  <a href="https://www.devtrends.dev/trends?c=v1.kZIBIg&v=change"><img src="https://api.devtrends.dev/badge/npm/%40hey-api%2Fopenapi-ts?period=year&style=flat&view=change" alt="DevTrends badge for @hey-api/openapi-ts" /></a>
10
- <a href="https://github.com/hey-api/openapi-ts/actions?query=branch%3Amain"><img src="https://github.com/hey-api/openapi-ts/actions/workflows/ci.yml/badge.svg?event=push&branch=main" alt="CI status" /></a>
11
- <a href="https://github.com/hey-api/openapi-ts"><img src="https://img.shields.io/github/stars/hey-api/openapi-ts?style=flat&logo=github&label=GitHub&color=54C82D" alt="GitHub stars" /></a>
12
- <a href="https://github.com/hey-api/openapi-ts/blob/main/LICENSE.md"><img src="https://img.shields.io/github/license/hey-api/openapi-ts" alt="MIT License"></a>
10
+ <a href="https://github.com/hey-api/hey-api/actions?query=branch%3Amain"><img src="https://github.com/hey-api/hey-api/actions/workflows/ci.yml/badge.svg?event=push&branch=main" alt="CI status" /></a>
11
+ <a href="https://github.com/hey-api/hey-api"><img src="https://img.shields.io/github/stars/hey-api/hey-api?style=flat&logo=github&label=GitHub&color=54C82D" alt="GitHub stars" /></a>
12
+ <a href="https://github.com/hey-api/hey-api/blob/main/LICENSE.md"><img src="https://img.shields.io/github/license/hey-api/hey-api" alt="MIT License"></a>
13
13
  </p>
14
14
 
15
15
  <p align="center">
16
16
  <a href="https://stackblitz.com/edit/hey-api-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fsdk.gen.ts,src%2Fclient%2Ftypes.gen.ts">Demo</a>
17
17
  <span>&nbsp;•&nbsp;</span>
18
- <a href="https://heyapi.dev">Manual</a>
18
+ <a href="https://heyapi.dev/docs/openapi/typescript/get-started">Manual</a>
19
19
  <span>&nbsp;•&nbsp;</span>
20
- <a href="https://github.com/hey-api/openapi-ts/issues">Issues</a>
20
+ <a href="https://github.com/hey-api/hey-api/issues">Issues</a>
21
21
  <span>&nbsp;•&nbsp;</span>
22
22
  <a href="https://heyapi.dev/docs/openapi/typescript/community/contributing">Contribute</a>
23
23
  </p>
@@ -59,10 +59,10 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
59
59
 
60
60
  <h3 align="center">Gold</h3>
61
61
 
62
- <table align="center" style="justify-content: center;align-items: center;display: flex;">
62
+ <table align="center">
63
63
  <tbody>
64
64
  <tr>
65
- <td align="center" width="336px">
65
+ <td align="center" width="50%">
66
66
  <p></p>
67
67
  <p>
68
68
  <a href="https://kutt.to/pkEZyc" target="_blank">
@@ -80,7 +80,7 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
80
80
  </p>
81
81
  <p></p>
82
82
  </td>
83
- <td align="center" width="336px">
83
+ <td align="center" width="50%">
84
84
  <p></p>
85
85
  <p>
86
86
  <a href="https://kutt.to/QM9Q2N" target="_blank">
@@ -104,10 +104,10 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
104
104
 
105
105
  <h3 align="center">Silver</h3>
106
106
 
107
- <table align="center" style="justify-content: center;align-items: center;display: flex;">
107
+ <table align="center">
108
108
  <tbody>
109
109
  <tr>
110
- <td align="center" width="172px">
110
+ <td align="center" width="33.333%">
111
111
  <a href="https://kutt.to/skQUVd" target="_blank">
112
112
  <picture height="40px">
113
113
  <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/scalar/logo-light.svg">
@@ -119,7 +119,7 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
119
119
  scalar.com
120
120
  </a>
121
121
  </td>
122
- <td align="center" width="172px">
122
+ <td align="center" width="33.333%">
123
123
  <a href="https://kutt.to/Dr9GuW" target="_blank">
124
124
  <picture height="40px">
125
125
  <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/fastapi/logo-light.svg">
@@ -131,16 +131,28 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
131
131
  fastapi.tiangolo.com
132
132
  </a>
133
133
  </td>
134
+ <td align="center" width="33.333%">
135
+ <a href="https://kutt.to/yZVkdV" target="_blank">
136
+ <picture height="40px">
137
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/brands/unblocked/logo-light.svg">
138
+ <img alt="Unblocked logo" height="40px" src="https://heyapi.dev/assets/brands/unblocked/logo-dark.svg">
139
+ </picture>
140
+ </a>
141
+ <br/>
142
+ <a href="https://kutt.to/yZVkdV" style="text-decoration:none;" target="_blank">
143
+ getunblocked.com
144
+ </a>
145
+ </td>
134
146
  </tr>
135
147
  </tbody>
136
148
  </table>
137
149
 
138
150
  <h3 align="center">Bronze</h3>
139
151
 
140
- <table align="center" style="justify-content: center;align-items: center;display: flex;">
152
+ <table align="center">
141
153
  <tbody>
142
154
  <tr>
143
- <td align="center" width="136px">
155
+ <td align="center" width="33.333%">
144
156
  <a href="https://kutt.to/YpaKsX" target="_blank">
145
157
  <picture height="34px">
146
158
  <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/.gen/kinde-logo-wordmark-dark-480w.webp">
@@ -148,7 +160,7 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
148
160
  </picture>
149
161
  </a>
150
162
  </td>
151
- <td align="center" width="136px">
163
+ <td align="center" width="33.333%">
152
164
  <a href="https://kutt.to/KkqSaw" target="_blank">
153
165
  <picture height="34px">
154
166
  <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/cella/logo-light.svg">
@@ -156,7 +168,7 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
156
168
  </picture>
157
169
  </a>
158
170
  </td>
159
- <td align="center" width="136px">
171
+ <td align="center" width="33.333%">
160
172
  <a href="https://kutt.to/HW4GYR" target="_blank">
161
173
  <picture height="34px">
162
174
  <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/photon/logo-light.svg">
@@ -333,7 +345,7 @@ Alternatively, you can use `openapi-ts.config.js` and configure the export state
333
345
 
334
346
  You must set the input so we can load your OpenAPI specification. It can be a path or URL, object containing a path or URL, or an object representing an OpenAPI specification. Hey API supports all valid OpenAPI versions and file formats.
335
347
 
336
- > If you use an HTTPS URL with a self-signed certificate in development, you will need to set [`NODE_TLS_REJECT_UNAUTHORIZED=0`](https://github.com/hey-api/openapi-ts/issues/276#issuecomment-2043143501) in your environment.
348
+ > If you use an HTTPS URL with a self-signed certificate in development, you will need to set [`NODE_TLS_REJECT_UNAUTHORIZED=0`](https://github.com/hey-api/hey-api/issues/276#issuecomment-2043143501) in your environment.
337
349
 
338
350
  ### Output
339
351
 
@@ -365,15 +377,15 @@ Clients are responsible for sending the actual HTTP requests. We default to Fetc
365
377
 
366
378
  ### Proposed Clients (Vote to Prioritize)
367
379
 
368
- The following clients are roadmap proposals and are not started yet. You can help us prioritize them by voting on [GitHub](https://github.com/hey-api/openapi-ts/issues?q=state%3Aopen%20label%3A%22vote%20%F0%9F%93%A9%22).
380
+ The following clients are roadmap proposals and are not started yet. You can help us prioritize them by voting on [GitHub](https://github.com/hey-api/hey-api/issues?q=state%3Aopen%20label%3A%22vote%20%F0%9F%93%A9%22).
369
381
 
370
382
  - [`@hey-api/client-effect`](https://heyapi.dev/docs/openapi/typescript/clients/effect)
371
383
 
372
- Don't see your client? [Build your own](https://heyapi.dev/docs/openapi/typescript/clients/custom) or let us know your interest by [opening an issue](https://github.com/hey-api/openapi-ts/issues).
384
+ Don't see your client? [Build your own](https://heyapi.dev/docs/openapi/typescript/clients/custom) or let us know your interest by [opening an issue](https://github.com/hey-api/hey-api/issues).
373
385
 
374
386
  ### Available Plugins
375
387
 
376
- These plugins help reduce boilerplate associated with third-party dependencies. Hey API natively supports the most popular packages. Please open an issue on [GitHub](https://github.com/hey-api/openapi-ts/issues) if you'd like us to support your favorite package.
388
+ These plugins help reduce boilerplate associated with third-party dependencies. Hey API natively supports the most popular packages. Please open an issue on [GitHub](https://github.com/hey-api/hey-api/issues) if you'd like us to support your favorite package.
377
389
 
378
390
  - [`@angular/common`](https://heyapi.dev/docs/openapi/typescript/plugins/angular)
379
391
  - [`@hey-api/schemas`](https://heyapi.dev/docs/openapi/typescript/plugins/schemas)
@@ -395,7 +407,7 @@ These plugins help reduce boilerplate associated with third-party dependencies.
395
407
 
396
408
  ### Proposed Plugins (Vote to Prioritize)
397
409
 
398
- The following plugins are roadmap proposals and are not started yet. You can help us prioritize them by voting on [GitHub](https://github.com/hey-api/openapi-ts/issues?q=state%3Aopen%20label%3A%22vote%20%F0%9F%93%A9%22).
410
+ The following plugins are roadmap proposals and are not started yet. You can help us prioritize them by voting on [GitHub](https://github.com/hey-api/hey-api/issues?q=state%3Aopen%20label%3A%22vote%20%F0%9F%93%A9%22).
399
411
 
400
412
  - [Adonis](https://heyapi.dev/docs/openapi/typescript/plugins/adonis)
401
413
  - [Ajv](https://heyapi.dev/docs/openapi/typescript/plugins/ajv)
@@ -418,7 +430,7 @@ The following plugins are roadmap proposals and are not started yet. You can hel
418
430
  - [Yup](https://heyapi.dev/docs/openapi/typescript/plugins/yup)
419
431
  - [Zustand](https://heyapi.dev/docs/openapi/typescript/plugins/zustand)
420
432
 
421
- Don't see your plugin? [Build your own](https://heyapi.dev/docs/openapi/typescript/plugins/custom) or let us know your interest by [opening an issue](https://github.com/hey-api/openapi-ts/issues).
433
+ Don't see your plugin? [Build your own](https://heyapi.dev/docs/openapi/typescript/plugins/custom) or let us know your interest by [opening an issue](https://github.com/hey-api/hey-api/issues).
422
434
 
423
435
  ## Migrating
424
436
 
@@ -428,6 +440,6 @@ You can learn more on the [Migrating](https://heyapi.dev/docs/openapi/typescript
428
440
 
429
441
  ## License
430
442
 
431
- Released under the [MIT License](https://github.com/hey-api/openapi-ts/blob/main/LICENSE.md).
443
+ Released under the [MIT License](https://github.com/hey-api/hey-api/blob/main/LICENSE.md).
432
444
 
433
445
  <!-- template-license-end -->
@@ -0,0 +1,15 @@
1
+ import { createRequire } from "node:module";
2
+ //#region \0rolldown/runtime.js
3
+ var __defProp = Object.defineProperty;
4
+ var __exportAll = (all, no_symbols) => {
5
+ let target = {};
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
11
+ return target;
12
+ };
13
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
14
+ //#endregion
15
+ export { __require as n, __exportAll as t };
@@ -82,7 +82,7 @@ export const createClient = (config: Config = {}): Client => {
82
82
 
83
83
  // remove Content-Type header if body is empty to avoid sending invalid requests
84
84
  if (opts.body === undefined || opts.serializedBody === '') {
85
- opts.headers.delete('Content-Type');
85
+ opts.headers = opts.headers.delete('Content-Type');
86
86
  }
87
87
 
88
88
  const url = buildUrl(opts as Config & RequestOptions);
@@ -8,6 +8,7 @@ export {
8
8
  export { buildClientParams } from '../core/params';
9
9
  export { serializeQueryKeyValue } from '../core/queryKeySerializer';
10
10
  export type { ServerSentEventsResult } from '../core/serverSentEvents';
11
+ export type { ClientMeta } from '../core/types';
11
12
  export { createClient } from './client';
12
13
  export type {
13
14
  Client,
@@ -8,6 +8,7 @@ export {
8
8
  export { buildClientParams } from '../core/params';
9
9
  export { serializeQueryKeyValue } from '../core/queryKeySerializer';
10
10
  export type { ServerSentEventsResult } from '../core/serverSentEvents';
11
+ export type { ClientMeta } from '../core/types';
11
12
  export { createClient } from './client';
12
13
  export type {
13
14
  Client,
@@ -86,16 +86,15 @@ function buildKeyMap(fields: FieldsConfig, map?: KeyMap): KeyMap {
86
86
  }
87
87
 
88
88
  interface Params {
89
- body: unknown;
89
+ body?: unknown;
90
90
  headers: Record<string, unknown>;
91
91
  path: Record<string, unknown>;
92
92
  query: Record<string, unknown>;
93
93
  }
94
94
 
95
- type ParamsSlotMap = Record<Slot, unknown>;
96
-
97
- function stripEmptySlots(params: ParamsSlotMap): void {
95
+ function stripEmptySlots(params: Params): void {
98
96
  for (const [slot, value] of Object.entries(params)) {
97
+ if (slot === 'body') continue;
99
98
  if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
100
99
  delete params[slot as Slot];
101
100
  }
@@ -103,8 +102,7 @@ function stripEmptySlots(params: ParamsSlotMap): void {
103
102
  }
104
103
 
105
104
  export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsConfig): Params {
106
- const params: ParamsSlotMap = {
107
- body: Object.create(null),
105
+ const params: Params = {
108
106
  headers: Object.create(null),
109
107
  path: Object.create(null),
110
108
  query: Object.create(null),
@@ -112,6 +110,15 @@ export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsCo
112
110
 
113
111
  const map = buildKeyMap(fields);
114
112
 
113
+ function writeSlot(slot: Slot, key: string, value: unknown): void {
114
+ let record = params[slot] as Record<string, unknown> | undefined;
115
+ if (record === undefined) {
116
+ record = Object.create(null) as Record<string, unknown>;
117
+ params[slot] = record;
118
+ }
119
+ record[key] = value;
120
+ }
121
+
115
122
  let config: FieldsConfig[number] | undefined;
116
123
 
117
124
  for (const [index, arg] of args.entries()) {
@@ -128,7 +135,7 @@ export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsCo
128
135
  const field = map.get(config.key)!;
129
136
  const name = field.map || config.key;
130
137
  if (field.in) {
131
- (params[field.in] as Record<string, unknown>)[name] = arg;
138
+ writeSlot(field.in, name, arg);
132
139
  }
133
140
  } else {
134
141
  params.body = arg;
@@ -140,7 +147,7 @@ export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsCo
140
147
  if (field) {
141
148
  if (field.in) {
142
149
  const name = field.map || key;
143
- (params[field.in] as Record<string, unknown>)[name] = value;
150
+ writeSlot(field.in, name, value);
144
151
  } else {
145
152
  params[field.map] = value;
146
153
  }
@@ -149,11 +156,11 @@ export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsCo
149
156
 
150
157
  if (extra) {
151
158
  const [prefix, slot] = extra;
152
- (params[slot] as Record<string, unknown>)[key.slice(prefix.length)] = value;
159
+ writeSlot(slot, key.slice(prefix.length), value);
153
160
  } else if ('allowExtra' in config && config.allowExtra) {
154
161
  for (const [slot, allowed] of Object.entries(config.allowExtra)) {
155
162
  if (allowed) {
156
- (params[slot as Slot] as Record<string, unknown>)[key] = value;
163
+ writeSlot(slot as Slot, key, value);
157
164
  break;
158
165
  }
159
166
  }
@@ -165,5 +172,5 @@ export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsCo
165
172
 
166
173
  stripEmptySlots(params);
167
174
 
168
- return params as Params;
175
+ return params;
169
176
  }
@@ -89,6 +89,12 @@ export interface Config {
89
89
  responseValidator?: (data: unknown) => Promise<unknown>;
90
90
  }
91
91
 
92
+ /**
93
+ * Arbitrary metadata passed through the `meta` request option.
94
+ */
95
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
96
+ export interface ClientMeta {}
97
+
92
98
  type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
93
99
  ? true
94
100
  : [T] extends [never | undefined]
@@ -8,6 +8,7 @@ export {
8
8
  export { buildClientParams } from '../core/params';
9
9
  export { serializeQueryKeyValue } from '../core/queryKeySerializer';
10
10
  export type { ServerSentEventsResult } from '../core/serverSentEvents';
11
+ export type { ClientMeta } from '../core/types';
11
12
  export { createClient } from './client';
12
13
  export type {
13
14
  Client,
@@ -8,6 +8,7 @@ export {
8
8
  export { buildClientParams } from '../core/params';
9
9
  export { serializeQueryKeyValue } from '../core/queryKeySerializer';
10
10
  export type { ServerSentEventsResult } from '../core/serverSentEvents';
11
+ export type { ClientMeta } from '../core/types';
11
12
  export { createClient } from './client';
12
13
  export type {
13
14
  Client,
@@ -8,6 +8,7 @@ export {
8
8
  export { buildClientParams } from '../core/params';
9
9
  export { serializeQueryKeyValue } from '../core/queryKeySerializer';
10
10
  export type { ServerSentEventsResult } from '../core/serverSentEvents';
11
+ export type { ClientMeta } from '../core/types';
11
12
  export { createClient } from './client';
12
13
  export type {
13
14
  Client,
@@ -8,6 +8,7 @@ export {
8
8
  export { buildClientParams } from '../core/params';
9
9
  export { serializeQueryKeyValue } from '../core/queryKeySerializer';
10
10
  export type { ServerSentEventsResult } from '../core/serverSentEvents';
11
+ export type { ClientMeta } from '../core/types';
11
12
  export { createClient } from './client';
12
13
  export type {
13
14
  Client,
@@ -8,6 +8,7 @@ export {
8
8
  export { buildClientParams } from '../core/params';
9
9
  export { serializeQueryKeyValue } from '../core/queryKeySerializer';
10
10
  export type { ServerSentEventsResult } from '../core/serverSentEvents';
11
+ export type { ClientMeta } from '../core/types';
11
12
  export { createClient } from './client';
12
13
  export type {
13
14
  Client,