@kubb/plugin-swr 3.0.0-alpha.4 → 3.0.0-alpha.6

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.
@@ -1,13 +1,13 @@
1
1
  // src/components/Mutation.tsx
2
2
  import transformers from "@kubb/core/transformers";
3
3
  import { FunctionParams, URLPath } from "@kubb/core/utils";
4
- import { Parser, File, Function, useApp as useApp2 } from "@kubb/react";
4
+ import { File as File2, Function, useApp as useApp2 } from "@kubb/react";
5
5
  import { pluginTsName as pluginTsName2 } from "@kubb/plugin-ts";
6
6
  import { useOperation as useOperation2, useOperationManager as useOperationManager2 } from "@kubb/plugin-oas/hooks";
7
7
  import { getASTParams, getComments } from "@kubb/plugin-oas/utils";
8
8
 
9
9
  // src/components/SchemaType.tsx
10
- import { Type, useApp } from "@kubb/react";
10
+ import { File, Type, useApp } from "@kubb/react";
11
11
  import { useOperation, useOperationManager } from "@kubb/plugin-oas/hooks";
12
12
  import { pluginTsName } from "@kubb/plugin-ts";
13
13
  import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
@@ -31,8 +31,8 @@ function SchemaType({ factory }) {
31
31
  ];
32
32
  const clientType = `${factory.name}Client`;
33
33
  return /* @__PURE__ */ jsxs(Fragment, { children: [
34
- /* @__PURE__ */ jsx(Type, { name: clientType, children: `typeof client<${TResponse}, ${TError}, ${TRequest}>` }),
35
- /* @__PURE__ */ jsx(Type, { name: factory.name, children: `
34
+ /* @__PURE__ */ jsx(File.Source, { name: clientType, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { name: clientType, children: `typeof client<${TResponse}, ${TError}, ${TRequest}>` }) }),
35
+ /* @__PURE__ */ jsx(File.Source, { name: factory.name, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { name: factory.name, children: `
36
36
  {
37
37
  data: ${TData}
38
38
  error: ${TError}
@@ -46,7 +46,7 @@ function SchemaType({ factory }) {
46
46
  return: Awaited<ReturnType<${clientType}>>
47
47
  }
48
48
  }
49
- ` })
49
+ ` }) })
50
50
  ] });
51
51
  }
52
52
 
@@ -64,7 +64,7 @@ function Template({ name, generics, returnType, params, JSDoc, client, hook, dat
64
64
  const resolvedClientOptions = `${transformers.createIndent(4)}${clientOptions.join(`,
65
65
  ${transformers.createIndent(4)}`)}`;
66
66
  if (client.withQueryParams) {
67
- return /* @__PURE__ */ jsx2(Function, { export: true, name, generics, returnType, params, JSDoc, children: `
67
+ return /* @__PURE__ */ jsx2(File2.Source, { name, isExportable: true, children: /* @__PURE__ */ jsx2(Function, { export: true, name, generics, returnType, params, JSDoc, children: `
68
68
  const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}
69
69
 
70
70
  const url = ${client.path.template} as const
@@ -79,9 +79,9 @@ ${transformers.createIndent(4)}`)}`;
79
79
  },
80
80
  mutationOptions
81
81
  )
82
- ` });
82
+ ` }) });
83
83
  }
84
- return /* @__PURE__ */ jsx2(Function, { export: true, name, generics, returnType, params, JSDoc, children: `
84
+ return /* @__PURE__ */ jsx2(File2.Source, { name, isExportable: true, children: /* @__PURE__ */ jsx2(Function, { export: true, name, generics, returnType, params, JSDoc, children: `
85
85
  const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}
86
86
 
87
87
  const url = ${client.path.template} as const
@@ -96,7 +96,7 @@ ${transformers.createIndent(4)}`)}`;
96
96
  },
97
97
  mutationOptions
98
98
  )
99
- ` });
99
+ ` }) });
100
100
  }
101
101
  var defaultTemplates = {
102
102
  default: Template
@@ -183,15 +183,14 @@ Mutation.File = function({ templates = defaultTemplates }) {
183
183
  const factory = {
184
184
  name: factoryName
185
185
  };
186
- return /* @__PURE__ */ jsx2(Parser, { language: "typescript", children: /* @__PURE__ */ jsxs2(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
187
- /* @__PURE__ */ jsx2(File.Import, { name: "useSWRMutation", path: "swr/mutation" }),
188
- /* @__PURE__ */ jsx2(File.Import, { name: ["SWRMutationConfiguration", "SWRMutationResponse"], path: "swr/mutation", isTypeOnly: true }),
189
- /* @__PURE__ */ jsx2(File.Import, { name: "client", path: importPath }),
190
- /* @__PURE__ */ jsx2(File.Import, { name: ["ResponseConfig"], path: importPath, isTypeOnly: true }),
186
+ return /* @__PURE__ */ jsxs2(File2, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
187
+ /* @__PURE__ */ jsx2(File2.Import, { name: "useSWRMutation", path: "swr/mutation" }),
188
+ /* @__PURE__ */ jsx2(File2.Import, { name: ["SWRMutationConfiguration", "SWRMutationResponse"], path: "swr/mutation", isTypeOnly: true }),
189
+ /* @__PURE__ */ jsx2(File2.Import, { name: "client", path: importPath }),
190
+ /* @__PURE__ */ jsx2(File2.Import, { name: ["ResponseConfig"], path: importPath, isTypeOnly: true }),
191
191
  /* @__PURE__ */ jsx2(
192
- File.Import,
192
+ File2.Import,
193
193
  {
194
- extName,
195
194
  name: [
196
195
  schemas.request?.name,
197
196
  schemas.response.name,
@@ -205,28 +204,26 @@ Mutation.File = function({ templates = defaultTemplates }) {
205
204
  isTypeOnly: true
206
205
  }
207
206
  ),
208
- /* @__PURE__ */ jsxs2(File.Source, { children: [
209
- /* @__PURE__ */ jsx2(SchemaType, { factory }),
210
- /* @__PURE__ */ jsx2(Mutation, { Template: Template4, factory })
211
- ] })
212
- ] }) });
207
+ /* @__PURE__ */ jsx2(SchemaType, { factory }),
208
+ /* @__PURE__ */ jsx2(Mutation, { Template: Template4, factory })
209
+ ] });
213
210
  };
214
211
  Mutation.templates = defaultTemplates;
215
212
 
216
213
  // src/components/Query.tsx
217
214
  import { FunctionParams as FunctionParams3, URLPath as URLPath3 } from "@kubb/core/utils";
218
- import { Parser as Parser2, File as File2, Function as Function3, useApp as useApp4 } from "@kubb/react";
219
- import { pluginTsName as pluginTsName4 } from "@kubb/plugin-ts";
220
215
  import { useOperation as useOperation4, useOperationManager as useOperationManager4 } from "@kubb/plugin-oas/hooks";
221
216
  import { getASTParams as getASTParams3, getComments as getComments2 } from "@kubb/plugin-oas/utils";
217
+ import { pluginTsName as pluginTsName4 } from "@kubb/plugin-ts";
222
218
  import { pluginZodName as pluginZodName2 } from "@kubb/plugin-zod";
219
+ import { File as File4, Function as Function3, useApp as useApp4 } from "@kubb/react";
223
220
 
224
221
  // src/components/QueryOptions.tsx
225
222
  import transformers2 from "@kubb/core/transformers";
226
223
  import { FunctionParams as FunctionParams2, URLPath as URLPath2 } from "@kubb/core/utils";
227
224
  import { useOperation as useOperation3, useOperationManager as useOperationManager3 } from "@kubb/plugin-oas/hooks";
228
225
  import { getASTParams as getASTParams2 } from "@kubb/plugin-oas/utils";
