@kubb/plugin-svelte-query 3.4.4 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,273 @@
1
+ 'use strict';
2
+
3
+ var chunk5E5RFWUM_cjs = require('./chunk-5E5RFWUM.cjs');
4
+ var pluginOas = require('@kubb/plugin-oas');
5
+ var hooks = require('@kubb/plugin-oas/hooks');
6
+ var utils = require('@kubb/plugin-oas/utils');
7
+ var pluginTs = require('@kubb/plugin-ts');
8
+ var pluginZod = require('@kubb/plugin-zod');
9
+ var react = require('@kubb/react');
10
+ var remeda = require('remeda');
11
+ var jsxRuntime = require('@kubb/react/jsx-runtime');
12
+
13
+ var queryGenerator = pluginOas.createReactGenerator({
14
+ name: "svelte-query",
15
+ Operation({ options, operation }) {
16
+ const {
17
+ plugin: {
18
+ options: { output }
19
+ }
20
+ } = react.useApp();
21
+ const oas = hooks.useOas();
22
+ const { getSchemas, getName, getFile } = hooks.useOperationManager();
23
+ const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
24
+ const isMutation = remeda.difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
25
+ (method) => operation.method === method
26
+ );
27
+ const importPath = options.query ? options.query.importPath : "@tanstack/svelte-query";
28
+ const query = {
29
+ name: getName(operation, { type: "function", prefix: "create" }),
30
+ typeName: getName(operation, { type: "type" }),
31
+ file: getFile(operation, { prefix: "create" })
32
+ };
33
+ const client = {
34
+ name: getName(operation, { type: "function" })
35
+ };
36
+ const queryOptions = {
37
+ name: getName(operation, { type: "function", suffix: "QueryOptions" })
38
+ };
39
+ const queryKey = {
40
+ name: getName(operation, { type: "const", suffix: "QueryKey" }),
41
+ typeName: getName(operation, { type: "type", suffix: "QueryKey" })
42
+ };
43
+ const type = {
44
+ file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
45
+ //todo remove type?
46
+ schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
47
+ };
48
+ const zod = {
49
+ file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
50
+ schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
51
+ };
52
+ if (!isQuery || isMutation) {
53
+ return null;
54
+ }
55
+ return /* @__PURE__ */ jsxRuntime.jsxs(
56
+ react.File,
57
+ {
58
+ baseName: query.file.baseName,
59
+ path: query.file.path,
60
+ meta: query.file.meta,
61
+ banner: utils.getBanner({ oas, output }),
62
+ footer: utils.getFooter({ oas, output }),
63
+ children: [
64
+ options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
65
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
66
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
67
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
68
+ /* @__PURE__ */ jsxRuntime.jsx(
69
+ react.File.Import,
70
+ {
71
+ name: [
72
+ type.schemas.request?.name,
73
+ type.schemas.response.name,
74
+ type.schemas.pathParams?.name,
75
+ type.schemas.queryParams?.name,
76
+ type.schemas.headerParams?.name,
77
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
78
+ ].filter(Boolean),
79
+ root: query.file.path,
80
+ path: type.file.path,
81
+ isTypeOnly: true
82
+ }
83
+ ),
84
+ /* @__PURE__ */ jsxRuntime.jsx(
85
+ chunk5E5RFWUM_cjs.QueryKey,
86
+ {
87
+ name: queryKey.name,
88
+ typeName: queryKey.typeName,
89
+ operation,
90
+ pathParamsType: options.pathParamsType,
91
+ typeSchemas: type.schemas,
92
+ paramsCasing: options.paramsCasing,
93
+ transformer: options.queryKey
94
+ }
95
+ ),
96
+ /* @__PURE__ */ jsxRuntime.jsx(
97
+ chunk5E5RFWUM_cjs.Client,
98
+ {
99
+ name: client.name,
100
+ isExportable: false,
101
+ isIndexable: false,
102
+ baseURL: options.client.baseURL,
103
+ operation,
104
+ typeSchemas: type.schemas,
105
+ zodSchemas: zod.schemas,
106
+ dataReturnType: options.client.dataReturnType,
107
+ paramsCasing: options.paramsCasing,
108
+ paramsType: options.paramsType,
109
+ pathParamsType: options.pathParamsType,
110
+ parser: options.parser
111
+ }
112
+ ),
113
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["queryOptions"], path: importPath }),
114
+ /* @__PURE__ */ jsxRuntime.jsx(
115
+ chunk5E5RFWUM_cjs.QueryOptions,
116
+ {
117
+ name: queryOptions.name,
118
+ clientName: client.name,
119
+ queryKeyName: queryKey.name,
120
+ typeSchemas: type.schemas,
121
+ paramsCasing: options.paramsCasing,
122
+ paramsType: options.paramsType,
123
+ pathParamsType: options.pathParamsType,
124
+ dataReturnType: options.client.dataReturnType
125
+ }
126
+ ),
127
+ options.query && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
128
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["createQuery"], path: importPath }),
129
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "CreateBaseQueryOptions", "CreateQueryResult"], path: importPath, isTypeOnly: true }),
130
+ /* @__PURE__ */ jsxRuntime.jsx(
131
+ chunk5E5RFWUM_cjs.Query,
132
+ {
133
+ name: query.name,
134
+ queryOptionsName: queryOptions.name,
135
+ typeSchemas: type.schemas,
136
+ pathParamsType: options.pathParamsType,
137
+ operation,
138
+ paramsCasing: options.paramsCasing,
139
+ paramsType: options.paramsType,
140
+ dataReturnType: options.client.dataReturnType,
141
+ queryKeyName: queryKey.name,
142
+ queryKeyTypeName: queryKey.typeName
143
+ }
144
+ )
145
+ ] })
146
+ ]
147
+ }
148
+ );
149
+ }
150
+ });
151
+ var mutationGenerator = pluginOas.createReactGenerator({
152
+ name: "svelte-query",
153
+ Operation({ options, operation }) {
154
+ const {
155
+ plugin: {
156
+ options: { output }
157
+ }
158
+ } = react.useApp();
159
+ const oas = hooks.useOas();
160
+ const { getSchemas, getName, getFile } = hooks.useOperationManager();
161
+ const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
162
+ const isMutation = !isQuery && remeda.difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
163
+ const importPath = options.mutation ? options.mutation.importPath : "@tanstack/svelte-query";
164
+ const mutation = {
165
+ name: getName(operation, { type: "function", prefix: "create" }),
166
+ typeName: getName(operation, { type: "type" }),
167
+ file: getFile(operation, { prefix: "create" })
168
+ };
169
+ const type = {
170
+ file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
171
+ //todo remove type?
172
+ schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
173
+ };
174
+ const zod = {
175
+ file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
176
+ schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
177
+ };
178
+ const client = {
179
+ name: getName(operation, { type: "function" })
180
+ };
181
+ const mutationKey = {
182
+ name: getName(operation, { type: "const", suffix: "MutationKey" }),
183
+ typeName: getName(operation, { type: "type", suffix: "MutationKey" })
184
+ };
185
+ if (!isMutation) {
186
+ return null;
187
+ }
188
+ return /* @__PURE__ */ jsxRuntime.jsxs(
189
+ react.File,
190
+ {
191
+ baseName: mutation.file.baseName,
192
+ path: mutation.file.path,
193
+ meta: mutation.file.meta,
194
+ banner: utils.getBanner({ oas, output }),
195
+ footer: utils.getFooter({ oas, output }),
196
+ children: [
197
+ options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: mutation.file.path, path: zod.file.path }),
198
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
199
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
200
+ /* @__PURE__ */ jsxRuntime.jsx(
201
+ react.File.Import,
202
+ {
203
+ name: [
204
+ type.schemas.request?.name,
205
+ type.schemas.response.name,
206
+ type.schemas.pathParams?.name,
207
+ type.schemas.queryParams?.name,
208
+ type.schemas.headerParams?.name,
209
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
210
+ ].filter(Boolean),
211
+ root: mutation.file.path,
212
+ path: type.file.path,
213
+ isTypeOnly: true
214
+ }
215
+ ),
216
+ /* @__PURE__ */ jsxRuntime.jsx(
217
+ chunk5E5RFWUM_cjs.MutationKey,
218
+ {
219
+ name: mutationKey.name,
220
+ typeName: mutationKey.typeName,
221
+ operation,
222
+ paramsCasing: options.paramsCasing,
223
+ pathParamsType: options.pathParamsType,
224
+ typeSchemas: type.schemas,
225
+ transformer: options.mutationKey
226
+ }
227
+ ),
228
+ /* @__PURE__ */ jsxRuntime.jsx(
229
+ chunk5E5RFWUM_cjs.Client,
230
+ {
231
+ name: client.name,
232
+ isExportable: false,
233
+ isIndexable: false,
234
+ baseURL: options.client.baseURL,
235
+ operation,
236
+ typeSchemas: type.schemas,
237
+ zodSchemas: zod.schemas,
238
+ dataReturnType: options.client.dataReturnType,
239
+ paramsCasing: options.paramsCasing,
240
+ paramsType: options.paramsType,
241
+ pathParamsType: options.pathParamsType,
242
+ parser: options.parser
243
+ }
244
+ ),
245
+ options.mutation && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
246
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["createMutation"], path: importPath }),
247
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["CreateMutationOptions", "CreateMutationResult"], path: importPath, isTypeOnly: true }),
248
+ /* @__PURE__ */ jsxRuntime.jsx(
249
+ chunk5E5RFWUM_cjs.Mutation,
250
+ {
251
+ name: mutation.name,
252
+ clientName: client.name,
253
+ typeName: mutation.typeName,
254
+ typeSchemas: type.schemas,
255
+ operation,
256
+ paramsCasing: options.paramsCasing,
257
+ dataReturnType: options.client.dataReturnType,
258
+ paramsType: options.paramsType,
259
+ pathParamsType: options.pathParamsType,
260
+ mutationKeyName: mutationKey.name
261
+ }
262
+ )
263
+ ] })
264
+ ]
265
+ }
266
+ );
267
+ }
268
+ });
269
+
270
+ exports.mutationGenerator = mutationGenerator;
271
+ exports.queryGenerator = queryGenerator;
272
+ //# sourceMappingURL=chunk-7GM4ILPD.cjs.map
273
+ //# sourceMappingURL=chunk-7GM4ILPD.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generators/queryGenerator.tsx","../src/generators/mutationGenerator.tsx"],"names":["createReactGenerator","useApp","useOas","useOperationManager","difference","pluginTsName","pluginZodName","jsxs","File","getBanner","getFooter","jsx","QueryKey","Client","QueryOptions","Fragment","Query","MutationKey","Mutation"],"mappings":";;;;;;;;;;;;AAWO,IAAM,iBAAiBA,8BAAwC,CAAA;AAAA,EACpE,IAAM,EAAA,cAAA;AAAA,EACN,SAAU,CAAA,EAAE,OAAS,EAAA,SAAA,EAAa,EAAA;AAChC,IAAM,MAAA;AAAA,MACJ,MAAQ,EAAA;AAAA,QACN,OAAA,EAAS,EAAE,MAAO;AAAA;AACpB,QACEC,YAA0B,EAAA;AAC9B,IAAA,MAAM,MAAMC,YAAO,EAAA;AACnB,IAAA,MAAM,EAAE,UAAA,EAAY,OAAS,EAAA,OAAA,KAAYC,yBAAoB,EAAA;AAE7D,IAAA,MAAM,OAAU,GAAA,OAAO,OAAQ,CAAA,KAAA,KAAU,YAAY,IAAO,GAAA,OAAA,CAAQ,KAAO,EAAA,OAAA,CAAQ,IAAK,CAAA,CAAC,MAAW,KAAA,SAAA,CAAU,WAAW,MAAM,CAAA;AAC/H,IAAA,MAAM,aAAaC,iBAAW,CAAA,OAAA,CAAQ,QAAW,GAAA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AAAA,WAClB;AAAA,UACC,OAAQ,CAAA,QAAA,oBACPN,eAAAA,CAAAQ,qBAAA,EACE,QAAA,EAAA;AAAA,4BAAAJ,cAAAA,CAACH,WAAK,MAAL,EAAA,EAAY,MAAM,CAAC,gBAAgB,CAAG,EAAA,IAAA,EAAM,UAAY,EAAA,CAAA;AAAA,4BACzDG,cAAAA,CAACH,UAAK,CAAA,MAAA,EAAL,EAAY,IAAA,EAAM,CAAC,uBAAA,EAAyB,sBAAsB,CAAA,EAAG,IAAM,EAAA,UAAA,EAAY,YAAU,IAAC,EAAA,CAAA;AAAA,4BACnGG,cAAAA;AAAA,cAACO,0BAAA;AAAA,cAAA;AAAA,gBACC,MAAM,QAAS,CAAA,IAAA;AAAA,gBACf,YAAY,MAAO,CAAA,IAAA;AAAA,gBACnB,UAAU,QAAS,CAAA,QAAA;AAAA,gBACnB,aAAa,IAAK,CAAA,OAAA;AAAA,gBAClB,SAAA;AAAA,gBACA,cAAc,OAAQ,CAAA,YAAA;AAAA,gBACtB,cAAA,EAAgB,QAAQ,MAAO,CAAA,cAAA;AAAA,gBAC/B,YAAY,OAAQ,CAAA,UAAA;AAAA,gBACpB,gBAAgB,OAAQ,CAAA,cAAA;AAAA,gBACxB,iBAAiB,WAAY,CAAA;AAAA;AAAA;AAC/B,WACF,EAAA;AAAA;AAAA;AAAA,KAEJ;AAAA;AAGN,CAAC","file":"chunk-7GM4ILPD.cjs","sourcesContent":["import { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginSvelteQuery } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSvelteQuery>({\n name: 'svelte-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n } = useApp<PluginSvelteQuery>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(\n (method) => operation.method === method,\n )\n const importPath = options.query ? options.query.importPath : '@tanstack/svelte-query'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\n }\n\n const client = {\n name: getName(operation, { type: 'function' }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),\n }\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 || isMutation) {\n return null\n }\n\n return (\n <File\n baseName={query.file.baseName}\n path={query.file.path}\n meta={query.file.meta}\n banner={getBanner({ oas, output })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={query.file.path} path={zod.file.path} />}\n <File.Import name={'client'} path={options.client.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['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={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.queryKey}\n />\n\n <Client\n name={client.name}\n isExportable={false}\n isIndexable={false}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n <File.Import name={['queryOptions']} path={importPath} />\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n queryKeyName={queryKey.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n dataReturnType={options.client.dataReturnType}\n />\n {options.query && (\n <>\n <File.Import name={['createQuery']} path={importPath} />\n <File.Import name={['QueryKey', 'CreateBaseQueryOptions', 'CreateQueryResult']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n pathParamsType={options.pathParamsType}\n operation={operation}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n dataReturnType={options.client.dataReturnType}\n queryKeyName={queryKey.name}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\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 { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Mutation, MutationKey } from '../components'\nimport type { PluginSvelteQuery } from '../types'\n\nexport const mutationGenerator = createReactGenerator<PluginSvelteQuery>({\n name: 'svelte-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n } = useApp<PluginSvelteQuery>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method)\n const isMutation =\n !isQuery &&\n difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method)\n\n const importPath = options.mutation ? options.mutation.importPath : '@tanstack/svelte-query'\n\n const mutation = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\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' }),\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 (!isMutation) {\n return null\n }\n\n return (\n <File\n baseName={mutation.file.baseName}\n path={mutation.file.path}\n meta={mutation.file.meta}\n banner={getBanner({ oas, output })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={mutation.file.path} path={zod.file.path} />}\n\n <File.Import name={'client'} path={options.client.importPath} />\n <File.Import name={['RequestConfig', 'ResponseConfig', 'ResponseErrorConfig']} 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\n <MutationKey\n name={mutationKey.name}\n typeName={mutationKey.typeName}\n operation={operation}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n transformer={options.mutationKey}\n />\n <Client\n name={client.name}\n isExportable={false}\n isIndexable={false}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n {options.mutation && (\n <>\n <File.Import name={['createMutation']} path={importPath} />\n <File.Import name={['CreateMutationOptions', 'CreateMutationResult']} path={importPath} isTypeOnly />\n <Mutation\n name={mutation.name}\n clientName={client.name}\n typeName={mutation.typeName}\n typeSchemas={type.schemas}\n operation={operation}\n paramsCasing={options.paramsCasing}\n dataReturnType={options.client.dataReturnType}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n mutationKeyName={mutationKey.name}\n />\n </>\n )}\n </File>\n )\n },\n})\n"]}
@@ -0,0 +1,270 @@
1
+ import { QueryKey, Client, QueryOptions, Query, MutationKey, Mutation } from './chunk-EE3OWZ2P.js';
2
+ import { createReactGenerator } from '@kubb/plugin-oas';
3
+ import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks';
4
+ import { getBanner, getFooter } from '@kubb/plugin-oas/utils';
5
+ import { pluginTsName } from '@kubb/plugin-ts';
6
+ import { pluginZodName } from '@kubb/plugin-zod';
7
+ import { useApp, File } from '@kubb/react';
8
+ import { difference } from 'remeda';
9
+ import { jsxs, jsx, Fragment } from '@kubb/react/jsx-runtime';
10
+
11
+ var queryGenerator = createReactGenerator({
12
+ name: "svelte-query",
13
+ Operation({ options, operation }) {
14
+ const {
15
+ plugin: {
16
+ options: { output }
17
+ }
18
+ } = useApp();
19
+ const oas = useOas();
20
+ const { getSchemas, getName, getFile } = useOperationManager();
21
+ const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
22
+ const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
23
+ (method) => operation.method === method
24
+ );
25
+ const importPath = options.query ? options.query.importPath : "@tanstack/svelte-query";
26
+ const query = {
27
+ name: getName(operation, { type: "function", prefix: "create" }),
28
+ typeName: getName(operation, { type: "type" }),
29
+ file: getFile(operation, { prefix: "create" })
30
+ };
31
+ const client = {
32
+ name: getName(operation, { type: "function" })
33
+ };
34
+ const queryOptions = {
35
+ name: getName(operation, { type: "function", suffix: "QueryOptions" })
36
+ };
37
+ const queryKey = {
38
+ name: getName(operation, { type: "const", suffix: "QueryKey" }),
39
+ typeName: getName(operation, { type: "type", suffix: "QueryKey" })
40
+ };
41
+ const type = {
42
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
43
+ //todo remove type?
44
+ schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
45
+ };
46
+ const zod = {
47
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
48
+ schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
49
+ };
50
+ if (!isQuery || isMutation) {
51
+ return null;
52
+ }
53
+ return /* @__PURE__ */ jsxs(
54
+ File,
55
+ {
56
+ baseName: query.file.baseName,
57
+ path: query.file.path,
58
+ meta: query.file.meta,
59
+ banner: getBanner({ oas, output }),
60
+ footer: getFooter({ oas, output }),
61
+ children: [
62
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
63
+ /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
64
+ /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
65
+ options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
66
+ /* @__PURE__ */ jsx(
67
+ File.Import,
68
+ {
69
+ name: [
70
+ type.schemas.request?.name,
71
+ type.schemas.response.name,
72
+ type.schemas.pathParams?.name,
73
+ type.schemas.queryParams?.name,
74
+ type.schemas.headerParams?.name,
75
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
76
+ ].filter(Boolean),
77
+ root: query.file.path,
78
+ path: type.file.path,
79
+ isTypeOnly: true
80
+ }
81
+ ),
82
+ /* @__PURE__ */ jsx(
83
+ QueryKey,
84
+ {
85
+ name: queryKey.name,
86
+ typeName: queryKey.typeName,
87
+ operation,
88
+ pathParamsType: options.pathParamsType,
89
+ typeSchemas: type.schemas,
90
+ paramsCasing: options.paramsCasing,
91
+ transformer: options.queryKey
92
+ }
93
+ ),
94
+ /* @__PURE__ */ jsx(
95
+ Client,
96
+ {
97
+ name: client.name,
98
+ isExportable: false,
99
+ isIndexable: false,
100
+ baseURL: options.client.baseURL,
101
+ operation,
102
+ typeSchemas: type.schemas,
103
+ zodSchemas: zod.schemas,
104
+ dataReturnType: options.client.dataReturnType,
105
+ paramsCasing: options.paramsCasing,
106
+ paramsType: options.paramsType,
107
+ pathParamsType: options.pathParamsType,
108
+ parser: options.parser
109
+ }
110
+ ),
111
+ /* @__PURE__ */ jsx(File.Import, { name: ["queryOptions"], path: importPath }),
112
+ /* @__PURE__ */ jsx(
113
+ QueryOptions,
114
+ {
115
+ name: queryOptions.name,
116
+ clientName: client.name,
117
+ queryKeyName: queryKey.name,
118
+ typeSchemas: type.schemas,
119
+ paramsCasing: options.paramsCasing,
120
+ paramsType: options.paramsType,
121
+ pathParamsType: options.pathParamsType,
122
+ dataReturnType: options.client.dataReturnType
123
+ }
124
+ ),
125
+ options.query && /* @__PURE__ */ jsxs(Fragment, { children: [
126
+ /* @__PURE__ */ jsx(File.Import, { name: ["createQuery"], path: importPath }),
127
+ /* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "CreateBaseQueryOptions", "CreateQueryResult"], path: importPath, isTypeOnly: true }),
128
+ /* @__PURE__ */ jsx(
129
+ Query,
130
+ {
131
+ name: query.name,
132
+ queryOptionsName: queryOptions.name,
133
+ typeSchemas: type.schemas,
134
+ pathParamsType: options.pathParamsType,
135
+ operation,
136
+ paramsCasing: options.paramsCasing,
137
+ paramsType: options.paramsType,
138
+ dataReturnType: options.client.dataReturnType,
139
+ queryKeyName: queryKey.name,
140
+ queryKeyTypeName: queryKey.typeName
141
+ }
142
+ )
143
+ ] })
144
+ ]
145
+ }
146
+ );
147
+ }
148
+ });
149
+ var mutationGenerator = createReactGenerator({
150
+ name: "svelte-query",
151
+ Operation({ options, operation }) {
152
+ const {
153
+ plugin: {
154
+ options: { output }
155
+ }
156
+ } = useApp();
157
+ const oas = useOas();
158
+ const { getSchemas, getName, getFile } = useOperationManager();
159
+ const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
160
+ const isMutation = !isQuery && difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
161
+ const importPath = options.mutation ? options.mutation.importPath : "@tanstack/svelte-query";
162
+ const mutation = {
163
+ name: getName(operation, { type: "function", prefix: "create" }),
164
+ typeName: getName(operation, { type: "type" }),
165
+ file: getFile(operation, { prefix: "create" })
166
+ };
167
+ const type = {
168
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
169
+ //todo remove type?
170
+ schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
171
+ };
172
+ const zod = {
173
+ file: getFile(operation, { pluginKey: [pluginZodName] }),
174
+ schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
175
+ };
176
+ const client = {
177
+ name: getName(operation, { type: "function" })
178
+ };
179
+ const mutationKey = {
180
+ name: getName(operation, { type: "const", suffix: "MutationKey" }),
181
+ typeName: getName(operation, { type: "type", suffix: "MutationKey" })
182
+ };
183
+ if (!isMutation) {
184
+ return null;
185
+ }
186
+ return /* @__PURE__ */ jsxs(
187
+ File,
188
+ {
189
+ baseName: mutation.file.baseName,
190
+ path: mutation.file.path,
191
+ meta: mutation.file.meta,
192
+ banner: getBanner({ oas, output }),
193
+ footer: getFooter({ oas, output }),
194
+ children: [
195
+ options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name], root: mutation.file.path, path: zod.file.path }),
196
+ /* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
197
+ /* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
198
+ /* @__PURE__ */ jsx(
199
+ File.Import,
200
+ {
201
+ name: [
202
+ type.schemas.request?.name,
203
+ type.schemas.response.name,
204
+ type.schemas.pathParams?.name,
205
+ type.schemas.queryParams?.name,
206
+ type.schemas.headerParams?.name,
207
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
208
+ ].filter(Boolean),
209
+ root: mutation.file.path,
210
+ path: type.file.path,
211
+ isTypeOnly: true
212
+ }
213
+ ),
214
+ /* @__PURE__ */ jsx(
215
+ MutationKey,
216
+ {
217
+ name: mutationKey.name,
218
+ typeName: mutationKey.typeName,
219
+ operation,
220
+ paramsCasing: options.paramsCasing,
221
+ pathParamsType: options.pathParamsType,
222
+ typeSchemas: type.schemas,
223
+ transformer: options.mutationKey
224
+ }
225
+ ),
226
+ /* @__PURE__ */ jsx(
227
+ Client,
228
+ {
229
+ name: client.name,
230
+ isExportable: false,
231
+ isIndexable: false,
232
+ baseURL: options.client.baseURL,
233
+ operation,
234
+ typeSchemas: type.schemas,
235
+ zodSchemas: zod.schemas,
236
+ dataReturnType: options.client.dataReturnType,
237
+ paramsCasing: options.paramsCasing,
238
+ paramsType: options.paramsType,
239
+ pathParamsType: options.pathParamsType,
240
+ parser: options.parser
241
+ }
242
+ ),
243
+ options.mutation && /* @__PURE__ */ jsxs(Fragment, { children: [
244
+ /* @__PURE__ */ jsx(File.Import, { name: ["createMutation"], path: importPath }),
245
+ /* @__PURE__ */ jsx(File.Import, { name: ["CreateMutationOptions", "CreateMutationResult"], path: importPath, isTypeOnly: true }),
246
+ /* @__PURE__ */ jsx(
247
+ Mutation,
248
+ {
249
+ name: mutation.name,
250
+ clientName: client.name,
251
+ typeName: mutation.typeName,
252
+ typeSchemas: type.schemas,
253
+ operation,
254
+ paramsCasing: options.paramsCasing,
255
+ dataReturnType: options.client.dataReturnType,
256
+ paramsType: options.paramsType,
257
+ pathParamsType: options.pathParamsType,
258
+ mutationKeyName: mutationKey.name
259
+ }
260
+ )
261
+ ] })
262
+ ]
263
+ }
264
+ );
265
+ }
266
+ });
267
+
268
+ export { mutationGenerator, queryGenerator };
269
+ //# sourceMappingURL=chunk-AKSVF5YB.js.map
270
+ //# sourceMappingURL=chunk-AKSVF5YB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generators/queryGenerator.tsx","../src/generators/mutationGenerator.tsx"],"names":["createReactGenerator","useApp","useOas","useOperationManager","difference","pluginTsName","pluginZodName","jsxs","File","getBanner","getFooter","jsx","Fragment"],"mappings":";;;;;;;;;;AAWO,IAAM,iBAAiB,oBAAwC,CAAA;AAAA,EACpE,IAAM,EAAA,cAAA;AAAA,EACN,SAAU,CAAA,EAAE,OAAS,EAAA,SAAA,EAAa,EAAA;AAChC,IAAM,MAAA;AAAA,MACJ,MAAQ,EAAA;AAAA,QACN,OAAA,EAAS,EAAE,MAAO;AAAA;AACpB,QACE,MAA0B,EAAA;AAC9B,IAAA,MAAM,MAAM,MAAO,EAAA;AACnB,IAAA,MAAM,EAAE,UAAA,EAAY,OAAS,EAAA,OAAA,KAAY,mBAAoB,EAAA;AAE7D,IAAA,MAAM,OAAU,GAAA,OAAO,OAAQ,CAAA,KAAA,KAAU,YAAY,IAAO,GAAA,OAAA,CAAQ,KAAO,EAAA,OAAA,CAAQ,IAAK,CAAA,CAAC,MAAW,KAAA,SAAA,CAAU,WAAW,MAAM,CAAA;AAC/H,IAAA,MAAM,aAAa,UAAW,CAAA,OAAA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Q,CAAA,QAAA,oBACPJ,IAAAA,CAAAK,UAAA,EACE,QAAA,EAAA;AAAA,4BAAAD,GAAAA,CAACH,KAAK,MAAL,EAAA,EAAY,MAAM,CAAC,gBAAgB,CAAG,EAAA,IAAA,EAAM,UAAY,EAAA,CAAA;AAAA,4BACzDG,GAAAA,CAACH,IAAK,CAAA,MAAA,EAAL,EAAY,IAAA,EAAM,CAAC,uBAAA,EAAyB,sBAAsB,CAAA,EAAG,IAAM,EAAA,UAAA,EAAY,YAAU,IAAC,EAAA,CAAA;AAAA,4BACnGG,GAAAA;AAAA,cAAC,QAAA;AAAA,cAAA;AAAA,gBACC,MAAM,QAAS,CAAA,IAAA;AAAA,gBACf,YAAY,MAAO,CAAA,IAAA;AAAA,gBACnB,UAAU,QAAS,CAAA,QAAA;AAAA,gBACnB,aAAa,IAAK,CAAA,OAAA;AAAA,gBAClB,SAAA;AAAA,gBACA,cAAc,OAAQ,CAAA,YAAA;AAAA,gBACtB,cAAA,EAAgB,QAAQ,MAAO,CAAA,cAAA;AAAA,gBAC/B,YAAY,OAAQ,CAAA,UAAA;AAAA,gBACpB,gBAAgB,OAAQ,CAAA,cAAA;AAAA,gBACxB,iBAAiB,WAAY,CAAA;AAAA;AAAA;AAC/B,WACF,EAAA;AAAA;AAAA;AAAA,KAEJ;AAAA;AAGN,CAAC","file":"chunk-AKSVF5YB.js","sourcesContent":["import { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginSvelteQuery } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSvelteQuery>({\n name: 'svelte-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n } = useApp<PluginSvelteQuery>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(\n (method) => operation.method === method,\n )\n const importPath = options.query ? options.query.importPath : '@tanstack/svelte-query'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\n }\n\n const client = {\n name: getName(operation, { type: 'function' }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),\n }\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 || isMutation) {\n return null\n }\n\n return (\n <File\n baseName={query.file.baseName}\n path={query.file.path}\n meta={query.file.meta}\n banner={getBanner({ oas, output })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={query.file.path} path={zod.file.path} />}\n <File.Import name={'client'} path={options.client.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['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={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.queryKey}\n />\n\n <Client\n name={client.name}\n isExportable={false}\n isIndexable={false}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n <File.Import name={['queryOptions']} path={importPath} />\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n queryKeyName={queryKey.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n dataReturnType={options.client.dataReturnType}\n />\n {options.query && (\n <>\n <File.Import name={['createQuery']} path={importPath} />\n <File.Import name={['QueryKey', 'CreateBaseQueryOptions', 'CreateQueryResult']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n pathParamsType={options.pathParamsType}\n operation={operation}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n dataReturnType={options.client.dataReturnType}\n queryKeyName={queryKey.name}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\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 { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Mutation, MutationKey } from '../components'\nimport type { PluginSvelteQuery } from '../types'\n\nexport const mutationGenerator = createReactGenerator<PluginSvelteQuery>({\n name: 'svelte-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n } = useApp<PluginSvelteQuery>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method)\n const isMutation =\n !isQuery &&\n difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method)\n\n const importPath = options.mutation ? options.mutation.importPath : '@tanstack/svelte-query'\n\n const mutation = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\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' }),\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 (!isMutation) {\n return null\n }\n\n return (\n <File\n baseName={mutation.file.baseName}\n path={mutation.file.path}\n meta={mutation.file.meta}\n banner={getBanner({ oas, output })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={mutation.file.path} path={zod.file.path} />}\n\n <File.Import name={'client'} path={options.client.importPath} />\n <File.Import name={['RequestConfig', 'ResponseConfig', 'ResponseErrorConfig']} 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\n <MutationKey\n name={mutationKey.name}\n typeName={mutationKey.typeName}\n operation={operation}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n transformer={options.mutationKey}\n />\n <Client\n name={client.name}\n isExportable={false}\n isIndexable={false}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n {options.mutation && (\n <>\n <File.Import name={['createMutation']} path={importPath} />\n <File.Import name={['CreateMutationOptions', 'CreateMutationResult']} path={importPath} isTypeOnly />\n <Mutation\n name={mutation.name}\n clientName={client.name}\n typeName={mutation.typeName}\n typeSchemas={type.schemas}\n operation={operation}\n paramsCasing={options.paramsCasing}\n dataReturnType={options.client.dataReturnType}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n mutationKeyName={mutationKey.name}\n />\n </>\n )}\n </File>\n )\n },\n})\n"]}
@@ -1,7 +1,7 @@
1
1
  import { Operation } from '@kubb/oas';
2
2
  import { OperationSchemas } from '@kubb/plugin-oas';
3
3
  import { ReactNode } from 'react';
4
- import { P as PluginSvelteQuery, T as Transformer } from './types-CdgT4Eeh.cjs';
4
+ import { P as PluginSvelteQuery, T as Transformer } from './types-C3C1lWLx.cjs';
5
5
  import { FunctionParams } from '@kubb/react';
6
6
  import '@kubb/core';
7
7
 
@@ -1,7 +1,7 @@
1
1
  import { Operation } from '@kubb/oas';
2
2
  import { OperationSchemas } from '@kubb/plugin-oas';
3
3
  import { ReactNode } from 'react';
4
- import { P as PluginSvelteQuery, T as Transformer } from './types-CdgT4Eeh.js';
4
+ import { P as PluginSvelteQuery, T as Transformer } from './types-C3C1lWLx.js';
5
5
  import { FunctionParams } from '@kubb/react';
6
6
  import '@kubb/core';
7
7