@tracken/cli 0.0.0-stage → 0.2.1
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 +404 -0
- package/LICENSE +21 -0
- package/README.md +310 -2
- package/dist/bin/tracken.d.ts +2 -0
- package/dist/bin/tracken.js +5 -0
- package/dist/cli/args.d.ts +17 -0
- package/dist/cli/args.js +114 -0
- package/dist/cli/commands/api.d.ts +2 -0
- package/dist/cli/commands/api.js +73 -0
- package/dist/cli/commands/auth.d.ts +8 -0
- package/dist/cli/commands/auth.js +141 -0
- package/dist/cli/commands/mcp.d.ts +19 -0
- package/dist/cli/commands/mcp.js +89 -0
- package/dist/cli/commands/org.d.ts +24 -0
- package/dist/cli/commands/org.js +123 -0
- package/dist/cli/context.d.ts +54 -0
- package/dist/cli/context.js +135 -0
- package/dist/cli/execute.d.ts +16 -0
- package/dist/cli/execute.js +112 -0
- package/dist/cli/help.d.ts +8 -0
- package/dist/cli/help.js +153 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +114 -0
- package/dist/cli/operation-args.d.ts +25 -0
- package/dist/cli/operation-args.js +245 -0
- package/dist/core/auth/oauth.d.ts +39 -0
- package/dist/core/auth/oauth.js +102 -0
- package/dist/core/auth/scopes.d.ts +19 -0
- package/dist/core/auth/scopes.js +49 -0
- package/dist/core/auth/secret-store.d.ts +60 -0
- package/dist/core/auth/secret-store.js +141 -0
- package/dist/core/auth/session.d.ts +75 -0
- package/dist/core/auth/session.js +200 -0
- package/dist/core/catalog.d.ts +12 -0
- package/dist/core/catalog.js +33 -0
- package/dist/core/client.d.ts +22 -0
- package/dist/core/client.js +45 -0
- package/dist/core/config.d.ts +27 -0
- package/dist/core/config.js +109 -0
- package/dist/core/environments.d.ts +21 -0
- package/dist/core/environments.js +53 -0
- package/dist/core/errors.d.ts +96 -0
- package/dist/core/errors.js +248 -0
- package/dist/core/index.d.ts +21 -0
- package/dist/core/index.js +22 -0
- package/dist/core/jobs.d.ts +15 -0
- package/dist/core/jobs.js +19 -0
- package/dist/core/operations.d.ts +108 -0
- package/dist/core/operations.js +7 -0
- package/dist/core/output/format.d.ts +19 -0
- package/dist/core/output/format.js +62 -0
- package/dist/core/output/render.d.ts +53 -0
- package/dist/core/output/render.js +229 -0
- package/dist/core/pagination.d.ts +2 -0
- package/dist/core/pagination.js +3 -0
- package/dist/core/request.d.ts +29 -0
- package/dist/core/request.js +109 -0
- package/dist/core/version.d.ts +10 -0
- package/dist/core/version.js +13 -0
- package/dist/generated/mcp-tools.d.ts +2 -0
- package/dist/generated/mcp-tools.js +5937 -0
- package/dist/generated/operations.d.ts +4 -0
- package/dist/generated/operations.js +17701 -0
- package/dist/mcp/errors.d.ts +34 -0
- package/dist/mcp/errors.js +100 -0
- package/dist/mcp/live.d.ts +3 -0
- package/dist/mcp/live.js +5 -0
- package/dist/mcp/prompts.d.ts +23 -0
- package/dist/mcp/prompts.js +101 -0
- package/dist/mcp/resources.d.ts +25 -0
- package/dist/mcp/resources.js +125 -0
- package/dist/mcp/server.d.ts +20 -0
- package/dist/mcp/server.js +59 -0
- package/dist/mcp/session.d.ts +60 -0
- package/dist/mcp/session.js +105 -0
- package/dist/mcp/tools.d.ts +17 -0
- package/dist/mcp/tools.js +181 -0
- package/dist/mcp/types.d.ts +25 -0
- package/dist/mcp/types.js +2 -0
- package/node_modules/@tracken/sdk/LICENSE +21 -0
- package/node_modules/@tracken/sdk/README.md +76 -0
- package/node_modules/@tracken/sdk/SOURCE.json +10 -0
- package/node_modules/@tracken/sdk/dist/client.d.ts +94 -0
- package/node_modules/@tracken/sdk/dist/client.js +258 -0
- package/node_modules/@tracken/sdk/dist/credentials.d.ts +60 -0
- package/node_modules/@tracken/sdk/dist/credentials.js +122 -0
- package/node_modules/@tracken/sdk/dist/decimal.d.ts +20 -0
- package/node_modules/@tracken/sdk/dist/decimal.js +67 -0
- package/node_modules/@tracken/sdk/dist/environments.d.ts +14 -0
- package/node_modules/@tracken/sdk/dist/environments.js +16 -0
- package/node_modules/@tracken/sdk/dist/errors.d.ts +150 -0
- package/node_modules/@tracken/sdk/dist/errors.js +190 -0
- package/node_modules/@tracken/sdk/dist/generated/operations.d.ts +1955 -0
- package/node_modules/@tracken/sdk/dist/generated/operations.js +2746 -0
- package/node_modules/@tracken/sdk/dist/generated/schema.d.ts +17988 -0
- package/node_modules/@tracken/sdk/dist/generated/schema.js +5 -0
- package/node_modules/@tracken/sdk/dist/index.d.ts +27 -0
- package/node_modules/@tracken/sdk/dist/index.js +24 -0
- package/node_modules/@tracken/sdk/dist/jobs.d.ts +23 -0
- package/node_modules/@tracken/sdk/dist/jobs.js +80 -0
- package/node_modules/@tracken/sdk/dist/operations.d.ts +23 -0
- package/node_modules/@tracken/sdk/dist/operations.js +2 -0
- package/node_modules/@tracken/sdk/dist/pagination.d.ts +19 -0
- package/node_modules/@tracken/sdk/dist/pagination.js +49 -0
- package/node_modules/@tracken/sdk/dist/request.d.ts +27 -0
- package/node_modules/@tracken/sdk/dist/request.js +10 -0
- package/node_modules/@tracken/sdk/dist/runtime.d.ts +22 -0
- package/node_modules/@tracken/sdk/dist/runtime.js +33 -0
- package/node_modules/@tracken/sdk/dist/tracken.d.ts +74 -0
- package/node_modules/@tracken/sdk/dist/tracken.js +203 -0
- package/node_modules/@tracken/sdk/dist/types.d.ts +130 -0
- package/node_modules/@tracken/sdk/dist/types.js +1 -0
- package/node_modules/@tracken/sdk/dist/version.d.ts +2 -0
- package/node_modules/@tracken/sdk/dist/version.js +2 -0
- package/node_modules/@tracken/sdk/package.json +42 -0
- package/node_modules/openapi-fetch/CHANGELOG.md +565 -0
- package/node_modules/openapi-fetch/CONTRIBUTING.md +102 -0
- package/node_modules/openapi-fetch/LICENSE +21 -0
- package/node_modules/openapi-fetch/README.md +122 -0
- package/node_modules/openapi-fetch/dist/index.cjs +547 -0
- package/node_modules/openapi-fetch/dist/index.cjs.map +1 -0
- package/node_modules/openapi-fetch/dist/index.d.cts +337 -0
- package/node_modules/openapi-fetch/dist/index.d.mts +335 -0
- package/node_modules/openapi-fetch/dist/index.d.ts +337 -0
- package/node_modules/openapi-fetch/dist/index.mjs +531 -0
- package/node_modules/openapi-fetch/dist/index.mjs.map +1 -0
- package/node_modules/openapi-fetch/package.json +77 -0
- package/node_modules/openapi-fetch/src/index.d.ts +345 -0
- package/node_modules/openapi-fetch/src/index.js +689 -0
- package/node_modules/openapi-typescript-helpers/CHANGELOG.md +98 -0
- package/node_modules/openapi-typescript-helpers/LICENSE +21 -0
- package/node_modules/openapi-typescript-helpers/README.md +5 -0
- package/node_modules/openapi-typescript-helpers/dist/index.cjs +3 -0
- package/node_modules/openapi-typescript-helpers/dist/index.cjs.map +1 -0
- package/node_modules/openapi-typescript-helpers/dist/index.d.cts +167 -0
- package/node_modules/openapi-typescript-helpers/dist/index.d.mts +167 -0
- package/node_modules/openapi-typescript-helpers/dist/index.d.ts +167 -0
- package/node_modules/openapi-typescript-helpers/dist/index.mjs +2 -0
- package/node_modules/openapi-typescript-helpers/dist/index.mjs.map +1 -0
- package/node_modules/openapi-typescript-helpers/package.json +39 -0
- package/openapi/SOURCE.json +10 -0
- package/openapi/openapi.yaml +30514 -0
- package/package.json +63 -4
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# openapi-typescript-helpers
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#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.
|
|
8
|
+
|
|
9
|
+
## 0.0.15
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
14
|
+
|
|
15
|
+
## 0.0.14
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#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
|
|
20
|
+
|
|
21
|
+
## 0.0.13
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#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
|
|
26
|
+
|
|
27
|
+
## 0.0.12
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- [#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
|
|
32
|
+
|
|
33
|
+
## 0.0.11
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- [#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
|
|
38
|
+
|
|
39
|
+
## 0.0.10
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- [#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
|
|
44
|
+
|
|
45
|
+
## 0.0.9
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Improved handling of `SuccessResponse<T>` and `ErrorResponse<T>`
|
|
50
|
+
- Changed handling of `ErrorResponse<T>` to produce one and only one error type (rather than an impossible union)
|
|
51
|
+
|
|
52
|
+
## 0.0.8
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- [#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
|
|
57
|
+
|
|
58
|
+
- [#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
|
|
59
|
+
|
|
60
|
+
## 0.0.7
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- [#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
|
|
65
|
+
|
|
66
|
+
## 0.0.6
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- [#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
|
|
71
|
+
|
|
72
|
+
## 0.0.5
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- [#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
|
|
77
|
+
|
|
78
|
+
## 0.0.4
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- [#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
|
|
83
|
+
|
|
84
|
+
## 0.0.3
|
|
85
|
+
|
|
86
|
+
### Patch Changes
|
|
87
|
+
|
|
88
|
+
- [#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
|
|
89
|
+
|
|
90
|
+
## 0.0.2
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- [#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
|
|
95
|
+
|
|
96
|
+
## 0.0.0
|
|
97
|
+
|
|
98
|
+
Initial release
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Drew Powers
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
type HttpMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
|
|
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 Readable<T> = T extends $Write<any> ? never : T extends $Read<infer U> ? Readable<U> : T extends (infer E)[] ? Readable<E>[] : T extends object ? {
|
|
159
|
+
[K in keyof T as NonNullable<T[K]> extends $Write<any> ? never : K]: Readable<T[K]>;
|
|
160
|
+
} : T;
|
|
161
|
+
type Writable<T> = T extends $Read<any> ? never : T extends $Write<infer U> ? Writable<U> : T extends (infer E)[] ? Writable<E>[] : T extends object ? {
|
|
162
|
+
[K in keyof T as NonNullable<T[K]> extends $Read<any> ? never : K]: Writable<T[K]>;
|
|
163
|
+
} & {
|
|
164
|
+
[K in keyof T as NonNullable<T[K]> extends $Read<any> ? K : never]?: never;
|
|
165
|
+
} : T;
|
|
166
|
+
|
|
167
|
+
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 };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
type HttpMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
|
|
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 Readable<T> = T extends $Write<any> ? never : T extends $Read<infer U> ? Readable<U> : T extends (infer E)[] ? Readable<E>[] : T extends object ? {
|
|
159
|
+
[K in keyof T as NonNullable<T[K]> extends $Write<any> ? never : K]: Readable<T[K]>;
|
|
160
|
+
} : T;
|
|
161
|
+
type Writable<T> = T extends $Read<any> ? never : T extends $Write<infer U> ? Writable<U> : T extends (infer E)[] ? Writable<E>[] : T extends object ? {
|
|
162
|
+
[K in keyof T as NonNullable<T[K]> extends $Read<any> ? never : K]: Writable<T[K]>;
|
|
163
|
+
} & {
|
|
164
|
+
[K in keyof T as NonNullable<T[K]> extends $Read<any> ? K : never]?: never;
|
|
165
|
+
} : T;
|
|
166
|
+
|
|
167
|
+
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 };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
type HttpMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
|
|
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 Readable<T> = T extends $Write<any> ? never : T extends $Read<infer U> ? Readable<U> : T extends (infer E)[] ? Readable<E>[] : T extends object ? {
|
|
159
|
+
[K in keyof T as NonNullable<T[K]> extends $Write<any> ? never : K]: Readable<T[K]>;
|
|
160
|
+
} : T;
|
|
161
|
+
type Writable<T> = T extends $Read<any> ? never : T extends $Write<infer U> ? Writable<U> : T extends (infer E)[] ? Writable<E>[] : T extends object ? {
|
|
162
|
+
[K in keyof T as NonNullable<T[K]> extends $Read<any> ? never : K]: Writable<T[K]>;
|
|
163
|
+
} & {
|
|
164
|
+
[K in keyof T as NonNullable<T[K]> extends $Read<any> ? K : never]?: never;
|
|
165
|
+
} : T;
|
|
166
|
+
|
|
167
|
+
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|