229
- import { Function as Function2, useApp as useApp3 } from "@kubb/react";
226
+ import { Function as Function2, File as File3, useApp as useApp3 } from "@kubb/react";
230
227
  import { pluginZodName } from "@kubb/plugin-zod";
231
228
  import { pluginTsName as pluginTsName3 } from "@kubb/plugin-ts";
232
229
  import { jsx as jsx3 } from "@kubb/react/jsx-runtime";
@@ -262,7 +259,7 @@ ${transformers2.createIndent(4)}`)}`;
262
259
  })
263
260
  }
264
261
  ` : void 0;
265
- return /* @__PURE__ */ jsx3(Function2, { name, export: true, generics, returnType, params, JSDoc, children: `
262
+ return /* @__PURE__ */ jsx3(File3.Source, { name, isExportable: true, children: /* @__PURE__ */ jsx3(Function2, { name, export: true, generics, returnType, params, JSDoc, children: `
266
263
  return {
267
264
  fetcher: async () => {
268
265
  ${formData || ""}
@@ -274,7 +271,7 @@ ${transformers2.createIndent(4)}`)}`;
274
271
  },
275
272
  }
276
273
 
277
- ` });
274
+ ` }) });
278
275
  }
279
276
  var defaultTemplates2 = {
280
277
  default: Template2
@@ -350,7 +347,7 @@ QueryOptions.templates = defaultTemplates2;
350
347
  import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs3 } from "@kubb/react/jsx-runtime";
351
348
  function Template3({ name, generics, returnType, params, JSDoc, hook, client }) {
352
349
  if (client.withQueryParams) {
353
- return /* @__PURE__ */ jsx4(Fragment2, { children: /* @__PURE__ */ jsx4(Function3, { name, export: true, generics, returnType, params, JSDoc, children: `
350
+ return /* @__PURE__ */ jsx4(File4.Source, { name, isExportable: true, children: /* @__PURE__ */ jsx4(Function3, { name, export: true, generics, returnType, params, JSDoc, children: `
354
351
  const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}
355
352
 
356
353
  const url = ${client.path.template}
@@ -365,7 +362,7 @@ function Template3({ name, generics, returnType, params, JSDoc, hook, client })
365
362
  return query
366
363
  ` }) });
367
364
  }
