@kubb/plugin-swr 3.0.0-alpha.15 → 3.0.0-alpha.17

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 (55) hide show
  1. package/dist/chunk-7WG6LPZJ.js +185 -0
  2. package/dist/chunk-7WG6LPZJ.js.map +1 -0
  3. package/dist/chunk-I5VDRAOG.cjs +190 -0
  4. package/dist/chunk-I5VDRAOG.cjs.map +1 -0
  5. package/dist/chunk-M27MSL33.js +183 -0
  6. package/dist/chunk-M27MSL33.js.map +1 -0
  7. package/dist/chunk-RMG5RYPG.cjs +189 -0
  8. package/dist/chunk-RMG5RYPG.cjs.map +1 -0
  9. package/dist/components.cjs +4 -4
  10. package/dist/components.d.cts +49 -5
  11. package/dist/components.d.ts +49 -5
  12. package/dist/components.js +1 -1
  13. package/dist/generators.cjs +17 -0
  14. package/dist/generators.cjs.map +1 -0
  15. package/dist/generators.d.cts +11 -0
  16. package/dist/generators.d.ts +11 -0
  17. package/dist/generators.js +4 -0
  18. package/dist/generators.js.map +1 -0
  19. package/dist/index.cjs +48 -74
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +2 -4
  22. package/dist/index.d.ts +2 -4
  23. package/dist/index.js +49 -75
  24. package/dist/index.js.map +1 -1
  25. package/dist/types-DdD2A6IQ.d.cts +143 -0
  26. package/dist/types-DdD2A6IQ.d.ts +143 -0
  27. package/package.json +23 -15
  28. package/src/components/Mutation.tsx +82 -212
  29. package/src/components/Query.tsx +86 -256
  30. package/src/components/QueryOptions.tsx +54 -177
  31. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +43 -0
  32. package/src/generators/__snapshots__/clientGetImportPath.ts +43 -0
  33. package/src/generators/__snapshots__/clientPostImportPath.ts +38 -0
  34. package/src/generators/__snapshots__/findByTags.ts +43 -0
  35. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +43 -0
  36. package/src/generators/__snapshots__/findByTagsWithZod.ts +43 -0
  37. package/src/generators/__snapshots__/getAsMutation.ts +39 -0
  38. package/src/generators/__snapshots__/postAsQuery.ts +47 -0
  39. package/src/generators/__snapshots__/updatePetById.ts +38 -0
  40. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +50 -0
  41. package/src/generators/index.ts +2 -0
  42. package/src/generators/mutationGenerator.tsx +94 -0
  43. package/src/generators/queryGenerator.tsx +99 -0
  44. package/src/plugin.ts +49 -28
  45. package/src/types.ts +57 -28
  46. package/dist/chunk-3AS6MQON.cjs +0 -512
  47. package/dist/chunk-3AS6MQON.cjs.map +0 -1
  48. package/dist/chunk-J3HYPMUC.js +0 -504
  49. package/dist/chunk-J3HYPMUC.js.map +0 -1
  50. package/dist/index-B3C-JOIU.d.cts +0 -299
  51. package/dist/index-B3C-JOIU.d.ts +0 -299
  52. package/src/OperationGenerator.tsx +0 -75
  53. package/src/components/SchemaType.tsx +0 -79
  54. package/src/components/__snapshots__/Mutation/Pets.ts +0 -46
  55. package/src/components/__snapshots__/Query/showPetById.ts +0 -59
