@kubb/plugin-swr 3.0.0-alpha.9 → 3.0.0-beta.2

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.
Files changed (61) hide show
  1. package/README.md +14 -5
  2. package/dist/chunk-4EGGCGSE.js +217 -0
  3. package/dist/chunk-4EGGCGSE.js.map +1 -0
  4. package/dist/chunk-H23WKEYP.js +243 -0
  5. package/dist/chunk-H23WKEYP.js.map +1 -0
  6. package/dist/chunk-JWGWABV5.cjs +249 -0
  7. package/dist/chunk-JWGWABV5.cjs.map +1 -0
  8. package/dist/chunk-PTOQHHST.cjs +220 -0
  9. package/dist/chunk-PTOQHHST.cjs.map +1 -0
  10. package/dist/components.cjs +23 -6
  11. package/dist/components.cjs.map +1 -1
  12. package/dist/components.d.cts +88 -6
  13. package/dist/components.d.ts +88 -6
  14. package/dist/components.js +2 -10
  15. package/dist/components.js.map +1 -1
  16. package/dist/generators.cjs +17 -0
  17. package/dist/generators.cjs.map +1 -0
  18. package/dist/generators.d.cts +11 -0
  19. package/dist/generators.d.ts +11 -0
  20. package/dist/generators.js +4 -0
  21. package/dist/generators.js.map +1 -0
  22. package/dist/index.cjs +93 -123
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +2 -4
  25. package/dist/index.d.ts +2 -4
  26. package/dist/index.js +77 -114
  27. package/dist/index.js.map +1 -1
  28. package/dist/types-DaH2Sc1M.d.cts +103 -0
  29. package/dist/types-DaH2Sc1M.d.ts +103 -0
  30. package/package.json +23 -17
  31. package/src/components/Mutation.tsx +93 -227
  32. package/src/components/MutationKey.tsx +48 -0
  33. package/src/components/Query.tsx +93 -259
  34. package/src/components/QueryKey.tsx +73 -0
  35. package/src/components/QueryOptions.tsx +54 -177
  36. package/src/components/index.ts +2 -0
  37. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +43 -0
  38. package/src/generators/__snapshots__/clientGetImportPath.ts +43 -0
  39. package/src/generators/__snapshots__/clientPostImportPath.ts +32 -0
  40. package/src/generators/__snapshots__/findByTags.ts +43 -0
  41. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +43 -0
  42. package/src/generators/__snapshots__/findByTagsWithZod.ts +43 -0
  43. package/src/generators/__snapshots__/getAsMutation.ts +34 -0
  44. package/src/generators/__snapshots__/postAsQuery.ts +41 -0
  45. package/src/generators/__snapshots__/updatePetById.ts +32 -0
  46. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +36 -0
  47. package/src/generators/index.ts +2 -0
  48. package/src/generators/mutationGenerator.tsx +109 -0
  49. package/src/generators/queryGenerator.tsx +114 -0
  50. package/src/plugin.ts +71 -52
  51. package/src/types.ts +62 -78
  52. package/dist/chunk-TGLXUPN4.cjs +0 -536
  53. package/dist/chunk-TGLXUPN4.cjs.map +0 -1
  54. package/dist/chunk-XWXMQJD6.js +0 -536
  55. package/dist/chunk-XWXMQJD6.js.map +0 -1
  56. package/dist/index-B3C-JOIU.d.cts +0 -299
  57. package/dist/index-B3C-JOIU.d.ts +0 -299
  58. package/src/OperationGenerator.tsx +0 -75
  59. package/src/components/SchemaType.tsx +0 -63
  60. package/src/components/__snapshots__/Mutation/Pets.ts +0 -46
  61. package/src/components/__snapshots__/Query/showPetById.ts +0 -59