368
- return /* @__PURE__ */ jsx4(Fragment2, { children: /* @__PURE__ */ jsx4(Function3, { name, export: true, generics, returnType, params, JSDoc, children: `
365
+ return /* @__PURE__ */ jsx4(File4.Source, { name, isExportable: true, children: /* @__PURE__ */ jsx4(Function3, { name, export: true, generics, returnType, params, JSDoc, children: `
369
366
  const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}
370
367
 
371
368
  const url = ${client.path.template}
@@ -503,16 +500,15 @@ Query.File = function({ templates }) {
503
500
  const factory = {
504
501
  name: factoryName
505
502
  };
506
- return /* @__PURE__ */ jsx4(Parser2, { language: "typescript", children: /* @__PURE__ */ jsxs3(File2, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
507
- parser === "zod" && /* @__PURE__ */ jsx4(File2.Import, { extName, name: [zodSchemas.response.name], root: file.path, path: fileZodSchemas.path }),
508
- /* @__PURE__ */ jsx4(File2.Import, { name: "useSWR", path: "swr" }),
509
- /* @__PURE__ */ jsx4(File2.Import, { name: ["SWRConfiguration", "SWRResponse"], path: "swr", isTypeOnly: true }),
510
- /* @__PURE__ */ jsx4(File2.Import, { name: "client", path: importPath }),
511
- /* @__PURE__ */ jsx4(File2.Import, { name: ["ResponseConfig"], path: importPath, isTypeOnly: true }),
503
+ return /* @__PURE__ */ jsxs3(File4, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
504
+ parser === "zod" && /* @__PURE__ */ jsx4(File4.Import, { name: [zodSchemas.response.name], root: file.path, path: fileZodSchemas.path }),
505
+ /* @__PURE__ */ jsx4(File4.Import, { name: "useSWR", path: "swr" }),
506
+ /* @__PURE__ */ jsx4(File4.Import, { name: ["SWRConfiguration", "SWRResponse"], path: "swr", isTypeOnly: true }),
507
+ /* @__PURE__ */ jsx4(File4.Import, { name: "client", path: importPath }),
508
+ /* @__PURE__ */ jsx4(File4.Import, { name: ["ResponseConfig"], path: importPath, isTypeOnly: true }),
512
509
  /* @__PURE__ */ jsx4(
513
- File2.Import,
510
+ File4.Import,
514
511
  {
515
- extName,
516
512
  name: [
517
513
  schemas.request?.name,
518
514
  schemas.response.name,
@@ -526,11 +522,9 @@ Query.File = function({ templates }) {
526
522
  isTypeOnly: true
527
523
  }
528
524
  ),
529
- /* @__PURE__ */ jsxs3(File2.Source, { children: [
530
- /* @__PURE__ */ jsx4(SchemaType, { factory }),
531
- /* @__PURE__ */ jsx4(Query, { factory, Template: Template4, QueryOptionsTemplate })
532
- ] })
533
- ] }) });
525
+ /* @__PURE__ */ jsx4(SchemaType, { factory }),
526
+ /* @__PURE__ */ jsx4(Query, { factory, Template: Template4, QueryOptionsTemplate })
527
+ ] });
534
528
  };
535
529
  Query.templates = defaultTemplates3;
536
530
 
@@ -539,4 +533,4 @@ export {
539
533
  QueryOptions,
540
534
  Query
541
535
  };
542
- //# sourceMappingURL=chunk-ECJ346AA.js.map
536
+ //# sourceMappingURL=chunk-I4GGJ5YS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Mutation.tsx","../src/components/SchemaType.tsx","../src/components/Query.tsx","../src/components/QueryOptions.tsx"],"sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { FunctionParams, URLPath } from '@kubb/core/utils'\nimport { File, Function, useApp } from '@kubb/react'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getASTParams, getComments } from '@kubb/plugin-oas/utils'\n\nimport { SchemaType } from './SchemaType.tsx'\n\nimport type { HttpMethod } from '@kubb/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginSwr } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: string\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n hook: {\n name: string\n generics?: string\n }\n client: {\n method: HttpMethod\n generics: string\n withQueryParams: boolean\n withPathParams: boolean\n withData: boolean\n withHeaders: boolean\n path: URLPath\n }\n dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>\n}\n\nfunction Template({ name, generics, returnType, params, JSDoc, client, hook, dataReturnType }: TemplateProps): ReactNode {\n const clientOptions = [\n `method: \"${client.method}\"`,\n 'url',\n client.withQueryParams ? 'params' : undefined,\n client.withData ? 'data' : undefined,\n client.withHeaders ? 'headers: { ...headers, ...clientOptions.headers }' : undefined,\n '...clientOptions',\n ].filter(Boolean)\n\n const resolvedClientOptions = `${transformers.createIndent(4)}${clientOptions.join(`,\\n${transformers.createIndent(4)}`)}`\n if (client.withQueryParams) {\n return (\n <File.Source name={name} isExportable>\n <Function export name={name} generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}\n\n const url = ${client.path.template} as const\n return ${hook.name}<${hook.generics}>(\n shouldFetch ? [url, params]: null,\n async (_url${client.withData ? ', { arg: data }' : ''}) => {\n const res = await client<${client.generics}>({\n ${resolvedClientOptions}\n })\n\n return ${dataReturnType === 'data' ? 'res.data' : 'res'}\n },\n mutationOptions\n )\n `}\n </Function>\n </File.Source>\n )\n }\n\n return (\n <File.Source name={name} isExportable>\n <Function export name={name} generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}\n\n const url = ${client.path.template} as const\n return ${hook.name}<${hook.generics}>(\n shouldFetch ? url : null,\n async (_url${client.withData ? ', { arg: data }' : ''}) => {\n const res = await client<${client.generics}>({\n ${resolvedClientOptions}\n })\n\n return ${dataReturnType === 'data' ? 'res.data' : 'res'}\n },\n mutationOptions\n )\n `}\n </Function>\n </File.Source>\n )\n}\n\nconst defaultTemplates = {\n default: Template,\n} as const\n\ntype Props = {\n factory: {\n name: string\n }\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<TemplateProps>\n}\n\nexport function Mutation({ factory, Template = defaultTemplates.default }: Props): ReactNode {\n const {\n plugin: {\n options: { dataReturnType },\n },\n } = useApp<PluginSwr>()\n const { getSchemas, getName } = useOperationManager()\n const operation = useOperation()\n\n const name = getName(operation, { type: 'function' })\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n const params = new FunctionParams()\n const client = {\n method: operation.method,\n path: new URLPath(operation.path),\n generics: [`${factory.name}[\"data\"]`, `${factory.name}[\"error\"]`, schemas.request?.name ? `${factory.name}[\"request\"]` : ''].filter(Boolean).join(', '),\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withPathParams: !!schemas.pathParams?.name,\n withHeaders: !!schemas.headerParams?.name,\n }\n\n const resultGenerics = [`${factory.name}[\"response\"]`, `${factory.name}[\"error\"]`]\n\n params.add([\n ...getASTParams(schemas.pathParams, { typed: true }),\n {\n name: 'params',\n type: `${factory.name}['queryParams']`,\n enabled: client.withQueryParams,\n required: false,\n },\n {\n name: 'headers',\n type: `${factory.name}['headerParams']`,\n enabled: client.withHeaders,\n required: false,\n },\n {\n name: 'options',\n required: false,\n type: `{\n mutation?: SWRMutationConfiguration<${resultGenerics.join(', ')}>,\n client?: ${factory.name}['client']['parameters'],\n shouldFetch?: boolean,\n }`,\n default: '{}',\n },\n ])\n\n const hook = {\n name: 'useSWRMutation',\n generics: [...resultGenerics, client.withQueryParams ? '[typeof url, typeof params] | null' : 'typeof url | null'].join(', '),\n }\n\n return (\n <Template\n name={name}\n JSDoc={{ comments: getComments(operation) }}\n client={client}\n hook={hook}\n params={params.toString()}\n returnType={`SWRMutationResponse<${resultGenerics.join(', ')}>`}\n dataReturnType={dataReturnType}\n />\n )\n}\n\ntype FileProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: typeof defaultTemplates\n}\n\nMutation.File = function ({ templates = defaultTemplates }: FileProps): ReactNode {\n const {\n plugin: {\n options: {\n extName,\n client: { importPath },\n },\n },\n } = useApp<PluginSwr>()\n\n const { getSchemas, getFile, getName } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const file = getFile(operation)\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n const factoryName = getName(operation, { type: 'type' })\n\n const Template = templates.default\n const factory = {\n name: factoryName,\n }\n\n return (\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name=\"useSWRMutation\" path=\"swr/mutation\" />\n <File.Import name={['SWRMutationConfiguration', 'SWRMutationResponse']} path=\"swr/mutation\" isTypeOnly />\n <File.Import name={'client'} path={importPath} />\n <File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />\n <File.Import\n name={[\n schemas.request?.name,\n schemas.response.name,\n schemas.pathParams?.name,\n schemas.queryParams?.name,\n schemas.headerParams?.name,\n ...(schemas.errors?.map((error) => error.name) || []),\n ].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n\n <SchemaType factory={factory} />\n <Mutation Template={Template} factory={factory} />\n </File>\n )\n}\n\nMutation.templates = defaultTemplates\n","import { File, Type, useApp } from '@kubb/react'\n\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport type { ReactNode } from 'react'\nimport type { PluginSwr } from '../types.ts'\n\ntype Props = {\n factory: {\n name: string\n }\n}\n\nexport function SchemaType({ factory }: Props): ReactNode {\n const {\n plugin: {\n options: { dataReturnType },\n },\n } = useApp<PluginSwr>()\n const { getSchemas } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n const [TData, TError, TRequest, TPathParams, TQueryParams, THeaderParams, TResponse] = [\n schemas.response.name,\n schemas.errors?.map((item) => item.name).join(' | ') || 'never',\n schemas.request?.name || 'never',\n schemas.pathParams?.name || 'never',\n schemas.queryParams?.name || 'never',\n schemas.headerParams?.name || 'never',\n schemas.response.name,\n ]\n\n const clientType = `${factory.name}Client`\n\n return (\n <>\n <File.Source name={clientType} isTypeOnly>\n <Type name={clientType}>{`typeof client<${TResponse}, ${TError}, ${TRequest}>`}</Type>\n </File.Source>\n <File.Source name={factory.name} isTypeOnly>\n <Type name={factory.name}>\n {`\n {\n data: ${TData}\n error: ${TError}\n request: ${TRequest}\n pathParams: ${TPathParams}\n queryParams: ${TQueryParams}\n headerParams: ${THeaderParams}\n response: ${dataReturnType === 'data' ? TData : `Awaited<ReturnType<${clientType}>>`}\n client: {\n parameters: Partial<Parameters<${clientType}>[0]>\n return: Awaited<ReturnType<${clientType}>>\n }\n }\n `}\n </Type>\n </File.Source>\n </>\n )\n}\n","import { FunctionParams, URLPath } from '@kubb/core/utils'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getASTParams, getComments } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, Function, useApp } from '@kubb/react'\n\nimport { QueryOptions } from './QueryOptions.tsx'\nimport { SchemaType } from './SchemaType.tsx'\n\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginSwr } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: string\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n hook: {\n name: string\n generics?: string\n queryOptions: string\n }\n client: {\n path: URLPath\n withQueryParams: boolean\n }\n}\n\nfunction Template({ name, generics, returnType, params, JSDoc, hook, client }: TemplateProps): ReactNode {\n if (client.withQueryParams) {\n return (\n <File.Source name={name} isExportable>\n <Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}\n\n const url = ${client.path.template}\n const query = ${hook.name}<${hook.generics}>(\n shouldFetch ? [url, params]: null,\n {\n ...${hook.queryOptions},\n ...queryOptions\n }\n )\n\n return query\n `}\n </Function>\n </File.Source>\n )\n }\n\n return (\n <File.Source name={name} isExportable>\n <Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}\n\n const url = ${client.path.template}\n const query = ${hook.name}<${hook.generics}>(\n shouldFetch ? url : null,\n {\n ...${hook.queryOptions},\n ...queryOptions\n }\n )\n\n return query\n `}\n </Function>\n </File.Source>\n )\n}\n\nconst defaultTemplates = {\n default: Template,\n} as const\n\ntype Props = {\n factory: {\n name: string\n }\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<TemplateProps>\n /**\n * This will make it possible to override the default behaviour.\n */\n QueryOptionsTemplate?: React.ComponentType<React.ComponentProps<typeof QueryOptions.templates.default>>\n}\n\nexport function Query({ factory, Template = defaultTemplates.default, QueryOptionsTemplate = QueryOptions.templates.default }: Props): ReactNode {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { dataReturnType },\n },\n } = useApp<PluginSwr>()\n\n const operation = useOperation()\n const { getSchemas, getName } = useOperationManager()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const zodSchemas = getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' })\n\n const name = getName(operation, { type: 'function' })\n\n const queryOptionsName = pluginManager.resolveName({\n name: `${factory.name}QueryOptions`,\n pluginKey,\n })\n const generics = new FunctionParams()\n const params = new FunctionParams()\n const queryParams = new FunctionParams()\n const client = {\n method: operation.method,\n path: new URLPath(operation.path),\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withPathParams: !!schemas.pathParams?.name,\n withHeaders: !!schemas.headerParams?.name,\n }\n\n const resultGenerics = ['TData', `${factory.name}[\"error\"]`]\n\n generics.add([{ type: 'TData', default: `${factory.name}[\"response\"]` }])\n\n const queryOptionsGenerics = ['TData']\n\n params.add([\n ...getASTParams(schemas.pathParams, { typed: true }),\n {\n name: 'params',\n type: `${factory.name}['queryParams']`,\n enabled: client.withQueryParams,\n required: false,\n },\n {\n name: 'headers',\n type: `${factory.name}['headerParams']`,\n enabled: client.withHeaders,\n required: false,\n },\n {\n name: 'options',\n required: false,\n type: `{\n query?: SWRConfiguration<${resultGenerics.join(', ')}>,\n client?: ${factory.name}['client']['parameters'],\n shouldFetch?: boolean,\n }`,\n default: '{}',\n },\n ])\n\n queryParams.add([\n ...getASTParams(schemas.pathParams, { typed: false }),\n {\n name: 'params',\n enabled: client.withQueryParams,\n required: false,\n },\n {\n name: 'headers',\n enabled: client.withHeaders,\n required: false,\n },\n {\n name: 'clientOptions',\n required: false,\n },\n ])\n\n const hook = {\n name: 'useSWR',\n generics: [...resultGenerics, client.withQueryParams ? '[typeof url, typeof params] | null' : 'typeof url | null'].join(', '),\n queryOptions: `${queryOptionsName}<${queryOptionsGenerics.join(', ')}>(${queryParams.toString()})`,\n }\n\n return (\n <>\n <QueryOptions factory={factory} Template={QueryOptionsTemplate} dataReturnType={dataReturnType} />\n <Template\n name={name}\n generics={generics.toString()}\n JSDoc={{ comments: getComments(operation) }}\n client={client}\n hook={hook}\n params={params.toString()}\n returnType={`SWRResponse<${resultGenerics.join(', ')}>`}\n />\n </>\n )\n}\n\ntype FileProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: {\n query: typeof defaultTemplates\n queryOptions: typeof QueryOptions.templates\n }\n}\n\nQuery.File = function ({ templates }: FileProps): ReactNode {\n const {\n pluginManager,\n plugin: {\n options: {\n extName,\n client: { importPath },\n parser,\n },\n },\n } = useApp<PluginSwr>()\n const { getSchemas, getFile, getName } = useOperationManager()\n const operation = useOperation()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const zodSchemas = getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' })\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n const fileZodSchemas = getFile(operation, {\n pluginKey: [pluginZodName],\n })\n\n const factoryName = getName(operation, { type: 'type' })\n\n const Template = templates?.query.default || defaultTemplates.default\n const QueryOptionsTemplate = templates?.queryOptions.default || QueryOptions.templates.default\n const factory = {\n name: factoryName,\n }\n\n return (\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n {parser === 'zod' && <File.Import name={[zodSchemas.response.name]} root={file.path} path={fileZodSchemas.path} />}\n <File.Import name=\"useSWR\" path=\"swr\" />\n <File.Import name={['SWRConfiguration', 'SWRResponse']} path=\"swr\" isTypeOnly />\n <File.Import name={'client'} path={importPath} />\n <File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />\n <File.Import\n name={[\n schemas.request?.name,\n schemas.response.name,\n schemas.pathParams?.name,\n schemas.queryParams?.name,\n schemas.headerParams?.name,\n ...(schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n\n <SchemaType factory={factory} />\n <Query factory={factory} Template={Template} QueryOptionsTemplate={QueryOptionsTemplate} />\n </File>\n )\n}\n\nQuery.templates = defaultTemplates\n","import transformers from '@kubb/core/transformers'\nimport { FunctionParams, URLPath } from '@kubb/core/utils'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getASTParams } from '@kubb/plugin-oas/utils'\nimport { Function, File, useApp } from '@kubb/react'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { HttpMethod } from '@kubb/oas'\nimport type { ReactNode } from 'react'\nimport type { PluginSwr } from '../types.ts'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: string\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n client: {\n generics: string\n method: HttpMethod\n path: URLPath\n withQueryParams: boolean\n withPathParams: boolean\n withData: boolean\n withHeaders: boolean\n contentType: string\n }\n dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>\n parser: string | undefined\n}\n\nfunction Template({ name, params, generics, returnType, JSDoc, client, dataReturnType, parser }: TemplateProps): ReactNode {\n const isFormData = client.contentType === 'multipart/form-data'\n const headers = [\n client.contentType !== 'application/json' ? `'Content-Type': '${client.contentType}'` : undefined,\n client.withHeaders ? '...headers' : undefined,\n ]\n .filter(Boolean)\n .join(', ')\n\n const clientOptions = [\n `method: \"${client.method}\"`,\n `url: ${client.path.template}`,\n client.withQueryParams ? 'params' : undefined,\n client.withData && !isFormData ? 'data' : undefined,\n client.withData && isFormData ? 'data: formData' : undefined,\n headers.length ? `headers: { ${headers}, ...options.headers }` : undefined,\n '...options',\n ].filter(Boolean)\n\n const resolvedClientOptions = `${transformers.createIndent(4)}${clientOptions.join(`,\\n${transformers.createIndent(4)}`)}`\n\n let returnRes = parser ? `return ${parser}(res.data)` : 'return res.data'\n\n if (dataReturnType === 'full') {\n returnRes = parser ? `return {...res, data: ${parser}(res.data)}` : 'return res'\n }\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if(data) {\n Object.keys(data).forEach((key) => {\n const value = data[key];\n if (typeof key === \"string\" && (typeof value === \"string\" || value instanceof Blob)) {\n formData.append(key, value);\n }\n })\n }\n `\n : undefined\n\n return (\n <File.Source name={name} isExportable>\n <Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n return {\n fetcher: async () => {\n ${formData || ''}\n const res = await client<${client.generics}>({\n ${resolvedClientOptions}\n })\n\n ${returnRes}\n },\n }\n\n `}\n </Function>\n </File.Source>\n )\n}\n\nconst defaultTemplates = {\n default: Template,\n} as const\n\ntype Props = {\n factory: {\n name: string\n }\n dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<TemplateProps>\n}\n\nexport function QueryOptions({ factory, dataReturnType, Template = defaultTemplates.default }: Props): ReactNode {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { parser },\n },\n } = useApp<PluginSwr>()\n const { getSchemas } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const zodSchemas = getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' })\n const name = pluginManager.resolveName({\n name: `${factory.name}QueryOptions`,\n pluginKey,\n })\n const contentType = operation.getContentType()\n\n const generics = new FunctionParams()\n const params = new FunctionParams()\n\n const clientGenerics = ['TData', `${factory.name}['error']`]\n const resultGenerics = ['TData', `${factory.name}['error']`]\n\n generics.add([{ type: 'TData', default: `${factory.name}['response']` }])\n\n params.add([\n ...getASTParams(schemas.pathParams, { typed: true }),\n {\n name: 'params',\n type: `${factory.name}['queryParams']`,\n enabled: !!schemas.queryParams?.name,\n required: false,\n },\n {\n name: 'headers',\n type: `${factory.name}['headerParams']`,\n enabled: !!schemas.headerParams?.name,\n required: false,\n },\n {\n name: 'options',\n type: `${factory.name}['client']['parameters']`,\n default: '{}',\n },\n ])\n\n const client = {\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withPathParams: !!schemas.pathParams?.name,\n withHeaders: !!schemas.headerParams?.name,\n method: operation.method,\n path: new URLPath(operation.path),\n generics: clientGenerics.join(', '),\n contentType,\n }\n\n return (\n <Template\n name={name}\n params={params.toString()}\n generics={generics.toString()}\n returnType={`SWRConfiguration<${resultGenerics.join(', ')}>`}\n client={client}\n dataReturnType={dataReturnType}\n parser={parser === 'zod' ? `${zodSchemas.response.name}.parse` : undefined}\n />\n )\n}\n\nQueryOptions.templates = defaultTemplates\n"],"mappings":";AAAA,OAAO,kBAAkB;AACzB,SAAS,gBAAgB,eAAe;AACxC,SAAS,QAAAA,OAAM,UAAU,UAAAC,eAAc;AACvC,SAAS,gBAAAC,qBAAoB;AAC7B,SAAS,gBAAAC,eAAc,uBAAAC,4BAA2B;AAClD,SAAS,cAAc,mBAAmB;;;ACL1C,SAAS,MAAM,MAAM,cAAc;AAEnC,SAAS,cAAc,2BAA2B;AAClD,SAAS,oBAAoB;AAkCzB,mBAEI,KAFJ;AAxBG,SAAS,WAAW,EAAE,QAAQ,GAAqB;AACxD,QAAM;AAAA,IACJ,QAAQ;AAAA,MACN,SAAS,EAAE,eAAe;AAAA,IAC5B;AAAA,EACF,IAAI,OAAkB;AACtB,QAAM,EAAE,WAAW,IAAI,oBAAoB;AAC3C,QAAM,YAAY,aAAa;AAE/B,QAAM,UAAU,WAAW,WAAW,EAAE,WAAW,CAAC,YAAY,GAAG,MAAM,OAAO,CAAC;AAEjF,QAAM,CAAC,OAAO,QAAQ,UAAU,aAAa,cAAc,eAAe,SAAS,IAAI;AAAA,IACrF,QAAQ,SAAS;AAAA,IACjB,QAAQ,QAAQ,IAAI,CAAC,SAAS,KAAK,IAAI,EAAE,KAAK,KAAK,KAAK;AAAA,IACxD,QAAQ,SAAS,QAAQ;AAAA,IACzB,QAAQ,YAAY,QAAQ;AAAA,IAC5B,QAAQ,aAAa,QAAQ;AAAA,IAC7B,QAAQ,cAAc,QAAQ;AAAA,IAC9B,QAAQ,SAAS;AAAA,EACnB;AAEA,QAAM,aAAa,GAAG,QAAQ,IAAI;AAElC,SACE,iCACE;AAAA,wBAAC,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GAAG,MAAM,YAAY,YAAU,MAAC;AAAA,IACpE,gBAAAH;AAAA,MAACG,MAAK;AAAA,MAAL;AAAA,QACC,MAAM;AAAA,UACJ,QAAQ,SAAS;AAAA,UACjB,QAAQ,SAAS;AAAA,UACjB,QAAQ,YAAY;AAAA,UACpB,QAAQ,aAAa;AAAA,UACrB,QAAQ,cAAc;AAAA,UACtB,GAAI,QAAQ,aAAa,IAAI,CAAC,SAAS,KAAK,IAAI,KAAK,CAAC;AAAA,QACxD,EAAE,OAAO,OAAO;AAAA,QAChB,MAAM,KAAK;AAAA,QACX,MAAM,SAAS;AAAA,QACf,YAAU;AAAA;AAAA,IACZ;AAAA,IAEA,gBAAAH,KAAC,cAAW,SAAkB;AAAA,IAC9B,gBAAAA,KAAC,SAAM,SAAkB,UAAUE,WAAU,sBAA4C;AAAA,KAC3F;AAEJ;AAEA,MAAM,YAAYG;","names":["File","useApp","pluginTsName","useOperation","useOperationManager","jsx","jsxs","File","Template","useApp","useOperationManager","useOperation","pluginTsName","FunctionParams","URLPath","useOperation","useOperationManager","getASTParams","getComments","pluginTsName","pluginZodName","File","Function","useApp","transformers","FunctionParams","URLPath","useOperation","useOperationManager","getASTParams","Function","File","useApp","pluginTsName","jsx","Template","defaultTemplates","Fragment","jsx","jsxs","Template","File","Function","defaultTemplates","useApp","useOperation","useOperationManager","pluginTsName","pluginZodName","FunctionParams","URLPath","getASTParams","getComments"]}
@@ -31,8 +31,8 @@ function SchemaType({ factory }) {
31
31
  ];
32
32
  const clientType = `${factory.name}Client`;
33
33
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
34
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { name: clientType, children: `typeof client<${TResponse}, ${TError}, ${TRequest}>` }),
35
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { name: factory.name, children: `
34
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: clientType, isTypeOnly: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { name: clientType, children: `typeof client<${TResponse}, ${TError}, ${TRequest}>` }) }),
35
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name: factory.name, isTypeOnly: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { name: factory.name, children: `
36
36
  {
37
37
  data: ${TData}
38
38
  error: ${TError}
@@ -46,7 +46,7 @@ function SchemaType({ factory }) {
46
46
  return: Awaited<ReturnType<${clientType}>>
47
47
  }
48
48
  }
49
- ` })
49
+ ` }) })
50
50
  ] });
