@kubb/plugin-swr 5.0.0-beta.42 → 5.0.0-beta.56
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/dist/{components-CD7ZoS3B.cjs → components-C8FJ3-Cb.cjs} +175 -196
- package/dist/components-C8FJ3-Cb.cjs.map +1 -0
- package/dist/{components-BuLagnaM.js → components-CR9NLFcO.js} +176 -197
- package/dist/components-CR9NLFcO.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-CSinCSzM.js → generators-BB6csINY.js} +67 -91
- package/dist/generators-BB6csINY.js.map +1 -0
- package/dist/{generators-D_Cz5DDw.cjs → generators-mw3FvFJD.cjs} +66 -90
- package/dist/generators-mw3FvFJD.cjs.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +6 -1
- package/dist/generators.js +1 -1
- package/dist/index.cjs +62 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +63 -13
- package/dist/index.js.map +1 -1
- package/dist/{types-BoANASs2.d.ts → types-Dz_j0Bqv.d.ts} +11 -14
- package/package.json +9 -17
- package/src/components/Mutation.tsx +3 -3
- package/src/components/Query.tsx +3 -3
- package/src/components/QueryOptions.tsx +3 -21
- package/src/generators/mutationGenerator.tsx +11 -7
- package/src/generators/queryGenerator.tsx +3 -7
- package/src/plugin.ts +6 -18
- package/src/resolvers/resolverSwr.ts +2 -2
- package/src/types.ts +9 -12
- package/src/utils.ts +8 -1
- package/dist/components-BuLagnaM.js.map +0 -1
- package/dist/components-CD7ZoS3B.cjs.map +0 -1
- package/dist/generators-CSinCSzM.js.map +0 -1
- package/dist/generators-D_Cz5DDw.cjs.map +0 -1
- package/extension.yaml +0 -199
package/extension.yaml
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
$schema: https://kubb.dev/schemas/extension.json
|
|
2
|
-
kind: plugin
|
|
3
|
-
id: plugin-swr
|
|
4
|
-
name: SWR
|
|
5
|
-
description: Generate SWR hooks (useSWR, useSWRMutation) from OpenAPI specifications.
|
|
6
|
-
category: framework
|
|
7
|
-
type: official
|
|
8
|
-
npmPackage: '@kubb/plugin-swr'
|
|
9
|
-
docsPath: /plugins/plugin-swr
|
|
10
|
-
repo: https://github.com/kubb-labs/plugins
|
|
11
|
-
maintainers:
|
|
12
|
-
- name: Stijn Van Hulle
|
|
13
|
-
github: stijnvanhulle
|
|
14
|
-
compatibility:
|
|
15
|
-
kubb: '>=5.0.0'
|
|
16
|
-
node: '>=22'
|
|
17
|
-
tags:
|
|
18
|
-
- swr
|
|
19
|
-
- react
|
|
20
|
-
- hooks
|
|
21
|
-
- data-fetching
|
|
22
|
-
- codegen
|
|
23
|
-
- openapi
|
|
24
|
-
dependencies:
|
|
25
|
-
- plugin-ts
|
|
26
|
-
- plugin-client
|
|
27
|
-
resources:
|
|
28
|
-
documentation: https://kubb.dev/plugins/plugin-swr
|
|
29
|
-
repository: https://github.com/kubb-labs/plugins
|
|
30
|
-
issues: https://github.com/kubb-labs/plugins/issues
|
|
31
|
-
changelog: https://github.com/kubb-labs/plugins/blob/main/packages/plugin-swr/CHANGELOG.md
|
|
32
|
-
codesandbox: https://codesandbox.io/p/github/kubb-labs/plugins/main/examples/swr
|
|
33
|
-
featured: true
|
|
34
|
-
intro: |
|
|
35
|
-
# @kubb/plugin-swr
|
|
36
|
-
|
|
37
|
-
Generate type-safe SWR hooks from your OpenAPI schema for data fetching, caching, and mutations.
|
|
38
|
-
options:
|
|
39
|
-
- name: output
|
|
40
|
-
type: Output
|
|
41
|
-
required: false
|
|
42
|
-
default: "{ path: 'hooks', barrel: { type: 'named' } }"
|
|
43
|
-
description: Specify the export location for the files and define the behavior of the output.
|
|
44
|
-
- name: group
|
|
45
|
-
type: Group
|
|
46
|
-
required: false
|
|
47
|
-
description: Grouping combines files in a folder based on a specific `type`.
|
|
48
|
-
- name: client
|
|
49
|
-
type: ClientImportPath & { clientType?, dataReturnType?, baseURL?, bundle?, paramsCasing? }
|
|
50
|
-
required: false
|
|
51
|
-
description: Client configuration for HTTP request generation.
|
|
52
|
-
- name: paramsType
|
|
53
|
-
type: "'object' | 'inline'"
|
|
54
|
-
required: false
|
|
55
|
-
default: "'inline'"
|
|
56
|
-
description: Defines how parameters are passed to generated functions.
|
|
57
|
-
- name: paramsCasing
|
|
58
|
-
type: "'camelcase'"
|
|
59
|
-
required: false
|
|
60
|
-
description: Transform parameter names to a specific casing format.
|
|
61
|
-
- name: pathParamsType
|
|
62
|
-
type: "'object' | 'inline'"
|
|
63
|
-
required: false
|
|
64
|
-
default: "'inline'"
|
|
65
|
-
description: Defines how pathParams are passed to generated functions.
|
|
66
|
-
- name: parser
|
|
67
|
-
type: "false | 'zod'"
|
|
68
|
-
required: false
|
|
69
|
-
default: 'false'
|
|
70
|
-
description: |
|
|
71
|
-
Runtime validator applied to the response body before it is returned.
|
|
72
|
-
|
|
73
|
-
- `false` (default) — no validation; the response is cast to the generated type.
|
|
74
|
-
- `'zod'` — pipes the response through the Zod schema from `@kubb/plugin-zod`.
|
|
75
|
-
- name: query
|
|
76
|
-
type: Query
|
|
77
|
-
required: false
|
|
78
|
-
description: |
|
|
79
|
-
Override some `useSWR` behaviors. Pass `false` to disable query hook generation.
|
|
80
|
-
codeBlock:
|
|
81
|
-
lang: typescript
|
|
82
|
-
title: Query
|
|
83
|
-
code: |
|
|
84
|
-
type Query = {
|
|
85
|
-
methods: Array<HttpMethod>
|
|
86
|
-
importPath?: string
|
|
87
|
-
} | false
|
|
88
|
-
properties:
|
|
89
|
-
- name: methods
|
|
90
|
-
type: Array<HttpMethod>
|
|
91
|
-
required: false
|
|
92
|
-
default: "['get']"
|
|
93
|
-
description: Define which HttpMethods can be used for queries.
|
|
94
|
-
- name: importPath
|
|
95
|
-
type: string
|
|
96
|
-
required: false
|
|
97
|
-
default: "'swr'"
|
|
98
|
-
description: Path to the `useSWR` import.
|
|
99
|
-
- name: queryKey
|
|
100
|
-
type: '(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]'
|
|
101
|
-
required: false
|
|
102
|
-
description: Customize the queryKey that will be used for the query.
|
|
103
|
-
- name: mutation
|
|
104
|
-
type: Mutation
|
|
105
|
-
required: false
|
|
106
|
-
description: |
|
|
107
|
-
Override some `useSWRMutation` behaviors. Pass `false` to disable mutation hook generation.
|
|
108
|
-
codeBlock:
|
|
109
|
-
lang: typescript
|
|
110
|
-
title: Mutation
|
|
111
|
-
code: |
|
|
112
|
-
type Mutation = {
|
|
113
|
-
methods: Array<HttpMethod>
|
|
114
|
-
importPath?: string
|
|
115
|
-
} | false
|
|
116
|
-
properties:
|
|
117
|
-
- name: methods
|
|
118
|
-
type: Array<HttpMethod>
|
|
119
|
-
required: false
|
|
120
|
-
default: "['post', 'put', 'patch', 'delete']"
|
|
121
|
-
description: Define which HttpMethods can be used for mutations.
|
|
122
|
-
- name: importPath
|
|
123
|
-
type: string
|
|
124
|
-
required: false
|
|
125
|
-
default: "'swr/mutation'"
|
|
126
|
-
description: Path to the `useSWRMutation` import.
|
|
127
|
-
- name: mutationKey
|
|
128
|
-
type: '(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]'
|
|
129
|
-
required: false
|
|
130
|
-
description: Customize the mutationKey.
|
|
131
|
-
- name: include
|
|
132
|
-
type: Array<Include>
|
|
133
|
-
required: false
|
|
134
|
-
description: Array containing include parameters.
|
|
135
|
-
- name: exclude
|
|
136
|
-
type: Array<Exclude>
|
|
137
|
-
required: false
|
|
138
|
-
description: Array containing exclude parameters.
|
|
139
|
-
- name: override
|
|
140
|
-
type: Array<Override>
|
|
141
|
-
required: false
|
|
142
|
-
description: Array containing override parameters.
|
|
143
|
-
- name: generators
|
|
144
|
-
type: Array<Generator<PluginSwr>>
|
|
145
|
-
required: false
|
|
146
|
-
experimental: true
|
|
147
|
-
description: Define additional generators next to the built-in generators.
|
|
148
|
-
- name: resolver
|
|
149
|
-
type: Partial<ResolverSwr> & ThisType<ResolverSwr>
|
|
150
|
-
required: false
|
|
151
|
-
description: Override naming conventions for function names and types.
|
|
152
|
-
- name: transformer
|
|
153
|
-
type: Visitor
|
|
154
|
-
required: false
|
|
155
|
-
description: AST visitor to transform generated nodes.
|
|
156
|
-
notes:
|
|
157
|
-
- type: tip
|
|
158
|
-
body: |
|
|
159
|
-
See [SWR](https://swr.vercel.app) for more information about SWR.
|
|
160
|
-
examples:
|
|
161
|
-
- name: kubb.config.ts
|
|
162
|
-
files:
|
|
163
|
-
- lang: typescript
|
|
164
|
-
code: |
|
|
165
|
-
import { defineConfig } from 'kubb'
|
|
166
|
-
import { pluginTs } from '@kubb/plugin-ts'
|
|
167
|
-
import { pluginSwr } from '@kubb/plugin-swr'
|
|
168
|
-
|
|
169
|
-
export default defineConfig({
|
|
170
|
-
input: {
|
|
171
|
-
path: './petStore.yaml',
|
|
172
|
-
},
|
|
173
|
-
output: {
|
|
174
|
-
path: './src/gen',
|
|
175
|
-
},
|
|
176
|
-
plugins: [
|
|
177
|
-
pluginTs(),
|
|
178
|
-
pluginSwr({
|
|
179
|
-
output: {
|
|
180
|
-
path: './hooks',
|
|
181
|
-
},
|
|
182
|
-
group: {
|
|
183
|
-
type: 'tag',
|
|
184
|
-
name: ({ group }) => `${group}Hooks`,
|
|
185
|
-
},
|
|
186
|
-
client: {
|
|
187
|
-
dataReturnType: 'data',
|
|
188
|
-
},
|
|
189
|
-
mutation: {
|
|
190
|
-
methods: ['post', 'put', 'delete'],
|
|
191
|
-
},
|
|
192
|
-
query: {
|
|
193
|
-
methods: ['get'],
|
|
194
|
-
importPath: 'swr',
|
|
195
|
-
},
|
|
196
|
-
}),
|
|
197
|
-
],
|
|
198
|
-
})
|
|
199
|
-
twoslash: false
|