@@ -0,0 +1,185 @@
1
+ import { URLPath } from '@kubb/core/utils';
2
+ import { File, Function, FunctionParams } from '@kubb/react';
3
+ import { isOptional } from '@kubb/oas';
4
+ import { Client } from '@kubb/plugin-client/components';
5
+ import { getComments, getPathParams } from '@kubb/plugin-oas/utils';
6
+ import { jsx } from '@kubb/react/jsx-runtime';
7
+
8
+ // src/components/Mutation.tsx
9
+ function getParams({ pathParamsType, dataReturnType, typeSchemas }) {
10
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
11
+ return FunctionParams.factory({
12
+ pathParams: {
13
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
14
+ children: getPathParams(typeSchemas.pathParams, { typed: true })
15
+ },
16
+ params: typeSchemas.queryParams?.name ? {
17
+ type: typeSchemas.queryParams?.name,
18
+ optional: isOptional(typeSchemas.queryParams?.schema)
19
+ } : void 0,
20
+ headers: typeSchemas.headerParams?.name ? {
21
+ type: typeSchemas.headerParams?.name,
22
+ optional: isOptional(typeSchemas.headerParams?.schema)
23
+ } : void 0,
24
+ options: {
25
+ type: `
26
+ {
27
+ mutation?: SWRMutationConfiguration<${[TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "unknown"].join(", ")}>,
28
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>"},
29
+ shouldFetch?: boolean,
30
+ }
31
+ `,
32
+ default: "{}"
33
+ }
34
+ });
35
+ }
36
+ function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation }) {
37
+ const path = new URLPath(operation.path);
38
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
39
+ const hookGenerics = [TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "unknown", "Key"];
40
+ const params = getParams({
41
+ pathParamsType,
42
+ dataReturnType,
43
+ typeSchemas
44
+ });
45
+ const clientParams = Client.getParams({
46
+ typeSchemas,
47
+ pathParamsType
48
+ });
49
+ const swrKey = [path.template, typeSchemas.queryParams?.name ? "params" : void 0].filter(Boolean);
50
+ return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(
51
+ Function,
52
+ {
53
+ name,
54
+ export: true,
55
+ params: params.toConstructor(),
56
+ JSDoc: {
57
+ comments: getComments(operation)
58
+ },
59
+ children: `
60
+ const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}
61
+
62
+ const swrKey = [${swrKey.join(", ")}] as const
63
+ return useSWRMutation<${hookGenerics}>(
64
+ shouldFetch ? swrKey : null,
65
+ async (_url${typeSchemas.request?.name ? ", { arg: data }" : ""}) => {
66
+ return ${clientName}(${clientParams.toCall()})
67
+ },
68
+ mutationOptions
69
+ )
70
+ `
71
+ }
72
+ ) });
73
+ }
74
+ function getParams2({ pathParamsType, typeSchemas }) {
75
+ return FunctionParams.factory({
76
+ pathParams: {
77
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
78
+ children: getPathParams(typeSchemas.pathParams, { typed: true })
79
+ },
80
+ data: typeSchemas.request?.name ? {
81
+ type: typeSchemas.request?.name,
82
+ optional: isOptional(typeSchemas.request?.schema)
83
+ } : void 0,
84
+ params: typeSchemas.queryParams?.name ? {
85
+ type: typeSchemas.queryParams?.name,
86
+ optional: isOptional(typeSchemas.queryParams?.schema)
87
+ } : void 0,
88
+ headers: typeSchemas.headerParams?.name ? {
89
+ type: typeSchemas.headerParams?.name,
90
+ optional: isOptional(typeSchemas.headerParams?.schema)
91
+ } : void 0,
92
+ config: {
93
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>",
94
+ default: "{}"
95
+ }
96
+ });
97
+ }
98
+ function QueryOptions({ name, clientName, typeSchemas, pathParamsType }) {
99
+ const params = getParams2({ pathParamsType, typeSchemas });
100
+ const clientParams = Client.getParams({
101
+ typeSchemas,
102
+ pathParamsType
103
+ });
104
+ return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function, { name, export: true, params: params.toConstructor(), children: `
105
+ return {
106
+ fetcher: async () => {
107
+ return ${clientName}(${clientParams.toCall()})
108
+ },
109
+ }
110
+ ` }) });
111
+ }
112
+ QueryOptions.getParams = getParams2;
113
+ function getParams3({ pathParamsType, dataReturnType, typeSchemas }) {
114
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
115
+ return FunctionParams.factory({
116
+ pathParams: {
117
+ mode: pathParamsType === "object" ? "object" : "inlineSpread",
118
+ children: getPathParams(typeSchemas.pathParams, { typed: true })
119
+ },
120
+ data: typeSchemas.request?.name ? {
121
+ type: typeSchemas.request?.name,
122
+ optional: isOptional(typeSchemas.request?.schema)
123
+ } : void 0,
124
+ params: typeSchemas.queryParams?.name ? {
125
+ type: typeSchemas.queryParams?.name,
126
+ optional: isOptional(typeSchemas.queryParams?.schema)
127
+ } : void 0,
128
+ headers: typeSchemas.headerParams?.name ? {
129
+ type: typeSchemas.headerParams?.name,
130
+ optional: isOptional(typeSchemas.headerParams?.schema)
131
+ } : void 0,
132
+ options: {
133
+ type: `
134
+ {
135
+ query?: SWRConfiguration<${[TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "unknown"].join(", ")}>,
136
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : "Partial<RequestConfig>"},
137
+ shouldFetch?: boolean,
138
+ }
139
+ `,
140
+ default: "{}"
141
+ }
142
+ });
143
+ }
144
+ function Query({ name, typeSchemas, queryOptionsName, operation, dataReturnType, pathParamsType }) {
145
+ const path = new URLPath(operation.path);
146
+ const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
147
+ const hookGenerics = [TData, typeSchemas.errors?.map((item) => item.name).join(" | ") || "unknown", "Key"];
148
+ const params = getParams3({
149
+ pathParamsType,
150
+ dataReturnType,
151
+ typeSchemas
152
+ });
153
+ const queryOptionsParams = QueryOptions.getParams({
154
+ pathParamsType,
155
+ typeSchemas
156
+ });
157
+ const swrKey = [path.template, typeSchemas.queryParams?.name ? "params" : void 0].filter(Boolean);
158
+ return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(
159
+ Function,
160
+ {
161
+ name,
162
+ export: true,
163
+ params: params.toConstructor(),
164
+ JSDoc: {
165
+ comments: getComments(operation)
166
+ },
167
+ children: `
168
+ const { query: queryOptions, client: config = {}, shouldFetch = true } = options ?? {}
169
+
170
+ const swrKey = [${swrKey.join(", ")}] as const
171
+ return useSWR<${hookGenerics.join(", ")}>(
172
+ shouldFetch ? swrKey : null,
173
+ {
174
+ ...${queryOptionsName}(${queryOptionsParams.toCall()})
175
+ ...queryOptions
176
+ }
177
+ )
178
+ `
179
+ }
180
+ ) });
181
+ }
182
+
183
+ export { Mutation, Query, QueryOptions };
184
+ //# sourceMappingURL=chunk-7WG6LPZJ.js.map
185
+ //# sourceMappingURL=chunk-7WG6LPZJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Mutation.tsx","../src/components/QueryOptions.tsx","../src/components/Query.tsx"],"names":["getParams","FunctionParams","getPathParams","isOptional","Client","jsx","File","Function","URLPath","getComments"],"mappings":";;;;;;;;AA6BA,SAAS,SAAU,CAAA,EAAE,cAAgB,EAAA,cAAA,EAAgB,aAA+B,EAAA;AAClF,EAAM,MAAA,KAAA,GAAQ,mBAAmB,MAAS,GAAA,WAAA,CAAY,SAAS,IAAO,GAAA,CAAA,eAAA,EAAkB,WAAY,CAAA,QAAA,CAAS,IAAI,CAAA,CAAA,CAAA,CAAA;AAEjH,EAAA,OAAO,eAAe,OAAQ,CAAA;AAAA,IAC5B,UAAY,EAAA;AAAA,MACV,IAAA,EAAM,cAAmB,KAAA,QAAA,GAAW,QAAW,GAAA,cAAA;AAAA,MAC/C,UAAU,aAAc,CAAA,WAAA,CAAY,YAAY,EAAE,KAAA,EAAO,MAAM,CAAA;AAAA,KACjE;AAAA,IACA,MAAA,EAAQ,WAAY,CAAA,WAAA,EAAa,IAC7B,GAAA;AAAA,MACE,IAAA,EAAM,YAAY,WAAa,EAAA,IAAA;AAAA,MAC/B,QAAU,EAAA,UAAA,CAAW,WAAY,CAAA,WAAA,EAAa,MAAM,CAAA;AAAA,KAEtD,GAAA,KAAA,CAAA;AAAA,IACJ,OAAA,EAAS,WAAY,CAAA,YAAA,EAAc,IAC/B,GAAA;AAAA,MACE,IAAA,EAAM,YAAY,YAAc,EAAA,IAAA;AAAA,MAChC,QAAU,EAAA,UAAA,CAAW,WAAY,CAAA,YAAA,EAAc,MAAM,CAAA;AAAA,KAEvD,GAAA,KAAA,CAAA;AAAA,IACJ,OAAS,EAAA;AAAA,MACP,IAAM,EAAA,CAAA;AAAA;AAAA,sCAAA,EAE4B,CAAC,KAAO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AM,MAAA,MAAA,GAAS,CAAC,IAAA,CAAK,QAAU,EAAA,WAAA,CAAY,WAAa,EAAA,IAAA,GAAO,QAAW,GAAA,KAAA,CAAS,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA,CAAA;AAEnG,EACE,uBAAAK,GAACC,CAAAA,IAAAA,CAAK,MAAL,EAAA,EAAY,MAAY,YAAY,EAAA,IAAA,EAAC,WAAW,EAAA,IAAA,EAC/C,QAAAD,kBAAAA,GAAAA;AAAA,IAACE,QAAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,MAAM,EAAA,IAAA;AAAA,MACN,MAAA,EAAQ,OAAO,aAAc,EAAA;AAAA,MAC7B,KAAO,EAAA;AAAA,QACL,QAAA,EAAUE,YAAY,SAAS,CAAA;AAAA,OACjC;AAAA,MAEC,QAAA,EAAA,CAAA;AAAA;AAAA;AAAA,uBAGgB,EAAA,MAAA,CAAO,IAAK,CAAA,IAAI,CAAC,CAAA;AAAA,qBACnB,EAAA,YAAA,CAAa,IAAK,CAAA,IAAI,CAAC,CAAA;AAAA;AAAA;AAAA,aAAA,EAG/B,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-7WG6LPZJ.js","sourcesContent":["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'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n clientName: 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}\n\nfunction getParams({ pathParamsType, dataReturnType, typeSchemas }: 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?: SWRMutationConfiguration<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown'].join(', ')}>,\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, pathParamsType, dataReturnType, typeSchemas, operation }: Props): ReactNode {\n const path = new URLPath(operation.path)\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const hookGenerics = [TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown', 'Key']\n\n const params = getParams({\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const clientParams = Client.getParams({\n typeSchemas,\n pathParamsType,\n })\n\n //fixed name, see Query.getParams and params\n const swrKey = [path.template, typeSchemas.queryParams?.name ? 'params' : undefined].filter(Boolean)\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\n const swrKey = [${swrKey.join(', ')}] as const\n return useSWRMutation<${hookGenerics}>(\n shouldFetch ? swrKey : 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 { 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 { QueryOptions } from './QueryOptions.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n queryOptionsName: 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\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, dataReturnType, typeSchemas }: 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?: SWRConfiguration<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown'].join(', ')}>,\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, queryOptionsName, operation, dataReturnType, pathParamsType }: Props): ReactNode {\n const path = new URLPath(operation.path)\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const hookGenerics = [TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'unknown', 'Key']\n const params = getParams({\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const queryOptionsParams = QueryOptions.getParams({\n pathParamsType,\n typeSchemas,\n })\n\n //fixed name, see Query.getParams and params\n const swrKey = [path.template, typeSchemas.queryParams?.name ? 'params' : undefined].filter(Boolean)\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 swrKey = [${swrKey.join(', ')}] as const\n return useSWR<${hookGenerics.join(', ')}>(\n shouldFetch ? swrKey : null,\n {\n ...${queryOptionsName}(${queryOptionsParams.toCall()})\n ...queryOptions\n }\n )\n `}\n </Function>\n </File.Source>\n )\n}\n"]}
@@ -0,0 +1,190 @@
1
+ 'use strict';
2
+
3
+ var chunkRMG5RYPG_cjs = require('./chunk-RMG5RYPG.cjs');
4
+ var transformers = 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
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
+
16
+ var transformers__default = /*#__PURE__*/_interopDefault(transformers);
17
+
18
+ var queryGenerator = pluginOas.createReactGenerator({
19
+ name: "swr-query",
20
+ Operation({ options, operation }) {
21
+ const {
22
+ plugin: { output }
23
+ } = react.useApp();
24
+ const { getSchemas, getName, getFile } = hooks.useOperationManager();
25
+ const isQuery = typeof options.query === "boolean" ? options.query : !!options.query.methods?.some((method) => operation.method === method);
26
+ const query = {
27
+ name: getName(operation, { type: "function", prefix: "use" }),
28
+ typeName: getName(operation, { type: "type" }),
29
+ file: getFile(operation, { prefix: "use" })
30
+ };
31
+ const client = {
32
+ name: getName(operation, { type: "function", pluginKey: [pluginClient.pluginClientName] })
33
+ };
34
+ const queryOptions = {
35
+ name: transformers__default.default.camelCase(`${operation.getOperationId()} QueryOptions`)
36
+ };
37
+ const type = {
38
+ file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
39
+ //todo remove type?
40
+ schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
41
+ };
42
+ const zod = {
43
+ file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
44
+ schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
45
+ };
46
+ if (!isQuery) {
47
+ return null;
48
+ }
49
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, children: [
50
+ options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { extName: output?.extName, name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
51
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["Key"], path: "swr", isTypeOnly: true }),
52
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "useSWR", path: options.query.importPath }),
53
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["SWRConfiguration", "SWRResponse"], path: options.query.importPath, isTypeOnly: true }),
54
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
55
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
56
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
57
+ /* @__PURE__ */ jsxRuntime.jsx(
58
+ react.File.Import,
59
+ {
60
+ extName: output?.extName,
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
+ components.Client,
76
+ {
77
+ name: client.name,
78
+ isExportable: false,
79
+ isIndexable: false,
80
+ baseURL: options.baseURL,
81
+ operation,
82
+ typeSchemas: type.schemas,
83
+ zodSchemas: zod.schemas,
84
+ dataReturnType: options.client.dataReturnType,
85
+ pathParamsType: options.pathParamsType,
86
+ parser: options.parser
87
+ }
88
+ ),
89
+ /* @__PURE__ */ jsxRuntime.jsx(chunkRMG5RYPG_cjs.QueryOptions, { name: queryOptions.name, clientName: client.name, typeSchemas: type.schemas, pathParamsType: options.pathParamsType }),
90
+ /* @__PURE__ */ jsxRuntime.jsx(
91
+ chunkRMG5RYPG_cjs.Query,
92
+ {
93
+ name: query.name,
94
+ queryOptionsName: queryOptions.name,
95
+ typeSchemas: type.schemas,
96
+ pathParamsType: options.pathParamsType,
97
+ operation,
98
+ dataReturnType: options.client.dataReturnType
99
+ }
100
+ )
101
+ ] });
102
+ }
103
+ });
104
+ var mutationGenerator = pluginOas.createReactGenerator({
105
+ name: "swr-mutation",
106
+ Operation({ options, operation }) {
107
+ const {
108
+ plugin: { output }
109
+ } = react.useApp();
110
+ const { getSchemas, getName, getFile } = hooks.useOperationManager();
111
+ const isMutate = typeof options.query === "boolean" ? options.mutation : !!options.mutation.methods?.some((method) => operation.method === method);
112
+ const mutation = {
113
+ name: getName(operation, { type: "function", prefix: "use" }),
114
+ typeName: getName(operation, { type: "type" }),
115
+ file: getFile(operation, { prefix: "use" })
116
+ };
117
+ const type = {
118
+ file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
119
+ //todo remove type?
120
+ schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
121
+ };
122
+ const zod = {
123
+ file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
124
+ schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
125
+ };
126
+ const client = {
127
+ name: getName(operation, { type: "function", pluginKey: [pluginClient.pluginClientName] })
128
+ };
129
+ if (!isMutate) {
130
+ return null;
131
+ }
132
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: mutation.file.baseName, path: mutation.file.path, meta: mutation.file.meta, children: [
133
+ options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { extName: output?.extName, name: [zod.schemas.response.name], root: mutation.file.path, path: zod.file.path }),
134
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["Key"], path: "swr", isTypeOnly: true }),
135
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "useSWRMutation", path: options.mutation.importPath }),
136
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["SWRMutationConfiguration", "SWRMutationResponse"], path: options.mutation.importPath, isTypeOnly: true }),
137
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
138
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
139
+ /* @__PURE__ */ jsxRuntime.jsx(
140
+ react.File.Import,
141
+ {
142
+ extName: output?.extName,
143
+ name: [
144
+ type.schemas.request?.name,
145
+ type.schemas.response.name,
146
+ type.schemas.pathParams?.name,
147
+ type.schemas.queryParams?.name,
148
+ type.schemas.headerParams?.name,
149
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
150
+ ].filter(Boolean),
151
+ root: mutation.file.path,
152
+ path: type.file.path,
153
+ isTypeOnly: true
154
+ }
155
+ ),
156
+ /* @__PURE__ */ jsxRuntime.jsx(
157
+ components.Client,
158
+ {
159
+ name: client.name,
160
+ isExportable: false,
161
+ isIndexable: false,
162
+ baseURL: options.baseURL,
163
+ operation,
164
+ typeSchemas: type.schemas,
165
+ zodSchemas: zod.schemas,
166
+ dataReturnType: options.client.dataReturnType,
167
+ pathParamsType: options.pathParamsType,
168
+ parser: options.parser
169
+ }
170
+ ),
171
+ /* @__PURE__ */ jsxRuntime.jsx(
172
+ chunkRMG5RYPG_cjs.Mutation,
173
+ {
174
+ name: mutation.name,
175
+ clientName: client.name,
176
+ typeName: mutation.typeName,
177
+ typeSchemas: type.schemas,
178
+ operation,
179
+ dataReturnType: options.client.dataReturnType,
180
+ pathParamsType: options.pathParamsType
181
+ }
182
+ )
183
+ ] });
184
+ }
185
+ });
186
+
187
+ exports.mutationGenerator = mutationGenerator;
188
+ exports.queryGenerator = queryGenerator;
189
+ //# sourceMappingURL=chunk-I5VDRAOG.cjs.map
190
+ //# sourceMappingURL=chunk-I5VDRAOG.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generators/queryGenerator.tsx","../src/generators/mutationGenerator.tsx"],"names":["createReactGenerator","useApp","useOperationManager","pluginClientName","transformers","pluginTsName","pluginZodName","jsxs","File","jsx","Client","QueryOptions","Query","Mutation"],"mappings":";;;;;;;;;;;;;;;;;AAWO,IAAM,iBAAiBA,8BAAgC,CAAA;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AAA;AAAA,OAClB;AAAA,sBACAD,cAAAA;AAAA,QAACI,0BAAA;AAAA,QAAA;AAAA,UACC,MAAM,QAAS,CAAA,IAAA;AAAA,UACf,YAAY,MAAO,CAAA,IAAA;AAAA,UACnB,UAAU,QAAS,CAAA,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,SAAA;AAAA,OAC1B;AAAA,KACF,EAAA,CAAA,CAAA;AAAA,GAEJ;AACF,CAAC","file":"chunk-I5VDRAOG.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 type { PluginSwr } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-query',\n Operation({ options, operation }) {\n const {\n plugin: { output },\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: transformers.camelCase(`${operation.getOperationId()} QueryOptions`),\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}>\n {options.parser === 'zod' && <File.Import extName={output?.extName} name={[zod.schemas.response.name]} root={query.file.path} path={zod.file.path} />}\n <File.Import name={['Key']} path=\"swr\" isTypeOnly />\n <File.Import name=\"useSWR\" path={options.query.importPath} />\n <File.Import name={['SWRConfiguration', '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 extName={output?.extName}\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 <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 />\n </File>\n )\n },\n})\n","import { 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 { 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: { output },\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 if (!isMutate) {\n return null\n }\n\n return (\n <File baseName={mutation.file.baseName} path={mutation.file.path} meta={mutation.file.meta}>\n {options.parser === 'zod' && (\n <File.Import extName={output?.extName} name={[zod.schemas.response.name]} root={mutation.file.path} path={zod.file.path} />\n )}\n <File.Import name={['Key']} path=\"swr\" isTypeOnly />\n <File.Import name=\"useSWRMutation\" path={options.mutation.importPath} />\n <File.Import name={['SWRMutationConfiguration', '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 extName={output?.extName}\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 <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 />\n </File>\n )\n },\n})\n"]}
@@ -0,0 +1,183 @@
1
+ import { QueryOptions, Query, Mutation } from './chunk-7WG6LPZJ.js';
2
+ import transformers from '@kubb/core/transformers';
3
+ import { pluginClientName } from '@kubb/plugin-client';
4
+ import { Client } from '@kubb/plugin-client/components';
5
+ import { createReactGenerator } from '@kubb/plugin-oas';
6
+ import { useOperationManager } from '@kubb/plugin-oas/hooks';
7
+ import { pluginTsName } from '@kubb/plugin-ts';
8
+ import { pluginZodName } from '@kubb/plugin-zod';
9
+ import { useApp, File } from '@kubb/react';
10
+ import { jsxs, jsx } from '@kubb/react/jsx-runtime';
11
+
12
+ var queryGenerator = createReactGenerator({
13
+ name: "swr-query",
14
+ Operation({ options, operation }) {
15
+ const {
16
+ plugin: { output }
17
+ } = useApp();
18
+ const { getSchemas, getName, getFile } = useOperationManager();
19
+ const isQuery = typeof options.query === "boolean" ? options.query : !!options.query.methods?.some((method) => operation.method === method);
20
+ const query = {
21
+ name: getName(operation, { type: "function", prefix: "use" }),
22
+ typeName: getName(operation, { type: "type" }),
23
+ file: getFile(operation, { prefix: "use" })
24
+ };
25
+ const client = {
26
+ name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
27
+ };
28
+ const queryOptions = {
29
+ name: transformers.camelCase(`${operation.getOperationId()} QueryOptions`)
30
+ };
31
+ const type = {
32
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
33
+ //todo remove type?
34
+ schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
35
+ };
36
+ const zod = {
37
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
38
+ schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
39
+ };
40
+ if (!isQuery) {
41
+ return null;
42
+ }
43
+ return /* @__PURE__ */ jsxs(File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, children: [
44
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { extName: output?.extName, name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
45
+ /* @__PURE__ */ jsx(File.Import, { name: ["Key"], path: "swr", isTypeOnly: true }),
46
+ /* @__PURE__ */ jsx(File.Import, { name: "useSWR", path: options.query.importPath }),
47
+ /* @__PURE__ */ jsx(File.Import, { name: ["SWRConfiguration", "SWRResponse"], path: options.query.importPath, isTypeOnly: true }),
48
+ /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
49
+ /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
50
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
51
+ /* @__PURE__ */ jsx(
52
+ File.Import,
53
+ {
54
+ extName: output?.extName,
55
+ name: [
56
+ type.schemas.request?.name,
57
+ type.schemas.response.name,
58
+ type.schemas.pathParams?.name,
59
+ type.schemas.queryParams?.name,
60
+ type.schemas.headerParams?.name,
61
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
62
+ ].filter(Boolean),
63
+ root: query.file.path,
64
+ path: type.file.path,
65
+ isTypeOnly: true
66
+ }
67
+ ),
68
+ /* @__PURE__ */ jsx(
69
+ Client,
70
+ {
71
+ name: client.name,
72
+ isExportable: false,
73
+ isIndexable: false,
74
+ baseURL: options.baseURL,
75
+ operation,
76
+ typeSchemas: type.schemas,
77
+ zodSchemas: zod.schemas,
78
+ dataReturnType: options.client.dataReturnType,
79
+ pathParamsType: options.pathParamsType,
80
+ parser: options.parser
81
+ }
82
+ ),
83
+ /* @__PURE__ */ jsx(QueryOptions, { name: queryOptions.name, clientName: client.name, typeSchemas: type.schemas, pathParamsType: options.pathParamsType }),
84
+ /* @__PURE__ */ jsx(
85
+ Query,
86
+ {
87
+ name: query.name,
88
+ queryOptionsName: queryOptions.name,
89
+ typeSchemas: type.schemas,
90
+ pathParamsType: options.pathParamsType,
91
+ operation,
92
+ dataReturnType: options.client.dataReturnType
93
+ }
94
+ )
95
+ ] });
96
+ }
97
+ });
98
+ var mutationGenerator = createReactGenerator({
99
+ name: "swr-mutation",
100
+ Operation({ options, operation }) {
101
+ const {
102
+ plugin: { output }
103
+ } = useApp();
104
+ const { getSchemas, getName, getFile } = useOperationManager();
105
+ const isMutate = typeof options.query === "boolean" ? options.mutation : !!options.mutation.methods?.some((method) => operation.method === method);
106
+ const mutation = {
107
+ name: getName(operation, { type: "function", prefix: "use" }),
108
+ typeName: getName(operation, { type: "type" }),
109
+ file: getFile(operation, { prefix: "use" })
110
+ };
111
+ const type = {
112
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
113
+ //todo remove type?
114
+ schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
115
+ };
116
+ const zod = {
117
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
118
+ schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
119
+ };
120
+ const client = {
121
+ name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
122
+ };
123
+ if (!isMutate) {
124
+ return null;
125
+ }
126
+ return /* @__PURE__ */ jsxs(File, { baseName: mutation.file.baseName, path: mutation.file.path, meta: mutation.file.meta, children: [
127
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { extName: output?.extName, name: [zod.schemas.response.name], root: mutation.file.path, path: zod.file.path }),
128
+ /* @__PURE__ */ jsx(File.Import, { name: ["Key"], path: "swr", isTypeOnly: true }),
129
+ /* @__PURE__ */ jsx(File.Import, { name: "useSWRMutation", path: options.mutation.importPath }),
130
+ /* @__PURE__ */ jsx(File.Import, { name: ["SWRMutationConfiguration", "SWRMutationResponse"], path: options.mutation.importPath, isTypeOnly: true }),
131
+ /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
132
+ /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
133
+ /* @__PURE__ */ jsx(
134
+ File.Import,
135
+ {
136
+ extName: output?.extName,
137
+ name: [
138
+ type.schemas.request?.name,
139
+ type.schemas.response.name,
140
+ type.schemas.pathParams?.name,
141
+ type.schemas.queryParams?.name,
142
+ type.schemas.headerParams?.name,
143
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
144
+ ].filter(Boolean),
145
+ root: mutation.file.path,
146
+ path: type.file.path,
147
+ isTypeOnly: true
148
+ }
149
+ ),
150
+ /* @__PURE__ */ jsx(
151
+ Client,
152
+ {
153
+ name: client.name,
154
+ isExportable: false,
155
+ isIndexable: false,
156
+ baseURL: options.baseURL,
157
+ operation,
158
+ typeSchemas: type.schemas,
159
+ zodSchemas: zod.schemas,
160
+ dataReturnType: options.client.dataReturnType,
161
+ pathParamsType: options.pathParamsType,
162
+ parser: options.parser
163
+ }
164
+ ),
165
+ /* @__PURE__ */ jsx(
166
+ Mutation,
167
+ {
168
+ name: mutation.name,
169
+ clientName: client.name,
170
+ typeName: mutation.typeName,
171
+ typeSchemas: type.schemas,
172
+ operation,
173
+ dataReturnType: options.client.dataReturnType,
174
+ pathParamsType: options.pathParamsType
175
+ }
176
+ )
177
+ ] });
178
+ }
179
+ });
180
+
181
+ export { mutationGenerator, queryGenerator };
182
+ //# sourceMappingURL=chunk-M27MSL33.js.map
183
+ //# sourceMappingURL=chunk-M27MSL33.js.map