51
51
  }
52
52
 
@@ -64,7 +64,7 @@ function Template({ name, generics, returnType, params, JSDoc, client, hook, dat
64
64
  const resolvedClientOptions = `${_transformers2.default.createIndent(4)}${clientOptions.join(`,
65
65
  ${_transformers2.default.createIndent(4)}`)}`;
66
66
  if (client.withQueryParams) {
67
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { export: true, name, generics, returnType, params, JSDoc, children: `
67
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { export: true, name, generics, returnType, params, JSDoc, children: `
68
68
  const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}
69
69
 
70
70
  const url = ${client.path.template} as const
@@ -79,9 +79,9 @@ ${_transformers2.default.createIndent(4)}`)}`;
79
79
  },
80
80
  mutationOptions
81
81
  )
82
- ` });
82
+ ` }) });
83
83
  }
84
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { export: true, name, generics, returnType, params, JSDoc, children: `
84
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { export: true, name, generics, returnType, params, JSDoc, children: `
85
85
  const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}
86
86
 
87
87
  const url = ${client.path.template} as const
@@ -96,7 +96,7 @@ ${_transformers2.default.createIndent(4)}`)}`;
96
96
  },
97
97
  mutationOptions
98
98
  )
99
- ` });
99
+ ` }) });
100
100
  }