@@ -0,0 +1,249 @@
1
+ 'use strict';
2
+
3
+ var utils = require('@kubb/core/utils');
4
+ var react = require('@kubb/react');
5
+ var oas = require('@kubb/oas');
6
+ var components = require('@kubb/plugin-client/components');
7
+ var utils$1 = require('@kubb/plugin-oas/utils');
8
+ var jsxRuntime = require('@kubb/react/jsx-runtime');
9
+
10
+ // src/components/Mutation.tsx
11
+ function getParams({}) {
12
+ return react.FunctionParams.factory({});
13
+ }
14
+ function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, keysFn = (name2) => name2 }) {
15
+ const path = new utils.URLPath(operation.path);
16
+ const params = getParams({ pathParamsType, typeSchemas });
17
+ const keys = [JSON.stringify({ url: path.path })].filter(Boolean);
18
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
19
+ /* @__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: `[${keysFn(keys).join(", ")}] as const` }) }),
20
+ /* @__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}>` }) })
21
+ ] });
22
+ }
23
+ MutationKey.getParams = getParams;
24
+ function getParams2({ pathParamsType, dataReturnType, typeSchemas, mutationKeyTypeName }) {
25
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
26
+ return react.FunctionParams.factory({
27
+ pathParams: {
28
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
29
+ children: utils$1.getPathParams(typeSchemas.pathParams, { typed: true })
30
+ },
31
+ params: typeSchemas.queryParams?.name ? {
32
+ type: typeSchemas.queryParams?.name,
33
+ optional: oas.isOptional(typeSchemas.queryParams?.schema)
34
+ } : void 0,
35
+ headers: typeSchemas.headerParams?.name ? {
36
+ type: typeSchemas.headerParams?.name,
37
+ optional: oas.isOptional(typeSchemas.headerParams?.schema)
38
+ } : void 0,
39
+ options: {
40
+ type: `
41
+ {
42
+ mutation?: Parameters<typeof useSWRMutation<${[TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error", mutationKeyTypeName, typeSchemas.request?.name].join(", ")}>>[2],
43
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>"},
44
+ shouldFetch?: boolean,
45
+ }
46
+ `,
47
+ default: "{}"
48
+ }
49
+ });
50
+ }
51
+ function Mutation({ name, clientName, mutationKeyName, mutationKeyTypeName, pathParamsType, dataReturnType, typeSchemas, operation }) {
52
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
53
+ const generics = [
54
+ TData,
55
+ typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error",
56
+ `${mutationKeyTypeName} | null`,
57
+ typeSchemas.request?.name
58
+ ].filter(Boolean);
59
+ const mutationKeyParams = MutationKey.getParams({
60
+ pathParamsType,
61
+ typeSchemas
62
+ });
63
+ const params = getParams2({
64
+ pathParamsType,
65
+ dataReturnType,
66
+ typeSchemas,
67
+ mutationKeyTypeName
68
+ });
69
+ const clientParams = components.Client.getParams({
70
+ typeSchemas,
71
+ pathParamsType
72
+ });
73
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(
74
+ react.Function,
75
+ {
76
+ name,
77
+ export: true,
78
+ params: params.toConstructor(),
79
+ JSDoc: {
80
+ comments: utils$1.getComments(operation)
81
+ },
82
+ children: `
83
+ const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}
84
+ const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})
85
+
86
+ return useSWRMutation<${generics}>(
87
+ shouldFetch ? mutationKey : null,
88
+ async (_url${typeSchemas.request?.name ? ", { arg: data }" : ""}) => {
89
+ return ${clientName}(${clientParams.toCall()})
90
+ },
91
+ mutationOptions
92
+ )
93
+ `
94
+ }
95
+ ) });
96
+ }
97
+ function getParams3({ pathParamsType, typeSchemas }) {
98
+ return react.FunctionParams.factory({
99
+ pathParams: {
100
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
101
+ children: utils$1.getPathParams(typeSchemas.pathParams, { typed: true })
102
+ },
103
+ data: typeSchemas.request?.name ? {
104
+ type: typeSchemas.request?.name,
105
+ optional: oas.isOptional(typeSchemas.request?.schema)
106
+ } : void 0,
107
+ params: typeSchemas.queryParams?.name ? {
108
+ type: typeSchemas.queryParams?.name,
109
+ optional: oas.isOptional(typeSchemas.queryParams?.schema)
110
+ } : void 0
111
+ });
112
+ }
113
+ function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, keysFn = (name2) => name2 }) {
114
+ const path = new utils.URLPath(operation.path);
115
+ const params = getParams3({ pathParamsType, typeSchemas });
116
+ const keys = [
117
+ path.toObject({
118
+ type: "path",
119
+ stringify: true
120
+ }),
121
+ typeSchemas.queryParams?.name ? "...(params ? [params] : [])" : void 0,
122
+ typeSchemas.request?.name ? "...(data ? [data] : [])" : void 0
123
+ ].filter(Boolean);
124
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
125
+ /* @__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: `[${keysFn(keys).join(", ")}] as const` }) }),
126
+ /* @__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}>` }) })
127
+ ] });
128
+ }
129
+ QueryKey.getParams = getParams3;
130
+ function getParams4({ pathParamsType, typeSchemas }) {
131
+ return react.FunctionParams.factory({
132
+ pathParams: {
133
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
134
+ children: utils$1.getPathParams(typeSchemas.pathParams, { typed: true })
135
+ },
136
+ data: typeSchemas.request?.name ? {
137
+ type: typeSchemas.request?.name,
138
+ optional: oas.isOptional(typeSchemas.request?.schema)
139
+ } : void 0,
140
+ params: typeSchemas.queryParams?.name ? {
141
+ type: typeSchemas.queryParams?.name,
142
+ optional: oas.isOptional(typeSchemas.queryParams?.schema)
143
+ } : void 0,
144
+ headers: typeSchemas.headerParams?.name ? {
145
+ type: typeSchemas.headerParams?.name,
146
+ optional: oas.isOptional(typeSchemas.headerParams?.schema)
147
+ } : void 0,
148
+ config: {
149
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>",
150
+ default: "{}"
151
+ }
152
+ });
153
+ }
154
+ function QueryOptions({ name, clientName, typeSchemas, pathParamsType }) {
155
+ const params = getParams4({ pathParamsType, typeSchemas });
156
+ const clientParams = components.Client.getParams({
157
+ typeSchemas,
158
+ pathParamsType
159
+ });
160
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function, { name, export: true, params: params.toConstructor(), children: `
161
+ return {
162
+ fetcher: async () => {
163
+ return ${clientName}(${clientParams.toCall()})
164
+ },
165
+ }
166
+ ` }) });
167
+ }
168
+ QueryOptions.getParams = getParams4;
169
+ function getParams5({ pathParamsType, dataReturnType, typeSchemas, queryKeyTypeName }) {
170
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
171
+ return react.FunctionParams.factory({
172
+ pathParams: {
173
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
174
+ children: utils$1.getPathParams(typeSchemas.pathParams, { typed: true })
175
+ },
176
+ data: typeSchemas.request?.name ? {
177
+ type: typeSchemas.request?.name,
178
+ optional: oas.isOptional(typeSchemas.request?.schema)
179
+ } : void 0,
180
+ params: typeSchemas.queryParams?.name ? {
181
+ type: typeSchemas.queryParams?.name,
182
+ optional: oas.isOptional(typeSchemas.queryParams?.schema)
183
+ } : void 0,
184
+ headers: typeSchemas.headerParams?.name ? {
185
+ type: typeSchemas.headerParams?.name,
186
+ optional: oas.isOptional(typeSchemas.headerParams?.schema)
187
+ } : void 0,
188
+ options: {
189
+ type: `
190
+ {
191
+ query?: Parameters<typeof useSWR<${[TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error", `${queryKeyTypeName} | null`].join(", ")}, any>>[2],
192
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>"},
193
+ shouldFetch?: boolean,
194
+ }
195
+ `,
196
+ default: "{}"
197
+ }
198
+ });
199
+ }
200
+ function Query({ name, typeSchemas, queryKeyName, queryKeyTypeName, queryOptionsName, operation, dataReturnType, pathParamsType }) {
201
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
202
+ const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error", `${queryKeyTypeName} | null`];
203
+ const queryKeyParams = QueryKey.getParams({
204
+ pathParamsType,
205
+ typeSchemas
206
+ });
207
+ const params = getParams5({
208
+ pathParamsType,
209
+ dataReturnType,
210
+ typeSchemas,
211
+ queryKeyTypeName
212
+ });
213
+ const queryOptionsParams = QueryOptions.getParams({
214
+ pathParamsType,
215
+ typeSchemas
216
+ });
217
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(
218
+ react.Function,
219
+ {
220
+ name,
221
+ export: true,
222
+ params: params.toConstructor(),
223
+ JSDoc: {
224
+ comments: utils$1.getComments(operation)
225
+ },
226
+ children: `
227
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {}
228
+
229
+ const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
230
+
231
+ return useSWR<${generics.join(", ")}>(
232
+ shouldFetch ? queryKey : null,
233
+ {
234
+ ...${queryOptionsName}(${queryOptionsParams.toCall()})
235
+ ...queryOptions
236
+ }
237
+ )
238
+ `
239
+ }
240
+ ) });
241
+ }
242
+
243
+ exports.Mutation = Mutation;
244
+ exports.MutationKey = MutationKey;
245
+ exports.Query = Query;
246
+ exports.QueryKey = QueryKey;
247
+ exports.QueryOptions = QueryOptions;
248
+ //# sourceMappingURL=chunk-JWGWABV5.cjs.map
249
+ //# sourceMappingURL=chunk-JWGWABV5.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","name","URLPath","jsxs","Fragment","jsx","File","Function","Type","getParams","getPathParams","isOptional","Client","getComments"],"mappings":";;;;;;;;;;AAsBA,SAAS,SAAA,CAAU,EAAoB,EAAA;AACrC,EAAO,OAAAA,oBAAA,CAAe,OAAQ,CAAA,EAAE,CAAA,CAAA;AAClC,CAAA;AAEO,SAAS,WAAA,CAAY,EAAE,IAAA,EAAM,WAAa,EAAA,cAAA,EAAgB,SAAW,EAAA,QAAA,EAAU,MAAS,GAAA,CAACC,KAASA,KAAAA,KAAAA,EAA0B,EAAA;AACjI,EAAA,MAAM,IAAO,GAAA,IAAIC,aAAQ,CAAA,SAAA,CAAU,IAAI,CAAA,CAAA;AACvC,EAAA,MAAM,MAAS,GAAA,SAAA,CAAU,EAAE,cAAA,EAAgB,aAAa,CAAA,CAAA;AACxD,EAAA,MAAM,IAAO,GAAA,CAAC,IAAK,CAAA,SAAA,CAAU,EAAE,GAAA,EAAK,IAAK,CAAA,IAAA,EAAM,CAAC,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA,CAAA;AAEhE,EAAA,uBAEIC,eAAA,CAAAC,mBAAA,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAAC,cAAA,CAACC,UAAK,CAAA,MAAA,EAAL,EAAY,IAAA,EAAY,YAAY,EAAA,IAAA,EAAC,WAAW,EAAA,IAAA,EAC/C,QAAC,kBAAAD,cAAA,CAAAE,cAAA,CAAS,KAAT,EAAA,EAAe,IAAY,EAAA,MAAA,EAAM,IAAC,EAAA,MAAA,EAAQ,MAAO,CAAA,aAAA,EAAiB,EAAA,UAAA,EAAU,IAC1E,EAAA,QAAA,EAAA,CAAA,CAAA,EAAI,MAAO,CAAA,IAAI,CAAE,CAAA,IAAA,CAAK,IAAI,CAAC,cAC9B,CACF,EAAA,CAAA;AAAA,oBACAF,cAAA,CAACC,WAAK,MAAL,EAAA,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AChD,cAAA;AAAA,IACA,WAAA;AAAA,GACD,CAAA,CAAA;AAED,EACE,uBAAAJ,cAACC,CAAAA,UAAAA,CAAK,MAAL,EAAA,EAAY,MAAY,YAAY,EAAA,IAAA,EAAC,WAAW,EAAA,IAAA,EAC/C,QAAAD,kBAAAA,cAAAA;AAAA,IAACE,cAAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,MAAM,EAAA,IAAA;AAAA,MACN,MAAA,EAAQ,OAAO,aAAc,EAAA;AAAA,MAC7B,KAAO,EAAA;AAAA,QACL,QAAA,EAAUM,oBAAY,SAAS,CAAA;AAAA,OACjC;AAAA,MAEC,QAAA,EAAA,CAAA;AAAA;AAAA;AAAA,wBAAA,EAGiB,YAAY,CAAA,CAAA,EAAI,cAAe,CAAA,MAAA,EAAQ,CAAA;AAAA;AAAA,qBAE1C,EAAA,QAAA,CAAS,IAAK,CAAA,IAAI,CAAC,CAAA;AAAA;AAAA;AAAA,aAAA,EAG3B,gBAAgB,CAAA,CAAA,EAAI,kBAAmB,CAAA,MAAA,EAAQ,CAAA;AAAA;AAAA;AAAA;AAAA,OAAA,CAAA;AAAA,KAAA;AAAA,GAM1D,EAAA,CAAA,CAAA;AAEJ","file":"chunk-JWGWABV5.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 } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n keysFn: ((keys: unknown[]) => unknown[]) | undefined\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({}: GetParamsProps) {\n return FunctionParams.factory({})\n}\n\nexport function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, keysFn = (name) => name }: Props): ReactNode {\n const path = new URLPath(operation.path)\n const params = getParams({ pathParamsType, typeSchemas })\n const keys = [JSON.stringify({ url: path.path })].filter(Boolean)\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keysFn(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\n","import { URLPath } from '@kubb/core/utils'\nimport { 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 dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n mutationKeyTypeName: string\n}\n\nfunction getParams({ pathParamsType, 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 }),\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({ name, clientName, mutationKeyName, mutationKeyTypeName, pathParamsType, dataReturnType, typeSchemas, operation }: 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,\n ].filter(Boolean)\n\n const mutationKeyParams = MutationKey.getParams({\n pathParamsType,\n typeSchemas,\n })\n\n const params = getParams({\n pathParamsType,\n dataReturnType,\n typeSchemas,\n mutationKeyTypeName,\n })\n\n const clientParams = Client.getParams({\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 } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n keysFn: ((keys: unknown[]) => unknown[]) | undefined\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true }),\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\nexport function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, keysFn = (name) => name }: Props): ReactNode {\n const path = new URLPath(operation.path)\n const params = getParams({ pathParamsType, typeSchemas })\n const keys = [\n path.toObject({\n type: 'path',\n stringify: true,\n }),\n typeSchemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,\n typeSchemas.request?.name ? '...(data ? [data] : [])' : undefined,\n ].filter(Boolean)\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keysFn(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\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 pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true }),\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 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, pathParamsType }: Props): ReactNode {\n const params = getParams({ pathParamsType, typeSchemas })\n const clientParams = Client.getParams({\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 pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n operation: Operation\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n queryKeyTypeName: string\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, dataReturnType, typeSchemas, queryKeyTypeName }: 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 }),\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 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({ name, typeSchemas, queryKeyName, queryKeyTypeName, queryOptionsName, operation, dataReturnType, pathParamsType }: 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 })\n const params = getParams({\n pathParamsType,\n dataReturnType,\n typeSchemas,\n queryKeyTypeName,\n })\n\n const queryOptionsParams = QueryOptions.getParams({\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"]}
@@ -0,0 +1,220 @@
1
+ 'use strict';
2
+
3
+ var chunkJWGWABV5_cjs = require('./chunk-JWGWABV5.cjs');
4
+ require('@kubb/core/transformers');
5
+ var pluginClient = require('@kubb/plugin-client');
6
+ var components = require('@kubb/plugin-client/components');
7
+ var pluginOas = require('@kubb/plugin-oas');
8
+ var hooks = require('@kubb/plugin-oas/hooks');
9
+ var pluginTs = require('@kubb/plugin-ts');
10
+ var pluginZod = require('@kubb/plugin-zod');
11
+ var react = require('@kubb/react');
12
+ var jsxRuntime = require('@kubb/react/jsx-runtime');
13
+
14
+ var queryGenerator = pluginOas.createReactGenerator({
15
+ name: "swr-query",
16
+ Operation({ options, operation }) {
17
+ const {
18
+ plugin: {
19
+ options: { output }
20
+ }
21
+ } = react.useApp();
22
+ const { getSchemas, getName, getFile } = hooks.useOperationManager();
23
+ const isQuery = typeof options.query === "boolean" ? options.query : !!options.query.methods?.some((method) => operation.method === method);
24
+ const query = {
25
+ name: getName(operation, { type: "function", prefix: "use" }),
26
+ typeName: getName(operation, { type: "type" }),
27
+ file: getFile(operation, { prefix: "use" })
28
+ };
29
+ const client = {
30
+ name: getName(operation, { type: "function", pluginKey: [pluginClient.pluginClientName] })
31
+ };
32
+ const queryOptions = {
33
+ name: getName(operation, { type: "function", suffix: "QueryOptions" })
34
+ };
35
+ const queryKey = {
36
+ name: getName(operation, { type: "const", suffix: "QueryKey" }),
37
+ typeName: getName(operation, { type: "type", suffix: "QueryKey" })
38
+ };
39
+ const type = {
40
+ file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
41
+ //todo remove type?
42
+ schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
43
+ };
44
+ const zod = {
45
+ file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
46
+ schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
47
+ };
48
+ if (!isQuery) {
49
+ return null;
50
+ }
51
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
52
+ options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
53
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "useSWR", path: options.query.importPath }),
54
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["SWRResponse"], path: options.query.importPath, isTypeOnly: true }),
55
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
56
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
57
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
58
+ /* @__PURE__ */ jsxRuntime.jsx(
59
+ react.File.Import,
60
+ {
61
+ name: [
62
+ type.schemas.request?.name,
63
+ type.schemas.response.name,
64
+ type.schemas.pathParams?.name,
65
+ type.schemas.queryParams?.name,
66
+ type.schemas.headerParams?.name,
67
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
68
+ ].filter(Boolean),
69
+ root: query.file.path,
70
+ path: type.file.path,
71
+ isTypeOnly: true
72
+ }
73
+ ),
74
+ /* @__PURE__ */ jsxRuntime.jsx(
75
+ chunkJWGWABV5_cjs.QueryKey,
76
+ {
77
+ name: queryKey.name,
78
+ typeName: queryKey.typeName,
79
+ operation,
80
+ pathParamsType: options.pathParamsType,
81
+ typeSchemas: type.schemas,
82
+ keysFn: options.query.key
83
+ }
84
+ ),
85
+ /* @__PURE__ */ jsxRuntime.jsx(
86
+ components.Client,
87
+ {
88
+ name: client.name,
89
+ isExportable: false,
90
+ isIndexable: false,
91
+ baseURL: options.baseURL,
92
+ operation,
93
+ typeSchemas: type.schemas,
94
+ zodSchemas: zod.schemas,
95
+ dataReturnType: options.client.dataReturnType,
96
+ pathParamsType: options.pathParamsType,
97
+ parser: options.parser
98
+ }
99
+ ),
100
+ /* @__PURE__ */ jsxRuntime.jsx(chunkJWGWABV5_cjs.QueryOptions, { name: queryOptions.name, clientName: client.name, typeSchemas: type.schemas, pathParamsType: options.pathParamsType }),
101
+ /* @__PURE__ */ jsxRuntime.jsx(
102
+ chunkJWGWABV5_cjs.Query,
103
+ {
104
+ name: query.name,
105
+ queryOptionsName: queryOptions.name,
106
+ typeSchemas: type.schemas,
107
+ pathParamsType: options.pathParamsType,
108
+ operation,
109
+ dataReturnType: options.client.dataReturnType,
110
+ queryKeyName: queryKey.name,
111
+ queryKeyTypeName: queryKey.typeName
112
+ }
113
+ )
114
+ ] });
115
+ }
116
+ });
117
+ var mutationGenerator = pluginOas.createReactGenerator({
118
+ name: "swr-mutation",
119
+ Operation({ options, operation }) {
120
+ const {
121
+ plugin: {
122
+ options: { output }
123
+ }
124
+ } = react.useApp();
125
+ const { getSchemas, getName, getFile } = hooks.useOperationManager();
126
+ const isMutate = typeof options.query === "boolean" ? options.mutation : !!options.mutation.methods?.some((method) => operation.method === method);
127
+ const mutation = {
128
+ name: getName(operation, { type: "function", prefix: "use" }),
129
+ typeName: getName(operation, { type: "type" }),
130
+ file: getFile(operation, { prefix: "use" })
131
+ };
132
+ const type = {
133
+ file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
134
+ //todo remove type?
135
+ schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
136
+ };
137
+ const zod = {
138
+ file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
139
+ schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
140
+ };
141
+ const client = {
142
+ name: getName(operation, { type: "function", pluginKey: [pluginClient.pluginClientName] })
143
+ };
144
+ const mutationKey = {
145
+ name: getName(operation, { type: "const", suffix: "MutationKey" }),
146
+ typeName: getName(operation, { type: "type", suffix: "MutationKey" })
147
+ };
148
+ if (!isMutate) {
149
+ return null;
150
+ }
151
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: mutation.file.baseName, path: mutation.file.path, meta: mutation.file.meta, banner: output?.banner, footer: output?.footer, children: [
152
+ options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: mutation.file.path, path: zod.file.path }),
153
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "useSWRMutation", path: options.mutation.importPath }),
154
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["SWRMutationResponse"], path: options.mutation.importPath, isTypeOnly: true }),
155
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
156
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
157
+ /* @__PURE__ */ jsxRuntime.jsx(
158
+ react.File.Import,
159
+ {
160
+ name: [
161
+ type.schemas.request?.name,
162
+ type.schemas.response.name,
163
+ type.schemas.pathParams?.name,
164
+ type.schemas.queryParams?.name,
165
+ type.schemas.headerParams?.name,
166
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
167
+ ].filter(Boolean),
168
+ root: mutation.file.path,
169
+ path: type.file.path,
170
+ isTypeOnly: true
171
+ }
172
+ ),
173
+ /* @__PURE__ */ jsxRuntime.jsx(
174
+ chunkJWGWABV5_cjs.MutationKey,
175
+ {
176
+ name: mutationKey.name,
177
+ typeName: mutationKey.typeName,
178
+ operation,
179
+ pathParamsType: options.pathParamsType,
180
+ typeSchemas: type.schemas,
181
+ keysFn: options.mutation.key
182
+ }
183
+ ),
184
+ /* @__PURE__ */ jsxRuntime.jsx(
185
+ components.Client,
186
+ {
187
+ name: client.name,
188
+ isExportable: false,
189
+ isIndexable: false,
190
+ baseURL: options.baseURL,
191
+ operation,
192
+ typeSchemas: type.schemas,
193
+ zodSchemas: zod.schemas,
194
+ dataReturnType: options.client.dataReturnType,
195
+ pathParamsType: options.pathParamsType,
196
+ parser: options.parser
197
+ }
198
+ ),
199
+ /* @__PURE__ */ jsxRuntime.jsx(
200
+ chunkJWGWABV5_cjs.Mutation,
201
+ {
202
+ name: mutation.name,
203
+ clientName: client.name,
204
+ typeName: mutation.typeName,
205
+ typeSchemas: type.schemas,
206
+ operation,
207
+ dataReturnType: options.client.dataReturnType,
208
+ pathParamsType: options.pathParamsType,
209
+ mutationKeyName: mutationKey.name,
210
+ mutationKeyTypeName: mutationKey.typeName
211
+ }
212
+ )
213
+ ] });
214
+ }
215
+ });
216
+
217
+ exports.mutationGenerator = mutationGenerator;
218
+ exports.queryGenerator = queryGenerator;
219
+ //# sourceMappingURL=chunk-PTOQHHST.cjs.map
220
+ //# sourceMappingURL=chunk-PTOQHHST.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generators/queryGenerator.tsx","../src/generators/mutationGenerator.tsx"],"names":["createReactGenerator","useApp","useOperationManager","pluginClientName","pluginTsName","pluginZodName","File","jsx","QueryKey","Client","QueryOptions","Query","jsxs","MutationKey","Mutation"],"mappings":";;;;;;;;;;;;;AAYO,IAAM,iBAAiBA,8BAAgC,CAAA;AAAA,EAC5D,IAAM,EAAA,WAAA;AAAA,EACN,SAAU,CAAA,EAAE,OAAS,EAAA,SAAA,EAAa,EAAA;AAChC,IAAM,MAAA;AAAA,MACJ,MAAQ,EAAA;AAAA,QACN,OAAA,EAAS,EAAE,MAAO,EAAA;AAAA,OACpB;AAAA,QACEC,YAAkB,EAAA,CAAA;AACtB,IAAA,MAAM,EAAE,UAAA,EAAY,OAAS,EAAA,OAAA,KAAYC,yBAAoB,EAAA,CAAA;AAE7D,IAAA,MAAM,UAAU,OAAO,OAAA,CAAQ,KAAU,KAAA,SAAA,GAAY,QAAQ,KAAQ,GAAA,CAAC,CAAC,OAAA,CAAQ,MAAM,OAAS,EAAA,IAAA,CAAK,CAAC,MAAW,KAAA,SAAA,CAAU,WAAW,MAAM,CAAA,CAAA;AAE1I,IAAA,MAAM,KAAQ,GAAA;AAAA,MACZ,IAAA,EAAM,QAAQ,SAAW,EAAA,EAAE,MAAM,UAAY,EAAA,MAAA,EAAQ,OAAO,CAAA;AAAA,MAC5D,UAAU,OAAQ,CAAA,SAAA,EAAW,EAAE,IAAA,EAAM,QAAQ,CAAA;AAAA,MAC7C,MAAM,OAAQ,CAAA,SAAA,EAAW,EAAE,MAAA,EAAQ,OAAO,CAAA;AAAA,KAC5C,CAAA;AAEA,IAAA,MAAM,MAAS,GAAA;AAAA,MACb,IAAA,EAAM,OAAQ,CAAA,SAAA,EAAW,EAAE,IAAA,EAAM,YAAY,SAAW,EAAA,CAACC,6BAAgB,CAAA,EAAG,CAAA;AAAA,KAC9E,CA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,QAAA;AAAA,UACnB,aAAa,IAAK,CAAA,OAAA;AAAA,UAClB,SAAA;AAAA,UACA,cAAA,EAAgB,QAAQ,MAAO,CAAA,cAAA;AAAA,UAC/B,gBAAgB,OAAQ,CAAA,cAAA;AAAA,UACxB,iBAAiB,WAAY,CAAA,IAAA;AAAA,UAC7B,qBAAqB,WAAY,CAAA,QAAA;AAAA,SAAA;AAAA,OACnC;AAAA,KACF,EAAA,CAAA,CAAA;AAAA,GAEJ;AACF,CAAC","file":"chunk-PTOQHHST.cjs","sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { Query, QueryOptions } from '../components'\nimport { QueryKey } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n } = useApp<PluginSwr>()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = typeof options.query === 'boolean' ? options.query : !!options.query.methods?.some((method) => operation.method === method)\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\n }\n\n const client = {\n name: getName(operation, { type: 'function', pluginKey: [pluginClientName] }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),\n }\n const queryKey = {\n name: getName(operation, { type: 'const', suffix: 'QueryKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'QueryKey' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n if (!isQuery) {\n return null\n }\n\n return (\n <File baseName={query.file.baseName} path={query.file.path} meta={query.file.meta} banner={output?.banner} footer={output?.footer}>\n {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={query.file.path} path={zod.file.path} />}\n <File.Import name=\"useSWR\" path={options.query.importPath} />\n <File.Import name={['SWRResponse']} path={options.query.importPath} isTypeOnly />\n <File.Import name={'client'} path={options.client.importPath} />\n <File.Import name={['RequestConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n keysFn={options.query.key}\n />\n <Client\n name={client.name}\n isExportable={false}\n isIndexable={false}\n baseURL={options.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n <QueryOptions name={queryOptions.name} clientName={client.name} typeSchemas={type.schemas} pathParamsType={options.pathParamsType} />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n pathParamsType={options.pathParamsType}\n operation={operation}\n dataReturnType={options.client.dataReturnType}\n queryKeyName={queryKey.name}\n queryKeyTypeName={queryKey.typeName}\n />\n </File>\n )\n },\n})\n","import transformers from '@kubb/core/transformers'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { MutationKey } from '../components'\nimport { Mutation } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const mutationGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-mutation',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n } = useApp<PluginSwr>()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isMutate = typeof options.query === 'boolean' ? options.mutation : !!options.mutation.methods?.some((method) => operation.method === method)\n\n const mutation = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n const client = {\n name: getName(operation, { type: 'function', pluginKey: [pluginClientName] }),\n }\n\n const mutationKey = {\n name: getName(operation, { type: 'const', suffix: 'MutationKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'MutationKey' }),\n }\n\n if (!isMutate) {\n return null\n }\n\n return (\n <File baseName={mutation.file.baseName} path={mutation.file.path} meta={mutation.file.meta} banner={output?.banner} footer={output?.footer}>\n {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={mutation.file.path} path={zod.file.path} />}\n <File.Import name=\"useSWRMutation\" path={options.mutation.importPath} />\n <File.Import name={['SWRMutationResponse']} path={options.mutation.importPath} isTypeOnly />\n <File.Import name={'client'} path={options.client.importPath} />\n <File.Import name={['RequestConfig', 'ResponseConfig']} path={options.client.importPath} isTypeOnly />\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={mutation.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <MutationKey\n name={mutationKey.name}\n typeName={mutationKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n keysFn={options.mutation.key}\n />\n <Client\n name={client.name}\n isExportable={false}\n isIndexable={false}\n baseURL={options.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n <Mutation\n name={mutation.name}\n clientName={client.name}\n typeName={mutation.typeName}\n typeSchemas={type.schemas}\n operation={operation}\n dataReturnType={options.client.dataReturnType}\n pathParamsType={options.pathParamsType}\n mutationKeyName={mutationKey.name}\n mutationKeyTypeName={mutationKey.typeName}\n />\n </File>\n )\n },\n})\n"]}
@@ -1,11 +1,28 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ 'use strict';
2
2
 
