@kubb/plugin-solid-query 4.0.0 → 4.1.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.
- package/dist/{components-Bi0-xvca.cjs → components-CrpQqUQQ.cjs} +181 -4
- package/dist/components-CrpQqUQQ.cjs.map +1 -0
- package/dist/{components-B_yhFBLa.js → components-JN6XAKh3.js} +169 -4
- package/dist/components-JN6XAKh3.js.map +1 -0
- package/dist/components.cjs +3 -1
- package/dist/components.d.cts +58 -2
- package/dist/components.d.ts +58 -2
- package/dist/components.js +2 -2
- package/dist/{generators-0TNaKUZf.cjs → generators-CUcA3_rk.cjs} +161 -5
- package/dist/generators-CUcA3_rk.cjs.map +1 -0
- package/dist/{generators-DsUzHPML.js → generators-DRX-ix2A.js} +155 -5
- package/dist/generators-DRX-ix2A.js.map +1 -0
- package/dist/generators.cjs +3 -2
- package/dist/generators.d.cts +5 -2
- package/dist/generators.d.ts +5 -2
- package/dist/generators.js +3 -3
- package/dist/index.cjs +14 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/{types-BcAT9UxT.d.cts → types-BI1GJc6y.d.cts} +27 -1
- package/dist/{types-B5mFPIGb.d.ts → types-fv5KLGsJ.d.ts} +27 -1
- package/package.json +9 -10
- package/src/components/Mutation.tsx +177 -0
- package/src/components/MutationKey.tsx +54 -0
- package/src/components/Query.tsx +1 -1
- package/src/components/index.ts +2 -0
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +2 -2
- package/src/generators/__snapshots__/clientGetImportPath.ts +2 -2
- package/src/generators/__snapshots__/findByTags.ts +2 -2
- package/src/generators/__snapshots__/findByTagsObject.ts +2 -2
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +2 -2
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +2 -2
- package/src/generators/__snapshots__/findByTagsWithZod.ts +2 -2
- package/src/generators/__snapshots__/postAsQuery.ts +2 -2
- package/src/generators/index.ts +1 -0
- package/src/generators/mutationGenerator.tsx +144 -0
- package/src/generators/queryGenerator.tsx +1 -1
- package/src/plugin.ts +14 -9
- package/src/types.ts +28 -0
- package/dist/components-B_yhFBLa.js.map +0 -1
- package/dist/components-Bi0-xvca.cjs.map +0 -1
- package/dist/generators-0TNaKUZf.cjs.map +0 -1
- package/dist/generators-DsUzHPML.js.map +0 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["QueryKey","queryGenerator","pluginOasName","pluginTsName","pluginZodName","path","FileManager","options","groupName: Group['name']","PluginManager","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["QueryKey","queryGenerator","mutationGenerator","MutationKey","pluginOasName","pluginTsName","pluginZodName","path","FileManager","options","groupName: Group['name']","PluginManager","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport type { Plugin } from '@kubb/core'\nimport { createPlugin, FileManager, type Group, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport type { PluginOas } from '@kubb/plugin-oas'\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 { PluginSolidQuery } from './types.ts'\n\nexport const pluginSolidQueryName = 'plugin-solid-query' satisfies PluginSolidQuery['name']\n\nexport const pluginSolidQuery = createPlugin<PluginSolidQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n paramsCasing,\n contentType,\n } = options\n\n return {\n name: pluginSolidQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/clients/axios',\n dataReturnType: 'data',\n pathParamsType,\n ...options.client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/solid-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/solid-query',\n ...mutation,\n },\n paramsType,\n pathParamsType,\n parser,\n group,\n paramsCasing,\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 ?? FileManager.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 buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\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.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\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.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":"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"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Options, PluginSolidQuery, UserPluginWithLifeCycle } from "./types-
|
|
1
|
+
import { Options, PluginSolidQuery, UserPluginWithLifeCycle } from "./types-BI1GJc6y.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginSolidQueryName = "plugin-solid-query";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Options, PluginSolidQuery, UserPluginWithLifeCycle } from "./types-
|
|
1
|
+
import { Options, PluginSolidQuery, UserPluginWithLifeCycle } from "./types-fv5KLGsJ.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginSolidQueryName = "plugin-solid-query";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { QueryKey } from "./components-
|
|
2
|
-
import { queryGenerator } from "./generators-
|
|
1
|
+
import { MutationKey, QueryKey } from "./components-JN6XAKh3.js";
|
|
2
|
+
import { mutationGenerator, queryGenerator } from "./generators-DRX-ix2A.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { FileManager, PluginManager, createPlugin } from "@kubb/core";
|
|
5
5
|
import { camelCase, pascalCase } from "@kubb/core/transformers";
|
|
@@ -13,7 +13,7 @@ const pluginSolidQuery = createPlugin((options) => {
|
|
|
13
13
|
const { output = {
|
|
14
14
|
path: "hooks",
|
|
15
15
|
barrelType: "named"
|
|
16
|
-
}, group, exclude = [], include, override = [], parser = "client", transformers = {}, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", queryKey = QueryKey.getTransformer, generators = [queryGenerator].filter(Boolean), query = {}, paramsCasing, contentType } = options;
|
|
16
|
+
}, group, exclude = [], include, override = [], parser = "client", transformers = {}, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", queryKey = QueryKey.getTransformer, generators = [queryGenerator, mutationGenerator].filter(Boolean), mutation = {}, query = {}, mutationKey = MutationKey.getTransformer, paramsCasing, contentType } = options;
|
|
17
17
|
return {
|
|
18
18
|
name: pluginSolidQueryName,
|
|
19
19
|
options: {
|
|
@@ -30,6 +30,17 @@ const pluginSolidQuery = createPlugin((options) => {
|
|
|
30
30
|
importPath: "@tanstack/solid-query",
|
|
31
31
|
...query
|
|
32
32
|
},
|
|
33
|
+
mutationKey,
|
|
34
|
+
mutation: {
|
|
35
|
+
methods: [
|
|
36
|
+
"post",
|
|
37
|
+
"put",
|
|
38
|
+
"patch",
|
|
39
|
+
"delete"
|
|
40
|
+
],
|
|
41
|
+
importPath: "@tanstack/solid-query",
|
|
42
|
+
...mutation
|
|
43
|
+
},
|
|
33
44
|
paramsType,
|
|
34
45
|
pathParamsType,
|
|
35
46
|
parser,
|
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'\
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport type { Plugin } from '@kubb/core'\nimport { createPlugin, FileManager, type Group, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport type { PluginOas } from '@kubb/plugin-oas'\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 { PluginSolidQuery } from './types.ts'\n\nexport const pluginSolidQueryName = 'plugin-solid-query' satisfies PluginSolidQuery['name']\n\nexport const pluginSolidQuery = createPlugin<PluginSolidQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n paramsCasing,\n contentType,\n } = options\n\n return {\n name: pluginSolidQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/clients/axios',\n dataReturnType: 'data',\n pathParamsType,\n ...options.client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/solid-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/solid-query',\n ...mutation,\n },\n paramsType,\n pathParamsType,\n parser,\n group,\n paramsCasing,\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 ?? FileManager.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 buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\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.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\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.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":"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"}
|
|
@@ -1254,6 +1254,10 @@ type Transformer = (props: TransformerProps) => unknown[];
|
|
|
1254
1254
|
* Customize the queryKey
|
|
1255
1255
|
*/
|
|
1256
1256
|
type QueryKey = Transformer;
|
|
1257
|
+
/**
|
|
1258
|
+
* Customize the mutationKey
|
|
1259
|
+
*/
|
|
1260
|
+
type MutationKey = Transformer;
|
|
1257
1261
|
type Query = {
|
|
1258
1262
|
/**
|
|
1259
1263
|
* Define which HttpMethods can be used for queries
|
|
@@ -1269,6 +1273,21 @@ type Query = {
|
|
|
1269
1273
|
*/
|
|
1270
1274
|
importPath?: string;
|
|
1271
1275
|
};
|
|
1276
|
+
type Mutation = {
|
|
1277
|
+
/**
|
|
1278
|
+
* Define which HttpMethods can be used for mutations
|
|
1279
|
+
* @default ['post', 'put', 'delete']
|
|
1280
|
+
*/
|
|
1281
|
+
methods: Array<HttpMethod>;
|
|
1282
|
+
/**
|
|
1283
|
+
* Path to the useQuery that will be used to do the useQuery functionality.
|
|
1284
|
+
* It will be used as `import { useQuery } from '${importPath}'`.
|
|
1285
|
+
* It allows both relative and absolute path.
|
|
1286
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
1287
|
+
* @default '@tanstack/solid-query'
|
|
1288
|
+
*/
|
|
1289
|
+
importPath?: string;
|
|
1290
|
+
};
|
|
1272
1291
|
type Options$1 = {
|
|
1273
1292
|
/**
|
|
1274
1293
|
* Specify the export location for the files and define the behavior of the output
|
|
@@ -1325,6 +1344,11 @@ type Options$1 = {
|
|
|
1325
1344
|
* Which parser should be used before returning the data to `@tanstack/query`.
|
|
1326
1345
|
* `'zod'` will use `@kubb/plugin-zod` to parse the data.
|
|
1327
1346
|
*/
|
|
1347
|
+
mutationKey?: MutationKey;
|
|
1348
|
+
/**
|
|
1349
|
+
* Override some useMutation behaviours.
|
|
1350
|
+
*/
|
|
1351
|
+
mutation?: Partial<Mutation> | false;
|
|
1328
1352
|
parser?: PluginClient['options']['parser'];
|
|
1329
1353
|
transformers?: {
|
|
1330
1354
|
/**
|
|
@@ -1349,8 +1373,10 @@ type ResolvedOptions = {
|
|
|
1349
1373
|
pathParamsType: NonNullable<Options$1['pathParamsType']>;
|
|
1350
1374
|
queryKey: QueryKey | undefined;
|
|
1351
1375
|
query: NonNullable<Required<Query>> | false;
|
|
1376
|
+
mutationKey: MutationKey | undefined;
|
|
1377
|
+
mutation: NonNullable<Required<Mutation>> | false;
|
|
1352
1378
|
};
|
|
1353
1379
|
type PluginSolidQuery = PluginFactoryOptions<'plugin-solid-query', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1354
1380
|
//#endregion
|
|
1355
1381
|
export { Generator, type Operation$1 as Operation, OperationSchemas, Options$1 as Options, PluginSolidQuery, Transformer, UserPluginWithLifeCycle };
|
|
1356
|
-
//# sourceMappingURL=types-
|
|
1382
|
+
//# sourceMappingURL=types-BI1GJc6y.d.cts.map
|
|
@@ -1254,6 +1254,10 @@ type Transformer = (props: TransformerProps) => unknown[];
|
|
|
1254
1254
|
* Customize the queryKey
|
|
1255
1255
|
*/
|
|
1256
1256
|
type QueryKey = Transformer;
|
|
1257
|
+
/**
|
|
1258
|
+
* Customize the mutationKey
|
|
1259
|
+
*/
|
|
1260
|
+
type MutationKey = Transformer;
|
|
1257
1261
|
type Query = {
|
|
1258
1262
|
/**
|
|
1259
1263
|
* Define which HttpMethods can be used for queries
|
|
@@ -1269,6 +1273,21 @@ type Query = {
|
|
|
1269
1273
|
*/
|
|
1270
1274
|
importPath?: string;
|
|
1271
1275
|
};
|
|
1276
|
+
type Mutation = {
|
|
1277
|
+
/**
|
|
1278
|
+
* Define which HttpMethods can be used for mutations
|
|
1279
|
+
* @default ['post', 'put', 'delete']
|
|
1280
|
+
*/
|
|
1281
|
+
methods: Array<HttpMethod>;
|
|
1282
|
+
/**
|
|
1283
|
+
* Path to the useQuery that will be used to do the useQuery functionality.
|
|
1284
|
+
* It will be used as `import { useQuery } from '${importPath}'`.
|
|
1285
|
+
* It allows both relative and absolute path.
|
|
1286
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
1287
|
+
* @default '@tanstack/solid-query'
|
|
1288
|
+
*/
|
|
1289
|
+
importPath?: string;
|
|
1290
|
+
};
|
|
1272
1291
|
type Options$1 = {
|
|
1273
1292
|
/**
|
|
1274
1293
|
* Specify the export location for the files and define the behavior of the output
|
|
@@ -1325,6 +1344,11 @@ type Options$1 = {
|
|
|
1325
1344
|
* Which parser should be used before returning the data to `@tanstack/query`.
|
|
1326
1345
|
* `'zod'` will use `@kubb/plugin-zod` to parse the data.
|
|
1327
1346
|
*/
|
|
1347
|
+
mutationKey?: MutationKey;
|
|
1348
|
+
/**
|
|
1349
|
+
* Override some useMutation behaviours.
|
|
1350
|
+
*/
|
|
1351
|
+
mutation?: Partial<Mutation> | false;
|
|
1328
1352
|
parser?: PluginClient['options']['parser'];
|
|
1329
1353
|
transformers?: {
|
|
1330
1354
|
/**
|
|
@@ -1349,8 +1373,10 @@ type ResolvedOptions = {
|
|
|
1349
1373
|
pathParamsType: NonNullable<Options$1['pathParamsType']>;
|
|
1350
1374
|
queryKey: QueryKey | undefined;
|
|
1351
1375
|
query: NonNullable<Required<Query>> | false;
|
|
1376
|
+
mutationKey: MutationKey | undefined;
|
|
1377
|
+
mutation: NonNullable<Required<Mutation>> | false;
|
|
1352
1378
|
};
|
|
1353
1379
|
type PluginSolidQuery = PluginFactoryOptions<'plugin-solid-query', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1354
1380
|
//#endregion
|
|
1355
1381
|
export { Generator, type Operation$1 as Operation, OperationSchemas, Options$1 as Options, PluginSolidQuery, Transformer, UserPluginWithLifeCycle };
|
|
1356
|
-
//# sourceMappingURL=types-
|
|
1382
|
+
//# sourceMappingURL=types-fv5KLGsJ.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-solid-query",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Solid Query hooks generator plugin for Kubb, creating type-safe API client hooks from OpenAPI specifications for Solid.js applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"solid-query",
|
|
@@ -62,20 +62,19 @@
|
|
|
62
62
|
],
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"remeda": "^2.32.0",
|
|
65
|
-
"@kubb/core": "4.
|
|
66
|
-
"@kubb/oas": "4.
|
|
67
|
-
"@kubb/plugin-client": "4.
|
|
68
|
-
"@kubb/plugin-oas": "4.
|
|
69
|
-
"@kubb/plugin-ts": "4.
|
|
70
|
-
"@kubb/plugin-zod": "4.
|
|
71
|
-
"@kubb/react": "4.
|
|
65
|
+
"@kubb/core": "4.1.0",
|
|
66
|
+
"@kubb/oas": "4.1.0",
|
|
67
|
+
"@kubb/plugin-client": "4.1.0",
|
|
68
|
+
"@kubb/plugin-oas": "4.1.0",
|
|
69
|
+
"@kubb/plugin-ts": "4.1.0",
|
|
70
|
+
"@kubb/plugin-zod": "4.1.0",
|
|
71
|
+
"@kubb/react": "4.1.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/react": "^18.3.24",
|
|
75
75
|
"react": "^18.3.1",
|
|
76
76
|
"tsdown": "^0.14.2",
|
|
77
|
-
"typescript": "^5.9.2"
|
|
78
|
-
"@kubb/config-ts": "4.0.0"
|
|
77
|
+
"typescript": "^5.9.2"
|
|
79
78
|
},
|
|
80
79
|
"peerDependencies": {
|
|
81
80
|
"@kubb/react": "^4.0.0"
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { isOptional, type Operation } from '@kubb/oas'
|
|
2
|
+
import { Client } from '@kubb/plugin-client/components'
|
|
3
|
+
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
4
|
+
import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
|
|
5
|
+
import { File, Function, FunctionParams } from '@kubb/react'
|
|
6
|
+
import type { Params } from '@kubb/react/types'
|
|
7
|
+
import type { ReactNode } from 'react'
|
|
8
|
+
import type { PluginSolidQuery } from '../types.ts'
|
|
9
|
+
import { MutationKey } from './MutationKey.tsx'
|
|
10
|
+
|
|
11
|
+
type Props = {
|
|
12
|
+
/**
|
|
13
|
+
* Name of the function
|
|
14
|
+
*/
|
|
15
|
+
name: string
|
|
16
|
+
typeName: string
|
|
17
|
+
clientName: string
|
|
18
|
+
mutationKeyName: string
|
|
19
|
+
typeSchemas: OperationSchemas
|
|
20
|
+
operation: Operation
|
|
21
|
+
dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']
|
|
22
|
+
paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']
|
|
23
|
+
paramsType: PluginSolidQuery['resolvedOptions']['paramsType']
|
|
24
|
+
pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type GetParamsProps = {
|
|
28
|
+
paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']
|
|
29
|
+
pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
|
|
30
|
+
dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']
|
|
31
|
+
typeSchemas: OperationSchemas
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getParams({ paramsCasing, dataReturnType, typeSchemas }: GetParamsProps) {
|
|
35
|
+
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
36
|
+
const mutationParams = FunctionParams.factory({
|
|
37
|
+
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
38
|
+
data: typeSchemas.request?.name
|
|
39
|
+
? {
|
|
40
|
+
type: typeSchemas.request?.name,
|
|
41
|
+
optional: isOptional(typeSchemas.request?.schema),
|
|
42
|
+
}
|
|
43
|
+
: undefined,
|
|
44
|
+
params: typeSchemas.queryParams?.name
|
|
45
|
+
? {
|
|
46
|
+
type: typeSchemas.queryParams?.name,
|
|
47
|
+
optional: isOptional(typeSchemas.queryParams?.schema),
|
|
48
|
+
}
|
|
49
|
+
: undefined,
|
|
50
|
+
headers: typeSchemas.headerParams?.name
|
|
51
|
+
? {
|
|
52
|
+
type: typeSchemas.headerParams?.name,
|
|
53
|
+
optional: isOptional(typeSchemas.headerParams?.schema),
|
|
54
|
+
}
|
|
55
|
+
: undefined,
|
|
56
|
+
})
|
|
57
|
+
const TRequest = mutationParams.toConstructor()
|
|
58
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
|
|
59
|
+
const generics = [TData, TError, TRequest ? `{${TRequest}}` : 'void', 'TContext'].join(', ')
|
|
60
|
+
|
|
61
|
+
return FunctionParams.factory({
|
|
62
|
+
options: {
|
|
63
|
+
type: `
|
|
64
|
+
{
|
|
65
|
+
mutation?: ReturnType<UseMutationOptions<${generics}>> & { client?: QueryClient },
|
|
66
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},
|
|
67
|
+
}
|
|
68
|
+
`,
|
|
69
|
+
default: '{}',
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function Mutation({
|
|
75
|
+
name,
|
|
76
|
+
clientName,
|
|
77
|
+
paramsCasing,
|
|
78
|
+
paramsType,
|
|
79
|
+
pathParamsType,
|
|
80
|
+
dataReturnType,
|
|
81
|
+
typeSchemas,
|
|
82
|
+
operation,
|
|
83
|
+
mutationKeyName,
|
|
84
|
+
}: Props): ReactNode {
|
|
85
|
+
const mutationKeyParams = MutationKey.getParams({
|
|
86
|
+
pathParamsType,
|
|
87
|
+
typeSchemas,
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const params = getParams({
|
|
91
|
+
paramsCasing,
|
|
92
|
+
pathParamsType,
|
|
93
|
+
dataReturnType,
|
|
94
|
+
typeSchemas,
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const clientParams = Client.getParams({
|
|
98
|
+
paramsCasing,
|
|
99
|
+
paramsType,
|
|
100
|
+
typeSchemas,
|
|
101
|
+
pathParamsType,
|
|
102
|
+
isConfigurable: true,
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const mutationParams = FunctionParams.factory({
|
|
106
|
+
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
107
|
+
data: typeSchemas.request?.name
|
|
108
|
+
? {
|
|
109
|
+
type: typeSchemas.request?.name,
|
|
110
|
+
optional: isOptional(typeSchemas.request?.schema),
|
|
111
|
+
}
|
|
112
|
+
: undefined,
|
|
113
|
+
params: typeSchemas.queryParams?.name
|
|
114
|
+
? {
|
|
115
|
+
type: typeSchemas.queryParams?.name,
|
|
116
|
+
optional: isOptional(typeSchemas.queryParams?.schema),
|
|
117
|
+
}
|
|
118
|
+
: undefined,
|
|
119
|
+
headers: typeSchemas.headerParams?.name
|
|
120
|
+
? {
|
|
121
|
+
type: typeSchemas.headerParams?.name,
|
|
122
|
+
optional: isOptional(typeSchemas.headerParams?.schema),
|
|
123
|
+
}
|
|
124
|
+
: undefined,
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
const dataParams = FunctionParams.factory({
|
|
128
|
+
data: {
|
|
129
|
+
// No use of pathParams because useMutation can only take one argument in object form,
|
|
130
|
+
// see https://tanstack.com/query/latest/docs/framework/react/reference/useMutation#usemutation
|
|
131
|
+
mode: 'object',
|
|
132
|
+
children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
|
|
133
|
+
if (value) {
|
|
134
|
+
acc[key] = {
|
|
135
|
+
...value,
|
|
136
|
+
type: undefined,
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return acc
|
|
141
|
+
}, {} as Params),
|
|
142
|
+
},
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
const TRequest = mutationParams.toConstructor()
|
|
146
|
+
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
147
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
|
|
148
|
+
const generics = [TData, TError, TRequest ? `{${TRequest}}` : 'void', 'TContext'].join(', ')
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<File.Source name={name} isExportable isIndexable>
|
|
152
|
+
<Function
|
|
153
|
+
name={name}
|
|
154
|
+
export
|
|
155
|
+
params={params.toConstructor()}
|
|
156
|
+
JSDoc={{
|
|
157
|
+
comments: getComments(operation),
|
|
158
|
+
}}
|
|
159
|
+
generics={['TContext']}
|
|
160
|
+
>
|
|
161
|
+
{`
|
|
162
|
+
const { mutation = {}, client: config = {} } = options ?? {}
|
|
163
|
+
const { client: queryClient, ...mutationOptions } = mutation;
|
|
164
|
+
const mutationKey = mutationOptions.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
|
|
165
|
+
|
|
166
|
+
return useMutation<${generics}>(()=> ({
|
|
167
|
+
mutationFn: async(${dataParams.toConstructor()}) => {
|
|
168
|
+
return ${clientName}(${clientParams.toCall()})
|
|
169
|
+
},
|
|
170
|
+
mutationKey,
|
|
171
|
+
...mutationOptions
|
|
172
|
+
}), queryClient? () => queryClient: undefined)
|
|
173
|
+
`}
|
|
174
|
+
</Function>
|
|
175
|
+
</File.Source>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { URLPath } from '@kubb/core/utils'
|
|
2
|
+
import type { Operation } from '@kubb/oas'
|
|
3
|
+
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
4
|
+
import { File, Function, FunctionParams, Type } from '@kubb/react'
|
|
5
|
+
import type { ReactNode } from 'react'
|
|
6
|
+
import type { PluginSolidQuery, Transformer } from '../types'
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
name: string
|
|
10
|
+
typeName: string
|
|
11
|
+
typeSchemas: OperationSchemas
|
|
12
|
+
operation: Operation
|
|
13
|
+
paramsCasing: PluginSolidQuery['resolvedOptions']['paramsCasing']
|
|
14
|
+
pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
|
|
15
|
+
transformer: Transformer | undefined
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type GetParamsProps = {
|
|
19
|
+
pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
|
|
20
|
+
typeSchemas: OperationSchemas
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getParams({}: GetParamsProps) {
|
|
24
|
+
return FunctionParams.factory({})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const getTransformer: Transformer = ({ operation, casing }) => {
|
|
28
|
+
const path = new URLPath(operation.path, { casing })
|
|
29
|
+
|
|
30
|
+
return [`{ url: '${path.toURLPath()}' }`]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function MutationKey({ name, typeSchemas, pathParamsType, paramsCasing, operation, typeName, transformer = getTransformer }: Props): ReactNode {
|
|
34
|
+
const params = getParams({ pathParamsType, typeSchemas })
|
|
35
|
+
const keys = transformer({ operation, schemas: typeSchemas, casing: paramsCasing })
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<File.Source name={name} isExportable isIndexable>
|
|
40
|
+
<Function.Arrow name={name} export params={params.toConstructor()} singleLine>
|
|
41
|
+
{`[${keys.join(', ')}] as const`}
|
|
42
|
+
</Function.Arrow>
|
|
43
|
+
</File.Source>
|
|
44
|
+
<File.Source name={typeName} isExportable isIndexable isTypeOnly>
|
|
45
|
+
<Type name={typeName} export>
|
|
46
|
+
{`ReturnType<typeof ${name}>`}
|
|
47
|
+
</Type>
|
|
48
|
+
</File.Source>
|
|
49
|
+
</>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
MutationKey.getParams = getParams
|
|
54
|
+
MutationKey.getTransformer = getTransformer
|
package/src/components/Query.tsx
CHANGED
|
@@ -165,7 +165,7 @@ export function Query({
|
|
|
165
165
|
const { client: queryClient, ...queryOptions } = queryConfig
|
|
166
166
|
const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
|
|
167
167
|
|
|
168
|
-
const query =
|
|
168
|
+
const query = useQuery(() => ({
|
|
169
169
|
...${queryOptions},
|
|
170
170
|
queryKey,
|
|
171
171
|
initialData: null,
|
package/src/components/index.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import fetch from '@kubb/plugin-client/clients/axios'
|
|
6
6
|
import type { RequestConfig, ResponseErrorConfig, ResponseConfig } from '@kubb/plugin-client/clients/axios'
|
|
7
7
|
import type { QueryKey, QueryClient, UseBaseQueryOptions, UseQueryResult } from '@tanstack/svelte-query'
|
|
8
|
-
import { queryOptions,
|
|
8
|
+
import { queryOptions, useQuery } from '@tanstack/svelte-query'
|
|
9
9
|
|
|
10
10
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
@@ -76,7 +76,7 @@ export function createFindPetsByTags<
|
|
|
76
76
|
const { client: queryClient, ...queryOptions } = queryConfig
|
|
77
77
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
|
|
78
78
|
|
|
79
|
-
const query =
|
|
79
|
+
const query = useQuery(
|
|
80
80
|
() => ({
|
|
81
81
|
...(findPetsByTagsQueryOptions(headers, params, config) as unknown as UseBaseQueryOptions),
|
|
82
82
|
queryKey,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import fetch from 'axios'
|
|
6
6
|
import type { QueryKey, QueryClient, UseBaseQueryOptions, UseQueryResult } from '@tanstack/svelte-query'
|
|
7
7
|
import type { RequestConfig, ResponseErrorConfig } from 'axios'
|
|
8
|
-
import { queryOptions,
|
|
8
|
+
import { queryOptions, useQuery } from '@tanstack/svelte-query'
|
|
9
9
|
|
|
10
10
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
@@ -71,7 +71,7 @@ export function createFindPetsByTags<
|
|
|
71
71
|
const { client: queryClient, ...queryOptions } = queryConfig
|
|
72
72
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
|
|
73
73
|
|
|
74
|
-
const query =
|
|
74
|
+
const query = useQuery(
|
|
75
75
|
() => ({
|
|
76
76
|
...(findPetsByTagsQueryOptions(headers, params, config) as unknown as UseBaseQueryOptions),
|
|
77
77
|
queryKey,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import fetch from '@kubb/plugin-client/clients/axios'
|
|
6
6
|
import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
|
|
7
7
|
import type { QueryKey, QueryClient, UseBaseQueryOptions, UseQueryResult } from '@tanstack/svelte-query'
|
|
8
|
-
import { queryOptions,
|
|
8
|
+
import { queryOptions, useQuery } from '@tanstack/svelte-query'
|
|
9
9
|
|
|
10
10
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
@@ -71,7 +71,7 @@ export function createFindPetsByTags<
|
|
|
71
71
|
const { client: queryClient, ...queryOptions } = queryConfig
|
|
72
72
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
|
|
73
73
|
|
|
74
|
-
const query =
|
|
74
|
+
const query = useQuery(
|
|
75
75
|
() => ({
|
|
76
76
|
...(findPetsByTagsQueryOptions(headers, params, config) as unknown as UseBaseQueryOptions),
|
|
77
77
|
queryKey,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import fetch from '@kubb/plugin-client/clients/axios'
|
|
6
6
|
import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
|
|
7
7
|
import type { QueryKey, QueryClient, UseBaseQueryOptions, UseQueryResult } from '@tanstack/svelte-query'
|
|
8
|
-
import { queryOptions,
|
|
8
|
+
import { queryOptions, useQuery } from '@tanstack/svelte-query'
|
|
9
9
|
|
|
10
10
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
@@ -68,7 +68,7 @@ export function createFindPetsByTags<
|
|
|
68
68
|
const { client: queryClient, ...queryOptions } = queryConfig
|
|
69
69
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
|
|
70
70
|
|
|
71
|
-
const query =
|
|
71
|
+
const query = useQuery(
|
|
72
72
|
() => ({
|
|
73
73
|
...(findPetsByTagsQueryOptions({ headers, params }, config) as unknown as UseBaseQueryOptions),
|
|
74
74
|
queryKey,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import fetch from '@kubb/plugin-client/clients/axios'
|
|
6
6
|
import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
|
|
7
7
|
import type { QueryKey, QueryClient, UseBaseQueryOptions, UseQueryResult } from '@tanstack/svelte-query'
|
|
8
|
-
import { queryOptions,
|
|
8
|
+
import { queryOptions, useQuery } from '@tanstack/svelte-query'
|
|
9
9
|
|
|
10
10
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
@@ -71,7 +71,7 @@ export function createFindPetsByTags<
|
|
|
71
71
|
const { client: queryClient, ...queryOptions } = queryConfig
|
|
72
72
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
|
|
73
73
|
|
|
74
|
-
const query =
|
|
74
|
+
const query = useQuery(
|
|
75
75
|
() => ({
|
|
76
76
|
...(findPetsByTagsQueryOptions(headers, params, config) as unknown as UseBaseQueryOptions),
|
|
77
77
|
queryKey,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import fetch from '@kubb/plugin-client/clients/axios'
|
|
6
6
|
import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
|
|
7
7
|
import type { QueryKey, QueryClient, UseBaseQueryOptions, UseQueryResult } from '@tanstack/react-query'
|
|
8
|
-
import { queryOptions,
|
|
8
|
+
import { queryOptions, useQuery } from '@tanstack/react-query'
|
|
9
9
|
|
|
10
10
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => ['test', { url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
@@ -71,7 +71,7 @@ export function createFindPetsByTags<
|
|
|
71
71
|
const { client: queryClient, ...queryOptions } = queryConfig
|
|
72
72
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
|
|
73
73
|
|
|
74
|
-
const query =
|
|
74
|
+
const query = useQuery(
|
|
75
75
|
() => ({
|
|
76
76
|
...(findPetsByTagsQueryOptions(headers, params, config) as unknown as UseBaseQueryOptions),
|
|
77
77
|
queryKey,
|