101
101
  var defaultTemplates = {
102
102
  default: Template
@@ -183,7 +183,7 @@ Mutation.File = function({ templates = defaultTemplates }) {
183
183
  const factory = {
184
184
  name: factoryName
185
185
  };
186
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Parser, { language: "typescript", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
186
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
187
187
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: "useSWRMutation", path: "swr/mutation" }),
188
188
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["SWRMutationConfiguration", "SWRMutationResponse"], path: "swr/mutation", isTypeOnly: true }),
189
189
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: "client", path: importPath }),
@@ -191,7 +191,6 @@ Mutation.File = function({ templates = defaultTemplates }) {
191
191
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
192
192
  _react.File.Import,
193
193
  {
194
- extName,
195
194
  name: [
196
195
  _optionalChain([schemas, 'access', _24 => _24.request, 'optionalAccess', _25 => _25.name]),
197
196
  schemas.response.name,
@@ -205,11 +204,9 @@ Mutation.File = function({ templates = defaultTemplates }) {
205
204
  isTypeOnly: true
206
205
  }
207
206
  ),
208
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File.Source, { children: [
209
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SchemaType, { factory }),
210
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Mutation, { Template: Template4, factory })
211
- ] })
212
- ] }) });
207
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SchemaType, { factory }),
208
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Mutation, { Template: Template4, factory })
209
+ ] });
213
210
  };
214
211
  Mutation.templates = defaultTemplates;
215
212
 
@@ -218,9 +215,9 @@ Mutation.templates = defaultTemplates;
218
215
 
219
216
 
220
217
 
221
-
222
218
  var _pluginzod = require('@kubb/plugin-zod');
223
219
 
220
+
224
221
  // src/components/QueryOptions.tsx
