@kubb/plugin-swr 5.0.0-alpha.9 → 5.0.0-beta.36
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.
- package/LICENSE +17 -10
- package/README.md +36 -21
- package/dist/components-BuLagnaM.js +933 -0
- package/dist/components-BuLagnaM.js.map +1 -0
- package/dist/components-CD7ZoS3B.cjs +1029 -0
- package/dist/components-CD7ZoS3B.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +46 -52
- package/dist/components.js +1 -1
- package/dist/generators-DM18y_Qk.cjs +445 -0
- package/dist/generators-DM18y_Qk.cjs.map +1 -0
- package/dist/generators-bnwHiUqJ.js +434 -0
- package/dist/generators-bnwHiUqJ.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +4 -501
- package/dist/generators.js +1 -1
- package/dist/index.cjs +134 -113
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.js +131 -114
- package/dist/index.js.map +1 -1
- package/dist/types-BoANASs2.d.ts +220 -0
- package/extension.yaml +199 -0
- package/package.json +58 -67
- package/src/components/Mutation.tsx +106 -227
- package/src/components/MutationKey.tsx +25 -1
- package/src/components/Query.tsx +75 -140
- package/src/components/QueryOptions.tsx +46 -95
- package/src/generators/mutationGenerator.tsx +113 -128
- package/src/generators/queryGenerator.tsx +125 -137
- package/src/index.ts +2 -2
- package/src/plugin.ts +117 -170
- package/src/resolvers/resolverSwr.ts +56 -0
- package/src/types.ts +115 -59
- package/src/utils.ts +10 -0
- package/dist/components-DRDGvgXG.js +0 -702
- package/dist/components-DRDGvgXG.js.map +0 -1
- package/dist/components-jd0l9XKn.cjs +0 -780
- package/dist/components-jd0l9XKn.cjs.map +0 -1
- package/dist/generators-CRSl6u2M.js +0 -399
- package/dist/generators-CRSl6u2M.js.map +0 -1
- package/dist/generators-D062obA7.cjs +0 -410
- package/dist/generators-D062obA7.cjs.map +0 -1
- package/dist/types-BIaGRPjD.d.ts +0 -210
- /package/dist/{chunk--u3MIqq1.js → chunk-C0LytTxp.js} +0 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["fetchClientSource","axiosClientSource","configSource"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { camelCase, pascalCase } from '@internals/utils'\nimport { createPlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'\nimport { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'\nimport { source as configSource } from '@kubb/plugin-client/templates/config.source'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n query,\n mutation,\n client,\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n paramsCasing,\n contentType,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginSwrName,\n options: {\n output,\n client: {\n bundle: client?.bundle,\n baseURL: client?.baseURL,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n importPath: clientImportPath,\n dataReturnType: client?.dataReturnType ?? 'data',\n paramsCasing,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n importPath: 'swr',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n importPath: 'swr/mutation',\n methods: ['post', 'put', 'delete', 'patch'],\n ...mutation,\n },\n parser,\n paramsType,\n pathParamsType,\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\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.driver.getPluginByName(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: this.plugin.options.client.client === 'fetch' ? fetchClientSource : axiosClientSource,\n isExportable: true,\n isIndexable: true,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n if (!hasClientPlugin) {\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: configSource,\n isExportable: false,\n isIndexable: false,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n driver: this.driver,\n events: this.events,\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 pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,gBAAgB;AAE7B,MAAa,YAAY,cAAyB,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,eAAe,EAAE,EACjB,OACA,UACA,QACA,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,cAAc,YAAY,gBAC1B,WAAW,SAAS,gBACpB,aAAa,CAAC,gBAAgB,kBAAkB,CAAC,OAAO,QAAQ,EAChE,cACA,gBACE;CAEJ,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,mBAAmB,QAAQ,eAAe,CAAC,QAAQ,SAAS,+BAA+B,eAAe,KAAA;AAEhH,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA,QAAQ;IACN,QAAQ,QAAQ;IAChB,SAAS,QAAQ;IACjB,QAAQ;IACR,YA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M,EACJ,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["fetchClientSource","axiosClientSource","configSource"],"sources":["../src/resolvers/resolverSwr.ts","../src/plugin.ts"],"sourcesContent":["import { camelCase } from '@internals/utils'\nimport { defineResolver } from '@kubb/core'\nimport type { PluginSwr } from '../types.ts'\n\nfunction capitalize(name: string): string {\n return `${name.charAt(0).toUpperCase()}${name.slice(1)}`\n}\n\n/**\n * Naming convention resolver for the SWR plugin.\n *\n * Provides default naming helpers using camelCase for functions and file paths.\n *\n * @example\n * `resolverSwr.default('list pets', 'function') // → 'listPets'`\n */\nexport const resolverSwr = defineResolver<PluginSwr>(() => ({\n name: 'default',\n pluginName: 'plugin-swr',\n default(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n resolveName(name) {\n return this.default(name, 'function')\n },\n resolvePathName(name, type) {\n return this.default(name, type)\n },\n resolveQueryName(node) {\n return `use${capitalize(this.resolveName(node.operationId))}`\n },\n resolveMutationName(node) {\n return `use${capitalize(this.resolveName(node.operationId))}`\n },\n resolveQueryOptionsName(node) {\n return `${this.resolveName(node.operationId)}QueryOptions`\n },\n resolveQueryKeyName(node) {\n return `${this.resolveName(node.operationId)}QueryKey`\n },\n resolveMutationKeyName(node) {\n return `${this.resolveName(node.operationId)}MutationKey`\n },\n resolveQueryKeyTypeName(node) {\n return `${capitalize(this.resolveName(node.operationId))}QueryKey`\n },\n resolveMutationKeyTypeName(node) {\n return `${capitalize(this.resolveName(node.operationId))}MutationKey`\n },\n resolveMutationArgTypeName(node) {\n return `${capitalize(this.resolveName(node.operationId))}MutationArg`\n },\n resolveClientName(node) {\n return this.resolveName(node.operationId)\n },\n}))\n","import path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { ast, definePlugin, type Group } from '@kubb/core'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'\nimport { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'\nimport { source as configSource } from '@kubb/plugin-client/templates/config.source'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { mutationKeyTransformer, queryKeyTransformer } from '@internals/tanstack-query'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport { resolverSwr } from './resolvers/resolverSwr.ts'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = definePlugin<PluginSwr>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = false,\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutation = {},\n query = {},\n mutationKey = mutationKeyTransformer,\n queryKey = queryKeyTransformer,\n paramsCasing,\n client,\n resolver: userResolver,\n transformer: userTransformer,\n generators: userGenerators = [],\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n const selectedGenerators =\n options.generators ?? [queryGenerator, mutationGenerator].filter((generator): generator is NonNullable<typeof generator> => Boolean(generator))\n\n const groupConfig = group\n ? ({\n ...group,\n name: group.name\n ? group.name\n : (ctx: { group: string }) => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n },\n } satisfies Group)\n : undefined\n\n return {\n name: pluginSwrName,\n options,\n dependencies: [pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter((dependency): dependency is string => Boolean(dependency)),\n hooks: {\n 'kubb:plugin:setup'(ctx) {\n const resolver = userResolver ? { ...resolverSwr, ...userResolver } : resolverSwr\n\n ctx.setOptions({\n output,\n client: {\n bundle: client?.bundle,\n baseURL: client?.baseURL,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n importPath: clientImportPath,\n dataReturnType: client?.dataReturnType ?? 'data',\n paramsCasing,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n importPath: 'swr',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n importPath: 'swr/mutation',\n methods: ['post', 'put', 'patch', 'delete'],\n ...mutation,\n },\n parser,\n paramsType,\n pathParamsType,\n paramsCasing,\n group: groupConfig,\n exclude,\n include,\n override,\n resolver,\n })\n ctx.setResolver(resolver)\n if (userTransformer) {\n ctx.setTransformer(userTransformer)\n }\n\n for (const gen of selectedGenerators) {\n ctx.addGenerator(gen)\n }\n for (const gen of userGenerators) {\n ctx.addGenerator(gen)\n }\n\n const root = path.resolve(ctx.config.root, ctx.config.output.path)\n const hasClientPlugin = !!ctx.config.plugins?.some((p) => (p as { name?: string }).name === pluginClientName)\n\n if (client?.bundle && !hasClientPlugin && !clientImportPath) {\n ctx.injectFile({\n baseName: 'client.ts',\n path: path.resolve(root, '.kubb/client.ts'),\n sources: [\n ast.createSource({\n name: 'client',\n nodes: [ast.createText(clientName === 'fetch' ? fetchClientSource : axiosClientSource)],\n isExportable: true,\n isIndexable: true,\n }),\n ],\n })\n }\n\n if (!hasClientPlugin) {\n ctx.injectFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n ast.createSource({\n name: 'config',\n nodes: [ast.createText(configSource)],\n isExportable: false,\n isIndexable: false,\n }),\n ],\n })\n }\n },\n },\n }\n})\n\nexport default pluginSwr\n"],"mappings":";;;;;;;;;;;;AAIA,SAAS,WAAW,MAAsB;CACxC,OAAO,GAAG,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC;AACvD;;;;;;;;;AAUA,MAAa,cAAc,sBAAiC;CAC1D,MAAM;CACN,YAAY;CACZ,QAAQ,MAAM,MAAM;EAClB,OAAO,UAAU,MAAM,EAAE,QAAQ,SAAS,OAAO,CAAC;CACp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AM,IAAI,OAAO,OAAO,IAAI;GACjE,MAAM,kBAAkB,CAAC,CAAC,IAAI,OAAO,SAAS,MAAM,MAAO,EAAwB,SAAS,gBAAgB;GAE5G,IAAI,QAAQ,UAAU,CAAC,mBAAmB,CAAC,kBACzC,IAAI,WAAW;IACb,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,CACP,IAAI,aAAa;KACf,MAAM;KACN,OAAO,CAAC,IAAI,WAAW,eAAe,UAAUA,WAAoBC,MAAiB,CAAC;KACtF,cAAc;KACd,aAAa;IACf,CAAC,CACH;GACF,CAAC;GAGH,IAAI,CAAC,iBACH,IAAI,WAAW;IACb,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,CACP,IAAI,aAAa;KACf,MAAM;KACN,OAAO,CAAC,IAAI,WAAWC,QAAY,CAAC;KACpC,cAAc;KACd,aAAa;IACf,CAAC,CACH;GACF,CAAC;EAEL,EACF;CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { t as __name } from "./chunk-C0LytTxp.js";
|
|
2
|
+
import { Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
|
|
3
|
+
import { ClientImportPath, PluginClient } from "@kubb/plugin-client";
|
|
4
|
+
import { PluginTs } from "@kubb/plugin-ts";
|
|
5
|
+
import { KubbReactNode } from "@kubb/renderer-jsx/types";
|
|
6
|
+
|
|
7
|
+
//#region ../../internals/tanstack-query/src/types.d.ts
|
|
8
|
+
type ParamsCasing = 'camelcase' | undefined;
|
|
9
|
+
type Transformer = (props: {
|
|
10
|
+
node: ast.OperationNode;
|
|
11
|
+
casing: ParamsCasing;
|
|
12
|
+
}) => unknown[];
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region ../../internals/tanstack-query/src/components/QueryKey.d.ts
|
|
15
|
+
type Props = {
|
|
16
|
+
name: string;
|
|
17
|
+
typeName: string;
|
|
18
|
+
node: ast.OperationNode;
|
|
19
|
+
tsResolver: PluginTs['resolver'];
|
|
20
|
+
paramsCasing: 'camelcase' | undefined;
|
|
21
|
+
pathParamsType: 'object' | 'inline';
|
|
22
|
+
transformer: Transformer | null | undefined;
|
|
23
|
+
};
|
|
24
|
+
declare function QueryKey$1({
|
|
25
|
+
name,
|
|
26
|
+
node,
|
|
27
|
+
tsResolver,
|
|
28
|
+
paramsCasing,
|
|
29
|
+
pathParamsType,
|
|
30
|
+
typeName,
|
|
31
|
+
transformer
|
|
32
|
+
}: Props): KubbReactNode;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/types.d.ts
|
|
35
|
+
/**
|
|
36
|
+
* Resolver for SWR that provides naming methods for hook functions.
|
|
37
|
+
*/
|
|
38
|
+
type ResolverSwr = Resolver & {
|
|
39
|
+
/**
|
|
40
|
+
* Resolves the base function name for an operation.
|
|
41
|
+
*
|
|
42
|
+
* @example Resolving base operation names
|
|
43
|
+
* `resolver.resolveName('show pet by id') // -> 'showPetById'`
|
|
44
|
+
*/
|
|
45
|
+
resolveName(this: ResolverSwr, name: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Resolves the output file name for a hook module.
|
|
48
|
+
*/
|
|
49
|
+
resolvePathName(this: ResolverSwr, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
|
|
50
|
+
/**
|
|
51
|
+
* Resolves a query hook function name.
|
|
52
|
+
*/
|
|
53
|
+
resolveQueryName(this: ResolverSwr, node: ast.OperationNode): string;
|
|
54
|
+
/**
|
|
55
|
+
* Resolves a mutation hook function name.
|
|
56
|
+
*/
|
|
57
|
+
resolveMutationName(this: ResolverSwr, node: ast.OperationNode): string;
|
|
58
|
+
/**
|
|
59
|
+
* Resolves the query options helper name.
|
|
60
|
+
*/
|
|
61
|
+
resolveQueryOptionsName(this: ResolverSwr, node: ast.OperationNode): string;
|
|
62
|
+
/**
|
|
63
|
+
* Resolves the query key helper name.
|
|
64
|
+
*/
|
|
65
|
+
resolveQueryKeyName(this: ResolverSwr, node: ast.OperationNode): string;
|
|
66
|
+
/**
|
|
67
|
+
* Resolves the mutation key helper name.
|
|
68
|
+
*/
|
|
69
|
+
resolveMutationKeyName(this: ResolverSwr, node: ast.OperationNode): string;
|
|
70
|
+
/**
|
|
71
|
+
* Resolves the query key type name.
|
|
72
|
+
*/
|
|
73
|
+
resolveQueryKeyTypeName(this: ResolverSwr, node: ast.OperationNode): string;
|
|
74
|
+
/**
|
|
75
|
+
* Resolves the mutation key type name.
|
|
76
|
+
*/
|
|
77
|
+
resolveMutationKeyTypeName(this: ResolverSwr, node: ast.OperationNode): string;
|
|
78
|
+
/**
|
|
79
|
+
* Resolves the mutation argument type name emitted alongside the mutation hook.
|
|
80
|
+
*/
|
|
81
|
+
resolveMutationArgTypeName(this: ResolverSwr, node: ast.OperationNode): string;
|
|
82
|
+
/**
|
|
83
|
+
* Resolves the client function name generated inline by query hooks.
|
|
84
|
+
*/
|
|
85
|
+
resolveClientName(this: ResolverSwr, node: ast.OperationNode): string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Customize the queryKey.
|
|
89
|
+
*/
|
|
90
|
+
type QueryKey = Transformer;
|
|
91
|
+
/**
|
|
92
|
+
* Customize the mutationKey.
|
|
93
|
+
*/
|
|
94
|
+
type MutationKey = Transformer;
|
|
95
|
+
type Query = {
|
|
96
|
+
/**
|
|
97
|
+
* HTTP methods to use for queries.
|
|
98
|
+
*
|
|
99
|
+
* @default ['get']
|
|
100
|
+
*/
|
|
101
|
+
methods?: Array<string>;
|
|
102
|
+
/**
|
|
103
|
+
* Path to the useSWR hook for useSWR functionality.
|
|
104
|
+
* Used as `import useSWR from '${importPath}'`.
|
|
105
|
+
* Accepts relative and absolute paths.
|
|
106
|
+
* Path is used as-is; relative paths are based on the generated file location.
|
|
107
|
+
* @default 'swr'
|
|
108
|
+
*/
|
|
109
|
+
importPath?: string;
|
|
110
|
+
};
|
|
111
|
+
type Mutation = {
|
|
112
|
+
/**
|
|
113
|
+
* HTTP methods to use for mutations.
|
|
114
|
+
*
|
|
115
|
+
* @default ['post', 'put', 'delete', 'patch']
|
|
116
|
+
*/
|
|
117
|
+
methods?: Array<string>;
|
|
118
|
+
/**
|
|
119
|
+
* Path to the useSWRMutation hook for useSWRMutation functionality.
|
|
120
|
+
* Used as `import useSWRMutation from '${importPath}'`.
|
|
121
|
+
* Accepts relative and absolute paths.
|
|
122
|
+
* Path is used as-is; relative paths are based on the generated file location.
|
|
123
|
+
* @default 'swr/mutation'
|
|
124
|
+
*/
|
|
125
|
+
importPath?: string;
|
|
126
|
+
};
|
|
127
|
+
type Options = {
|
|
128
|
+
/**
|
|
129
|
+
* Specify the export location for the files and define the behavior of the output
|
|
130
|
+
* @default { path: 'hooks', barrelType: 'named' }
|
|
131
|
+
*/
|
|
132
|
+
output?: Output;
|
|
133
|
+
/**
|
|
134
|
+
* Group the SWR hooks based on the provided name.
|
|
135
|
+
*/
|
|
136
|
+
group?: Group;
|
|
137
|
+
client?: ClientImportPath & Pick<PluginClient['options'], 'clientType' | 'dataReturnType' | 'baseURL' | 'bundle' | 'paramsCasing'>;
|
|
138
|
+
/**
|
|
139
|
+
* Tags, operations, or paths to exclude from generation.
|
|
140
|
+
*/
|
|
141
|
+
exclude?: Array<Exclude>;
|
|
142
|
+
/**
|
|
143
|
+
* Tags, operations, or paths to include in generation.
|
|
144
|
+
*/
|
|
145
|
+
include?: Array<Include>;
|
|
146
|
+
/**
|
|
147
|
+
* Override options for specific tags, operations, or paths.
|
|
148
|
+
*/
|
|
149
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
150
|
+
/**
|
|
151
|
+
* Apply casing to parameter names.
|
|
152
|
+
*/
|
|
153
|
+
paramsCasing?: 'camelcase';
|
|
154
|
+
/**
|
|
155
|
+
* How parameters are passed: grouped in an object or spread inline.
|
|
156
|
+
*
|
|
157
|
+
* @default 'inline'
|
|
158
|
+
*/
|
|
159
|
+
paramsType?: 'object' | 'inline';
|
|
160
|
+
/**
|
|
161
|
+
* How path parameters are passed: grouped in an object or spread inline.
|
|
162
|
+
*
|
|
163
|
+
* @default 'inline'
|
|
164
|
+
*/
|
|
165
|
+
pathParamsType?: PluginClient['options']['pathParamsType'];
|
|
166
|
+
queryKey?: QueryKey;
|
|
167
|
+
/**
|
|
168
|
+
* Configure useSWR behavior.
|
|
169
|
+
*/
|
|
170
|
+
query?: Partial<Query> | false;
|
|
171
|
+
mutationKey?: MutationKey;
|
|
172
|
+
/**
|
|
173
|
+
* Configure useSWRMutation behavior.
|
|
174
|
+
*/
|
|
175
|
+
mutation?: Partial<Mutation> | false;
|
|
176
|
+
/**
|
|
177
|
+
* Parser to use for validating response data.
|
|
178
|
+
*/
|
|
179
|
+
parser?: PluginClient['options']['parser'];
|
|
180
|
+
/**
|
|
181
|
+
* Override naming conventions for function names and types.
|
|
182
|
+
*/
|
|
183
|
+
resolver?: Partial<ResolverSwr> & ThisType<ResolverSwr>;
|
|
184
|
+
/**
|
|
185
|
+
* AST visitor to transform generated nodes.
|
|
186
|
+
*/
|
|
187
|
+
transformer?: ast.Visitor;
|
|
188
|
+
/**
|
|
189
|
+
* Additional generators alongside the default generators.
|
|
190
|
+
*/
|
|
191
|
+
generators?: Array<Generator<PluginSwr>>;
|
|
192
|
+
};
|
|
193
|
+
type ResolvedOptions = {
|
|
194
|
+
output: Output;
|
|
195
|
+
group: Group | undefined;
|
|
196
|
+
exclude: NonNullable<Options['exclude']>;
|
|
197
|
+
include: Options['include'];
|
|
198
|
+
override: NonNullable<Options['override']>;
|
|
199
|
+
client: Pick<PluginClient['options'], 'client' | 'clientType' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle' | 'paramsCasing'>;
|
|
200
|
+
parser: Required<NonNullable<Options['parser']>>;
|
|
201
|
+
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
202
|
+
paramsCasing: Options['paramsCasing'];
|
|
203
|
+
paramsType: NonNullable<Options['paramsType']>;
|
|
204
|
+
queryKey: QueryKey | undefined;
|
|
205
|
+
query: NonNullable<Required<Query>> | false;
|
|
206
|
+
mutationKey: MutationKey | undefined;
|
|
207
|
+
mutation: NonNullable<Required<Mutation>> | false;
|
|
208
|
+
resolver: ResolverSwr;
|
|
209
|
+
};
|
|
210
|
+
type PluginSwr = PluginFactoryOptions<'plugin-swr', Options, ResolvedOptions, ResolverSwr>;
|
|
211
|
+
declare global {
|
|
212
|
+
namespace Kubb {
|
|
213
|
+
interface PluginRegistry {
|
|
214
|
+
'plugin-swr': PluginSwr;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
//#endregion
|
|
219
|
+
export { Transformer as i, PluginSwr as n, QueryKey$1 as r, Options as t };
|
|
220
|
+
//# sourceMappingURL=types-BoANASs2.d.ts.map
|
package/extension.yaml
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
$schema: https://kubb.dev/schemas/extension.json
|
|
2
|
+
kind: plugin
|
|
3
|
+
id: plugin-swr
|
|
4
|
+
name: SWR
|
|
5
|
+
description: Generate SWR hooks (useSWR, useSWRMutation) from OpenAPI specifications.
|
|
6
|
+
category: framework
|
|
7
|
+
type: official
|
|
8
|
+
npmPackage: '@kubb/plugin-swr'
|
|
9
|
+
docsPath: /plugins/plugin-swr
|
|
10
|
+
repo: https://github.com/kubb-labs/plugins
|
|
11
|
+
maintainers:
|
|
12
|
+
- name: Stijn Van Hulle
|
|
13
|
+
github: stijnvanhulle
|
|
14
|
+
compatibility:
|
|
15
|
+
kubb: '>=5.0.0'
|
|
16
|
+
node: '>=22'
|
|
17
|
+
tags:
|
|
18
|
+
- swr
|
|
19
|
+
- react
|
|
20
|
+
- hooks
|
|
21
|
+
- data-fetching
|
|
22
|
+
- codegen
|
|
23
|
+
- openapi
|
|
24
|
+
dependencies:
|
|
25
|
+
- plugin-ts
|
|
26
|
+
- plugin-client
|
|
27
|
+
resources:
|
|
28
|
+
documentation: https://kubb.dev/plugins/plugin-swr
|
|
29
|
+
repository: https://github.com/kubb-labs/plugins
|
|
30
|
+
issues: https://github.com/kubb-labs/plugins/issues
|
|
31
|
+
changelog: https://github.com/kubb-labs/plugins/blob/main/packages/plugin-swr/CHANGELOG.md
|
|
32
|
+
codesandbox: https://codesandbox.io/p/github/kubb-labs/plugins/main/examples/swr
|
|
33
|
+
featured: true
|
|
34
|
+
intro: |
|
|
35
|
+
# @kubb/plugin-swr
|
|
36
|
+
|
|
37
|
+
Generate type-safe SWR hooks from your OpenAPI schema for data fetching, caching, and mutations.
|
|
38
|
+
options:
|
|
39
|
+
- name: output
|
|
40
|
+
type: Output
|
|
41
|
+
required: false
|
|
42
|
+
default: "{ path: 'hooks', barrel: { type: 'named' } }"
|
|
43
|
+
description: Specify the export location for the files and define the behavior of the output.
|
|
44
|
+
- name: group
|
|
45
|
+
type: Group
|
|
46
|
+
required: false
|
|
47
|
+
description: Grouping combines files in a folder based on a specific `type`.
|
|
48
|
+
- name: client
|
|
49
|
+
type: ClientImportPath & { clientType?, dataReturnType?, baseURL?, bundle?, paramsCasing? }
|
|
50
|
+
required: false
|
|
51
|
+
description: Client configuration for HTTP request generation.
|
|
52
|
+
- name: paramsType
|
|
53
|
+
type: "'object' | 'inline'"
|
|
54
|
+
required: false
|
|
55
|
+
default: "'inline'"
|
|
56
|
+
description: Defines how parameters are passed to generated functions.
|
|
57
|
+
- name: paramsCasing
|
|
58
|
+
type: "'camelcase'"
|
|
59
|
+
required: false
|
|
60
|
+
description: Transform parameter names to a specific casing format.
|
|
61
|
+
- name: pathParamsType
|
|
62
|
+
type: "'object' | 'inline'"
|
|
63
|
+
required: false
|
|
64
|
+
default: "'inline'"
|
|
65
|
+
description: Defines how pathParams are passed to generated functions.
|
|
66
|
+
- name: parser
|
|
67
|
+
type: "false | 'zod'"
|
|
68
|
+
required: false
|
|
69
|
+
default: 'false'
|
|
70
|
+
description: |
|
|
71
|
+
Runtime validator applied to the response body before it is returned.
|
|
72
|
+
|
|
73
|
+
- `false` (default) — no validation; the response is cast to the generated type.
|
|
74
|
+
- `'zod'` — pipes the response through the Zod schema from `@kubb/plugin-zod`.
|
|
75
|
+
- name: query
|
|
76
|
+
type: Query
|
|
77
|
+
required: false
|
|
78
|
+
description: |
|
|
79
|
+
Override some `useSWR` behaviors. Pass `false` to disable query hook generation.
|
|
80
|
+
codeBlock:
|
|
81
|
+
lang: typescript
|
|
82
|
+
title: Query
|
|
83
|
+
code: |
|
|
84
|
+
type Query = {
|
|
85
|
+
methods: Array<HttpMethod>
|
|
86
|
+
importPath?: string
|
|
87
|
+
} | false
|
|
88
|
+
properties:
|
|
89
|
+
- name: methods
|
|
90
|
+
type: Array<HttpMethod>
|
|
91
|
+
required: false
|
|
92
|
+
default: "['get']"
|
|
93
|
+
description: Define which HttpMethods can be used for queries.
|
|
94
|
+
- name: importPath
|
|
95
|
+
type: string
|
|
96
|
+
required: false
|
|
97
|
+
default: "'swr'"
|
|
98
|
+
description: Path to the `useSWR` import.
|
|
99
|
+
- name: queryKey
|
|
100
|
+
type: '(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]'
|
|
101
|
+
required: false
|
|
102
|
+
description: Customize the queryKey that will be used for the query.
|
|
103
|
+
- name: mutation
|
|
104
|
+
type: Mutation
|
|
105
|
+
required: false
|
|
106
|
+
description: |
|
|
107
|
+
Override some `useSWRMutation` behaviors. Pass `false` to disable mutation hook generation.
|
|
108
|
+
codeBlock:
|
|
109
|
+
lang: typescript
|
|
110
|
+
title: Mutation
|
|
111
|
+
code: |
|
|
112
|
+
type Mutation = {
|
|
113
|
+
methods: Array<HttpMethod>
|
|
114
|
+
importPath?: string
|
|
115
|
+
} | false
|
|
116
|
+
properties:
|
|
117
|
+
- name: methods
|
|
118
|
+
type: Array<HttpMethod>
|
|
119
|
+
required: false
|
|
120
|
+
default: "['post', 'put', 'patch', 'delete']"
|
|
121
|
+
description: Define which HttpMethods can be used for mutations.
|
|
122
|
+
- name: importPath
|
|
123
|
+
type: string
|
|
124
|
+
required: false
|
|
125
|
+
default: "'swr/mutation'"
|
|
126
|
+
description: Path to the `useSWRMutation` import.
|
|
127
|
+
- name: mutationKey
|
|
128
|
+
type: '(props: { operation: Operation; schemas: OperationSchemas }) => unknown[]'
|
|
129
|
+
required: false
|
|
130
|
+
description: Customize the mutationKey.
|
|
131
|
+
- name: include
|
|
132
|
+
type: Array<Include>
|
|
133
|
+
required: false
|
|
134
|
+
description: Array containing include parameters.
|
|
135
|
+
- name: exclude
|
|
136
|
+
type: Array<Exclude>
|
|
137
|
+
required: false
|
|
138
|
+
description: Array containing exclude parameters.
|
|
139
|
+
- name: override
|
|
140
|
+
type: Array<Override>
|
|
141
|
+
required: false
|
|
142
|
+
description: Array containing override parameters.
|
|
143
|
+
- name: generators
|
|
144
|
+
type: Array<Generator<PluginSwr>>
|
|
145
|
+
required: false
|
|
146
|
+
experimental: true
|
|
147
|
+
description: Define additional generators next to the built-in generators.
|
|
148
|
+
- name: resolver
|
|
149
|
+
type: Partial<ResolverSwr> & ThisType<ResolverSwr>
|
|
150
|
+
required: false
|
|
151
|
+
description: Override naming conventions for function names and types.
|
|
152
|
+
- name: transformer
|
|
153
|
+
type: Visitor
|
|
154
|
+
required: false
|
|
155
|
+
description: AST visitor to transform generated nodes.
|
|
156
|
+
notes:
|
|
157
|
+
- type: tip
|
|
158
|
+
body: |
|
|
159
|
+
See [SWR](https://swr.vercel.app) for more information about SWR.
|
|
160
|
+
examples:
|
|
161
|
+
- name: kubb.config.ts
|
|
162
|
+
files:
|
|
163
|
+
- lang: typescript
|
|
164
|
+
code: |
|
|
165
|
+
import { defineConfig } from 'kubb'
|
|
166
|
+
import { pluginTs } from '@kubb/plugin-ts'
|
|
167
|
+
import { pluginSwr } from '@kubb/plugin-swr'
|
|
168
|
+
|
|
169
|
+
export default defineConfig({
|
|
170
|
+
input: {
|
|
171
|
+
path: './petStore.yaml',
|
|
172
|
+
},
|
|
173
|
+
output: {
|
|
174
|
+
path: './src/gen',
|
|
175
|
+
},
|
|
176
|
+
plugins: [
|
|
177
|
+
pluginTs(),
|
|
178
|
+
pluginSwr({
|
|
179
|
+
output: {
|
|
180
|
+
path: './hooks',
|
|
181
|
+
},
|
|
182
|
+
group: {
|
|
183
|
+
type: 'tag',
|
|
184
|
+
name: ({ group }) => `${group}Hooks`,
|
|
185
|
+
},
|
|
186
|
+
client: {
|
|
187
|
+
dataReturnType: 'data',
|
|
188
|
+
},
|
|
189
|
+
mutation: {
|
|
190
|
+
methods: ['post', 'put', 'delete'],
|
|
191
|
+
},
|
|
192
|
+
query: {
|
|
193
|
+
methods: ['get'],
|
|
194
|
+
importPath: 'swr',
|
|
195
|
+
},
|
|
196
|
+
}),
|
|
197
|
+
],
|
|
198
|
+
})
|
|
199
|
+
twoslash: false
|
package/package.json
CHANGED
|
@@ -1,38 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-swr",
|
|
3
|
-
"version": "5.0.0-
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "5.0.0-beta.36",
|
|
4
|
+
"description": "Generate type-safe SWR hooks from your OpenAPI specification. Covers useSWR and useSWRMutation with full TypeScript support.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"nextjs",
|
|
9
|
-
"next",
|
|
10
|
-
"next.js",
|
|
11
|
-
"vercel",
|
|
6
|
+
"code-generation",
|
|
7
|
+
"codegen",
|
|
12
8
|
"data-fetching",
|
|
13
|
-
"react-hooks",
|
|
14
9
|
"hooks",
|
|
15
|
-
"
|
|
16
|
-
"sdk-generator",
|
|
17
|
-
"typescript",
|
|
18
|
-
"type-safe",
|
|
10
|
+
"kubb",
|
|
19
11
|
"openapi",
|
|
12
|
+
"react",
|
|
20
13
|
"swagger",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"kubb"
|
|
14
|
+
"swr",
|
|
15
|
+
"typescript",
|
|
16
|
+
"use-swr",
|
|
17
|
+
"use-swr-mutation"
|
|
26
18
|
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "stijnvanhulle",
|
|
27
21
|
"repository": {
|
|
28
22
|
"type": "git",
|
|
29
|
-
"url": "git+https://github.com/kubb-labs/
|
|
23
|
+
"url": "git+https://github.com/kubb-labs/plugins.git",
|
|
30
24
|
"directory": "packages/plugin-swr"
|
|
31
25
|
},
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
"files": [
|
|
27
|
+
"src",
|
|
28
|
+
"dist",
|
|
29
|
+
"extension.yaml",
|
|
30
|
+
"!/**/**.test.**",
|
|
31
|
+
"!/**/__tests__/**",
|
|
32
|
+
"!/**/__snapshots__/**"
|
|
33
|
+
],
|
|
35
34
|
"type": "module",
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"main": "./dist/index.cjs",
|
|
37
|
+
"module": "./dist/index.js",
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"typesVersions": {
|
|
40
|
+
"*": {
|
|
41
|
+
"components": [
|
|
42
|
+
"./dist/components.d.ts"
|
|
43
|
+
],
|
|
44
|
+
"generators": [
|
|
45
|
+
"./dist/generators.d.ts"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
36
49
|
"exports": {
|
|
37
50
|
".": {
|
|
38
51
|
"import": "./dist/index.js",
|
|
@@ -48,24 +61,26 @@
|
|
|
48
61
|
},
|
|
49
62
|
"./package.json": "./package.json"
|
|
50
63
|
},
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public",
|
|
66
|
+
"registry": "https://registry.npmjs.org/"
|
|
67
|
+
},
|
|
68
|
+
"dependencies": {
|
|
69
|
+
"@kubb/core": "5.0.0-beta.36",
|
|
70
|
+
"@kubb/renderer-jsx": "5.0.0-beta.36",
|
|
71
|
+
"remeda": "^2.37.0",
|
|
72
|
+
"@kubb/plugin-client": "5.0.0-beta.36",
|
|
73
|
+
"@kubb/plugin-ts": "5.0.0-beta.36",
|
|
74
|
+
"@kubb/plugin-zod": "5.0.0-beta.36"
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@internals/shared": "0.0.0",
|
|
78
|
+
"@internals/tanstack-query": "0.0.0",
|
|
79
|
+
"@internals/utils": "0.0.0"
|
|
80
|
+
},
|
|
81
|
+
"peerDependencies": {
|
|
82
|
+
"@kubb/renderer-jsx": "5.0.0-beta.36"
|
|
61
83
|
},
|
|
62
|
-
"files": [
|
|
63
|
-
"src",
|
|
64
|
-
"dist",
|
|
65
|
-
"!/**/**.test.**",
|
|
66
|
-
"!/**/__tests__/**",
|
|
67
|
-
"!/**/__snapshots__/**"
|
|
68
|
-
],
|
|
69
84
|
"size-limit": [
|
|
70
85
|
{
|
|
71
86
|
"path": "./dist/*.js",
|
|
@@ -73,41 +88,17 @@
|
|
|
73
88
|
"gzip": true
|
|
74
89
|
}
|
|
75
90
|
],
|
|
76
|
-
"dependencies": {
|
|
77
|
-
"@kubb/fabric-core": "0.14.0",
|
|
78
|
-
"@kubb/react-fabric": "0.14.0",
|
|
79
|
-
"remeda": "^2.33.6",
|
|
80
|
-
"@kubb/core": "5.0.0-alpha.9",
|
|
81
|
-
"@kubb/oas": "5.0.0-alpha.9",
|
|
82
|
-
"@kubb/plugin-client": "5.0.0-alpha.9",
|
|
83
|
-
"@kubb/plugin-oas": "5.0.0-alpha.9",
|
|
84
|
-
"@kubb/plugin-ts": "5.0.0-alpha.9",
|
|
85
|
-
"@kubb/plugin-zod": "5.0.0-alpha.9"
|
|
86
|
-
},
|
|
87
|
-
"peerDependencies": {
|
|
88
|
-
"@kubb/fabric-core": "0.14.0",
|
|
89
|
-
"@kubb/react-fabric": "0.14.0"
|
|
90
|
-
},
|
|
91
91
|
"engines": {
|
|
92
92
|
"node": ">=22"
|
|
93
93
|
},
|
|
94
|
-
"publishConfig": {
|
|
95
|
-
"access": "public",
|
|
96
|
-
"registry": "https://registry.npmjs.org/"
|
|
97
|
-
},
|
|
98
|
-
"main": "./dist/index.cjs",
|
|
99
|
-
"module": "./dist/index.js",
|
|
100
|
-
"devDependencies": {
|
|
101
|
-
"@internals/tanstack-query": "0.0.0",
|
|
102
|
-
"@internals/utils": "0.0.0"
|
|
103
|
-
},
|
|
104
94
|
"scripts": {
|
|
105
95
|
"build": "tsdown && size-limit",
|
|
106
|
-
"clean": "rimraf ./dist",
|
|
107
|
-
"lint": "
|
|
108
|
-
"lint:fix": "
|
|
96
|
+
"clean": "npx rimraf ./dist",
|
|
97
|
+
"lint": "oxlint .",
|
|
98
|
+
"lint:fix": "oxlint --fix .",
|
|
109
99
|
"release": "pnpm publish --no-git-check",
|
|
110
100
|
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
101
|
+
"release:stage": "pnpm stage publish --no-git-check",
|
|
111
102
|
"start": "tsdown --watch",
|
|
112
103
|
"test": "vitest --passWithNoTests",
|
|
113
104
|
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
|