@kubb/plugin-react-query 4.5.14 → 4.6.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.
Files changed (33) hide show
  1. package/dist/{components-0G5mZf1J.cjs → components-C0HQi0Tg.cjs} +319 -25
  2. package/dist/components-C0HQi0Tg.cjs.map +1 -0
  3. package/dist/{components-BWrDXrTl.js → components-K4qy3AIg.js} +307 -25
  4. package/dist/components-K4qy3AIg.js.map +1 -0
  5. package/dist/components.cjs +3 -1
  6. package/dist/components.d.cts +121 -30
  7. package/dist/components.d.ts +121 -30
  8. package/dist/components.js +2 -2
  9. package/dist/{generators-DTCyUuOe.cjs → generators-CKLkXi1h.cjs} +225 -2
  10. package/dist/generators-CKLkXi1h.cjs.map +1 -0
  11. package/dist/{generators-BAjiYTwQ.js → generators-Df7UUFaq.js} +220 -3
  12. package/dist/generators-Df7UUFaq.js.map +1 -0
  13. package/dist/generators.cjs +3 -2
  14. package/dist/generators.d.cts +4 -1
  15. package/dist/generators.d.ts +4 -1
  16. package/dist/generators.js +3 -3
  17. package/dist/index.cjs +3 -2
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.js +3 -2
  20. package/dist/index.js.map +1 -1
  21. package/package.json +7 -7
  22. package/src/components/SuspenseInfiniteQuery.tsx +212 -0
  23. package/src/components/SuspenseInfiniteQueryOptions.tsx +230 -0
  24. package/src/components/index.ts +2 -0
  25. package/src/generators/__snapshots__/findSuspenseInfiniteByTags.ts +100 -0
  26. package/src/generators/__snapshots__/findSuspenseInfiniteByTagsCursor.ts +100 -0
  27. package/src/generators/index.ts +1 -0
  28. package/src/generators/suspenseInfiniteQueryGenerator.tsx +191 -0
  29. package/src/plugin.ts +2 -2
  30. package/dist/components-0G5mZf1J.cjs.map +0 -1
  31. package/dist/components-BWrDXrTl.js.map +0 -1
  32. package/dist/generators-BAjiYTwQ.js.map +0 -1
  33. package/dist/generators-DTCyUuOe.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["queryGenerator","suspenseQueryGenerator","infiniteQueryGenerator","mutationGenerator","MutationKey","QueryKey","pluginOasName","pluginTsName","pluginZodName","path","options","groupName: Group['name']","pluginClientName","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey } from './components'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator } from './generators'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = definePlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n suspense = {},\n infinite = false,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n generators = [queryGenerator, suspenseQueryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n paramsCasing,\n contentType,\n client,\n } = options\n\n const clientType = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientType}` : undefined)\n\n return {\n name: pluginReactQueryName,\n options: {\n output,\n client: {\n ...options.client,\n client: clientType,\n dataReturnType: client?.dataReturnType ?? 'data',\n pathParamsType,\n importPath: clientImportPath,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/react-query',\n ...mutation,\n },\n paramsType,\n pathParamsType,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.upsertFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n })\n }\n\n await this.upsertFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAa,uBAAuB;AAEpC,MAAa,kDAAmD,YAAY;CAC1E,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,WAAW,EAAE,EACb,WAAW,OACX,eAAe,EAAE,EACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,aAAa;EAACA;EAAgBC;EAAwBC;EAAwBC;EAAkB,CAAC,OAAO,QAAQ,EAChH,WAAW,EAAE,EACb,QAAQ,EAAE,EACV,cAAcC,+BAAY,gBAC1B,WAAWC,4BAAS,gBACpB,cACA,aACA,WACE;CAEJ,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,mBAAmB,QAAQ,eAAe,CAAC,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AAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
1
+ {"version":3,"file":"index.cjs","names":["queryGenerator","suspenseQueryGenerator","infiniteQueryGenerator","suspenseInfiniteQueryGenerator","mutationGenerator","MutationKey","QueryKey","pluginOasName","pluginTsName","pluginZodName","path","options","groupName: Group['name']","pluginClientName","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey } from './components'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseInfiniteQueryGenerator, suspenseQueryGenerator } from './generators'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = definePlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n suspense = {},\n infinite = false,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n generators = [queryGenerator, suspenseQueryGenerator, infiniteQueryGenerator, suspenseInfiniteQueryGenerator, mutationGenerator].filter(Boolean),\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n paramsCasing,\n contentType,\n client,\n } = options\n\n const clientType = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientType}` : undefined)\n\n return {\n name: pluginReactQueryName,\n options: {\n output,\n client: {\n ...options.client,\n client: clientType,\n dataReturnType: client?.dataReturnType ?? 'data',\n pathParamsType,\n importPath: clientImportPath,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/react-query',\n ...mutation,\n },\n paramsType,\n pathParamsType,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.upsertFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n })\n }\n\n await this.upsertFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAa,uBAAuB;AAEpC,MAAa,kDAAmD,YAAY;CAC1E,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,WAAW,EAAE,EACb,WAAW,OACX,eAAe,EAAE,EACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,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ACF;IACF,CAAC;GAcF,MAAM,QAAQ,MAZa,IAAII,qCAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,sCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a as MutationKey, l as QueryKey } from "./components-BWrDXrTl.js";
2
- import { i as infiniteQueryGenerator, n as queryGenerator, r as mutationGenerator, t as suspenseQueryGenerator } from "./generators-BAjiYTwQ.js";
1
+ import { d as QueryKey, s as MutationKey } from "./components-K4qy3AIg.js";
2
+ import { a as infiniteQueryGenerator, i as mutationGenerator, n as suspenseInfiniteQueryGenerator, r as queryGenerator, t as suspenseQueryGenerator } from "./generators-Df7UUFaq.js";
3
3
  import path from "node:path";
4
4
  import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
5
5
  import { camelCase, pascalCase } from "@kubb/core/transformers";
@@ -19,6 +19,7 @@ const pluginReactQuery = definePlugin((options) => {
19
19
  queryGenerator,
20
20
  suspenseQueryGenerator,
21
21
  infiniteQueryGenerator,
22
+ suspenseInfiniteQueryGenerator,
22
23
  mutationGenerator
23
24
  ].filter(Boolean), mutation = {}, query = {}, mutationKey = MutationKey.getTransformer, queryKey = QueryKey.getTransformer, paramsCasing, contentType, client } = options;
24
25
  const clientType = client?.client ?? "axios";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey } from './components'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator } from './generators'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = definePlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n suspense = {},\n infinite = false,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n generators = [queryGenerator, suspenseQueryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n paramsCasing,\n contentType,\n client,\n } = options\n\n const clientType = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientType}` : undefined)\n\n return {\n name: pluginReactQueryName,\n options: {\n output,\n client: {\n ...options.client,\n client: clientType,\n dataReturnType: client?.dataReturnType ?? 'data',\n pathParamsType,\n importPath: clientImportPath,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/react-query',\n ...mutation,\n },\n paramsType,\n pathParamsType,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.upsertFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n })\n }\n\n await this.upsertFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,uBAAuB;AAEpC,MAAa,mBAAmB,cAAgC,YAAY;CAC1E,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,WAAW,EAAE,EACb,WAAW,OACX,eAAe,EAAE,EACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,aAAa;EAAC;EAAgB;EAAwB;EAAwB;EAAkB,CAAC,OAAO,QAAQ,EAChH,WAAW,EAAE,EACb,QAAQ,EAAE,EACV,cAAc,YAAY,gBAC1B,WAAW,SAAS,gBACpB,cACA,aACA,WACE;CAEJ,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,mBAAmB,QAAQ,eAAe,CAAC,QAAQ,SAAS,+BAA+B,eAAe;AAEhH,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA,QAAQ;IACN,GAAG,QAAQ;IACX,QAAQ;IACR,gBAAgB,QAAQ,kBAAkB;IAC1C;IACA,YAAY;IACb;GACD,UAAU,WACN;IACE,YAAY;IACZ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AExC;EACD"}
1
+ {"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey } from './components'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseInfiniteQueryGenerator, suspenseQueryGenerator } from './generators'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = definePlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n suspense = {},\n infinite = false,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n generators = [queryGenerator, suspenseQueryGenerator, infiniteQueryGenerator, suspenseInfiniteQueryGenerator, mutationGenerator].filter(Boolean),\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n paramsCasing,\n contentType,\n client,\n } = options\n\n const clientType = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientType}` : undefined)\n\n return {\n name: pluginReactQueryName,\n options: {\n output,\n client: {\n ...options.client,\n client: clientType,\n dataReturnType: client?.dataReturnType ?? 'data',\n pathParamsType,\n importPath: clientImportPath,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/react-query',\n ...mutation,\n },\n paramsType,\n pathParamsType,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.upsertFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n })\n }\n\n await this.upsertFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,uBAAuB;AAEpC,MAAa,mBAAmB,cAAgC,YAAY;CAC1E,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,WAAW,EAAE,EACb,WAAW,OACX,eAAe,EAAE,EACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,aAAa;EAAC;EAAgB;EAAwB;EAAwB;EAAgC;EAAkB,CAAC,OAAO,QAAQ,EAChJ,WAAW,EAAE,EACb,QAAQ,EAAE,EACV,cAAc,YAAY,gBAC1B,WAAW,SAAS,gBACpB,cACA,aACA,WACE;CAEJ,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,mBAAmB,QAAQ,eAAe,CAAC,QAAQ,SAAS,+BAA+B,eAAe;AAEhH,QAAO;EACL,MAAM;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,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-react-query",
3
- "version": "4.5.14",
3
+ "version": "4.6.0",
4
4
  "description": "React Query hooks generator plugin for Kubb, creating type-safe API client hooks from OpenAPI specifications for React applications.",
5
5
  "keywords": [
6
6
  "react-query",
@@ -69,12 +69,12 @@
69
69
  "dependencies": {
70
70
  "@kubb/react-fabric": "0.5.2",
71
71
  "remeda": "^2.32.0",
72
- "@kubb/core": "4.5.14",
73
- "@kubb/oas": "4.5.14",
74
- "@kubb/plugin-client": "4.5.14",
75
- "@kubb/plugin-oas": "4.5.14",
76
- "@kubb/plugin-ts": "4.5.14",
77
- "@kubb/plugin-zod": "4.5.14"
72
+ "@kubb/core": "4.6.0",
73
+ "@kubb/oas": "4.6.0",
74
+ "@kubb/plugin-client": "4.6.0",
75
+ "@kubb/plugin-oas": "4.6.0",
76
+ "@kubb/plugin-ts": "4.6.0",
77
+ "@kubb/plugin-zod": "4.6.0"
78
78
  },
79
79
  "peerDependencies": {
80
80
  "@kubb/react-fabric": "0.5.2"
@@ -0,0 +1,212 @@
1
+ import { isOptional, type Operation } from '@kubb/oas'
2
+ import type { OperationSchemas } from '@kubb/plugin-oas'
3
+ import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
4
+ import { File, Function, FunctionParams } from '@kubb/react-fabric'
5
+ import type { KubbNode } from '@kubb/react-fabric/types'
6
+ import type { Infinite, PluginReactQuery } from '../types.ts'
7
+ import { QueryKey } from './QueryKey.tsx'
8
+ import { QueryOptions } from './QueryOptions.tsx'
9
+
10
+ type Props = {
11
+ /**
12
+ * Name of the function
13
+ */
14
+ name: string
15
+ queryOptionsName: string
16
+ queryKeyName: string
17
+ queryKeyTypeName: string
18
+ typeSchemas: OperationSchemas
19
+ operation: Operation
20
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
21
+ paramsType: PluginReactQuery['resolvedOptions']['paramsType']
22
+ pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
23
+ dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
24
+ initialPageParam: Infinite['initialPageParam']
25
+ queryParam?: Infinite['queryParam']
26
+ }
27
+
28
+ type GetParamsProps = {
29
+ paramsType: PluginReactQuery['resolvedOptions']['paramsType']
30
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
31
+ pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
32
+ typeSchemas: OperationSchemas
33
+ pageParamGeneric: string
34
+ }
35
+
36
+ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, pageParamGeneric }: GetParamsProps) {
37
+ if (paramsType === 'object') {
38
+ return FunctionParams.factory({
39
+ data: {
40
+ mode: 'object',
41
+ children: {
42
+ ...getPathParams(typeSchemas.pathParams, {
43
+ typed: true,
44
+ casing: paramsCasing,
45
+ }),
46
+ data: typeSchemas.request?.name
47
+ ? {
48
+ type: typeSchemas.request?.name,
49
+ optional: isOptional(typeSchemas.request?.schema),
50
+ }
51
+ : undefined,
52
+ params: typeSchemas.queryParams?.name
53
+ ? {
54
+ type: typeSchemas.queryParams?.name,
55
+ optional: isOptional(typeSchemas.queryParams?.schema),
56
+ }
57
+ : undefined,
58
+ headers: typeSchemas.headerParams?.name
59
+ ? {
60
+ type: typeSchemas.headerParams?.name,
61
+ optional: isOptional(typeSchemas.headerParams?.schema),
62
+ }
63
+ : undefined,
64
+ },
65
+ },
66
+ options: {
67
+ type: `
68
+ {
69
+ query?: Partial<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
70
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}
71
+ }
72
+ `,
73
+ default: '{}',
74
+ },
75
+ })
76
+ }
77
+
78
+ return FunctionParams.factory({
79
+ pathParams: typeSchemas.pathParams?.name
80
+ ? {
81
+ mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
82
+ children: getPathParams(typeSchemas.pathParams, {
83
+ typed: true,
84
+ casing: paramsCasing,
85
+ }),
86
+ optional: isOptional(typeSchemas.pathParams?.schema),
87
+ }
88
+ : undefined,
89
+ data: typeSchemas.request?.name
90
+ ? {
91
+ type: typeSchemas.request?.name,
92
+ optional: isOptional(typeSchemas.request?.schema),
93
+ }
94
+ : undefined,
95
+ params: typeSchemas.queryParams?.name
96
+ ? {
97
+ type: typeSchemas.queryParams?.name,
98
+ optional: isOptional(typeSchemas.queryParams?.schema),
99
+ }
100
+ : undefined,
101
+ headers: typeSchemas.headerParams?.name
102
+ ? {
103
+ type: typeSchemas.headerParams?.name,
104
+ optional: isOptional(typeSchemas.headerParams?.schema),
105
+ }
106
+ : undefined,
107
+ options: {
108
+ type: `
109
+ {
110
+ query?: Partial<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
111
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}
112
+ }
113
+ `,
114
+ default: '{}',
115
+ },
116
+ })
117
+ }
118
+
119
+ export function SuspenseInfiniteQuery({
120
+ name,
121
+ queryKeyTypeName,
122
+ queryOptionsName,
123
+ queryKeyName,
124
+ paramsType,
125
+ paramsCasing,
126
+ pathParamsType,
127
+ dataReturnType,
128
+ typeSchemas,
129
+ operation,
130
+ initialPageParam,
131
+ queryParam,
132
+ }: Props): KubbNode {
133
+ const responseType = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
134
+ const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
135
+ const isInitialPageParamDefined = initialPageParam !== undefined && initialPageParam !== null
136
+ const fallbackPageParamType =
137
+ typeof initialPageParam === 'number'
138
+ ? 'number'
139
+ : typeof initialPageParam === 'string'
140
+ ? initialPageParam.includes(' as ')
141
+ ? (() => {
142
+ const parts = initialPageParam.split(' as ')
143
+ return parts[parts.length - 1] ?? 'unknown'
144
+ })()
145
+ : 'string'
146
+ : typeof initialPageParam === 'boolean'
147
+ ? 'boolean'
148
+ : 'unknown'
149
+ const queryParamType = queryParam && typeSchemas.queryParams?.name ? `${typeSchemas.queryParams?.name}['${queryParam}']` : undefined
150
+ const pageParamType = queryParamType ? (isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType) : fallbackPageParamType
151
+ const returnType = 'UseSuspenseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }'
152
+ const generics = [
153
+ `TQueryFnData = ${responseType}`,
154
+ `TError = ${errorType}`,
155
+ 'TData = InfiniteData<TQueryFnData>',
156
+ `TQueryKey extends QueryKey = ${queryKeyTypeName}`,
157
+ `TPageParam = ${pageParamType}`,
158
+ ]
159
+
160
+ const queryKeyParams = QueryKey.getParams({
161
+ pathParamsType,
162
+ typeSchemas,
163
+ paramsCasing,
164
+ })
165
+ const queryOptionsParams = QueryOptions.getParams({
166
+ paramsType,
167
+ pathParamsType,
168
+ typeSchemas,
169
+ paramsCasing,
170
+ })
171
+ const params = getParams({
172
+ paramsCasing,
173
+ paramsType,
174
+ pathParamsType,
175
+ typeSchemas,
176
+ pageParamGeneric: 'TPageParam',
177
+ })
178
+
179
+ const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`
180
+
181
+ return (
182
+ <File.Source name={name} isExportable isIndexable>
183
+ <Function
184
+ name={name}
185
+ export
186
+ generics={generics.join(', ')}
187
+ params={params.toConstructor()}
188
+ JSDoc={{
189
+ comments: getComments(operation),
190
+ }}
191
+ >
192
+ {`
193
+ const { query: queryConfig = {}, client: config = {} } = options ?? {}
194
+ const { client: queryClient, ...queryOptions } = queryConfig
195
+ const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
196
+
197
+ const query = useSuspenseInfiniteQuery({
198
+ ...${queryOptions},
199
+ queryKey,
200
+ ...queryOptions
201
+ } as unknown as UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType}
202
+
203
+ query.queryKey = queryKey as TQueryKey
204
+
205
+ return query
206
+ `}
207
+ </Function>
208
+ </File.Source>
209
+ )
210
+ }
211
+
212
+ SuspenseInfiniteQuery.getParams = getParams
@@ -0,0 +1,230 @@
1
+ import { isOptional } from '@kubb/oas'
2
+ import { Client } from '@kubb/plugin-client/components'
3
+ import type { OperationSchemas } from '@kubb/plugin-oas'
4
+ import { getPathParams } from '@kubb/plugin-oas/utils'
5
+ import { File, Function, FunctionParams } from '@kubb/react-fabric'
6
+ import type { KubbNode } from '@kubb/react-fabric/types'
7
+ import type { Infinite, PluginReactQuery } from '../types.ts'
8
+ import { QueryKey } from './QueryKey.tsx'
9
+
10
+ type Props = {
11
+ name: string
12
+ clientName: string
13
+ queryKeyName: string
14
+ typeSchemas: OperationSchemas
15
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
16
+ paramsType: PluginReactQuery['resolvedOptions']['paramsType']
17
+ pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
18
+ dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
19
+ initialPageParam: Infinite['initialPageParam']
20
+ cursorParam: Infinite['cursorParam']
21
+ queryParam: Infinite['queryParam']
22
+ }
23
+
24
+ type GetParamsProps = {
25
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
26
+ paramsType: PluginReactQuery['resolvedOptions']['paramsType']
27
+ pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
28
+ typeSchemas: OperationSchemas
29
+ }
30
+
31
+ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {
32
+ if (paramsType === 'object') {
33
+ return FunctionParams.factory({
34
+ data: {
35
+ mode: 'object',
36
+ children: {
37
+ ...getPathParams(typeSchemas.pathParams, {
38
+ typed: true,
39
+ casing: paramsCasing,
40
+ }),
41
+ data: typeSchemas.request?.name
42
+ ? {
43
+ type: typeSchemas.request?.name,
44
+ optional: isOptional(typeSchemas.request?.schema),
45
+ }
46
+ : undefined,
47
+ params: typeSchemas.queryParams?.name
48
+ ? {
49
+ type: typeSchemas.queryParams?.name,
50
+ optional: isOptional(typeSchemas.queryParams?.schema),
51
+ }
52
+ : undefined,
53
+ headers: typeSchemas.headerParams?.name
54
+ ? {
55
+ type: typeSchemas.headerParams?.name,
56
+ optional: isOptional(typeSchemas.headerParams?.schema),
57
+ }
58
+ : undefined,
59
+ },
60
+ },
61
+ config: {
62
+ type: typeSchemas.request?.name
63
+ ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`
64
+ : 'Partial<RequestConfig> & { client?: typeof fetch }',
65
+ default: '{}',
66
+ },
67
+ })
68
+ }
69
+
70
+ return FunctionParams.factory({
71
+ pathParams: typeSchemas.pathParams?.name
72
+ ? {
73
+ mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
74
+ children: getPathParams(typeSchemas.pathParams, {
75
+ typed: true,
76
+ casing: paramsCasing,
77
+ }),
78
+ optional: isOptional(typeSchemas.pathParams?.schema),
79
+ }
80
+ : undefined,
81
+ data: typeSchemas.request?.name
82
+ ? {
83
+ type: typeSchemas.request?.name,
84
+ optional: isOptional(typeSchemas.request?.schema),
85
+ }
86
+ : undefined,
87
+ params: typeSchemas.queryParams?.name
88
+ ? {
89
+ type: typeSchemas.queryParams?.name,
90
+ optional: isOptional(typeSchemas.queryParams?.schema),
91
+ }
92
+ : undefined,
93
+ headers: typeSchemas.headerParams?.name
94
+ ? {
95
+ type: typeSchemas.headerParams?.name,
96
+ optional: isOptional(typeSchemas.headerParams?.schema),
97
+ }
98
+ : undefined,
99
+ config: {
100
+ type: typeSchemas.request?.name
101
+ ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`
102
+ : 'Partial<RequestConfig> & { client?: typeof fetch }',
103
+ default: '{}',
104
+ },
105
+ })
106
+ }
107
+
108
+ export function SuspenseInfiniteQueryOptions({
109
+ name,
110
+ clientName,
111
+ initialPageParam,
112
+ cursorParam,
113
+ typeSchemas,
114
+ paramsCasing,
115
+ paramsType,
116
+ dataReturnType,
117
+ pathParamsType,
118
+ queryParam,
119
+ queryKeyName,
120
+ }: Props): KubbNode {
121
+ const queryFnDataType = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
122
+ const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
123
+ const isInitialPageParamDefined = initialPageParam !== undefined && initialPageParam !== null
124
+ const fallbackPageParamType =
125
+ typeof initialPageParam === 'number'
126
+ ? 'number'
127
+ : typeof initialPageParam === 'string'
128
+ ? initialPageParam.includes(' as ')
129
+ ? (() => {
130
+ const parts = initialPageParam.split(' as ')
131
+ return parts[parts.length - 1] ?? 'unknown'
132
+ })()
133
+ : 'string'
134
+ : typeof initialPageParam === 'boolean'
135
+ ? 'boolean'
136
+ : 'unknown'
137
+ const queryParamType = queryParam && typeSchemas.queryParams?.name ? `${typeSchemas.queryParams?.name}['${queryParam}']` : undefined
138
+ const pageParamType = queryParamType ? (isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType) : fallbackPageParamType
139
+
140
+ const params = getParams({
141
+ paramsType,
142
+ paramsCasing,
143
+ pathParamsType,
144
+ typeSchemas,
145
+ })
146
+ const clientParams = Client.getParams({
147
+ paramsCasing,
148
+ typeSchemas,
149
+ paramsType,
150
+ pathParamsType,
151
+ isConfigurable: true,
152
+ })
153
+ const queryKeyParams = QueryKey.getParams({
154
+ pathParamsType,
155
+ typeSchemas,
156
+ paramsCasing,
157
+ })
158
+
159
+ const queryOptions = [
160
+ `initialPageParam: ${typeof initialPageParam === 'string' ? JSON.stringify(initialPageParam) : initialPageParam}`,
161
+ cursorParam ? `getNextPageParam: (lastPage) => lastPage['${cursorParam}']` : undefined,
162
+ cursorParam ? `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']` : undefined,
163
+ !cursorParam && dataReturnType === 'full'
164
+ ? 'getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1'
165
+ : undefined,
166
+ !cursorParam && dataReturnType === 'data'
167
+ ? 'getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1'
168
+ : undefined,
169
+ !cursorParam ? 'getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1' : undefined,
170
+ ].filter(Boolean)
171
+
172
+ const infiniteOverrideParams =
173
+ queryParam && typeSchemas.queryParams?.name
174
+ ? `
175
+ params = {
176
+ ...(params ?? {}),
177
+ ['${queryParam}']: pageParam as unknown as ${typeSchemas.queryParams?.name}['${queryParam}'],
178
+ } as ${typeSchemas.queryParams?.name}`
179
+ : ''
180
+
181
+ const enabled = Object.entries(queryKeyParams.flatParams)
182
+ .map(([key, item]) => (item && !item.optional ? key : undefined))
183
+ .filter(Boolean)
184
+ .join('&& ')
185
+
186
+ const enabledText = enabled ? `enabled: !!(${enabled}),` : ''
187
+
188
+ if (infiniteOverrideParams) {
189
+ return (
190
+ <File.Source name={name} isExportable isIndexable>
191
+ <Function name={name} export params={params.toConstructor()}>
192
+ {`
193
+ const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
194
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
195
+ ${enabledText}
196
+ queryKey,
197
+ queryFn: async ({ signal, pageParam }) => {
198
+ config.signal = signal
199
+ ${infiniteOverrideParams}
200
+ return ${clientName}(${clientParams.toCall()})
201
+ },
202
+ ${queryOptions.join(',\n')}
203
+ })
204
+ `}
205
+ </Function>
206
+ </File.Source>
207
+ )
208
+ }
209
+
210
+ return (
211
+ <File.Source name={name} isExportable isIndexable>
212
+ <Function name={name} export params={params.toConstructor()}>
213
+ {`
214
+ const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
215
+ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
216
+ ${enabledText}
217
+ queryKey,
218
+ queryFn: async ({ signal }) => {
219
+ config.signal = signal
220
+ return ${clientName}(${clientParams.toCall()})
221
+ },
222
+ ${queryOptions.join(',\n')}
223
+ })
224
+ `}
225
+ </Function>
226
+ </File.Source>
227
+ )
228
+ }
229
+
230
+ SuspenseInfiniteQueryOptions.getParams = getParams
@@ -6,4 +6,6 @@ export { MutationOptions } from './MutationOptions.tsx'
6
6
  export { Query } from './Query.tsx'
7
7
  export { QueryKey } from './QueryKey.tsx'
8
8
  export { QueryOptions } from './QueryOptions.tsx'
9
+ export { SuspenseInfiniteQuery } from './SuspenseInfiniteQuery.tsx'
10
+ export { SuspenseInfiniteQueryOptions } from './SuspenseInfiniteQueryOptions.tsx'
9
11
  export { SuspenseQuery } from './SuspenseQuery.tsx'