225
222
 
226
223
 
@@ -262,7 +259,7 @@ ${_transformers2.default.createIndent(4)}`)}`;
262
259
  })
263
260
  }
264
261
  ` : void 0;
265
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, generics, returnType, params, JSDoc, children: `
262
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, generics, returnType, params, JSDoc, children: `
266
263
  return {
267
264
  fetcher: async () => {
268
265
  ${formData || ""}
@@ -274,7 +271,7 @@ ${_transformers2.default.createIndent(4)}`)}`;
274
271
  },
275
272
  }
276
273
 
277
- ` });
274
+ ` }) });
278
275
  }
279
276
  var defaultTemplates2 = {
280
277
  default: Template2
@@ -350,7 +347,7 @@ QueryOptions.templates = defaultTemplates2;
350
347
 
351
348
  function Template3({ name, generics, returnType, params, JSDoc, hook, client }) {
352
349
  if (client.withQueryParams) {
353
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, generics, returnType, params, JSDoc, children: `
350
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, generics, returnType, params, JSDoc, children: `
354
351
  const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}
355
352
 
356
353
  const url = ${client.path.template}
@@ -365,7 +362,7 @@ function Template3({ name, generics, returnType, params, JSDoc, hook, client })
365
362
  return query
366
363
  ` }) });
367
364
  }
368
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, generics, returnType, params, JSDoc, children: `
365
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, generics, returnType, params, JSDoc, children: `
369
366
  const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}
370
367
 
371
368
  const url = ${client.path.template}
@@ -503,8 +500,8 @@ Query.File = function({ templates }) {
503
500
  const factory = {
504
501
  name: factoryName
505
502
  };
506
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Parser, { language: "typescript", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
507
- parser === "zod" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { extName, name: [zodSchemas.response.name], root: file.path, path: fileZodSchemas.path }),
503
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
504
+ parser === "zod" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: [zodSchemas.response.name], root: file.path, path: fileZodSchemas.path }),
508
505
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: "useSWR", path: "swr" }),
509
506
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["SWRConfiguration", "SWRResponse"], path: "swr", isTypeOnly: true }),
510
507
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: "client", path: importPath }),
@@ -512,7 +509,6 @@ Query.File = function({ templates }) {
512
509
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
513
510
  _react.File.Import,
514
511
  {
515
- extName,
516
512
  name: [
517
513
  _optionalChain([schemas, 'access', _59 => _59.request, 'optionalAccess', _60 => _60.name]),
518
514
  schemas.response.name,
@@ -526,11 +522,9 @@ Query.File = function({ templates }) {
526
522
  isTypeOnly: true
527
523
  }
528
524
  ),
529
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File.Source, { children: [
530
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SchemaType, { factory }),
531
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Query, { factory, Template: Template4, QueryOptionsTemplate })
532
- ] })
533
- ] }) });
525
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SchemaType, { factory }),
526
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Query, { factory, Template: Template4, QueryOptionsTemplate })
527
+ ] });
534
528
  };
535
529
  Query.templates = defaultTemplates3;
536
530
 
@@ -539,4 +533,4 @@ Query.templates = defaultTemplates3;
539
533
 
540
534
 
541
535
  exports.Mutation = Mutation; exports.QueryOptions = QueryOptions; exports.Query = Query;
