@kubb/plugin-fetch 5.5.8 → 5.5.9
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/OVERVIEW.md +19 -0
- package/dist/index.cjs +8 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/kubb-extension.json +191 -0
- package/package.json +8 -5
- package/src/plugin.ts +2 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://kubb.dev/schemas/kubb-extension.json",
|
|
3
|
+
"kind": "plugin",
|
|
4
|
+
"name": "plugin-fetch",
|
|
5
|
+
"export": "pluginFetch",
|
|
6
|
+
"displayName": "Fetch",
|
|
7
|
+
"description": "Generates a type-safe Fetch API client from your OpenAPI spec, one async function per operation, so each call stays in sync with the API.",
|
|
8
|
+
"category": "client",
|
|
9
|
+
"icon": {
|
|
10
|
+
"light": "https://kubb.dev/feature/javascript.svg"
|
|
11
|
+
},
|
|
12
|
+
"tags": ["api-client", "fetch", "http-client", "codegen", "openapi", "validator"],
|
|
13
|
+
"docs": "https://kubb.dev/plugins/plugin-fetch",
|
|
14
|
+
"compatibility": {
|
|
15
|
+
"kubb": ">=5.8.0",
|
|
16
|
+
"node": ">=22"
|
|
17
|
+
},
|
|
18
|
+
"role": "client",
|
|
19
|
+
"options": [
|
|
20
|
+
{
|
|
21
|
+
"key": "outputPath",
|
|
22
|
+
"path": ["output", "path"],
|
|
23
|
+
"label": "Output Path",
|
|
24
|
+
"description": "Output folder for generated files",
|
|
25
|
+
"type": "text",
|
|
26
|
+
"default": "clients"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"key": "barrel",
|
|
30
|
+
"path": ["output", "barrel"],
|
|
31
|
+
"label": "Barrel",
|
|
32
|
+
"description": "How index.ts barrel files are generated",
|
|
33
|
+
"type": "select",
|
|
34
|
+
"default": {
|
|
35
|
+
"type": "named"
|
|
36
|
+
},
|
|
37
|
+
"choices": [
|
|
38
|
+
{
|
|
39
|
+
"label": "named",
|
|
40
|
+
"value": {
|
|
41
|
+
"type": "named"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"label": "named (nested)",
|
|
46
|
+
"value": {
|
|
47
|
+
"type": "named",
|
|
48
|
+
"nested": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"label": "all",
|
|
53
|
+
"value": {
|
|
54
|
+
"type": "all"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"label": "all (nested)",
|
|
59
|
+
"value": {
|
|
60
|
+
"type": "all",
|
|
61
|
+
"nested": true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"label": "false (disabled)",
|
|
66
|
+
"value": false
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"key": "outputMode",
|
|
72
|
+
"path": ["output", "mode"],
|
|
73
|
+
"label": "Output Mode",
|
|
74
|
+
"description": "How the plugin consolidates its code into files. File mode writes everything into a single file, so the output path must include a file extension and cannot be grouped.",
|
|
75
|
+
"type": "select",
|
|
76
|
+
"default": "directory",
|
|
77
|
+
"choices": [
|
|
78
|
+
{
|
|
79
|
+
"label": "directory (one file per schema)",
|
|
80
|
+
"value": "directory"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"label": "file (single file)",
|
|
84
|
+
"value": "file"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"key": "validator",
|
|
90
|
+
"path": ["validator"],
|
|
91
|
+
"label": "Validator",
|
|
92
|
+
"description": "Validate request and response bodies with schemas from @kubb/plugin-zod",
|
|
93
|
+
"type": "select",
|
|
94
|
+
"default": false,
|
|
95
|
+
"choices": [
|
|
96
|
+
{
|
|
97
|
+
"label": "false (disabled)",
|
|
98
|
+
"value": false
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"label": "zod",
|
|
102
|
+
"value": "zod"
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"key": "group",
|
|
108
|
+
"path": ["group"],
|
|
109
|
+
"label": "Group",
|
|
110
|
+
"description": "Group generated operations by OpenAPI tag or path",
|
|
111
|
+
"type": "select",
|
|
112
|
+
"default": null,
|
|
113
|
+
"choices": [
|
|
114
|
+
{
|
|
115
|
+
"label": "none",
|
|
116
|
+
"value": null
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"label": "by tag",
|
|
120
|
+
"value": {
|
|
121
|
+
"type": "tag"
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"label": "by path",
|
|
126
|
+
"value": {
|
|
127
|
+
"type": "path"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"key": "excludeTags",
|
|
134
|
+
"path": ["exclude"],
|
|
135
|
+
"label": "Exclude Tags",
|
|
136
|
+
"description": "Comma-separated OpenAPI tags to exclude from generation",
|
|
137
|
+
"type": "list",
|
|
138
|
+
"item": {
|
|
139
|
+
"type": "tag",
|
|
140
|
+
"pattern": "$item"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"key": "includeTags",
|
|
145
|
+
"path": ["include"],
|
|
146
|
+
"label": "Include Tags",
|
|
147
|
+
"description": "Comma-separated OpenAPI tags to include. Only operations with these tags are generated",
|
|
148
|
+
"type": "list",
|
|
149
|
+
"item": {
|
|
150
|
+
"type": "tag",
|
|
151
|
+
"pattern": "$item"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"key": "baseURL",
|
|
156
|
+
"path": ["baseURL"],
|
|
157
|
+
"label": "Base URL",
|
|
158
|
+
"description": "Custom API base URL",
|
|
159
|
+
"type": "text"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"key": "sdkMode",
|
|
163
|
+
"path": ["sdk", "mode"],
|
|
164
|
+
"label": "SDK Mode",
|
|
165
|
+
"description": "Group generated operations into an SDK client by tag or flat",
|
|
166
|
+
"type": "select",
|
|
167
|
+
"default": null,
|
|
168
|
+
"choices": [
|
|
169
|
+
{
|
|
170
|
+
"label": "off (standalone functions)",
|
|
171
|
+
"value": null
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"label": "tag",
|
|
175
|
+
"value": "tag"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"label": "flat",
|
|
179
|
+
"value": "flat"
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"key": "sdkName",
|
|
185
|
+
"path": ["sdk", "name"],
|
|
186
|
+
"label": "SDK Name",
|
|
187
|
+
"description": "Root client name for the generated SDK",
|
|
188
|
+
"type": "text"
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-fetch",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.9",
|
|
4
4
|
"description": "Generate a slim, type-safe HTTP client with Kubb based on the native Fetch api.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api-client",
|
|
@@ -39,6 +39,8 @@
|
|
|
39
39
|
"src",
|
|
40
40
|
"dist",
|
|
41
41
|
"templates",
|
|
42
|
+
"kubb-extension.json",
|
|
43
|
+
"OVERVIEW.md",
|
|
42
44
|
"!/**/**.test.**",
|
|
43
45
|
"!/**/__tests__/**",
|
|
44
46
|
"!/**/__snapshots__/**"
|
|
@@ -58,6 +60,7 @@
|
|
|
58
60
|
"require": "./dist/index.cjs"
|
|
59
61
|
},
|
|
60
62
|
"./package.json": "./package.json",
|
|
63
|
+
"./kubb-extension.json": "./kubb-extension.json",
|
|
61
64
|
"./templates/*": "./templates/*"
|
|
62
65
|
},
|
|
63
66
|
"publishConfig": {
|
|
@@ -65,17 +68,17 @@
|
|
|
65
68
|
"registry": "https://registry.npmjs.org/"
|
|
66
69
|
},
|
|
67
70
|
"dependencies": {
|
|
68
|
-
"@kubb/plugin-ts": "^5.0.
|
|
69
|
-
"@kubb/plugin-zod": "^5.4.
|
|
71
|
+
"@kubb/plugin-ts": "^5.0.8",
|
|
72
|
+
"@kubb/plugin-zod": "^5.4.6"
|
|
70
73
|
},
|
|
71
74
|
"devDependencies": {
|
|
72
75
|
"@internals/client": "0.0.0",
|
|
73
76
|
"@internals/shared": "0.0.0",
|
|
74
|
-
"kubb": "^5.8.
|
|
77
|
+
"kubb": "^5.8.1",
|
|
75
78
|
"typescript": "^6.0.3"
|
|
76
79
|
},
|
|
77
80
|
"peerDependencies": {
|
|
78
|
-
"kubb": "^5.8.
|
|
81
|
+
"kubb": "^5.8.1"
|
|
79
82
|
},
|
|
80
83
|
"engines": {
|
|
81
84
|
"node": ">=22"
|
package/src/plugin.ts
CHANGED
|
@@ -2,6 +2,7 @@ import path from 'node:path'
|
|
|
2
2
|
import { createSdkGenerator, defaultMacros, resolverClient } from '@internals/client'
|
|
3
3
|
import { createGroupConfig } from '@internals/shared'
|
|
4
4
|
import { addGenerator, definePlugin, injectFile, Resolver, setMacros, setResolver, useConfig } from 'kubb/kit'
|
|
5
|
+
import { compatibility } from '../kubb-extension.json'
|
|
5
6
|
import { version } from '../package.json'
|
|
6
7
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
7
8
|
import { pluginZodName } from '@kubb/plugin-zod'
|
|
@@ -38,7 +39,7 @@ export const pluginFetchName = 'plugin-fetch' satisfies PluginFetch['name']
|
|
|
38
39
|
* ```
|
|
39
40
|
*/
|
|
40
41
|
export const pluginFetch = definePlugin<PluginFetch>({
|
|
41
|
-
meta: { name: pluginFetchName, version, compatibility
|
|
42
|
+
meta: { name: pluginFetchName, version, compatibility },
|
|
42
43
|
// Both are ordering hints, skipped when the plugin is not in the pipeline. `plugin-ts` supplies
|
|
43
44
|
// the operation types unless it is absent, in which case `pluginZod({ inferred: true })` does.
|
|
44
45
|
dependencies: { [pluginTsName]: { optional: true }, [pluginZodName]: { optional: true } },
|