openapi-typesafe-helpers 1.0.0-rc.0 → 1.0.0-rc.10

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,229 @@
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.10
6
+
7
+ ### Patch Changes
8
+
9
+ - Updated dependencies [[`e635904`](https://github.com/openapi-typesafe/openapi-typesafe/commit/e6359045a637d6edd0addf58b6703aabb2f3fceb), [`e635904`](https://github.com/openapi-typesafe/openapi-typesafe/commit/e6359045a637d6edd0addf58b6703aabb2f3fceb)]:
10
+ - openapi-typesafe-fetch@1.0.0-rc.10
11
+
12
+ ## 1.0.0-rc.9
13
+
14
+ ### Patch Changes
15
+
16
+ - [#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`,
17
+ `ErrorResponseJSON` and the `data` and `error` of `FetchResponse` for `Paths[Path]` gave the whole
18
+ `responses` map next to the response bodies, so assigning them to the bodies failed with TS2322.
19
+ They give the bodies now. This also fixes the error type of hook wrappers generic in the path.
20
+ - 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)]:
21
+ - openapi-typesafe-fetch@1.0.0-rc.9
22
+
23
+ ## 1.0.0-rc.8
24
+
25
+ ### Patch Changes
26
+
27
+ - [#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
28
+ `if (error)` made the whole result `never`. `SuccessResponse<any>` and `ErrorResponse<any>` are
29
+ `any` too.
30
+
31
+ - [#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
32
+ `data` and `error` of a client made with ``createClient<paths, `${string}/json`>()`` keep a
33
+ JSON body of any JSON media type: an `application/problem+json` error, an
34
+ `application/vnd.api+json` success and `application/json; charset=utf-8` bodies were left out,
35
+ so the error could be `never` or miss a status. An error that is not JSON, such as the HTML page
36
+ of a proxy, is typed `string`, the text the client returns, instead of being left out.
37
+ - 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)]:
38
+ - openapi-typesafe-fetch@1.0.0-rc.8
39
+
40
+ ## 1.0.0-rc.7
41
+
42
+ ### Patch Changes
43
+
44
+ - [#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
45
+ ``createClient<paths, `${string}/json`>()`` leave out a response that has no JSON media type. It
46
+ added its whole `content` map, so a `text/html` 500 typed the error as `{ "text/html": string }`,
47
+ a value the client never returns.
48
+ - 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)]:
49
+ - openapi-typesafe-fetch@1.0.0-rc.7
50
+
51
+ ## 1.0.0-rc.6
52
+
53
+ ### Patch Changes
54
+
55
+ - Updated dependencies [[`dfb0fe3`](https://github.com/openapi-typesafe/openapi-typesafe/commit/dfb0fe3c61a75d2b8ca512577f4b699049171a64)]:
56
+ - openapi-typesafe-fetch@1.0.0-rc.6
57
+
58
+ ## 1.0.0-rc.5
59
+
60
+ ### Patch Changes
61
+
62
+ - 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)]:
63
+ - openapi-typesafe-fetch@1.0.0-rc.5
64
+
65
+ ## 1.0.0-rc.4
66
+
67
+ ### Patch Changes
68
+
69
+ - [#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
70
+ `error` as the union of each operation's types. In openapi-fetch a path without a response body
71
+ typed `data` as its content map, and a path with only a `default` response typed it `undefined`.
72
+ `SuccessResponse` and `ErrorResponse` of a union of response maps are the union of each map's
73
+ responses.
74
+ - 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)]:
75
+ - openapi-typesafe-fetch@1.0.0-rc.4
76
+
77
+ ## 1.0.0-rc.3
78
+
79
+ No changes in this release.
80
+
81
+ ## 1.0.0-rc.2
82
+
83
+ ### Major Changes
84
+
85
+ - [#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
86
+ 0.1.0. From 1.0 the package follows semver.
87
+
88
+ Changes that can need work when you move from openapi-typescript-helpers 0.1.0:
89
+ - `engines.node` is `>=22`.
90
+ - `HttpMethod` includes `"query"`: a hand-written `Record<HttpMethod, …>` needs a `query` entry.
91
+
92
+ ### Patch Changes
93
+
94
+ - [#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.
95
+
96
+ ## 1.0.0-rc.1
97
+
98
+ ### Patch Changes
99
+
100
+ - [#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
101
+ every undeclared status, successes too. `data` was `never` (upstream [#1862](https://github.com/openapi-typesafe/openapi-typesafe/issues/1862)). `SuccessResponse`
102
+ follows the same rule. With a 2XX response declared, `default` still types only `error`.
103
+
104
+ - [#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
105
+ client's `request`) takes the arguments of every operation; its path was `never` (upstream [#2178](https://github.com/openapi-typesafe/openapi-typesafe/issues/2178)).
106
+ `PathsWithMethod<paths, HttpMethod>` is now every path that has some method; a known method or set
107
+ of methods still gives the paths that have each of them, as before. Code that is generic in the
108
+ paths, such as swr-openapi's hooks, compiles as with openapi-typescript's helpers. The init in those parameters is required when some operation
109
+ requires one (`IsInitOptional`), so a helper passes `{}` for a path that needs none. A single call
110
+ is checked as before, also with a union of paths or methods.
111
+ `ReturnType` of these generic functions stays `any`; the `queryOptions` docs show what to use.
112
+
113
+ ## 1.0.0-rc.0
114
+
115
+ ### Minor Changes
116
+
117
+ - [`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
118
+ `client.QUERY(url, { body })` (also through `request("query", …)` and the path-based client), and
119
+ the react-query hooks accept `"query"`. A `Record<HttpMethod, …>` written by hand needs a `query`
120
+ entry. The path-based client maps only HTTP method keys, so `parameters` no longer shows up as a
121
+ `PARAMETERS()` call that always failed.
122
+
123
+ ### Patch Changes
124
+
125
+ - [`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.
126
+
127
+ - [`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`
128
+ in response data into an object whose methods could not be called, so `data.file.arrayBuffer()`
129
+ did not type check. The helper types that `--read-write-markers` writes into the output change the
130
+ same way. See ADR-014, decision 6.
131
+
132
+ - [`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).
133
+
134
+ ## 0.1.0
135
+
136
+ ### Minor Changes
137
+
138
+ - [#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.
139
+
140
+ ## 0.0.15
141
+
142
+ ### Patch Changes
143
+
144
+ - [#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
145
+
146
+ ## 0.0.14
147
+
148
+ ### Patch Changes
149
+
150
+ - [#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
151
+
152
+ ## 0.0.13
153
+
154
+ ### Patch Changes
155
+
156
+ - [#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
157
+
158
+ ## 0.0.12
159
+
160
+ ### Patch Changes
161
+
162
+ - [#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
163
+
164
+ ## 0.0.11
165
+
166
+ ### Patch Changes
167
+
168
+ - [#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
169
+
170
+ ## 0.0.10
171
+
172
+ ### Patch Changes
173
+
174
+ - [#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
175
+
176
+ ## 0.0.9
177
+
178
+ ### Patch Changes
179
+
180
+ - Improved handling of `SuccessResponse<T>` and `ErrorResponse<T>`
181
+ - Changed handling of `ErrorResponse<T>` to produce one and only one error type (rather than an impossible union)
182
+
183
+ ## 0.0.8
184
+
185
+ ### Patch Changes
186
+
187
+ - [#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
188
+
189
+ - [#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
190
+
191
+ ## 0.0.7
192
+
193
+ ### Patch Changes
194
+
195
+ - [#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
196
+
197
+ ## 0.0.6
198
+
199
+ ### Patch Changes
200
+
201
+ - [#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
202
+
203
+ ## 0.0.5
204
+
205
+ ### Patch Changes
206
+
207
+ - [#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
208
+
209
+ ## 0.0.4
210
+
211
+ ### Patch Changes
212
+
213
+ - [#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
214
+
215
+ ## 0.0.3
216
+
217
+ ### Patch Changes
218
+
219
+ - [#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
220
+
221
+ ## 0.0.2
222
+
223
+ ### Patch Changes
224
+
225
+ - [#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
226
+
227
+ ## 0.0.0
228
+
229
+ 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,176 +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 PathsWithMethod<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
- interface OperationObject {
114
- parameters: any;
115
- requestBody: any;
116
- responses: any;
117
- }
118
- type PathItemObject = {
119
- [M in HttpMethod]: OperationObject;
120
- } & {
121
- parameters?: any;
122
- };
123
- type ResponseObjectMap<T> = T extends {
124
- responses: any;
125
- } ? T["responses"] : unknown;
126
- type ResponseContent<T> = T extends {
127
- content: any;
128
- } ? T["content"] : unknown;
129
- type OperationRequestBody<T> = "requestBody" extends keyof T ? T["requestBody"] : never;
130
- type PickRequestBody<T> = "requestBody" extends keyof T ? Pick<T, "requestBody"> : never;
131
- type IsOperationRequestBodyOptional<T> = RequiredKeysOf<PickRequestBody<T>> extends never ? true : false;
132
- type OperationRequestBodyMediaContent<T> = IsOperationRequestBodyOptional<T> extends true ? ResponseContent<NonNullable<OperationRequestBody<T>>> | undefined : ResponseContent<OperationRequestBody<T>>;
133
- type OperationRequestBodyContent<T> = FilterKeys<OperationRequestBodyMediaContent<T>, MediaType> extends never ? FilterKeys<NonNullable<OperationRequestBodyMediaContent<T>>, MediaType> | undefined : FilterKeys<OperationRequestBodyMediaContent<T>, MediaType>;
134
- type SuccessResponse<T extends Record<string | number, any>, Media extends MediaType = MediaType> = GetResponseContent<T, Media, OkStatus>;
135
- type GetResponseContent<T extends Record<string | number, any>, Media extends MediaType = MediaType, ResponseCode extends keyof T = keyof T> = ResponseCode extends keyof T ? {
136
- [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;
137
- }[ResponseCode] : never;
138
- type ErrorResponse<T extends Record<string | number, any>, Media extends MediaType = MediaType> = GetResponseContent<T, Media, ErrorStatus>;
139
- type SuccessResponseJSON<PathMethod extends Record<string | number, any>> = SuccessResponse<ResponseObjectMap<PathMethod>, `${string}/json`>;
140
- type ErrorResponseJSON<PathMethod extends Record<string | number, any>> = ErrorResponse<ResponseObjectMap<PathMethod>, `${string}/json`>;
141
- type RequestBodyJSON<PathMethod> = JSONLike<FilterKeys<OperationRequestBody<PathMethod>, "content">>;
142
- type FilterKeys<Obj, Matchers> = Obj[keyof Obj & Matchers];
143
- type GetValueWithDefault<Obj, KeyPattern, Default> = Obj extends any ? FilterKeys<Obj, KeyPattern> extends never ? Default : FilterKeys<Obj, KeyPattern> : never;
144
- type MediaType = `${string}/${string}`;
145
- type JSONLike<T> = FilterKeys<T, `${string}/json`>;
146
- type FindRequiredKeys<T, K extends keyof T> = K extends unknown ? undefined extends T[K] ? never : K : K;
147
- type HasRequiredKeys<T> = FindRequiredKeys<T, keyof T>;
148
- type RequiredKeysOfHelper<T> = {
149
- [K in keyof T]: {} extends Pick<T, K> ? never : K;
150
- }[keyof T];
151
- type RequiredKeysOf<T> = RequiredKeysOfHelper<T> extends undefined ? never : RequiredKeysOfHelper<T>;
152
- type $Read<T> = {
153
- readonly $read: T;
154
- };
155
- type $Write<T> = {
156
- readonly $write: T;
157
- };
158
- type ReadWritePrimitive = string | number | boolean | bigint | symbol | null | undefined;
159
- type ReadWriteLeaf = ReadWritePrimitive | ((...args: never) => unknown);
160
- type ReadWriteMarkedKeys<T, Marker> = {
161
- [K in keyof T]-?: NonNullable<T[K]> extends never ? never : NonNullable<T[K]> extends Marker ? K : never;
162
- }[keyof T];
163
- 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>[] : {
164
- [K in keyof T]: ReadWriteResolve<T[K], Resolved>;
165
- };
166
- type ReadWriteResolve<T, Resolved extends "read" | "write"> = Resolved extends "read" ? Readable<T> : Writable<T>;
167
- 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 ? {
168
- [K in keyof T as K extends ReadWriteMarkedKeys<T, $Write<any>> ? never : K]: Readable<T[K]>;
169
- } : T;
170
- 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 ? {
171
- [K in keyof T as K extends ReadWriteMarkedKeys<T, $Read<any>> ? never : K]: Writable<T[K]>;
172
- } & {
173
- [K in ReadWriteMarkedKeys<T, $Read<any>>]?: never;
174
- } : T;
175
-
176
- 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,176 +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 PathsWithMethod<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
- interface OperationObject {
114
- parameters: any;
115
- requestBody: any;
116
- responses: any;
117
- }
118
- type PathItemObject = {
119
- [M in HttpMethod]: OperationObject;
120
- } & {
121
- parameters?: any;
122
- };
123
- type ResponseObjectMap<T> = T extends {
124
- responses: any;
125
- } ? T["responses"] : unknown;
126
- type ResponseContent<T> = T extends {
127
- content: any;
128
- } ? T["content"] : unknown;
129
- type OperationRequestBody<T> = "requestBody" extends keyof T ? T["requestBody"] : never;
130
- type PickRequestBody<T> = "requestBody" extends keyof T ? Pick<T, "requestBody"> : never;
131
- type IsOperationRequestBodyOptional<T> = RequiredKeysOf<PickRequestBody<T>> extends never ? true : false;
132
- type OperationRequestBodyMediaContent<T> = IsOperationRequestBodyOptional<T> extends true ? ResponseContent<NonNullable<OperationRequestBody<T>>> | undefined : ResponseContent<OperationRequestBody<T>>;
133
- type OperationRequestBodyContent<T> = FilterKeys<OperationRequestBodyMediaContent<T>, MediaType> extends never ? FilterKeys<NonNullable<OperationRequestBodyMediaContent<T>>, MediaType> | undefined : FilterKeys<OperationRequestBodyMediaContent<T>, MediaType>;
134
- type SuccessResponse<T extends Record<string | number, any>, Media extends MediaType = MediaType> = GetResponseContent<T, Media, OkStatus>;
135
- type GetResponseContent<T extends Record<string | number, any>, Media extends MediaType = MediaType, ResponseCode extends keyof T = keyof T> = ResponseCode extends keyof T ? {
136
- [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;
137
- }[ResponseCode] : never;
138
- type ErrorResponse<T extends Record<string | number, any>, Media extends MediaType = MediaType> = GetResponseContent<T, Media, ErrorStatus>;
139
- type SuccessResponseJSON<PathMethod extends Record<string | number, any>> = SuccessResponse<ResponseObjectMap<PathMethod>, `${string}/json`>;
140
- type ErrorResponseJSON<PathMethod extends Record<string | number, any>> = ErrorResponse<ResponseObjectMap<PathMethod>, `${string}/json`>;
141
- type RequestBodyJSON<PathMethod> = JSONLike<FilterKeys<OperationRequestBody<PathMethod>, "content">>;
142
- type FilterKeys<Obj, Matchers> = Obj[keyof Obj & Matchers];
143
- type GetValueWithDefault<Obj, KeyPattern, Default> = Obj extends any ? FilterKeys<Obj, KeyPattern> extends never ? Default : FilterKeys<Obj, KeyPattern> : never;
144
- type MediaType = `${string}/${string}`;
145
- type JSONLike<T> = FilterKeys<T, `${string}/json`>;
146
- type FindRequiredKeys<T, K extends keyof T> = K extends unknown ? undefined extends T[K] ? never : K : K;
147
- type HasRequiredKeys<T> = FindRequiredKeys<T, keyof T>;
148
- type RequiredKeysOfHelper<T> = {
149
- [K in keyof T]: {} extends Pick<T, K> ? never : K;
150
- }[keyof T];
151
- type RequiredKeysOf<T> = RequiredKeysOfHelper<T> extends undefined ? never : RequiredKeysOfHelper<T>;
152
- type $Read<T> = {
153
- readonly $read: T;
154
- };
155
- type $Write<T> = {
156
- readonly $write: T;
157
- };
158
- type ReadWritePrimitive = string | number | boolean | bigint | symbol | null | undefined;
159
- type ReadWriteLeaf = ReadWritePrimitive | ((...args: never) => unknown);
160
- type ReadWriteMarkedKeys<T, Marker> = {
161
- [K in keyof T]-?: NonNullable<T[K]> extends never ? never : NonNullable<T[K]> extends Marker ? K : never;
162
- }[keyof T];
163
- 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>[] : {
164
- [K in keyof T]: ReadWriteResolve<T[K], Resolved>;
165
- };
166
- type ReadWriteResolve<T, Resolved extends "read" | "write"> = Resolved extends "read" ? Readable<T> : Writable<T>;
167
- 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 ? {
168
- [K in keyof T as K extends ReadWriteMarkedKeys<T, $Write<any>> ? never : K]: Readable<T[K]>;
169
- } : T;
170
- 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 ? {
171
- [K in keyof T as K extends ReadWriteMarkedKeys<T, $Read<any>> ? never : K]: Writable<T[K]>;
172
- } & {
173
- [K in ReadWriteMarkedKeys<T, $Read<any>>]?: never;
174
- } : T;
175
-
176
- 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,176 +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 PathsWithMethod<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
- interface OperationObject {
114
- parameters: any;
115
- requestBody: any;
116
- responses: any;
117
- }
118
- type PathItemObject = {
119
- [M in HttpMethod]: OperationObject;
120
- } & {
121
- parameters?: any;
122
- };
123
- type ResponseObjectMap<T> = T extends {
124
- responses: any;
125
- } ? T["responses"] : unknown;
126
- type ResponseContent<T> = T extends {
127
- content: any;
128
- } ? T["content"] : unknown;
129
- type OperationRequestBody<T> = "requestBody" extends keyof T ? T["requestBody"] : never;
130
- type PickRequestBody<T> = "requestBody" extends keyof T ? Pick<T, "requestBody"> : never;
131
- type IsOperationRequestBodyOptional<T> = RequiredKeysOf<PickRequestBody<T>> extends never ? true : false;
132
- type OperationRequestBodyMediaContent<T> = IsOperationRequestBodyOptional<T> extends true ? ResponseContent<NonNullable<OperationRequestBody<T>>> | undefined : ResponseContent<OperationRequestBody<T>>;
133
- type OperationRequestBodyContent<T> = FilterKeys<OperationRequestBodyMediaContent<T>, MediaType> extends never ? FilterKeys<NonNullable<OperationRequestBodyMediaContent<T>>, MediaType> | undefined : FilterKeys<OperationRequestBodyMediaContent<T>, MediaType>;
134
- type SuccessResponse<T extends Record<string | number, any>, Media extends MediaType = MediaType> = GetResponseContent<T, Media, OkStatus>;
135
- type GetResponseContent<T extends Record<string | number, any>, Media extends MediaType = MediaType, ResponseCode extends keyof T = keyof T> = ResponseCode extends keyof T ? {
136
- [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;
137
- }[ResponseCode] : never;
138
- type ErrorResponse<T extends Record<string | number, any>, Media extends MediaType = MediaType> = GetResponseContent<T, Media, ErrorStatus>;
139
- type SuccessResponseJSON<PathMethod extends Record<string | number, any>> = SuccessResponse<ResponseObjectMap<PathMethod>, `${string}/json`>;
140
- type ErrorResponseJSON<PathMethod extends Record<string | number, any>> = ErrorResponse<ResponseObjectMap<PathMethod>, `${string}/json`>;
141
- type RequestBodyJSON<PathMethod> = JSONLike<FilterKeys<OperationRequestBody<PathMethod>, "content">>;
142
- type FilterKeys<Obj, Matchers> = Obj[keyof Obj & Matchers];
143
- type GetValueWithDefault<Obj, KeyPattern, Default> = Obj extends any ? FilterKeys<Obj, KeyPattern> extends never ? Default : FilterKeys<Obj, KeyPattern> : never;
144
- type MediaType = `${string}/${string}`;
145
- type JSONLike<T> = FilterKeys<T, `${string}/json`>;
146
- type FindRequiredKeys<T, K extends keyof T> = K extends unknown ? undefined extends T[K] ? never : K : K;
147
- type HasRequiredKeys<T> = FindRequiredKeys<T, keyof T>;
148
- type RequiredKeysOfHelper<T> = {
149
- [K in keyof T]: {} extends Pick<T, K> ? never : K;
150
- }[keyof T];
151
- type RequiredKeysOf<T> = RequiredKeysOfHelper<T> extends undefined ? never : RequiredKeysOfHelper<T>;
152
- type $Read<T> = {
153
- readonly $read: T;
154
- };
155
- type $Write<T> = {
156
- readonly $write: T;
157
- };
158
- type ReadWritePrimitive = string | number | boolean | bigint | symbol | null | undefined;
159
- type ReadWriteLeaf = ReadWritePrimitive | ((...args: never) => unknown);
160
- type ReadWriteMarkedKeys<T, Marker> = {
161
- [K in keyof T]-?: NonNullable<T[K]> extends never ? never : NonNullable<T[K]> extends Marker ? K : never;
162
- }[keyof T];
163
- 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>[] : {
164
- [K in keyof T]: ReadWriteResolve<T[K], Resolved>;
165
- };
166
- type ReadWriteResolve<T, Resolved extends "read" | "write"> = Resolved extends "read" ? Readable<T> : Writable<T>;
167
- 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 ? {
168
- [K in keyof T as K extends ReadWriteMarkedKeys<T, $Write<any>> ? never : K]: Readable<T[K]>;
169
- } : T;
170
- 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 ? {
171
- [K in keyof T as K extends ReadWriteMarkedKeys<T, $Read<any>> ? never : K]: Writable<T[K]>;
172
- } & {
173
- [K in ReadWriteMarkedKeys<T, $Read<any>>]?: never;
174
- } : T;
175
-
176
- 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.0",
4
+ "version": "1.0.0-rc.10",
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.10"
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
  }