@kubb/plugin-swr 3.1.0 → 3.2.0
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/{chunk-23A6KPTG.js → chunk-4EFF327C.js} +10 -3
- package/dist/chunk-4EFF327C.js.map +1 -0
- package/dist/{chunk-ZO4CRCE6.cjs → chunk-4ZIGOWYH.cjs} +15 -8
- package/dist/chunk-4ZIGOWYH.cjs.map +1 -0
- package/dist/{chunk-HOCARL2F.js → chunk-7ELDJ4IB.js} +33 -24
- package/dist/chunk-7ELDJ4IB.js.map +1 -0
- package/dist/{chunk-442Q5BKM.cjs → chunk-DJ57MWSH.cjs} +33 -24
- package/dist/chunk-DJ57MWSH.cjs.map +1 -0
- package/dist/components.cjs +6 -6
- package/dist/components.d.cts +15 -8
- package/dist/components.d.ts +15 -8
- package/dist/components.js +1 -1
- package/dist/generators.cjs +4 -4
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +7 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/{types-C68y96t2.d.cts → types-CwvU4w1t.d.cts} +14 -0
- package/dist/{types-C68y96t2.d.ts → types-CwvU4w1t.d.ts} +14 -0
- package/package.json +12 -12
- package/src/components/Mutation.tsx +7 -2
- package/src/components/MutationKey.tsx +5 -4
- package/src/components/Query.tsx +9 -3
- package/src/components/QueryKey.tsx +9 -6
- package/src/components/QueryOptions.tsx +8 -5
- package/src/generators/mutationGenerator.tsx +3 -0
- package/src/generators/queryGenerator.tsx +4 -0
- package/src/plugin.ts +2 -0
- package/src/types.ts +7 -0
- package/dist/chunk-23A6KPTG.js.map +0 -1
- package/dist/chunk-442Q5BKM.cjs.map +0 -1
- package/dist/chunk-HOCARL2F.js.map +0 -1
- package/dist/chunk-ZO4CRCE6.cjs.map +0 -1
|
@@ -11,13 +11,13 @@ var jsxRuntime = require('@kubb/react/jsx-runtime');
|
|
|
11
11
|
function getParams({}) {
|
|
12
12
|
return react.FunctionParams.factory({});
|
|
13
13
|
}
|
|
14
|
-
var getTransformer = ({ operation }) => {
|
|
15
|
-
const path = new utils$1.URLPath(operation.path);
|
|
14
|
+
var getTransformer = ({ operation, casing }) => {
|
|
15
|
+
const path = new utils$1.URLPath(operation.path, { casing });
|
|
16
16
|
return [JSON.stringify({ url: path.path })].filter(Boolean);
|
|
17
17
|
};
|
|
18
|
-
function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }) {
|
|
18
|
+
function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }) {
|
|
19
19
|
const params = getParams({ pathParamsType, typeSchemas });
|
|
20
|
-
const keys = transformer({ operation, schemas: typeSchemas });
|
|
20
|
+
const keys = transformer({ operation, schemas: typeSchemas, casing: paramsCasing });
|
|
21
21
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
22
22
|
/* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function.Arrow, { name, export: true, params: params.toConstructor(), singleLine: true, children: `[${keys.join(", ")}] as const` }) }),
|
|
23
23
|
/* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Type, { name: typeName, export: true, children: `ReturnType<typeof ${name}>` }) })
|
|
@@ -25,12 +25,12 @@ function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, t
|
|
|
25
25
|
}
|
|
26
26
|
MutationKey.getParams = getParams;
|
|
27
27
|
MutationKey.getTransformer = getTransformer;
|
|
28
|
-
function getParams2({ pathParamsType, dataReturnType, typeSchemas, mutationKeyTypeName }) {
|
|
28
|
+
function getParams2({ pathParamsType, paramsCasing, dataReturnType, typeSchemas, mutationKeyTypeName }) {
|
|
29
29
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
30
30
|
return react.FunctionParams.factory({
|
|
31
31
|
pathParams: {
|
|
32
32
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
33
|
-
children: utils.getPathParams(typeSchemas.pathParams, { typed: true })
|
|
33
|
+
children: utils.getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing })
|
|
34
34
|
},
|
|
35
35
|
params: typeSchemas.queryParams?.name ? {
|
|
36
36
|
type: typeSchemas.queryParams?.name,
|
|
@@ -58,6 +58,7 @@ function Mutation({
|
|
|
58
58
|
mutationKeyName,
|
|
59
59
|
mutationKeyTypeName,
|
|
60
60
|
paramsType,
|
|
61
|
+
paramsCasing,
|
|
61
62
|
pathParamsType,
|
|
62
63
|
dataReturnType,
|
|
63
64
|
typeSchemas,
|
|
@@ -76,12 +77,14 @@ function Mutation({
|
|
|
76
77
|
typeSchemas
|
|
77
78
|
});
|
|
78
79
|
const params = getParams2({
|
|
80
|
+
paramsCasing,
|
|
79
81
|
pathParamsType,
|
|
80
82
|
dataReturnType,
|
|
81
83
|
typeSchemas,
|
|
82
84
|
mutationKeyTypeName
|
|
83
85
|
});
|
|
84
86
|
const clientParams = components.Client.getParams({
|
|
87
|
+
paramsCasing,
|
|
85
88
|
paramsType,
|
|
86
89
|
typeSchemas,
|
|
87
90
|
pathParamsType
|
|
@@ -110,11 +113,11 @@ function Mutation({
|
|
|
110
113
|
}
|
|
111
114
|
) });
|
|
112
115
|
}
|
|
113
|
-
function getParams3({ pathParamsType, typeSchemas }) {
|
|
116
|
+
function getParams3({ pathParamsType, paramsCasing, typeSchemas }) {
|
|
114
117
|
return react.FunctionParams.factory({
|
|
115
118
|
pathParams: {
|
|
116
119
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
117
|
-
children: utils.getPathParams(typeSchemas.pathParams, { typed: true })
|
|
120
|
+
children: utils.getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing })
|
|
118
121
|
},
|
|
119
122
|
data: typeSchemas.request?.name ? {
|
|
120
123
|
type: typeSchemas.request?.name,
|
|
@@ -126,8 +129,8 @@ function getParams3({ pathParamsType, typeSchemas }) {
|
|
|
126
129
|
} : void 0
|
|
127
130
|
});
|
|
128
131
|
}
|
|
129
|
-
var getTransformer2 = ({ operation, schemas }) => {
|
|
130
|
-
const path = new utils$1.URLPath(operation.path);
|
|
132
|
+
var getTransformer2 = ({ operation, schemas, casing }) => {
|
|
133
|
+
const path = new utils$1.URLPath(operation.path, { casing });
|
|
131
134
|
const keys = [
|
|
132
135
|
path.toObject({
|
|
133
136
|
type: "path",
|
|
@@ -138,11 +141,12 @@ var getTransformer2 = ({ operation, schemas }) => {
|
|
|
138
141
|
].filter(Boolean);
|
|
139
142
|
return keys;
|
|
140
143
|
};
|
|
141
|
-
function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer2 }) {
|
|
142
|
-
const params = getParams3({ pathParamsType, typeSchemas });
|
|
144
|
+
function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer2 }) {
|
|
145
|
+
const params = getParams3({ pathParamsType, paramsCasing, typeSchemas });
|
|
143
146
|
const keys = transformer({
|
|
144
147
|
operation,
|
|
145
|
-
schemas: typeSchemas
|
|
148
|
+
schemas: typeSchemas,
|
|
149
|
+
casing: paramsCasing
|
|
146
150
|
});
|
|
147
151
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
148
152
|
/* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function.Arrow, { name, export: true, params: params.toConstructor(), singleLine: true, children: `[${keys.join(", ")}] as const` }) }),
|
|
@@ -151,13 +155,13 @@ function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, tran
|
|
|
151
155
|
}
|
|
152
156
|
QueryKey.getParams = getParams3;
|
|
153
157
|
QueryKey.getTransformer = getTransformer2;
|
|
154
|
-
function getParams4({ paramsType, pathParamsType, typeSchemas }) {
|
|
158
|
+
function getParams4({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
155
159
|
if (paramsType === "object") {
|
|
156
160
|
return react.FunctionParams.factory({
|
|
157
161
|
data: {
|
|
158
162
|
mode: "object",
|
|
159
163
|
children: {
|
|
160
|
-
...utils.getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
164
|
+
...utils.getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
161
165
|
data: typeSchemas.request?.name ? {
|
|
162
166
|
type: typeSchemas.request?.name,
|
|
163
167
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
@@ -181,7 +185,7 @@ function getParams4({ paramsType, pathParamsType, typeSchemas }) {
|
|
|
181
185
|
return react.FunctionParams.factory({
|
|
182
186
|
pathParams: typeSchemas.pathParams?.name ? {
|
|
183
187
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
184
|
-
children: utils.getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
188
|
+
children: utils.getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
185
189
|
optional: oas.isOptional(typeSchemas.pathParams?.schema)
|
|
186
190
|
} : void 0,
|
|
187
191
|
data: typeSchemas.request?.name ? {
|
|
@@ -202,9 +206,10 @@ function getParams4({ paramsType, pathParamsType, typeSchemas }) {
|
|
|
202
206
|
}
|
|
203
207
|
});
|
|
204
208
|
}
|
|
205
|
-
function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType }) {
|
|
206
|
-
const params = getParams4({ paramsType, pathParamsType, typeSchemas });
|
|
209
|
+
function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, pathParamsType }) {
|
|
210
|
+
const params = getParams4({ paramsType, paramsCasing, pathParamsType, typeSchemas });
|
|
207
211
|
const clientParams = components.Client.getParams({
|
|
212
|
+
paramsCasing,
|
|
208
213
|
paramsType,
|
|
209
214
|
typeSchemas,
|
|
210
215
|
pathParamsType
|
|
@@ -218,14 +223,14 @@ function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsTyp
|
|
|
218
223
|
` }) });
|
|
219
224
|
}
|
|
220
225
|
QueryOptions.getParams = getParams4;
|
|
221
|
-
function getParams5({ paramsType, pathParamsType, dataReturnType, typeSchemas, queryKeyTypeName }) {
|
|
226
|
+
function getParams5({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, queryKeyTypeName }) {
|
|
222
227
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
223
228
|
if (paramsType === "object") {
|
|
224
229
|
return react.FunctionParams.factory({
|
|
225
230
|
data: {
|
|
226
231
|
mode: "object",
|
|
227
232
|
children: {
|
|
228
|
-
...utils.getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
233
|
+
...utils.getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
229
234
|
data: typeSchemas.request?.name ? {
|
|
230
235
|
type: typeSchemas.request?.name,
|
|
231
236
|
optional: oas.isOptional(typeSchemas.request?.schema)
|
|
@@ -255,7 +260,7 @@ function getParams5({ paramsType, pathParamsType, dataReturnType, typeSchemas, q
|
|
|
255
260
|
return react.FunctionParams.factory({
|
|
256
261
|
pathParams: typeSchemas.pathParams?.name ? {
|
|
257
262
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
258
|
-
children: utils.getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
263
|
+
children: utils.getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
259
264
|
optional: oas.isOptional(typeSchemas.pathParams?.schema)
|
|
260
265
|
} : void 0,
|
|
261
266
|
data: typeSchemas.request?.name ? {
|
|
@@ -291,15 +296,18 @@ function Query({
|
|
|
291
296
|
operation,
|
|
292
297
|
dataReturnType,
|
|
293
298
|
paramsType,
|
|
299
|
+
paramsCasing,
|
|
294
300
|
pathParamsType
|
|
295
301
|
}) {
|
|
296
302
|
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
297
303
|
const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error", `${queryKeyTypeName} | null`];
|
|
298
304
|
const queryKeyParams = QueryKey.getParams({
|
|
299
305
|
pathParamsType,
|
|
300
|
-
typeSchemas
|
|
306
|
+
typeSchemas,
|
|
307
|
+
paramsCasing
|
|
301
308
|
});
|
|
302
309
|
const params = getParams5({
|
|
310
|
+
paramsCasing,
|
|
303
311
|
paramsType,
|
|
304
312
|
pathParamsType,
|
|
305
313
|
dataReturnType,
|
|
@@ -307,6 +315,7 @@ function Query({
|
|
|
307
315
|
queryKeyTypeName
|
|
308
316
|
});
|
|
309
317
|
const queryOptionsParams = QueryOptions.getParams({
|
|
318
|
+
paramsCasing,
|
|
310
319
|
paramsType,
|
|
311
320
|
pathParamsType,
|
|
312
321
|
typeSchemas
|
|
@@ -342,5 +351,5 @@ exports.MutationKey = MutationKey;
|
|
|
342
351
|
exports.Query = Query;
|
|
343
352
|
exports.QueryKey = QueryKey;
|
|
344
353
|
exports.QueryOptions = QueryOptions;
|
|
345
|
-
//# sourceMappingURL=chunk-
|
|
346
|
-
//# sourceMappingURL=chunk-
|
|
354
|
+
//# sourceMappingURL=chunk-DJ57MWSH.cjs.map
|
|
355
|
+
//# sourceMappingURL=chunk-DJ57MWSH.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/MutationKey.tsx","../src/components/Mutation.tsx","../src/components/QueryKey.tsx","../src/components/QueryOptions.tsx","../src/components/Query.tsx"],"names":["FunctionParams","URLPath","jsxs","Fragment","jsx","File","Function","Type","getParams","getPathParams","isOptional","Client","getComments","getTransformer"],"mappings":";;;;;;;;;;AAuB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CAAA,MAAA,EAAQ,CAAA;AAAA;AAAA;AAAA;AAAA,OAAA;AAAA;AAAA,GAM1D,EAAA,CAAA;AAEJ","file":"chunk-DJ57MWSH.cjs","sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { File, Function, FunctionParams, Type } from '@kubb/react'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { ReactNode } from 'react'\nimport type { PluginSwr, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({}: GetParamsProps) {\n return FunctionParams.factory({})\n}\n\nconst getTransformer: Transformer = ({ operation, casing }) => {\n const path = new URLPath(operation.path, { casing })\n\n return [JSON.stringify({ url: path.path })].filter(Boolean)\n}\n\nexport function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {\n const params = getParams({ pathParamsType, typeSchemas })\n const keys = transformer({ operation, schemas: typeSchemas, casing: paramsCasing })\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keys.join(', ')}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={typeName} isExportable isIndexable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\nMutationKey.getParams = getParams\nMutationKey.getTransformer = getTransformer\n","import { File, Function, FunctionParams } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport type { ReactNode } from 'react'\nimport type { PluginSwr } from '../types.ts'\nimport { MutationKey } from './MutationKey.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n clientName: string\n mutationKeyName: string\n mutationKeyTypeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n mutationKeyTypeName: string\n}\n// TODO add same logic as being done for react-query mutations\nfunction getParams({ pathParamsType, paramsCasing, dataReturnType, typeSchemas, mutationKeyTypeName }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: `\n{\n mutation?: Parameters<typeof useSWRMutation<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', mutationKeyTypeName, typeSchemas.request?.name].join(', ')}>>[2],\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'},\n shouldFetch?: boolean,\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Mutation({\n name,\n clientName,\n mutationKeyName,\n mutationKeyTypeName,\n paramsType,\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n}: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const generics = [\n TData,\n typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error',\n `${mutationKeyTypeName} | null`,\n typeSchemas.request?.name, //arg: data\n ].filter(Boolean)\n\n const mutationKeyParams = MutationKey.getParams({\n pathParamsType,\n typeSchemas,\n })\n\n const params = getParams({\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n mutationKeyTypeName,\n })\n\n const clientParams = Client.getParams({\n paramsCasing,\n paramsType,\n typeSchemas,\n pathParamsType,\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {`\n const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}\n const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})\n\n return useSWRMutation<${generics}>(\n shouldFetch ? mutationKey : null,\n async (_url${typeSchemas.request?.name ? ', { arg: data }' : ''}) => {\n return ${clientName}(${clientParams.toCall()})\n },\n mutationOptions\n )\n `}\n </Function>\n </File.Source>\n )\n}\n","import { URLPath } from '@kubb/core/utils'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams, Type } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { ReactNode } from 'react'\nimport type { PluginSwr, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n })\n}\n\nconst getTransformer: Transformer = ({ operation, schemas, casing }) => {\n const path = new URLPath(operation.path, { casing })\n const keys = [\n path.toObject({\n type: 'path',\n stringify: true,\n }),\n schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,\n schemas.request?.name ? '...(data ? [data] : [])' : undefined,\n ].filter(Boolean)\n\n return keys\n}\n\nexport function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {\n const params = getParams({ pathParamsType, paramsCasing, typeSchemas })\n const keys = transformer({\n operation,\n schemas: typeSchemas,\n casing: paramsCasing,\n })\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keys.join(', ')}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={typeName} isExportable isIndexable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\nQueryKey.getParams = getParams\nQueryKey.getTransformer = getTransformer\n","import { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\nimport type { ReactNode } from 'react'\nimport type { PluginSwr } from '../types.ts'\n\nimport { isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\n\ntype Props = {\n name: string\n clientName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n}\n\ntype GetParamsProps = {\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n config: {\n type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n config: {\n type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',\n default: '{}',\n },\n })\n}\n\nexport function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, pathParamsType }: Props): ReactNode {\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n const clientParams = Client.getParams({\n paramsCasing,\n paramsType,\n typeSchemas,\n pathParamsType,\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function name={name} export params={params.toConstructor()}>\n {`\n return {\n fetcher: async () => {\n return ${clientName}(${clientParams.toCall()})\n },\n }\n `}\n </Function>\n </File.Source>\n )\n}\n\nQueryOptions.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport type { ReactNode } from 'react'\nimport type { PluginSwr } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\nimport { QueryOptions } from './QueryOptions.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n queryOptionsName: string\n queryKeyName: string\n queryKeyTypeName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n operation: Operation\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n queryKeyTypeName: string\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, queryKeyTypeName }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: `\n{\n query?: Parameters<typeof useSWR<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `${queryKeyTypeName} | null`].join(', ')}, any>>[2],\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'},\n shouldFetch?: boolean,\n}\n`,\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: `\n{\n query?: Parameters<typeof useSWR<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `${queryKeyTypeName} | null`].join(', ')}, any>>[2],\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'},\n shouldFetch?: boolean,\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Query({\n name,\n typeSchemas,\n queryKeyName,\n queryKeyTypeName,\n queryOptionsName,\n operation,\n dataReturnType,\n paramsType,\n paramsCasing,\n pathParamsType,\n}: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `${queryKeyTypeName} | null`]\n\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n typeSchemas,\n paramsCasing,\n })\n const params = getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n queryKeyTypeName,\n })\n\n const queryOptionsParams = QueryOptions.getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n typeSchemas,\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {`\n const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {}\n\n const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})\n\n return useSWR<${generics.join(', ')}>(\n shouldFetch ? queryKey : null,\n {\n ...${queryOptionsName}(${queryOptionsParams.toCall()}),\n ...queryOptions\n }\n )\n `}\n </Function>\n </File.Source>\n )\n}\n"]}
|
package/dist/components.cjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkDJ57MWSH_cjs = require('./chunk-DJ57MWSH.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "Mutation", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkDJ57MWSH_cjs.Mutation; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "MutationKey", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkDJ57MWSH_cjs.MutationKey; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "Query", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkDJ57MWSH_cjs.Query; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "QueryKey", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkDJ57MWSH_cjs.QueryKey; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "QueryOptions", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkDJ57MWSH_cjs.QueryOptions; }
|
|
26
26
|
});
|
|
27
27
|
//# sourceMappingURL=components.cjs.map
|
|
28
28
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Operation } from '@kubb/oas';
|
|
2
2
|
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { P as PluginSwr, T as Transformer } from './types-
|
|
4
|
+
import { P as PluginSwr, T as Transformer } from './types-CwvU4w1t.cjs';
|
|
5
5
|
import { FunctionParams } from '@kubb/react';
|
|
6
6
|
import '@kubb/core';
|
|
7
7
|
import '@kubb/plugin-client';
|
|
@@ -17,11 +17,12 @@ type Props$4 = {
|
|
|
17
17
|
mutationKeyTypeName: string;
|
|
18
18
|
typeSchemas: OperationSchemas;
|
|
19
19
|
operation: Operation;
|
|
20
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing'];
|
|
20
21
|
paramsType: PluginSwr['resolvedOptions']['paramsType'];
|
|
21
22
|
dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType'];
|
|
22
23
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
23
24
|
};
|
|
24
|
-
declare function Mutation({ name, clientName, mutationKeyName, mutationKeyTypeName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, }: Props$4): ReactNode;
|
|
25
|
+
declare function Mutation({ name, clientName, mutationKeyName, mutationKeyTypeName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, }: Props$4): ReactNode;
|
|
25
26
|
|
|
26
27
|
type Props$3 = {
|
|
27
28
|
/**
|
|
@@ -32,28 +33,31 @@ type Props$3 = {
|
|
|
32
33
|
queryKeyName: string;
|
|
33
34
|
queryKeyTypeName: string;
|
|
34
35
|
typeSchemas: OperationSchemas;
|
|
36
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing'];
|
|
35
37
|
paramsType: PluginSwr['resolvedOptions']['paramsType'];
|
|
36
38
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
37
39
|
dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType'];
|
|
38
40
|
operation: Operation;
|
|
39
41
|
};
|
|
40
|
-
declare function Query({ name, typeSchemas, queryKeyName, queryKeyTypeName, queryOptionsName, operation, dataReturnType, paramsType, pathParamsType, }: Props$3): ReactNode;
|
|
42
|
+
declare function Query({ name, typeSchemas, queryKeyName, queryKeyTypeName, queryOptionsName, operation, dataReturnType, paramsType, paramsCasing, pathParamsType, }: Props$3): ReactNode;
|
|
41
43
|
|
|
42
44
|
type Props$2 = {
|
|
43
45
|
name: string;
|
|
44
46
|
clientName: string;
|
|
45
47
|
typeSchemas: OperationSchemas;
|
|
48
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing'];
|
|
46
49
|
paramsType: PluginSwr['resolvedOptions']['paramsType'];
|
|
47
50
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
48
51
|
};
|
|
49
52
|
type GetParamsProps$2 = {
|
|
50
53
|
paramsType: PluginSwr['resolvedOptions']['paramsType'];
|
|
54
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing'];
|
|
51
55
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
52
56
|
typeSchemas: OperationSchemas;
|
|
53
57
|
};
|
|
54
|
-
declare function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType }: Props$2): ReactNode;
|
|
58
|
+
declare function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, pathParamsType }: Props$2): ReactNode;
|
|
55
59
|
declare namespace QueryOptions {
|
|
56
|
-
var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps$2) => FunctionParams;
|
|
60
|
+
var getParams: ({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps$2) => FunctionParams;
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
type Props$1 = {
|
|
@@ -61,16 +65,18 @@ type Props$1 = {
|
|
|
61
65
|
typeName: string;
|
|
62
66
|
typeSchemas: OperationSchemas;
|
|
63
67
|
operation: Operation;
|
|
68
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing'];
|
|
64
69
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
65
70
|
transformer: Transformer | undefined;
|
|
66
71
|
};
|
|
67
72
|
type GetParamsProps$1 = {
|
|
73
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing'];
|
|
68
74
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
69
75
|
typeSchemas: OperationSchemas;
|
|
70
76
|
};
|
|
71
|
-
declare function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer }: Props$1): ReactNode;
|
|
77
|
+
declare function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer }: Props$1): ReactNode;
|
|
72
78
|
declare namespace QueryKey {
|
|
73
|
-
var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps$1) => FunctionParams;
|
|
79
|
+
var getParams: ({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps$1) => FunctionParams;
|
|
74
80
|
var getTransformer: Transformer;
|
|
75
81
|
}
|
|
76
82
|
|
|
@@ -79,6 +85,7 @@ type Props = {
|
|
|
79
85
|
typeName: string;
|
|
80
86
|
typeSchemas: OperationSchemas;
|
|
81
87
|
operation: Operation;
|
|
88
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing'];
|
|
82
89
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
83
90
|
transformer: Transformer | undefined;
|
|
84
91
|
};
|
|
@@ -86,7 +93,7 @@ type GetParamsProps = {
|
|
|
86
93
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
87
94
|
typeSchemas: OperationSchemas;
|
|
88
95
|
};
|
|
89
|
-
declare function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer }: Props): ReactNode;
|
|
96
|
+
declare function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer }: Props): ReactNode;
|
|
90
97
|
declare namespace MutationKey {
|
|
91
98
|
var getParams: ({}: GetParamsProps) => FunctionParams;
|
|
92
99
|
var getTransformer: Transformer;
|
package/dist/components.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Operation } from '@kubb/oas';
|
|
2
2
|
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { P as PluginSwr, T as Transformer } from './types-
|
|
4
|
+
import { P as PluginSwr, T as Transformer } from './types-CwvU4w1t.js';
|
|
5
5
|
import { FunctionParams } from '@kubb/react';
|
|
6
6
|
import '@kubb/core';
|
|
7
7
|
import '@kubb/plugin-client';
|
|
@@ -17,11 +17,12 @@ type Props$4 = {
|
|
|
17
17
|
mutationKeyTypeName: string;
|
|
18
18
|
typeSchemas: OperationSchemas;
|
|
19
19
|
operation: Operation;
|
|
20
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing'];
|
|
20
21
|
paramsType: PluginSwr['resolvedOptions']['paramsType'];
|
|
21
22
|
dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType'];
|
|
22
23
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
23
24
|
};
|
|
24
|
-
declare function Mutation({ name, clientName, mutationKeyName, mutationKeyTypeName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, }: Props$4): ReactNode;
|
|
25
|
+
declare function Mutation({ name, clientName, mutationKeyName, mutationKeyTypeName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, }: Props$4): ReactNode;
|
|
25
26
|
|
|
26
27
|
type Props$3 = {
|
|
27
28
|
/**
|
|
@@ -32,28 +33,31 @@ type Props$3 = {
|
|
|
32
33
|
queryKeyName: string;
|
|
33
34
|
queryKeyTypeName: string;
|
|
34
35
|
typeSchemas: OperationSchemas;
|
|
36
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing'];
|
|
35
37
|
paramsType: PluginSwr['resolvedOptions']['paramsType'];
|
|
36
38
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
37
39
|
dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType'];
|
|
38
40
|
operation: Operation;
|
|
39
41
|
};
|
|
40
|
-
declare function Query({ name, typeSchemas, queryKeyName, queryKeyTypeName, queryOptionsName, operation, dataReturnType, paramsType, pathParamsType, }: Props$3): ReactNode;
|
|
42
|
+
declare function Query({ name, typeSchemas, queryKeyName, queryKeyTypeName, queryOptionsName, operation, dataReturnType, paramsType, paramsCasing, pathParamsType, }: Props$3): ReactNode;
|
|
41
43
|
|
|
42
44
|
type Props$2 = {
|
|
43
45
|
name: string;
|
|
44
46
|
clientName: string;
|
|
45
47
|
typeSchemas: OperationSchemas;
|
|
48
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing'];
|
|
46
49
|
paramsType: PluginSwr['resolvedOptions']['paramsType'];
|
|
47
50
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
48
51
|
};
|
|
49
52
|
type GetParamsProps$2 = {
|
|
50
53
|
paramsType: PluginSwr['resolvedOptions']['paramsType'];
|
|
54
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing'];
|
|
51
55
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
52
56
|
typeSchemas: OperationSchemas;
|
|
53
57
|
};
|
|
54
|
-
declare function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType }: Props$2): ReactNode;
|
|
58
|
+
declare function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, pathParamsType }: Props$2): ReactNode;
|
|
55
59
|
declare namespace QueryOptions {
|
|
56
|
-
var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps$2) => FunctionParams;
|
|
60
|
+
var getParams: ({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps$2) => FunctionParams;
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
type Props$1 = {
|
|
@@ -61,16 +65,18 @@ type Props$1 = {
|
|
|
61
65
|
typeName: string;
|
|
62
66
|
typeSchemas: OperationSchemas;
|
|
63
67
|
operation: Operation;
|
|
68
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing'];
|
|
64
69
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
65
70
|
transformer: Transformer | undefined;
|
|
66
71
|
};
|
|
67
72
|
type GetParamsProps$1 = {
|
|
73
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing'];
|
|
68
74
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
69
75
|
typeSchemas: OperationSchemas;
|
|
70
76
|
};
|
|
71
|
-
declare function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer }: Props$1): ReactNode;
|
|
77
|
+
declare function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer }: Props$1): ReactNode;
|
|
72
78
|
declare namespace QueryKey {
|
|
73
|
-
var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps$1) => FunctionParams;
|
|
79
|
+
var getParams: ({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps$1) => FunctionParams;
|
|
74
80
|
var getTransformer: Transformer;
|
|
75
81
|
}
|
|
76
82
|
|
|
@@ -79,6 +85,7 @@ type Props = {
|
|
|
79
85
|
typeName: string;
|
|
80
86
|
typeSchemas: OperationSchemas;
|
|
81
87
|
operation: Operation;
|
|
88
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing'];
|
|
82
89
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
83
90
|
transformer: Transformer | undefined;
|
|
84
91
|
};
|
|
@@ -86,7 +93,7 @@ type GetParamsProps = {
|
|
|
86
93
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType'];
|
|
87
94
|
typeSchemas: OperationSchemas;
|
|
88
95
|
};
|
|
89
|
-
declare function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer }: Props): ReactNode;
|
|
96
|
+
declare function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer }: Props): ReactNode;
|
|
90
97
|
declare namespace MutationKey {
|
|
91
98
|
var getParams: ({}: GetParamsProps) => FunctionParams;
|
|
92
99
|
var getTransformer: Transformer;
|
package/dist/components.js
CHANGED
package/dist/generators.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunk4ZIGOWYH_cjs = require('./chunk-4ZIGOWYH.cjs');
|
|
4
|
+
require('./chunk-DJ57MWSH.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "mutationGenerator", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunk4ZIGOWYH_cjs.mutationGenerator; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "queryGenerator", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunk4ZIGOWYH_cjs.queryGenerator; }
|
|
15
15
|
});
|
|
16
16
|
//# sourceMappingURL=generators.cjs.map
|
|
17
17
|
//# sourceMappingURL=generators.cjs.map
|
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { mutationGenerator, queryGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { mutationGenerator, queryGenerator } from './chunk-4EFF327C.js';
|
|
2
|
+
import './chunk-7ELDJ4IB.js';
|
|
3
3
|
//# sourceMappingURL=generators.js.map
|
|
4
4
|
//# sourceMappingURL=generators.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk4ZIGOWYH_cjs = require('./chunk-4ZIGOWYH.cjs');
|
|
4
|
+
var chunkDJ57MWSH_cjs = require('./chunk-DJ57MWSH.cjs');
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var core = require('@kubb/core');
|
|
7
7
|
var transformers = require('@kubb/core/transformers');
|
|
@@ -28,9 +28,10 @@ var pluginSwr = core.createPlugin((options) => {
|
|
|
28
28
|
client,
|
|
29
29
|
paramsType = "inline",
|
|
30
30
|
pathParamsType = "inline",
|
|
31
|
-
mutationKey =
|
|
32
|
-
queryKey =
|
|
33
|
-
generators = [
|
|
31
|
+
mutationKey = chunkDJ57MWSH_cjs.MutationKey.getTransformer,
|
|
32
|
+
queryKey = chunkDJ57MWSH_cjs.QueryKey.getTransformer,
|
|
33
|
+
generators = [chunk4ZIGOWYH_cjs.queryGenerator, chunk4ZIGOWYH_cjs.mutationGenerator].filter(Boolean),
|
|
34
|
+
paramsCasing
|
|
34
35
|
} = options;
|
|
35
36
|
return {
|
|
36
37
|
name: pluginSwrName,
|
|
@@ -56,6 +57,7 @@ var pluginSwr = core.createPlugin((options) => {
|
|
|
56
57
|
parser,
|
|
57
58
|
paramsType,
|
|
58
59
|
pathParamsType: paramsType === "object" ? "object" : pathParamsType,
|
|
60
|
+
paramsCasing,
|
|
59
61
|
group
|
|
60
62
|
},
|
|
61
63
|
pre: [pluginOas.pluginOasName, pluginTs.pluginTsName, parser === "zod" ? pluginZod.pluginZodName : void 0].filter(Boolean),
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","MutationKey","QueryKey","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","pascalCase","PluginManager","OperationGenerator"],"mappings":";;;;;;;;;;;;;;;AAeO,IAAM,aAAgB,GAAA;AAEhB,IAAA,SAAA,GAAYA,iBAAwB,CAAA,CAAC,OAAY,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAAY,OAAQ,EAAA;AAAA,IAC9C,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,kBACTC,iBAAe,EAAC;AAAA,IAChB,KAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAa,GAAA,QAAA;AAAA,IACb,cAAiB,GAAA,QAAA;AAAA,IACjB,cAAcC,6BAAY,CAAA,cAAA;AAAA,IAC1B,WAAWC,0BAAS,CAAA,cAAA;AAAA,IACpB,aAAa,CAACC,gCAAA,EAAgBC,mCAAiB,CAAA,CAAE,OAAO,OAAO;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","MutationKey","QueryKey","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","pascalCase","PluginManager","OperationGenerator"],"mappings":";;;;;;;;;;;;;;;AAeO,IAAM,aAAgB,GAAA;AAEhB,IAAA,SAAA,GAAYA,iBAAwB,CAAA,CAAC,OAAY,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAAY,OAAQ,EAAA;AAAA,IAC9C,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,kBACTC,iBAAe,EAAC;AAAA,IAChB,KAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,UAAa,GAAA,QAAA;AAAA,IACb,cAAiB,GAAA,QAAA;AAAA,IACjB,cAAcC,6BAAY,CAAA,cAAA;AAAA,IAC1B,WAAWC,0BAAS,CAAA,cAAA;AAAA,IACpB,aAAa,CAACC,gCAAA,EAAgBC,mCAAiB,CAAA,CAAE,OAAO,OAAO,CAAA;AAAA,IAC/D;AAAA,GACE,GAAA,OAAA;AAEJ,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,aAAA;AAAA,IACN,OAAS,EAAA;AAAA,MACP,MAAA;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,UAAY,EAAA,4BAAA;AAAA,QACZ,cAAgB,EAAA,MAAA;AAAA,QAChB,GAAG;AAAA,OACL;AAAA,MACA,QAAA;AAAA,MACA,KAAA,EACE,KAAU,KAAA,KAAA,GACN,KACA,GAAA;AAAA,QACE,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 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n query,\n mutation,\n client,\n paramsType = 'inline',\n pathParamsType = 'inline',\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n paramsCasing,\n } = options\n\n return {\n name: pluginSwrName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n ...client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n importPath: 'swr',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation: {\n importPath: 'swr/mutation',\n methods: ['post', 'put', 'delete', 'patch'],\n ...mutation,\n },\n parser,\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : pathParamsType,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.group && group) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(root, output.path, groupName({ group: options.group }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"]}
|
package/dist/index.d.cts
CHANGED