542
- //# sourceMappingURL=chunk-H4LHXYRJ.cjs.map
536
+ //# sourceMappingURL=chunk-PX3AB367.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-swr/dist/chunk-PX3AB367.cjs","../src/components/Mutation.tsx","../src/components/SchemaType.tsx","../src/components/Query.tsx","../src/components/QueryOptions.tsx"],"names":["useOperation","Template","jsx","File","transformers","Function","defaultTemplates","FunctionParams","URLPath","Fragment","pluginZodName"],"mappings":"AAAA;ACAA,mHAAyB;AACzB,yCAAwC;AACxC,oCAAuC;AACvC,2CAA6B;AAC7B,+CAAkD;AAClD,gDAA0C;ADE1C;AACA;AERA;AAEA;AACA;AAkCI,qDAAA;AAxBG,SAAS,UAAA,CAAW,EAAE,QAAQ,CAAA,EAAqB;A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;AACI,UAAA;AACL,QAAA;AACE,QAAA;AACL,QAAA;AACI,QAAA;AAAA,MAAA;AACZ,IAAA;AAEAA,oBAAAA;AACAA,oBAAAA;AACF,EAAA;AAEJ;AAEkBI;AHsPI;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-swr/dist/chunk-PX3AB367.cjs","sourcesContent":[null,"import transformers from '@kubb/core/transformers'\nimport { FunctionParams, URLPath } from '@kubb/core/utils'\nimport { File, Function, useApp } from '@kubb/react'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getASTParams, getComments } from '@kubb/plugin-oas/utils'\n\nimport { SchemaType } from './SchemaType.tsx'\n\nimport type { HttpMethod } from '@kubb/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginSwr } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: string\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n hook: {\n name: string\n generics?: string\n }\n client: {\n method: HttpMethod\n generics: string\n withQueryParams: boolean\n withPathParams: boolean\n withData: boolean\n withHeaders: boolean\n path: URLPath\n }\n dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>\n}\n\nfunction Template({ name, generics, returnType, params, JSDoc, client, hook, dataReturnType }: TemplateProps): ReactNode {\n const clientOptions = [\n `method: \"${client.method}\"`,\n 'url',\n client.withQueryParams ? 'params' : undefined,\n client.withData ? 'data' : undefined,\n client.withHeaders ? 'headers: { ...headers, ...clientOptions.headers }' : undefined,\n '...clientOptions',\n ].filter(Boolean)\n\n const resolvedClientOptions = `${transformers.createIndent(4)}${clientOptions.join(`,\\n${transformers.createIndent(4)}`)}`\n if (client.withQueryParams) {\n return (\n <File.Source name={name} isExportable>\n <Function export name={name} generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}\n\n const url = ${client.path.template} as const\n return ${hook.name}<${hook.generics}>(\n shouldFetch ? [url, params]: null,\n async (_url${client.withData ? ', { arg: data }' : ''}) => {\n const res = await client<${client.generics}>({\n ${resolvedClientOptions}\n })\n\n return ${dataReturnType === 'data' ? 'res.data' : 'res'}\n },\n mutationOptions\n )\n `}\n </Function>\n </File.Source>\n )\n }\n\n return (\n <File.Source name={name} isExportable>\n <Function export name={name} generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}\n\n const url = ${client.path.template} as const\n return ${hook.name}<${hook.generics}>(\n shouldFetch ? url : null,\n async (_url${client.withData ? ', { arg: data }' : ''}) => {\n const res = await client<${client.generics}>({\n ${resolvedClientOptions}\n })\n\n return ${dataReturnType === 'data' ? 'res.data' : 'res'}\n },\n mutationOptions\n )\n `}\n </Function>\n </File.Source>\n )\n}\n\nconst defaultTemplates = {\n default: Template,\n} as const\n\ntype Props = {\n factory: {\n name: string\n }\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<TemplateProps>\n}\n\nexport function Mutation({ factory, Template = defaultTemplates.default }: Props): ReactNode {\n const {\n plugin: {\n options: { dataReturnType },\n },\n } = useApp<PluginSwr>()\n const { getSchemas, getName } = useOperationManager()\n const operation = useOperation()\n\n const name = getName(operation, { type: 'function' })\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n const params = new FunctionParams()\n const client = {\n method: operation.method,\n path: new URLPath(operation.path),\n generics: [`${factory.name}[\"data\"]`, `${factory.name}[\"error\"]`, schemas.request?.name ? `${factory.name}[\"request\"]` : ''].filter(Boolean).join(', '),\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withPathParams: !!schemas.pathParams?.name,\n withHeaders: !!schemas.headerParams?.name,\n }\n\n const resultGenerics = [`${factory.name}[\"response\"]`, `${factory.name}[\"error\"]`]\n\n params.add([\n ...getASTParams(schemas.pathParams, { typed: true }),\n {\n name: 'params',\n type: `${factory.name}['queryParams']`,\n enabled: client.withQueryParams,\n required: false,\n },\n {\n name: 'headers',\n type: `${factory.name}['headerParams']`,\n enabled: client.withHeaders,\n required: false,\n },\n {\n name: 'options',\n required: false,\n type: `{\n mutation?: SWRMutationConfiguration<${resultGenerics.join(', ')}>,\n client?: ${factory.name}['client']['parameters'],\n shouldFetch?: boolean,\n }`,\n default: '{}',\n },\n ])\n\n const hook = {\n name: 'useSWRMutation',\n generics: [...resultGenerics, client.withQueryParams ? '[typeof url, typeof params] | null' : 'typeof url | null'].join(', '),\n }\n\n return (\n <Template\n name={name}\n JSDoc={{ comments: getComments(operation) }}\n client={client}\n hook={hook}\n params={params.toString()}\n returnType={`SWRMutationResponse<${resultGenerics.join(', ')}>`}\n dataReturnType={dataReturnType}\n />\n )\n}\n\ntype FileProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: typeof defaultTemplates\n}\n\nMutation.File = function ({ templates = defaultTemplates }: FileProps): ReactNode {\n const {\n plugin: {\n options: {\n extName,\n client: { importPath },\n },\n },\n } = useApp<PluginSwr>()\n\n const { getSchemas, getFile, getName } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const file = getFile(operation)\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n const factoryName = getName(operation, { type: 'type' })\n\n const Template = templates.default\n const factory = {\n name: factoryName,\n }\n\n return (\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name=\"useSWRMutation\" path=\"swr/mutation\" />\n <File.Import name={['SWRMutationConfiguration', 'SWRMutationResponse']} path=\"swr/mutation\" isTypeOnly />\n <File.Import name={'client'} path={importPath} />\n <File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />\n <File.Import\n name={[\n schemas.request?.name,\n schemas.response.name,\n schemas.pathParams?.name,\n schemas.queryParams?.name,\n schemas.headerParams?.name,\n ...(schemas.errors?.map((error) => error.name) || []),\n ].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n\n <SchemaType factory={factory} />\n <Mutation Template={Template} factory={factory} />\n </File>\n )\n}\n\nMutation.templates = defaultTemplates\n","import { File, Type, useApp } from '@kubb/react'\n\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport type { ReactNode } from 'react'\nimport type { PluginSwr } from '../types.ts'\n\ntype Props = {\n factory: {\n name: string\n }\n}\n\nexport function SchemaType({ factory }: Props): ReactNode {\n const {\n plugin: {\n options: { dataReturnType },\n },\n } = useApp<PluginSwr>()\n const { getSchemas } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n const [TData, TError, TRequest, TPathParams, TQueryParams, THeaderParams, TResponse] = [\n schemas.response.name,\n schemas.errors?.map((item) => item.name).join(' | ') || 'never',\n schemas.request?.name || 'never',\n schemas.pathParams?.name || 'never',\n schemas.queryParams?.name || 'never',\n schemas.headerParams?.name || 'never',\n schemas.response.name,\n ]\n\n const clientType = `${factory.name}Client`\n\n return (\n <>\n <File.Source name={clientType} isTypeOnly>\n <Type name={clientType}>{`typeof client<${TResponse}, ${TError}, ${TRequest}>`}</Type>\n </File.Source>\n <File.Source name={factory.name} isTypeOnly>\n <Type name={factory.name}>\n {`\n {\n data: ${TData}\n error: ${TError}\n request: ${TRequest}\n pathParams: ${TPathParams}\n queryParams: ${TQueryParams}\n headerParams: ${THeaderParams}\n response: ${dataReturnType === 'data' ? TData : `Awaited<ReturnType<${clientType}>>`}\n client: {\n parameters: Partial<Parameters<${clientType}>[0]>\n return: Awaited<ReturnType<${clientType}>>\n }\n }\n `}\n </Type>\n </File.Source>\n </>\n )\n}\n","import { FunctionParams, URLPath } from '@kubb/core/utils'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getASTParams, getComments } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, Function, useApp } from '@kubb/react'\n\nimport { QueryOptions } from './QueryOptions.tsx'\nimport { SchemaType } from './SchemaType.tsx'\n\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginSwr } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: string\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n hook: {\n name: string\n generics?: string\n queryOptions: string\n }\n client: {\n path: URLPath\n withQueryParams: boolean\n }\n}\n\nfunction Template({ name, generics, returnType, params, JSDoc, hook, client }: TemplateProps): ReactNode {\n if (client.withQueryParams) {\n return (\n <File.Source name={name} isExportable>\n <Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}\n\n const url = ${client.path.template}\n const query = ${hook.name}<${hook.generics}>(\n shouldFetch ? [url, params]: null,\n {\n ...${hook.queryOptions},\n ...queryOptions\n }\n )\n\n return query\n `}\n </Function>\n </File.Source>\n )\n }\n\n return (\n <File.Source name={name} isExportable>\n <Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}\n\n const url = ${client.path.template}\n const query = ${hook.name}<${hook.generics}>(\n shouldFetch ? url : null,\n {\n ...${hook.queryOptions},\n ...queryOptions\n }\n )\n\n return query\n `}\n </Function>\n </File.Source>\n )\n}\n\nconst defaultTemplates = {\n default: Template,\n} as const\n\ntype Props = {\n factory: {\n name: string\n }\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<TemplateProps>\n /**\n * This will make it possible to override the default behaviour.\n */\n QueryOptionsTemplate?: React.ComponentType<React.ComponentProps<typeof QueryOptions.templates.default>>\n}\n\nexport function Query({ factory, Template = defaultTemplates.default, QueryOptionsTemplate = QueryOptions.templates.default }: Props): ReactNode {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { dataReturnType },\n },\n } = useApp<PluginSwr>()\n\n const operation = useOperation()\n const { getSchemas, getName } = useOperationManager()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const zodSchemas = getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' })\n\n const name = getName(operation, { type: 'function' })\n\n const queryOptionsName = pluginManager.resolveName({\n name: `${factory.name}QueryOptions`,\n pluginKey,\n })\n const generics = new FunctionParams()\n const params = new FunctionParams()\n const queryParams = new FunctionParams()\n const client = {\n method: operation.method,\n path: new URLPath(operation.path),\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withPathParams: !!schemas.pathParams?.name,\n withHeaders: !!schemas.headerParams?.name,\n }\n\n const resultGenerics = ['TData', `${factory.name}[\"error\"]`]\n\n generics.add([{ type: 'TData', default: `${factory.name}[\"response\"]` }])\n\n const queryOptionsGenerics = ['TData']\n\n params.add([\n ...getASTParams(schemas.pathParams, { typed: true }),\n {\n name: 'params',\n type: `${factory.name}['queryParams']`,\n enabled: client.withQueryParams,\n required: false,\n },\n {\n name: 'headers',\n type: `${factory.name}['headerParams']`,\n enabled: client.withHeaders,\n required: false,\n },\n {\n name: 'options',\n required: false,\n type: `{\n query?: SWRConfiguration<${resultGenerics.join(', ')}>,\n client?: ${factory.name}['client']['parameters'],\n shouldFetch?: boolean,\n }`,\n default: '{}',\n },\n ])\n\n queryParams.add([\n ...getASTParams(schemas.pathParams, { typed: false }),\n {\n name: 'params',\n enabled: client.withQueryParams,\n required: false,\n },\n {\n name: 'headers',\n enabled: client.withHeaders,\n required: false,\n },\n {\n name: 'clientOptions',\n required: false,\n },\n ])\n\n const hook = {\n name: 'useSWR',\n generics: [...resultGenerics, client.withQueryParams ? '[typeof url, typeof params] | null' : 'typeof url | null'].join(', '),\n queryOptions: `${queryOptionsName}<${queryOptionsGenerics.join(', ')}>(${queryParams.toString()})`,\n }\n\n return (\n <>\n <QueryOptions factory={factory} Template={QueryOptionsTemplate} dataReturnType={dataReturnType} />\n <Template\n name={name}\n generics={generics.toString()}\n JSDoc={{ comments: getComments(operation) }}\n client={client}\n hook={hook}\n params={params.toString()}\n returnType={`SWRResponse<${resultGenerics.join(', ')}>`}\n />\n </>\n )\n}\n\ntype FileProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: {\n query: typeof defaultTemplates\n queryOptions: typeof QueryOptions.templates\n }\n}\n\nQuery.File = function ({ templates }: FileProps): ReactNode {\n const {\n pluginManager,\n plugin: {\n options: {\n extName,\n client: { importPath },\n parser,\n },\n },\n } = useApp<PluginSwr>()\n const { getSchemas, getFile, getName } = useOperationManager()\n const operation = useOperation()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const zodSchemas = getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' })\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n const fileZodSchemas = getFile(operation, {\n pluginKey: [pluginZodName],\n })\n\n const factoryName = getName(operation, { type: 'type' })\n\n const Template = templates?.query.default || defaultTemplates.default\n const QueryOptionsTemplate = templates?.queryOptions.default || QueryOptions.templates.default\n const factory = {\n name: factoryName,\n }\n\n return (\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n {parser === 'zod' && <File.Import name={[zodSchemas.response.name]} root={file.path} path={fileZodSchemas.path} />}\n <File.Import name=\"useSWR\" path=\"swr\" />\n <File.Import name={['SWRConfiguration', 'SWRResponse']} path=\"swr\" isTypeOnly />\n <File.Import name={'client'} path={importPath} />\n <File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />\n <File.Import\n name={[\n schemas.request?.name,\n schemas.response.name,\n schemas.pathParams?.name,\n schemas.queryParams?.name,\n schemas.headerParams?.name,\n ...(schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n\n <SchemaType factory={factory} />\n <Query factory={factory} Template={Template} QueryOptionsTemplate={QueryOptionsTemplate} />\n </File>\n )\n}\n\nQuery.templates = defaultTemplates\n","import transformers from '@kubb/core/transformers'\nimport { FunctionParams, URLPath } from '@kubb/core/utils'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getASTParams } from '@kubb/plugin-oas/utils'\nimport { Function, File, useApp } from '@kubb/react'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { HttpMethod } from '@kubb/oas'\nimport type { ReactNode } from 'react'\nimport type { PluginSwr } from '../types.ts'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: string\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n client: {\n generics: string\n method: HttpMethod\n path: URLPath\n withQueryParams: boolean\n withPathParams: boolean\n withData: boolean\n withHeaders: boolean\n contentType: string\n }\n dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>\n parser: string | undefined\n}\n\nfunction Template({ name, params, generics, returnType, JSDoc, client, dataReturnType, parser }: TemplateProps): ReactNode {\n const isFormData = client.contentType === 'multipart/form-data'\n const headers = [\n client.contentType !== 'application/json' ? `'Content-Type': '${client.contentType}'` : undefined,\n client.withHeaders ? '...headers' : undefined,\n ]\n .filter(Boolean)\n .join(', ')\n\n const clientOptions = [\n `method: \"${client.method}\"`,\n `url: ${client.path.template}`,\n client.withQueryParams ? 'params' : undefined,\n client.withData && !isFormData ? 'data' : undefined,\n client.withData && isFormData ? 'data: formData' : undefined,\n headers.length ? `headers: { ${headers}, ...options.headers }` : undefined,\n '...options',\n ].filter(Boolean)\n\n const resolvedClientOptions = `${transformers.createIndent(4)}${clientOptions.join(`,\\n${transformers.createIndent(4)}`)}`\n\n let returnRes = parser ? `return ${parser}(res.data)` : 'return res.data'\n\n if (dataReturnType === 'full') {\n returnRes = parser ? `return {...res, data: ${parser}(res.data)}` : 'return res'\n }\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if(data) {\n Object.keys(data).forEach((key) => {\n const value = data[key];\n if (typeof key === \"string\" && (typeof value === \"string\" || value instanceof Blob)) {\n formData.append(key, value);\n }\n })\n }\n `\n : undefined\n\n return (\n <File.Source name={name} isExportable>\n <Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n return {\n fetcher: async () => {\n ${formData || ''}\n const res = await client<${client.generics}>({\n ${resolvedClientOptions}\n })\n\n ${returnRes}\n },\n }\n\n `}\n </Function>\n </File.Source>\n )\n}\n\nconst defaultTemplates = {\n default: Template,\n} as const\n\ntype Props = {\n factory: {\n name: string\n }\n dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<TemplateProps>\n}\n\nexport function QueryOptions({ factory, dataReturnType, Template = defaultTemplates.default }: Props): ReactNode {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { parser },\n },\n } = useApp<PluginSwr>()\n const { getSchemas } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const zodSchemas = getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' })\n const name = pluginManager.resolveName({\n name: `${factory.name}QueryOptions`,\n pluginKey,\n })\n const contentType = operation.getContentType()\n\n const generics = new FunctionParams()\n const params = new FunctionParams()\n\n const clientGenerics = ['TData', `${factory.name}['error']`]\n const resultGenerics = ['TData', `${factory.name}['error']`]\n\n generics.add([{ type: 'TData', default: `${factory.name}['response']` }])\n\n params.add([\n ...getASTParams(schemas.pathParams, { typed: true }),\n {\n name: 'params',\n type: `${factory.name}['queryParams']`,\n enabled: !!schemas.queryParams?.name,\n required: false,\n },\n {\n name: 'headers',\n type: `${factory.name}['headerParams']`,\n enabled: !!schemas.headerParams?.name,\n required: false,\n },\n {\n name: 'options',\n type: `${factory.name}['client']['parameters']`,\n default: '{}',\n },\n ])\n\n const client = {\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withPathParams: !!schemas.pathParams?.name,\n withHeaders: !!schemas.headerParams?.name,\n method: operation.method,\n path: new URLPath(operation.path),\n generics: clientGenerics.join(', '),\n contentType,\n }\n\n return (\n <Template\n name={name}\n params={params.toString()}\n generics={generics.toString()}\n returnType={`SWRConfiguration<${resultGenerics.join(', ')}>`}\n client={client}\n dataReturnType={dataReturnType}\n parser={parser === 'zod' ? `${zodSchemas.response.name}.parse` : undefined}\n />\n )\n}\n\nQueryOptions.templates = defaultTemplates\n"]}
@@ -2,10 +2,10 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkH4LHXYRJcjs = require('./chunk-H4LHXYRJ.cjs');
5
+ var _chunkPX3AB367cjs = require('./chunk-PX3AB367.cjs');
6
6
 
7
7
 
8
8
 
9
9
 
10
- exports.Mutation = _chunkH4LHXYRJcjs.Mutation; exports.Query = _chunkH4LHXYRJcjs.Query; exports.QueryOptions = _chunkH4LHXYRJcjs.QueryOptions;
10
+ exports.Mutation = _chunkPX3AB367cjs.Mutation; exports.Query = _chunkPX3AB367cjs.Query; exports.QueryOptions = _chunkPX3AB367cjs.QueryOptions;
11
11
  //# sourceMappingURL=components.cjs.map
@@ -2,7 +2,7 @@ import {
2
2
  Mutation,
3
3
  Query,
4
4
  QueryOptions
5
- } from "./chunk-ECJ346AA.js";
5
+ } from "./chunk-I4GGJ5YS.js";
6
6
  export {
7
7
  Mutation,
8
8
  Query,