3
+ var chunkJWGWABV5_cjs = require('./chunk-JWGWABV5.cjs');
3
4
 
4
5
 
5
- var _chunkTGLXUPN4cjs = require('./chunk-TGLXUPN4.cjs');
6
6
 
7
-
8
-
9
-
10
- exports.Mutation = _chunkTGLXUPN4cjs.Mutation; exports.Query = _chunkTGLXUPN4cjs.Query; exports.QueryOptions = _chunkTGLXUPN4cjs.QueryOptions;
7
+ Object.defineProperty(exports, "Mutation", {
8
+ enumerable: true,
9
+ get: function () { return chunkJWGWABV5_cjs.Mutation; }
10
+ });
11
+ Object.defineProperty(exports, "MutationKey", {
12
+ enumerable: true,
13
+ get: function () { return chunkJWGWABV5_cjs.MutationKey; }
14
+ });
15
+ Object.defineProperty(exports, "Query", {
16
+ enumerable: true,
17
+ get: function () { return chunkJWGWABV5_cjs.Query; }
18
+ });
19
+ Object.defineProperty(exports, "QueryKey", {
20
+ enumerable: true,
21
+ get: function () { return chunkJWGWABV5_cjs.QueryKey; }
22
+ });
23
+ Object.defineProperty(exports, "QueryOptions", {
24
+ enumerable: true,
25
+ get: function () { return chunkJWGWABV5_cjs.QueryOptions; }
26
+ });
27
+ //# sourceMappingURL=components.cjs.map
11
28
  //# sourceMappingURL=components.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-swr/dist/components.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,8IAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-swr/dist/components.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"components.cjs"}