openapi-typesafe-helpers 1.0.0-rc.1 → 1.0.0-rc.11

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/CHANGELOG.md ADDED
@@ -0,0 +1,241 @@
1
+ # openapi-typesafe-helpers
2
+
3
+ This package is a fork of `openapi-typescript-helpers`. The entries above `0.1.0` are releases of openapi-typesafe-helpers; `0.1.0` and the entries below it are the upstream history up to the fork point (upstream commit `d46a319a`), with `openapi-typescript-helpers` versions.
4
+
5
+ ## 1.0.0-rc.11
6
+
7
+ ### Patch Changes
8
+
9
+ - [#128](https://github.com/openapi-typesafe/openapi-typesafe/pull/128) [`fad3163`](https://github.com/openapi-typesafe/openapi-typesafe/commit/fad31635ed28508082d59c2e0a3ba6e881b20d02) Thanks [@fedorello](https://github.com/fedorello)! - A `json` inside the parameters of a media type no longer makes it a JSON media type in the types,
10
+ as at runtime: an error declared as `text/plain; profile=urn:a+json` or
11
+ `message/http; msgtype=application/json` is typed as the text (`string`) the client returns, and
12
+ `JSONLike`, `RequestBodyJSON`, `SuccessResponseJSON` and `ErrorResponseJSON` leave such media
13
+ types out. Only the media type before the `;` counts, for media ranges (`text/*`) too.
14
+ - Updated dependencies [[`fad3163`](https://github.com/openapi-typesafe/openapi-typesafe/commit/fad31635ed28508082d59c2e0a3ba6e881b20d02), [`fad3163`](https://github.com/openapi-typesafe/openapi-typesafe/commit/fad31635ed28508082d59c2e0a3ba6e881b20d02), [`fad3163`](https://github.com/openapi-typesafe/openapi-typesafe/commit/fad31635ed28508082d59c2e0a3ba6e881b20d02)]:
15
+ - openapi-typesafe-fetch@1.0.0-rc.11
16
+
17
+ ## 1.0.0-rc.10
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [[`e635904`](https://github.com/openapi-typesafe/openapi-typesafe/commit/e6359045a637d6edd0addf58b6703aabb2f3fceb), [`e635904`](https://github.com/openapi-typesafe/openapi-typesafe/commit/e6359045a637d6edd0addf58b6703aabb2f3fceb)]:
22
+ - openapi-typesafe-fetch@1.0.0-rc.10
23
+
24
+ ## 1.0.0-rc.9
25
+
26
+ ### Patch Changes
27
+
28
+ - [#112](https://github.com/openapi-typesafe/openapi-typesafe/pull/112) [`05886b5`](https://github.com/openapi-typesafe/openapi-typesafe/commit/05886b5b8fdbb832f58abd12b9f8c741b0c73ad2) Thanks [@fedorello](https://github.com/fedorello)! - Code that is generic in the path compiles again. `SuccessResponse`, `ErrorResponse`,
29
+ `ErrorResponseJSON` and the `data` and `error` of `FetchResponse` for `Paths[Path]` gave the whole
30
+ `responses` map next to the response bodies, so assigning them to the bodies failed with TS2322.
31
+ They give the bodies now. This also fixes the error type of hook wrappers generic in the path.
32
+ - Updated dependencies [[`05886b5`](https://github.com/openapi-typesafe/openapi-typesafe/commit/05886b5b8fdbb832f58abd12b9f8c741b0c73ad2), [`05886b5`](https://github.com/openapi-typesafe/openapi-typesafe/commit/05886b5b8fdbb832f58abd12b9f8c741b0c73ad2), [`05886b5`](https://github.com/openapi-typesafe/openapi-typesafe/commit/05886b5b8fdbb832f58abd12b9f8c741b0c73ad2)]:
33
+ - openapi-typesafe-fetch@1.0.0-rc.9
34
+
35
+ ## 1.0.0-rc.8
36
+
37
+ ### Patch Changes
38
+
39
+ - [#103](https://github.com/openapi-typesafe/openapi-typesafe/pull/103) [`091b864`](https://github.com/openapi-typesafe/openapi-typesafe/commit/091b864cdb6dd9e1ff5810d4d44cebee8a01a721) Thanks [@fedorello](https://github.com/fedorello)! - `createClient<any>()` types `data` and `error` as `any` again; they were `never`, so
40
+ `if (error)` made the whole result `never`. `SuccessResponse<any>` and `ErrorResponse<any>` are
41
+ `any` too.
42
+
43
+ - [#103](https://github.com/openapi-typesafe/openapi-typesafe/pull/103) [`091b864`](https://github.com/openapi-typesafe/openapi-typesafe/commit/091b864cdb6dd9e1ff5810d4d44cebee8a01a721) Thanks [@fedorello](https://github.com/fedorello)! - Response types follow what the client returns. `ErrorResponseJSON`, `SuccessResponseJSON` and the
44
+ `data` and `error` of a client made with ``createClient<paths, `${string}/json`>()`` keep a
45
+ JSON body of any JSON media type: an `application/problem+json` error, an
46
+ `application/vnd.api+json` success and `application/json; charset=utf-8` bodies were left out,
47
+ so the error could be `never` or miss a status. An error that is not JSON, such as the HTML page
48
+ of a proxy, is typed `string`, the text the client returns, instead of being left out.
49
+ - Updated dependencies [[`091b864`](https://github.com/openapi-typesafe/openapi-typesafe/commit/091b864cdb6dd9e1ff5810d4d44cebee8a01a721), [`091b864`](https://github.com/openapi-typesafe/openapi-typesafe/commit/091b864cdb6dd9e1ff5810d4d44cebee8a01a721), [`091b864`](https://github.com/openapi-typesafe/openapi-typesafe/commit/091b864cdb6dd9e1ff5810d4d44cebee8a01a721), [`091b864`](https://github.com/openapi-typesafe/openapi-typesafe/commit/091b864cdb6dd9e1ff5810d4d44cebee8a01a721)]:
50
+ - openapi-typesafe-fetch@1.0.0-rc.8
51
+
52
+ ## 1.0.0-rc.7
53
+
54
+ ### Patch Changes
55
+
56
+ - [#96](https://github.com/openapi-typesafe/openapi-typesafe/pull/96) [`171fa71`](https://github.com/openapi-typesafe/openapi-typesafe/commit/171fa71311107e4e26a9ae7a62b431662fb13de5) Thanks [@fedorello](https://github.com/fedorello)! - `SuccessResponseJSON`, `ErrorResponseJSON` and the `data` and `error` of a client made with
57
+ ``createClient<paths, `${string}/json`>()`` leave out a response that has no JSON media type. It
58
+ added its whole `content` map, so a `text/html` 500 typed the error as `{ "text/html": string }`,
59
+ a value the client never returns.
60
+ - Updated dependencies [[`171fa71`](https://github.com/openapi-typesafe/openapi-typesafe/commit/171fa71311107e4e26a9ae7a62b431662fb13de5), [`171fa71`](https://github.com/openapi-typesafe/openapi-typesafe/commit/171fa71311107e4e26a9ae7a62b431662fb13de5), [`171fa71`](https://github.com/openapi-typesafe/openapi-typesafe/commit/171fa71311107e4e26a9ae7a62b431662fb13de5)]:
61
+ - openapi-typesafe-fetch@1.0.0-rc.7
62
+
63
+ ## 1.0.0-rc.6
64
+
65
+ ### Patch Changes
66
+
67
+ - Updated dependencies [[`dfb0fe3`](https://github.com/openapi-typesafe/openapi-typesafe/commit/dfb0fe3c61a75d2b8ca512577f4b699049171a64)]:
68
+ - openapi-typesafe-fetch@1.0.0-rc.6
69
+
70
+ ## 1.0.0-rc.5
71
+
72
+ ### Patch Changes
73
+
74
+ - Updated dependencies [[`0f0792b`](https://github.com/openapi-typesafe/openapi-typesafe/commit/0f0792b8efa4f5139653cd285455f7d6165ddb95), [`fbaded2`](https://github.com/openapi-typesafe/openapi-typesafe/commit/fbaded241385d032d5b28d2c93d5e0a7d6ae292b), [`0f0792b`](https://github.com/openapi-typesafe/openapi-typesafe/commit/0f0792b8efa4f5139653cd285455f7d6165ddb95), [`0f0792b`](https://github.com/openapi-typesafe/openapi-typesafe/commit/0f0792b8efa4f5139653cd285455f7d6165ddb95), [`0f0792b`](https://github.com/openapi-typesafe/openapi-typesafe/commit/0f0792b8efa4f5139653cd285455f7d6165ddb95), [`0f0792b`](https://github.com/openapi-typesafe/openapi-typesafe/commit/0f0792b8efa4f5139653cd285455f7d6165ddb95), [`0f0792b`](https://github.com/openapi-typesafe/openapi-typesafe/commit/0f0792b8efa4f5139653cd285455f7d6165ddb95), [`a74608e`](https://github.com/openapi-typesafe/openapi-typesafe/commit/a74608ec36b0a938594e0d0fac10c9fb222c1742), [`0f0792b`](https://github.com/openapi-typesafe/openapi-typesafe/commit/0f0792b8efa4f5139653cd285455f7d6165ddb95)]:
75
+ - openapi-typesafe-fetch@1.0.0-rc.5
76
+
77
+ ## 1.0.0-rc.4
78
+
79
+ ### Patch Changes
80
+
81
+ - [#48](https://github.com/openapi-typesafe/openapi-typesafe/pull/48) [`cff72cd`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cff72cd19bf7a68429f302e0ece79304fcb6ba5c) Thanks [@fedorello](https://github.com/fedorello)! - A call with a union of paths (`client.GET(path)` with `path: "/a" | "/b"`) types `data` and
82
+ `error` as the union of each operation's types. In openapi-fetch a path without a response body
83
+ typed `data` as its content map, and a path with only a `default` response typed it `undefined`.
84
+ `SuccessResponse` and `ErrorResponse` of a union of response maps are the union of each map's
85
+ responses.
86
+ - Updated dependencies [[`bc4d41d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/bc4d41d870d13fdb5eb1303744e5235308cdc2bb), [`1c8af0d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1c8af0dc371ae8be5b595b055ee1ebc53916088f), [`2afc816`](https://github.com/openapi-typesafe/openapi-typesafe/commit/2afc816881dab23d3dd8fe4d1a2d20456dd917f8), [`cff72cd`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cff72cd19bf7a68429f302e0ece79304fcb6ba5c), [`bc4d41d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/bc4d41d870d13fdb5eb1303744e5235308cdc2bb), [`1c8af0d`](https://github.com/openapi-typesafe/openapi-typesafe/commit/1c8af0dc371ae8be5b595b055ee1ebc53916088f), [`cff72cd`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cff72cd19bf7a68429f302e0ece79304fcb6ba5c)]:
87
+ - openapi-typesafe-fetch@1.0.0-rc.4
88
+
89
+ ## 1.0.0-rc.3
90
+
91
+ No changes in this release.
92
+
93
+ ## 1.0.0-rc.2
94
+
95
+ ### Major Changes
96
+
97
+ - [#18](https://github.com/openapi-typesafe/openapi-typesafe/pull/18) [`bfd3e60`](https://github.com/openapi-typesafe/openapi-typesafe/commit/bfd3e605bdbe240d7a8a327a59d8924781016fbd) Thanks [@fedorello](https://github.com/fedorello)! - First stable release of openapi-typesafe-helpers, the successor of openapi-typescript-helpers
98
+ 0.1.0. From 1.0 the package follows semver.
99
+
100
+ Changes that can need work when you move from openapi-typescript-helpers 0.1.0:
101
+ - `engines.node` is `>=22`.
102
+ - `HttpMethod` includes `"query"`: a hand-written `Record<HttpMethod, …>` needs a `query` entry.
103
+
104
+ ### Patch Changes
105
+
106
+ - [#16](https://github.com/openapi-typesafe/openapi-typesafe/pull/16) [`cd79dbd`](https://github.com/openapi-typesafe/openapi-typesafe/commit/cd79dbd39d33dc913ec101a4c46560dff801da4e) Thanks [@fedorello](https://github.com/fedorello)! - The type declarations keep their JSDoc, so editors show descriptions and mark deprecated exports.
107
+
108
+ ## 1.0.0-rc.1
109
+
110
+ ### Patch Changes
111
+
112
+ - [#9](https://github.com/openapi-typesafe/openapi-typesafe/pull/9) [`14494f5`](https://github.com/openapi-typesafe/openapi-typesafe/commit/14494f5553575d15ad8f4d54f59ddabddb3a3e01) Thanks [@fedorello](https://github.com/fedorello)! - An operation that declares no 2XX response types `data` with its `default` response, which covers
113
+ every undeclared status, successes too. `data` was `never` (upstream [#1862](https://github.com/openapi-typesafe/openapi-typesafe/issues/1862)). `SuccessResponse`
114
+ follows the same rule. With a 2XX response declared, `default` still types only `error`.
115
+
116
+ - [#9](https://github.com/openapi-typesafe/openapi-typesafe/pull/9) [`14494f5`](https://github.com/openapi-typesafe/openapi-typesafe/commit/14494f5553575d15ad8f4d54f59ddabddb3a3e01) Thanks [@fedorello](https://github.com/fedorello)! - `Parameters<typeof $api.queryOptions>` (and of `useQuery`, `useSuspenseQuery` and the fetch
117
+ client's `request`) takes the arguments of every operation; its path was `never` (upstream [#2178](https://github.com/openapi-typesafe/openapi-typesafe/issues/2178)).
118
+ `PathsWithMethod<paths, HttpMethod>` is now every path that has some method; a known method or set
119
+ of methods still gives the paths that have each of them, as before. Code that is generic in the
120
+ paths, such as swr-openapi's hooks, compiles as with openapi-typescript's helpers. The init in those parameters is required when some operation
121
+ requires one (`IsInitOptional`), so a helper passes `{}` for a path that needs none. A single call
122
+ is checked as before, also with a union of paths or methods.
123
+ `ReturnType` of these generic functions stays `any`; the `queryOptions` docs show what to use.
124
+
125
+ ## 1.0.0-rc.0
126
+
127
+ ### Minor Changes
128
+
129
+ - [`551c058`](https://github.com/openapi-typesafe/openapi-typesafe/commit/551c05889d32eaf1d328111e5c4d167e0337e5a4) Thanks [@fedorello](https://github.com/fedorello)! - The OpenAPI 3.2 `QUERY` method: `HttpMethod` includes `"query"`, the fetch client has
130
+ `client.QUERY(url, { body })` (also through `request("query", …)` and the path-based client), and
131
+ the react-query hooks accept `"query"`. A `Record<HttpMethod, …>` written by hand needs a `query`
132
+ entry. The path-based client maps only HTTP method keys, so `parameters` no longer shows up as a
133
+ `PARAMETERS()` call that always failed.
134
+
135
+ ### Patch Changes
136
+
137
+ - [`e49344a`](https://github.com/openapi-typesafe/openapi-typesafe/commit/e49344a208fb3bb38cd86f62c1395f8f7ca950f6) Thanks [@fedorello](https://github.com/fedorello)! - Packages contain only their build output, sources for source maps, the CLI, and the README, license and changelog. Coverage reports, local logs and tool configs are no longer packed.
138
+
139
+ - [`63275f8`](https://github.com/openapi-typesafe/openapi-typesafe/commit/63275f86ff7ba855338f09f87fb9567c8ed91300) Thanks [@fedorello](https://github.com/fedorello)! - `Readable` and `Writable` keep function types as they are. Before, they mapped a `Blob` or a `Date`
140
+ in response data into an object whose methods could not be called, so `data.file.arrayBuffer()`
141
+ did not type check. The helper types that `--read-write-markers` writes into the output change the
142
+ same way. See ADR-014, decision 6.
143
+
144
+ - [`d5dcbb3`](https://github.com/openapi-typesafe/openapi-typesafe/commit/d5dcbb3f38e4d583334977c50db92461085d4a11) Thanks [@fedorello](https://github.com/fedorello)! - `Readable` and `Writable` keep the shape of types without markers: readonly arrays stay arrays, tuples stay tuples, branded primitives (`string & { __brand }`) stay as they are, `allOf` arrays keep the properties of every member (so unions narrow again), and an optional `null` property is no longer dropped from request bodies. The `--read-write-markers` output carries the same fixed helpers (ADR-014). Fixes upstream [#2615](https://github.com/openapi-typesafe/openapi-typesafe/issues/2615), [#2620](https://github.com/openapi-typesafe/openapi-typesafe/issues/2620), [#2632](https://github.com/openapi-typesafe/openapi-typesafe/issues/2632), [#2717](https://github.com/openapi-typesafe/openapi-typesafe/issues/2717), [#2765](https://github.com/openapi-typesafe/openapi-typesafe/issues/2765).
145
+
146
+ ## 0.1.0
147
+
148
+ ### Minor Changes
149
+
150
+ - [#2549](https://github.com/openapi-ts/openapi-typescript/pull/2549) [`a690e52`](https://github.com/openapi-ts/openapi-typescript/commit/a690e526b7693479bc2f2f002d71a020fa5e4e16) Thanks [@abumalick](https://github.com/abumalick)! - Add readOnly/writeOnly support via `--read-write-markers` flag. When enabled, readOnly properties are wrapped with `$Read<T>` and writeOnly properties with `$Write<T>`. openapi-fetch uses `Readable<T>` and `Writable<T>` helpers to exclude these properties from responses and request bodies respectively.
151
+
152
+ ## 0.0.15
153
+
154
+ ### Patch Changes
155
+
156
+ - [#1937](https://github.com/openapi-ts/openapi-typescript/pull/1937) [`06163a2`](https://github.com/openapi-ts/openapi-typescript/commit/06163a2030eaf8d0579f624d86481e1205aef396) Thanks [@DjordyKoert](https://github.com/DjordyKoert)! - client data & error now return a union of possible types
157
+
158
+ ## 0.0.14
159
+
160
+ ### Patch Changes
161
+
162
+ - [#1948](https://github.com/openapi-ts/openapi-typescript/pull/1948) [`abfad56`](https://github.com/openapi-ts/openapi-typescript/commit/abfad5659183f95f705598dc52ae2dfe7a18ec04) Thanks [@piousdeer](https://github.com/piousdeer)! - fix SuccessResponseJSON, ErrorResponseJSON and RequestBodyJSON helpers
163
+
164
+ ## 0.0.13
165
+
166
+ ### Patch Changes
167
+
168
+ - [#1871](https://github.com/openapi-ts/openapi-typescript/pull/1871) [`bd88568`](https://github.com/openapi-ts/openapi-typescript/commit/bd8856854eaaf213b96d04b9eb130db1695bb1f1) Thanks [@brunolca](https://github.com/brunolca)! - fix SuccessResponseJSON and ErrorResponseJSON helpers
169
+
170
+ ## 0.0.12
171
+
172
+ ### Patch Changes
173
+
174
+ - [#1833](https://github.com/openapi-ts/openapi-typescript/pull/1833) [`cec023d`](https://github.com/openapi-ts/openapi-typescript/commit/cec023d3461c79ca355a88366949d0f6382e4e2a) Thanks [@ngraef](https://github.com/ngraef)! - Fix identification of required properties when `strictNullChecks` is disabled
175
+
176
+ ## 0.0.11
177
+
178
+ ### Patch Changes
179
+
180
+ - [#1788](https://github.com/openapi-ts/openapi-typescript/pull/1788) [`bcc9222`](https://github.com/openapi-ts/openapi-typescript/commit/bcc92223c83ba074316e17534a173fee8da9cd41) Thanks [@yukukotani](https://github.com/yukukotani)! - keep index.d.cts in npm distribution
181
+
182
+ ## 0.0.10
183
+
184
+ ### Patch Changes
185
+
186
+ - [#1717](https://github.com/openapi-ts/openapi-typescript/pull/1717) [`335530c`](https://github.com/openapi-ts/openapi-typescript/commit/335530c4f8f966d0154f19504585c462f5f5a409) Thanks [@kerwanp](https://github.com/kerwanp)! - Ignore configuration files in published package
187
+
188
+ ## 0.0.9
189
+
190
+ ### Patch Changes
191
+
192
+ - Improved handling of `SuccessResponse<T>` and `ErrorResponse<T>`
193
+ - Changed handling of `ErrorResponse<T>` to produce one and only one error type (rather than an impossible union)
194
+
195
+ ## 0.0.8
196
+
197
+ ### Patch Changes
198
+
199
+ - [#1610](https://github.com/openapi-ts/openapi-typescript/pull/1610) [`cc8073b`](https://github.com/openapi-ts/openapi-typescript/commit/cc8073b3ee42e7aaa546a9c6a0553c300d8882de) Thanks [@illright](https://github.com/illright)! - Fix data/error discrimination when there are empty-body errors
200
+
201
+ - [#1559](https://github.com/openapi-ts/openapi-typescript/pull/1559) [`6fe2c85`](https://github.com/openapi-ts/openapi-typescript/commit/6fe2c856331e910b9c8376fc151d63028dcfba11) Thanks [@drwpow](https://github.com/drwpow)! - Simplify build
202
+
203
+ ## 0.0.7
204
+
205
+ ### Patch Changes
206
+
207
+ - [#1479](https://github.com/openapi-ts/openapi-typescript/pull/1479) [`c6d945b`](https://github.com/openapi-ts/openapi-typescript/commit/c6d945be717bb3999178fb3a77292e41e1b7ab80) Thanks [@darwish](https://github.com/darwish)! - Fixed build of openapi-typescript-helpers for CommonJS environments
208
+
209
+ ## 0.0.6
210
+
211
+ ### Patch Changes
212
+
213
+ - [#1458](https://github.com/openapi-ts/openapi-typescript/pull/1458) [`23517a2`](https://github.com/openapi-ts/openapi-typescript/commit/23517a2c2ab94d49085391130cd7d11f4da33cfb) Thanks [@drwpow](https://github.com/drwpow)! - Add RequestBodyJSON helper
214
+
215
+ ## 0.0.5
216
+
217
+ ### Patch Changes
218
+
219
+ - [#1456](https://github.com/openapi-ts/openapi-typescript/pull/1456) [`5be2082`](https://github.com/openapi-ts/openapi-typescript/commit/5be20827334c60e53222445561b9cfc526f4f6a9) Thanks [@drwpow](https://github.com/drwpow)! - Add SuccessResponseJSON, ErrorResponseJSON helpers
220
+
221
+ ## 0.0.4
222
+
223
+ ### Patch Changes
224
+
225
+ - [#1366](https://github.com/openapi-ts/openapi-typescript/pull/1366) [`04dbd6d`](https://github.com/openapi-ts/openapi-typescript/commit/04dbd6d84fffd1d88300421bae25e946f1c303da) Thanks [@drwpow](https://github.com/drwpow)! - Add HasRequiredKeys<T> helper
226
+
227
+ ## 0.0.3
228
+
229
+ ### Patch Changes
230
+
231
+ - [#1357](https://github.com/openapi-ts/openapi-typescript/pull/1357) [`996e51e`](https://github.com/openapi-ts/openapi-typescript/commit/996e51e9b475f4818af77301ed5c0ab458736cb9) Thanks [@muttonchop](https://github.com/muttonchop)! - adds 500-511 error status codes
232
+
233
+ ## 0.0.2
234
+
235
+ ### Patch Changes
236
+
237
+ - [#1326](https://github.com/openapi-ts/openapi-typescript/pull/1326) [`e63a345`](https://github.com/openapi-ts/openapi-typescript/commit/e63a34561c8137c4cfdef858a2272be32960ca4f) Thanks [@drwpow](https://github.com/drwpow)! - Fix type bug
238
+
239
+ ## 0.0.0
240
+
241
+ Initial release
package/README.md CHANGED
@@ -1,11 +1,27 @@
1
1
  # openapi-typesafe-helpers
2
2
 
3
- Type helpers shared by `openapi-typesafe-fetch` and `openapi-typesafe-react-query` (for example `PathsWithMethod`,
3
+ Type helpers for the types that openapi-typesafe generates (for example `PathsWithMethod`,
4
4
  `SuccessResponse`, `ErrorResponse`, `MediaType`). Types only; no runtime code.
5
5
 
6
+ `openapi-typesafe-fetch` declares the helper types in its `helpers` entry, and this package
7
+ re-exports them, so it depends on the client. The names of both packages are one declaration: a
8
+ value typed with one fits the other, also in generic code. A library built with
9
+ `declaration: true` under Yarn PnP that depends only on this package and exports an inferred type
10
+ that prints a helper type gets `import("openapi-typesafe-fetch/helpers")` in its declarations: add
11
+ `openapi-typesafe-fetch` to its dependencies, or annotate the type.
12
+
6
13
  A maintained successor to `openapi-typescript-helpers` (see the [repository README](../../README.md)).
7
14
  Most projects do not need to install it directly.
8
15
 
16
+ > **Release candidate.** The current version is a 1.0.0 release candidate (`1.0.0-rc.N`);
17
+ > names and output can still change before 1.0.0.
18
+
19
+ ## Versioning
20
+
21
+ Semantic versioning from 1.0.0, with one version for all openapi-typesafe packages. What the
22
+ version promises, and what may grow in a minor release, is listed under
23
+ [Versioning](https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/compatibility.md#versioning).
24
+
9
25
  ## License
10
26
 
11
27
  [MIT](./LICENSE)
package/dist/index.d.cts CHANGED
@@ -1,185 +1 @@
1
- type HttpMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace" | "query";
2
- type OkStatus = 200 | 201 | 202 | 203 | 204 | 206 | 207 | "2XX";
3
- type ErrorStatus = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 | "5XX" | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 444 | 450 | 451 | 497 | 498 | 499 | "4XX" | "default";
4
- type OKStatusUnion<T> = FilterKeys<T, OkStatus>;
5
- type FirstErrorStatus<T> = T extends {
6
- 500: any;
7
- } ? T[500] : T extends {
8
- 501: any;
9
- } ? T[501] : T extends {
10
- 502: any;
11
- } ? T[502] : T extends {
12
- 503: any;
13
- } ? T[503] : T extends {
14
- 504: any;
15
- } ? T[504] : T extends {
16
- 505: any;
17
- } ? T[505] : T extends {
18
- 506: any;
19
- } ? T[506] : T extends {
20
- 507: any;
21
- } ? T[507] : T extends {
22
- 508: any;
23
- } ? T[508] : T extends {
24
- 510: any;
25
- } ? T[510] : T extends {
26
- 511: any;
27
- } ? T[511] : T extends {
28
- "5XX": any;
29
- } ? T["5XX"] : T extends {
30
- 400: any;
31
- } ? T[400] : T extends {
32
- 401: any;
33
- } ? T[401] : T extends {
34
- 402: any;
35
- } ? T[402] : T extends {
36
- 403: any;
37
- } ? T[403] : T extends {
38
- 404: any;
39
- } ? T[404] : T extends {
40
- 405: any;
41
- } ? T[405] : T extends {
42
- 406: any;
43
- } ? T[406] : T extends {
44
- 407: any;
45
- } ? T[407] : T extends {
46
- 408: any;
47
- } ? T[408] : T extends {
48
- 409: any;
49
- } ? T[409] : T extends {
50
- 410: any;
51
- } ? T[410] : T extends {
52
- 411: any;
53
- } ? T[411] : T extends {
54
- 412: any;
55
- } ? T[412] : T extends {
56
- 413: any;
57
- } ? T[413] : T extends {
58
- 414: any;
59
- } ? T[414] : T extends {
60
- 415: any;
61
- } ? T[415] : T extends {
62
- 416: any;
63
- } ? T[416] : T extends {
64
- 417: any;
65
- } ? T[417] : T extends {
66
- 418: any;
67
- } ? T[418] : T extends {
68
- 420: any;
69
- } ? T[420] : T extends {
70
- 421: any;
71
- } ? T[421] : T extends {
72
- 422: any;
73
- } ? T[422] : T extends {
74
- 423: any;
75
- } ? T[423] : T extends {
76
- 424: any;
77
- } ? T[424] : T extends {
78
- 425: any;
79
- } ? T[425] : T extends {
80
- 426: any;
81
- } ? T[426] : T extends {
82
- 427: any;
83
- } ? T[427] : T extends {
84
- 428: any;
85
- } ? T[428] : T extends {
86
- 429: any;
87
- } ? T[429] : T extends {
88
- 430: any;
89
- } ? T[430] : T extends {
90
- 431: any;
91
- } ? T[431] : T extends {
92
- 444: any;
93
- } ? T[444] : T extends {
94
- 450: any;
95
- } ? T[450] : T extends {
96
- 451: any;
97
- } ? T[451] : T extends {
98
- 497: any;
99
- } ? T[497] : T extends {
100
- 498: any;
101
- } ? T[498] : T extends {
102
- 499: any;
103
- } ? T[499] : T extends {
104
- "4XX": any;
105
- } ? T["4XX"] : T extends {
106
- default: any;
107
- } ? T["default"] : never;
108
- type PathsWithEveryMethod<Paths extends {}, PathnameMethod extends HttpMethod> = {
109
- [Pathname in keyof Paths]: Paths[Pathname] extends {
110
- [K in PathnameMethod]: any;
111
- } ? Pathname : never;
112
- }[keyof Paths];
113
- type PathsWithAnyMethod<Paths extends {}> = {
114
- [Pathname in keyof Paths]: {
115
- [Method in HttpMethod]: Paths[Pathname] extends {
116
- [K in Method]: any;
117
- } ? Pathname : never;
118
- }[HttpMethod];
119
- }[keyof Paths];
120
- type PathsWithMethod<Paths extends {}, PathnameMethod extends HttpMethod> = PathsWithEveryMethod<Paths, PathnameMethod> | (HttpMethod extends PathnameMethod ? PathsWithAnyMethod<Paths> : never);
121
- interface OperationObject {
122
- parameters: any;
123
- requestBody: any;
124
- responses: any;
125
- }
126
- type PathItemObject = {
127
- [M in HttpMethod]: OperationObject;
128
- } & {
129
- parameters?: any;
130
- };
131
- type ResponseObjectMap<T> = T extends {
132
- responses: any;
133
- } ? T["responses"] : unknown;
134
- type ResponseContent<T> = T extends {
135
- content: any;
136
- } ? T["content"] : unknown;
137
- type OperationRequestBody<T> = "requestBody" extends keyof T ? T["requestBody"] : never;
138
- type PickRequestBody<T> = "requestBody" extends keyof T ? Pick<T, "requestBody"> : never;
139
- type IsOperationRequestBodyOptional<T> = RequiredKeysOf<PickRequestBody<T>> extends never ? true : false;
140
- type OperationRequestBodyMediaContent<T> = IsOperationRequestBodyOptional<T> extends true ? ResponseContent<NonNullable<OperationRequestBody<T>>> | undefined : ResponseContent<OperationRequestBody<T>>;
141
- type OperationRequestBodyContent<T> = FilterKeys<OperationRequestBodyMediaContent<T>, MediaType> extends never ? FilterKeys<NonNullable<OperationRequestBodyMediaContent<T>>, MediaType> | undefined : FilterKeys<OperationRequestBodyMediaContent<T>, MediaType>;
142
- type SuccessStatus<T> = [Extract<keyof T, OkStatus>] extends [never] ? "default" : OkStatus;
143
- type SuccessResponse<T extends Record<string | number, any>, Media extends MediaType = MediaType> = GetResponseContent<T, Media, SuccessStatus<T>>;
144
- type GetResponseContent<T extends Record<string | number, any>, Media extends MediaType = MediaType, ResponseCode extends keyof T = keyof T> = ResponseCode extends keyof T ? {
145
- [K in ResponseCode]: T[K]["content"] extends Record<string, any> ? FilterKeys<T[K]["content"], Media> extends never ? T[K]["content"] : FilterKeys<T[K]["content"], Media> : K extends keyof T ? T[K]["content"] : never;
146
- }[ResponseCode] : never;
147
- type ErrorResponse<T extends Record<string | number, any>, Media extends MediaType = MediaType> = GetResponseContent<T, Media, ErrorStatus>;
148
- type SuccessResponseJSON<PathMethod extends Record<string | number, any>> = SuccessResponse<ResponseObjectMap<PathMethod>, `${string}/json`>;
149
- type ErrorResponseJSON<PathMethod extends Record<string | number, any>> = ErrorResponse<ResponseObjectMap<PathMethod>, `${string}/json`>;
150
- type RequestBodyJSON<PathMethod> = JSONLike<FilterKeys<OperationRequestBody<PathMethod>, "content">>;
151
- type FilterKeys<Obj, Matchers> = Obj[keyof Obj & Matchers];
152
- type GetValueWithDefault<Obj, KeyPattern, Default> = Obj extends any ? FilterKeys<Obj, KeyPattern> extends never ? Default : FilterKeys<Obj, KeyPattern> : never;
153
- type MediaType = `${string}/${string}`;
154
- type JSONLike<T> = FilterKeys<T, `${string}/json`>;
155
- type FindRequiredKeys<T, K extends keyof T> = K extends unknown ? undefined extends T[K] ? never : K : K;
156
- type HasRequiredKeys<T> = FindRequiredKeys<T, keyof T>;
157
- type RequiredKeysOfHelper<T> = {
158
- [K in keyof T]: {} extends Pick<T, K> ? never : K;
159
- }[keyof T];
160
- type RequiredKeysOf<T> = RequiredKeysOfHelper<T> extends undefined ? never : RequiredKeysOfHelper<T>;
161
- type $Read<T> = {
162
- readonly $read: T;
163
- };
164
- type $Write<T> = {
165
- readonly $write: T;
166
- };
167
- type ReadWritePrimitive = string | number | boolean | bigint | symbol | null | undefined;
168
- type ReadWriteLeaf = ReadWritePrimitive | ((...args: never) => unknown);
169
- type ReadWriteMarkedKeys<T, Marker> = {
170
- [K in keyof T]-?: NonNullable<T[K]> extends never ? never : NonNullable<T[K]> extends Marker ? K : never;
171
- }[keyof T];
172
- type ReadWriteResolveArray<T extends readonly unknown[], Resolved extends "read" | "write"> = T[number][] extends T ? T extends unknown[] ? ReadWriteResolve<T[number], Resolved>[] : readonly ReadWriteResolve<T[number], Resolved>[] : {
173
- [K in keyof T]: ReadWriteResolve<T[K], Resolved>;
174
- };
175
- type ReadWriteResolve<T, Resolved extends "read" | "write"> = Resolved extends "read" ? Readable<T> : Writable<T>;
176
- type Readable<T> = T extends $Write<any> ? never : T extends $Read<infer U> ? Readable<U> : T extends ReadWriteLeaf ? T : T extends readonly unknown[] ? ReadWriteResolveArray<T, "read"> : T extends object ? {
177
- [K in keyof T as K extends ReadWriteMarkedKeys<T, $Write<any>> ? never : K]: Readable<T[K]>;
178
- } : T;
179
- type Writable<T> = T extends $Read<any> ? never : T extends $Write<infer U> ? Writable<U> : T extends ReadWriteLeaf ? T : T extends readonly unknown[] ? ReadWriteResolveArray<T, "write"> : T extends object ? {
180
- [K in keyof T as K extends ReadWriteMarkedKeys<T, $Read<any>> ? never : K]: Writable<T[K]>;
181
- } & {
182
- [K in ReadWriteMarkedKeys<T, $Read<any>>]?: never;
183
- } : T;
184
-
185
- export type { $Read, $Write, ErrorResponse, ErrorResponseJSON, ErrorStatus, FilterKeys, FindRequiredKeys, FirstErrorStatus, GetResponseContent, GetValueWithDefault, HasRequiredKeys, HttpMethod, IsOperationRequestBodyOptional, JSONLike, MediaType, OKStatusUnion, OkStatus, OperationObject, OperationRequestBody, OperationRequestBodyContent, OperationRequestBodyMediaContent, PathItemObject, PathsWithMethod, Readable, RequestBodyJSON, RequiredKeysOf, ResponseContent, ResponseObjectMap, SuccessResponse, SuccessResponseJSON, Writable };
1
+ export * from 'openapi-typesafe-fetch/helpers';
package/dist/index.d.mts CHANGED
@@ -1,185 +1 @@
1
- type HttpMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace" | "query";
2
- type OkStatus = 200 | 201 | 202 | 203 | 204 | 206 | 207 | "2XX";
3
- type ErrorStatus = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 | "5XX" | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 444 | 450 | 451 | 497 | 498 | 499 | "4XX" | "default";
4
- type OKStatusUnion<T> = FilterKeys<T, OkStatus>;
5
- type FirstErrorStatus<T> = T extends {
6
- 500: any;
7
- } ? T[500] : T extends {
8
- 501: any;
9
- } ? T[501] : T extends {
10
- 502: any;
11
- } ? T[502] : T extends {
12
- 503: any;
13
- } ? T[503] : T extends {
14
- 504: any;
15
- } ? T[504] : T extends {
16
- 505: any;
17
- } ? T[505] : T extends {
18
- 506: any;
19
- } ? T[506] : T extends {
20
- 507: any;
21
- } ? T[507] : T extends {
22
- 508: any;
23
- } ? T[508] : T extends {
24
- 510: any;
25
- } ? T[510] : T extends {
26
- 511: any;
27
- } ? T[511] : T extends {
28
- "5XX": any;
29
- } ? T["5XX"] : T extends {
30
- 400: any;
31
- } ? T[400] : T extends {
32
- 401: any;
33
- } ? T[401] : T extends {
34
- 402: any;
35
- } ? T[402] : T extends {
36
- 403: any;
37
- } ? T[403] : T extends {
38
- 404: any;
39
- } ? T[404] : T extends {
40
- 405: any;
41
- } ? T[405] : T extends {
42
- 406: any;
43
- } ? T[406] : T extends {
44
- 407: any;
45
- } ? T[407] : T extends {
46
- 408: any;
47
- } ? T[408] : T extends {
48
- 409: any;
49
- } ? T[409] : T extends {
50
- 410: any;
51
- } ? T[410] : T extends {
52
- 411: any;
53
- } ? T[411] : T extends {
54
- 412: any;
55
- } ? T[412] : T extends {
56
- 413: any;
57
- } ? T[413] : T extends {
58
- 414: any;
59
- } ? T[414] : T extends {
60
- 415: any;
61
- } ? T[415] : T extends {
62
- 416: any;
63
- } ? T[416] : T extends {
64
- 417: any;
65
- } ? T[417] : T extends {
66
- 418: any;
67
- } ? T[418] : T extends {
68
- 420: any;
69
- } ? T[420] : T extends {
70
- 421: any;
71
- } ? T[421] : T extends {
72
- 422: any;
73
- } ? T[422] : T extends {
74
- 423: any;
75
- } ? T[423] : T extends {
76
- 424: any;
77
- } ? T[424] : T extends {
78
- 425: any;
79
- } ? T[425] : T extends {
80
- 426: any;
81
- } ? T[426] : T extends {
82
- 427: any;
83
- } ? T[427] : T extends {
84
- 428: any;
85
- } ? T[428] : T extends {
86
- 429: any;
87
- } ? T[429] : T extends {
88
- 430: any;
89
- } ? T[430] : T extends {
90
- 431: any;
91
- } ? T[431] : T extends {
92
- 444: any;
93
- } ? T[444] : T extends {
94
- 450: any;
95
- } ? T[450] : T extends {
96
- 451: any;
97
- } ? T[451] : T extends {
98
- 497: any;
99
- } ? T[497] : T extends {
100
- 498: any;
101
- } ? T[498] : T extends {
102
- 499: any;
103
- } ? T[499] : T extends {
104
- "4XX": any;
105
- } ? T["4XX"] : T extends {
106
- default: any;
107
- } ? T["default"] : never;
108
- type PathsWithEveryMethod<Paths extends {}, PathnameMethod extends HttpMethod> = {
109
- [Pathname in keyof Paths]: Paths[Pathname] extends {
110
- [K in PathnameMethod]: any;
111
- } ? Pathname : never;
112
- }[keyof Paths];
113
- type PathsWithAnyMethod<Paths extends {}> = {
114
- [Pathname in keyof Paths]: {
115
- [Method in HttpMethod]: Paths[Pathname] extends {
116
- [K in Method]: any;
117
- } ? Pathname : never;
118
- }[HttpMethod];
119
- }[keyof Paths];
120
- type PathsWithMethod<Paths extends {}, PathnameMethod extends HttpMethod> = PathsWithEveryMethod<Paths, PathnameMethod> | (HttpMethod extends PathnameMethod ? PathsWithAnyMethod<Paths> : never);
121
- interface OperationObject {
122
- parameters: any;
123
- requestBody: any;
124
- responses: any;
125
- }
126
- type PathItemObject = {
127
- [M in HttpMethod]: OperationObject;
128
- } & {
129
- parameters?: any;
130
- };
131
- type ResponseObjectMap<T> = T extends {
132
- responses: any;
133
- } ? T["responses"] : unknown;
134
- type ResponseContent<T> = T extends {
135
- content: any;
136
- } ? T["content"] : unknown;
137
- type OperationRequestBody<T> = "requestBody" extends keyof T ? T["requestBody"] : never;
138
- type PickRequestBody<T> = "requestBody" extends keyof T ? Pick<T, "requestBody"> : never;
139
- type IsOperationRequestBodyOptional<T> = RequiredKeysOf<PickRequestBody<T>> extends never ? true : false;
140
- type OperationRequestBodyMediaContent<T> = IsOperationRequestBodyOptional<T> extends true ? ResponseContent<NonNullable<OperationRequestBody<T>>> | undefined : ResponseContent<OperationRequestBody<T>>;
141
- type OperationRequestBodyContent<T> = FilterKeys<OperationRequestBodyMediaContent<T>, MediaType> extends never ? FilterKeys<NonNullable<OperationRequestBodyMediaContent<T>>, MediaType> | undefined : FilterKeys<OperationRequestBodyMediaContent<T>, MediaType>;
142
- type SuccessStatus<T> = [Extract<keyof T, OkStatus>] extends [never] ? "default" : OkStatus;
143
- type SuccessResponse<T extends Record<string | number, any>, Media extends MediaType = MediaType> = GetResponseContent<T, Media, SuccessStatus<T>>;
144
- type GetResponseContent<T extends Record<string | number, any>, Media extends MediaType = MediaType, ResponseCode extends keyof T = keyof T> = ResponseCode extends keyof T ? {
145
- [K in ResponseCode]: T[K]["content"] extends Record<string, any> ? FilterKeys<T[K]["content"], Media> extends never ? T[K]["content"] : FilterKeys<T[K]["content"], Media> : K extends keyof T ? T[K]["content"] : never;
146
- }[ResponseCode] : never;
147
- type ErrorResponse<T extends Record<string | number, any>, Media extends MediaType = MediaType> = GetResponseContent<T, Media, ErrorStatus>;
148
- type SuccessResponseJSON<PathMethod extends Record<string | number, any>> = SuccessResponse<ResponseObjectMap<PathMethod>, `${string}/json`>;
149
- type ErrorResponseJSON<PathMethod extends Record<string | number, any>> = ErrorResponse<ResponseObjectMap<PathMethod>, `${string}/json`>;
150
- type RequestBodyJSON<PathMethod> = JSONLike<FilterKeys<OperationRequestBody<PathMethod>, "content">>;
151
- type FilterKeys<Obj, Matchers> = Obj[keyof Obj & Matchers];
152
- type GetValueWithDefault<Obj, KeyPattern, Default> = Obj extends any ? FilterKeys<Obj, KeyPattern> extends never ? Default : FilterKeys<Obj, KeyPattern> : never;
153
- type MediaType = `${string}/${string}`;
154
- type JSONLike<T> = FilterKeys<T, `${string}/json`>;
155
- type FindRequiredKeys<T, K extends keyof T> = K extends unknown ? undefined extends T[K] ? never : K : K;
156
- type HasRequiredKeys<T> = FindRequiredKeys<T, keyof T>;
157
- type RequiredKeysOfHelper<T> = {
158
- [K in keyof T]: {} extends Pick<T, K> ? never : K;
159
- }[keyof T];
160
- type RequiredKeysOf<T> = RequiredKeysOfHelper<T> extends undefined ? never : RequiredKeysOfHelper<T>;
161
- type $Read<T> = {
162
- readonly $read: T;
163
- };
164
- type $Write<T> = {
165
- readonly $write: T;
166
- };
167
- type ReadWritePrimitive = string | number | boolean | bigint | symbol | null | undefined;
168
- type ReadWriteLeaf = ReadWritePrimitive | ((...args: never) => unknown);
169
- type ReadWriteMarkedKeys<T, Marker> = {
170
- [K in keyof T]-?: NonNullable<T[K]> extends never ? never : NonNullable<T[K]> extends Marker ? K : never;
171
- }[keyof T];
172
- type ReadWriteResolveArray<T extends readonly unknown[], Resolved extends "read" | "write"> = T[number][] extends T ? T extends unknown[] ? ReadWriteResolve<T[number], Resolved>[] : readonly ReadWriteResolve<T[number], Resolved>[] : {
173
- [K in keyof T]: ReadWriteResolve<T[K], Resolved>;
174
- };
175
- type ReadWriteResolve<T, Resolved extends "read" | "write"> = Resolved extends "read" ? Readable<T> : Writable<T>;
176
- type Readable<T> = T extends $Write<any> ? never : T extends $Read<infer U> ? Readable<U> : T extends ReadWriteLeaf ? T : T extends readonly unknown[] ? ReadWriteResolveArray<T, "read"> : T extends object ? {
177
- [K in keyof T as K extends ReadWriteMarkedKeys<T, $Write<any>> ? never : K]: Readable<T[K]>;
178
- } : T;
179
- type Writable<T> = T extends $Read<any> ? never : T extends $Write<infer U> ? Writable<U> : T extends ReadWriteLeaf ? T : T extends readonly unknown[] ? ReadWriteResolveArray<T, "write"> : T extends object ? {
180
- [K in keyof T as K extends ReadWriteMarkedKeys<T, $Read<any>> ? never : K]: Writable<T[K]>;
181
- } & {
182
- [K in ReadWriteMarkedKeys<T, $Read<any>>]?: never;
183
- } : T;
184
-
185
- export type { $Read, $Write, ErrorResponse, ErrorResponseJSON, ErrorStatus, FilterKeys, FindRequiredKeys, FirstErrorStatus, GetResponseContent, GetValueWithDefault, HasRequiredKeys, HttpMethod, IsOperationRequestBodyOptional, JSONLike, MediaType, OKStatusUnion, OkStatus, OperationObject, OperationRequestBody, OperationRequestBodyContent, OperationRequestBodyMediaContent, PathItemObject, PathsWithMethod, Readable, RequestBodyJSON, RequiredKeysOf, ResponseContent, ResponseObjectMap, SuccessResponse, SuccessResponseJSON, Writable };
1
+ export * from 'openapi-typesafe-fetch/helpers';
package/dist/index.d.ts CHANGED
@@ -1,185 +1 @@
1
- type HttpMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace" | "query";
2
- type OkStatus = 200 | 201 | 202 | 203 | 204 | 206 | 207 | "2XX";
3
- type ErrorStatus = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 | "5XX" | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 444 | 450 | 451 | 497 | 498 | 499 | "4XX" | "default";
4
- type OKStatusUnion<T> = FilterKeys<T, OkStatus>;
5
- type FirstErrorStatus<T> = T extends {
6
- 500: any;
7
- } ? T[500] : T extends {
8
- 501: any;
9
- } ? T[501] : T extends {
10
- 502: any;
11
- } ? T[502] : T extends {
12
- 503: any;
13
- } ? T[503] : T extends {
14
- 504: any;
15
- } ? T[504] : T extends {
16
- 505: any;
17
- } ? T[505] : T extends {
18
- 506: any;
19
- } ? T[506] : T extends {
20
- 507: any;
21
- } ? T[507] : T extends {
22
- 508: any;
23
- } ? T[508] : T extends {
24
- 510: any;
25
- } ? T[510] : T extends {
26
- 511: any;
27
- } ? T[511] : T extends {
28
- "5XX": any;
29
- } ? T["5XX"] : T extends {
30
- 400: any;
31
- } ? T[400] : T extends {
32
- 401: any;
33
- } ? T[401] : T extends {
34
- 402: any;
35
- } ? T[402] : T extends {
36
- 403: any;
37
- } ? T[403] : T extends {
38
- 404: any;
39
- } ? T[404] : T extends {
40
- 405: any;
41
- } ? T[405] : T extends {
42
- 406: any;
43
- } ? T[406] : T extends {
44
- 407: any;
45
- } ? T[407] : T extends {
46
- 408: any;
47
- } ? T[408] : T extends {
48
- 409: any;
49
- } ? T[409] : T extends {
50
- 410: any;
51
- } ? T[410] : T extends {
52
- 411: any;
53
- } ? T[411] : T extends {
54
- 412: any;
55
- } ? T[412] : T extends {
56
- 413: any;
57
- } ? T[413] : T extends {
58
- 414: any;
59
- } ? T[414] : T extends {
60
- 415: any;
61
- } ? T[415] : T extends {
62
- 416: any;
63
- } ? T[416] : T extends {
64
- 417: any;
65
- } ? T[417] : T extends {
66
- 418: any;
67
- } ? T[418] : T extends {
68
- 420: any;
69
- } ? T[420] : T extends {
70
- 421: any;
71
- } ? T[421] : T extends {
72
- 422: any;
73
- } ? T[422] : T extends {
74
- 423: any;
75
- } ? T[423] : T extends {
76
- 424: any;
77
- } ? T[424] : T extends {
78
- 425: any;
79
- } ? T[425] : T extends {
80
- 426: any;
81
- } ? T[426] : T extends {
82
- 427: any;
83
- } ? T[427] : T extends {
84
- 428: any;
85
- } ? T[428] : T extends {
86
- 429: any;
87
- } ? T[429] : T extends {
88
- 430: any;
89
- } ? T[430] : T extends {
90
- 431: any;
91
- } ? T[431] : T extends {
92
- 444: any;
93
- } ? T[444] : T extends {
94
- 450: any;
95
- } ? T[450] : T extends {
96
- 451: any;
97
- } ? T[451] : T extends {
98
- 497: any;
99
- } ? T[497] : T extends {
100
- 498: any;
101
- } ? T[498] : T extends {
102
- 499: any;
103
- } ? T[499] : T extends {
104
- "4XX": any;
105
- } ? T["4XX"] : T extends {
106
- default: any;
107
- } ? T["default"] : never;
108
- type PathsWithEveryMethod<Paths extends {}, PathnameMethod extends HttpMethod> = {
109
- [Pathname in keyof Paths]: Paths[Pathname] extends {
110
- [K in PathnameMethod]: any;
111
- } ? Pathname : never;
112
- }[keyof Paths];
113
- type PathsWithAnyMethod<Paths extends {}> = {
114
- [Pathname in keyof Paths]: {
115
- [Method in HttpMethod]: Paths[Pathname] extends {
116
- [K in Method]: any;
117
- } ? Pathname : never;
118
- }[HttpMethod];
119
- }[keyof Paths];
120
- type PathsWithMethod<Paths extends {}, PathnameMethod extends HttpMethod> = PathsWithEveryMethod<Paths, PathnameMethod> | (HttpMethod extends PathnameMethod ? PathsWithAnyMethod<Paths> : never);
121
- interface OperationObject {
122
- parameters: any;
123
- requestBody: any;
124
- responses: any;
125
- }
126
- type PathItemObject = {
127
- [M in HttpMethod]: OperationObject;
128
- } & {
129
- parameters?: any;
130
- };
131
- type ResponseObjectMap<T> = T extends {
132
- responses: any;
133
- } ? T["responses"] : unknown;
134
- type ResponseContent<T> = T extends {
135
- content: any;
136
- } ? T["content"] : unknown;
137
- type OperationRequestBody<T> = "requestBody" extends keyof T ? T["requestBody"] : never;
138
- type PickRequestBody<T> = "requestBody" extends keyof T ? Pick<T, "requestBody"> : never;
139
- type IsOperationRequestBodyOptional<T> = RequiredKeysOf<PickRequestBody<T>> extends never ? true : false;
140
- type OperationRequestBodyMediaContent<T> = IsOperationRequestBodyOptional<T> extends true ? ResponseContent<NonNullable<OperationRequestBody<T>>> | undefined : ResponseContent<OperationRequestBody<T>>;
141
- type OperationRequestBodyContent<T> = FilterKeys<OperationRequestBodyMediaContent<T>, MediaType> extends never ? FilterKeys<NonNullable<OperationRequestBodyMediaContent<T>>, MediaType> | undefined : FilterKeys<OperationRequestBodyMediaContent<T>, MediaType>;
142
- type SuccessStatus<T> = [Extract<keyof T, OkStatus>] extends [never] ? "default" : OkStatus;
143
- type SuccessResponse<T extends Record<string | number, any>, Media extends MediaType = MediaType> = GetResponseContent<T, Media, SuccessStatus<T>>;
144
- type GetResponseContent<T extends Record<string | number, any>, Media extends MediaType = MediaType, ResponseCode extends keyof T = keyof T> = ResponseCode extends keyof T ? {
145
- [K in ResponseCode]: T[K]["content"] extends Record<string, any> ? FilterKeys<T[K]["content"], Media> extends never ? T[K]["content"] : FilterKeys<T[K]["content"], Media> : K extends keyof T ? T[K]["content"] : never;
146
- }[ResponseCode] : never;
147
- type ErrorResponse<T extends Record<string | number, any>, Media extends MediaType = MediaType> = GetResponseContent<T, Media, ErrorStatus>;
148
- type SuccessResponseJSON<PathMethod extends Record<string | number, any>> = SuccessResponse<ResponseObjectMap<PathMethod>, `${string}/json`>;
149
- type ErrorResponseJSON<PathMethod extends Record<string | number, any>> = ErrorResponse<ResponseObjectMap<PathMethod>, `${string}/json`>;
150
- type RequestBodyJSON<PathMethod> = JSONLike<FilterKeys<OperationRequestBody<PathMethod>, "content">>;
151
- type FilterKeys<Obj, Matchers> = Obj[keyof Obj & Matchers];
152
- type GetValueWithDefault<Obj, KeyPattern, Default> = Obj extends any ? FilterKeys<Obj, KeyPattern> extends never ? Default : FilterKeys<Obj, KeyPattern> : never;
153
- type MediaType = `${string}/${string}`;
154
- type JSONLike<T> = FilterKeys<T, `${string}/json`>;
155
- type FindRequiredKeys<T, K extends keyof T> = K extends unknown ? undefined extends T[K] ? never : K : K;
156
- type HasRequiredKeys<T> = FindRequiredKeys<T, keyof T>;
157
- type RequiredKeysOfHelper<T> = {
158
- [K in keyof T]: {} extends Pick<T, K> ? never : K;
159
- }[keyof T];
160
- type RequiredKeysOf<T> = RequiredKeysOfHelper<T> extends undefined ? never : RequiredKeysOfHelper<T>;
161
- type $Read<T> = {
162
- readonly $read: T;
163
- };
164
- type $Write<T> = {
165
- readonly $write: T;
166
- };
167
- type ReadWritePrimitive = string | number | boolean | bigint | symbol | null | undefined;
168
- type ReadWriteLeaf = ReadWritePrimitive | ((...args: never) => unknown);
169
- type ReadWriteMarkedKeys<T, Marker> = {
170
- [K in keyof T]-?: NonNullable<T[K]> extends never ? never : NonNullable<T[K]> extends Marker ? K : never;
171
- }[keyof T];
172
- type ReadWriteResolveArray<T extends readonly unknown[], Resolved extends "read" | "write"> = T[number][] extends T ? T extends unknown[] ? ReadWriteResolve<T[number], Resolved>[] : readonly ReadWriteResolve<T[number], Resolved>[] : {
173
- [K in keyof T]: ReadWriteResolve<T[K], Resolved>;
174
- };
175
- type ReadWriteResolve<T, Resolved extends "read" | "write"> = Resolved extends "read" ? Readable<T> : Writable<T>;
176
- type Readable<T> = T extends $Write<any> ? never : T extends $Read<infer U> ? Readable<U> : T extends ReadWriteLeaf ? T : T extends readonly unknown[] ? ReadWriteResolveArray<T, "read"> : T extends object ? {
177
- [K in keyof T as K extends ReadWriteMarkedKeys<T, $Write<any>> ? never : K]: Readable<T[K]>;
178
- } : T;
179
- type Writable<T> = T extends $Read<any> ? never : T extends $Write<infer U> ? Writable<U> : T extends ReadWriteLeaf ? T : T extends readonly unknown[] ? ReadWriteResolveArray<T, "write"> : T extends object ? {
180
- [K in keyof T as K extends ReadWriteMarkedKeys<T, $Read<any>> ? never : K]: Writable<T[K]>;
181
- } & {
182
- [K in ReadWriteMarkedKeys<T, $Read<any>>]?: never;
183
- } : T;
184
-
185
- export type { $Read, $Write, ErrorResponse, ErrorResponseJSON, ErrorStatus, FilterKeys, FindRequiredKeys, FirstErrorStatus, GetResponseContent, GetValueWithDefault, HasRequiredKeys, HttpMethod, IsOperationRequestBodyOptional, JSONLike, MediaType, OKStatusUnion, OkStatus, OperationObject, OperationRequestBody, OperationRequestBodyContent, OperationRequestBodyMediaContent, PathItemObject, PathsWithMethod, Readable, RequestBodyJSON, RequiredKeysOf, ResponseContent, ResponseObjectMap, SuccessResponse, SuccessResponseJSON, Writable };
1
+ export * from 'openapi-typesafe-fetch/helpers';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "openapi-typesafe-helpers",
3
3
  "description": "TypeScript helpers for consuming openapi-typesafe types",
4
- "version": "1.0.0-rc.1",
4
+ "version": "1.0.0-rc.11",
5
5
  "author": {
6
6
  "name": "Fedor Chishchin",
7
7
  "url": "https://github.com/fedorello"
@@ -24,6 +24,7 @@
24
24
  "./*": "./*"
25
25
  },
26
26
  "files": [
27
+ "CHANGELOG.md",
27
28
  "dist"
28
29
  ],
29
30
  "homepage": "https://github.com/openapi-typesafe/openapi-typesafe#readme",
@@ -35,8 +36,12 @@
35
36
  "bugs": {
36
37
  "url": "https://github.com/openapi-typesafe/openapi-typesafe/issues"
37
38
  },
39
+ "dependencies": {
40
+ "openapi-typesafe-fetch": "^1.0.0-rc.11"
41
+ },
38
42
  "devDependencies": {
39
- "typescript": "^6.0.3"
43
+ "typescript": "^6.0.3",
44
+ "vite-node": "6.0.0"
40
45
  },
41
46
  "engines": {
42
47
  "node": ">=22"
@@ -44,10 +49,12 @@
44
49
  "scripts": {
45
50
  "build": "unbuild",
46
51
  "format": "biome format src --write",
47
- "lint": "pnpm run lint:js && pnpm run lint:ts",
52
+ "lint": "pnpm run lint:js && pnpm run lint:ts && pnpm run lint:sizes",
48
53
  "lint:js": "biome check src",
49
54
  "lint:ts": "tsc --noEmit",
50
- "test": "pnpm run test:exports",
51
- "test:exports": "pnpm run build && ../../scripts/check-exports.sh"
55
+ "lint:sizes": "vite-node ../openapi-typesafe/scripts/size-rules/check-sizes.ts src",
56
+ "test": "pnpm run test:js && pnpm run test:exports",
57
+ "test:js": "vitest run",
58
+ "test:exports": "../../scripts/check-exports.sh"
52
59
  }
53
60
  }