@kubb/plugin-svelte-query 3.0.14 → 3.2.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/{chunk-TOBORUCM.js → chunk-BB5SCJJT.js} +10 -3
- package/dist/chunk-BB5SCJJT.js.map +1 -0
- package/dist/{chunk-F6TRULM6.cjs → chunk-DJNDGHXY.cjs} +17 -10
- package/dist/chunk-DJNDGHXY.cjs.map +1 -0
- package/dist/{chunk-SP3FM442.js → chunk-EZRBBWGF.js} +50 -30
- package/dist/chunk-EZRBBWGF.js.map +1 -0
- package/dist/{chunk-PHEQCKJY.cjs → chunk-YSVAGB5Y.cjs} +50 -30
- package/dist/chunk-YSVAGB5Y.cjs.map +1 -0
- package/dist/components.cjs +6 -6
- package/dist/components.d.cts +17 -9
- package/dist/components.d.ts +17 -9
- package/dist/components.js +1 -1
- package/dist/generators.cjs +4 -4
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +18 -10
- 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 +15 -7
- package/dist/index.js.map +1 -1
- package/dist/{types-B9W9aYra.d.ts → types-CRc4pNA-.d.cts} +22 -0
- package/dist/{types-B9W9aYra.d.cts → types-CRc4pNA-.d.ts} +22 -0
- package/package.json +11 -11
- package/src/components/Mutation.tsx +18 -4
- package/src/components/MutationKey.tsx +5 -4
- package/src/components/Query.tsx +9 -3
- package/src/components/QueryKey.tsx +9 -6
- package/src/components/QueryOptions.tsx +9 -5
- package/src/generators/mutationGenerator.tsx +3 -0
- package/src/generators/queryGenerator.tsx +4 -0
- package/src/plugin.ts +16 -6
- package/src/types.ts +8 -0
- package/dist/chunk-F6TRULM6.cjs.map +0 -1
- package/dist/chunk-PHEQCKJY.cjs.map +0 -1
- package/dist/chunk-SP3FM442.js.map +0 -1
- package/dist/chunk-TOBORUCM.js.map +0 -1
package/dist/components.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Operation } from '@kubb/oas';
|
|
2
2
|
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { P as PluginSvelteQuery, T as Transformer } from './types-
|
|
4
|
+
import { P as PluginSvelteQuery, T as Transformer } from './types-CRc4pNA-.js';
|
|
5
5
|
import { FunctionParams } from '@kubb/react';
|
|
6
6
|
import '@kubb/core';
|
|
7
7
|
|
|
@@ -15,11 +15,12 @@ type Props$4 = {
|
|
|
15
15
|
mutationKeyName: string;
|
|
16
16
|
typeSchemas: OperationSchemas;
|
|
17
17
|
operation: Operation;
|
|
18
|
+
paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing'];
|
|
18
19
|
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
19
20
|
dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType'];
|
|
20
21
|
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
21
22
|
};
|
|
22
|
-
declare function Mutation({ name, clientName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props$4): ReactNode;
|
|
23
|
+
declare function Mutation({ name, clientName, paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName, }: Props$4): ReactNode;
|
|
23
24
|
|
|
24
25
|
type Props$3 = {
|
|
25
26
|
/**
|
|
@@ -31,19 +32,21 @@ type Props$3 = {
|
|
|
31
32
|
queryKeyTypeName: string;
|
|
32
33
|
typeSchemas: OperationSchemas;
|
|
33
34
|
operation: Operation;
|
|
35
|
+
paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing'];
|
|
34
36
|
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
35
37
|
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
36
38
|
dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType'];
|
|
37
39
|
};
|
|
38
40
|
type GetParamsProps$3 = {
|
|
41
|
+
paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing'];
|
|
39
42
|
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
40
43
|
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
41
44
|
dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType'];
|
|
42
45
|
typeSchemas: OperationSchemas;
|
|
43
46
|
};
|
|
44
|
-
declare function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, }: Props$3): ReactNode;
|
|
47
|
+
declare function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, }: Props$3): ReactNode;
|
|
45
48
|
declare namespace Query {
|
|
46
|
-
var getParams: ({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps$3) => FunctionParams;
|
|
49
|
+
var getParams: ({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps$3) => FunctionParams;
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
type Props$2 = {
|
|
@@ -51,16 +54,18 @@ type Props$2 = {
|
|
|
51
54
|
typeName: string;
|
|
52
55
|
typeSchemas: OperationSchemas;
|
|
53
56
|
operation: Operation;
|
|
57
|
+
paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing'];
|
|
54
58
|
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
55
59
|
transformer: Transformer | undefined;
|
|
56
60
|
};
|
|
57
61
|
type GetParamsProps$2 = {
|
|
62
|
+
paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing'];
|
|
58
63
|
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
59
64
|
typeSchemas: OperationSchemas;
|
|
60
65
|
};
|
|
61
|
-
declare function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer }: Props$2): ReactNode;
|
|
66
|
+
declare function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer }: Props$2): ReactNode;
|
|
62
67
|
declare namespace QueryKey {
|
|
63
|
-
var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps$2) => FunctionParams;
|
|
68
|
+
var getParams: ({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps$2) => FunctionParams;
|
|
64
69
|
var getTransformer: Transformer;
|
|
65
70
|
}
|
|
66
71
|
|
|
@@ -69,6 +74,7 @@ type Props$1 = {
|
|
|
69
74
|
typeName: string;
|
|
70
75
|
typeSchemas: OperationSchemas;
|
|
71
76
|
operation: Operation;
|
|
77
|
+
paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing'];
|
|
72
78
|
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
73
79
|
transformer: Transformer | undefined;
|
|
74
80
|
};
|
|
@@ -76,7 +82,7 @@ type GetParamsProps$1 = {
|
|
|
76
82
|
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
77
83
|
typeSchemas: OperationSchemas;
|
|
78
84
|
};
|
|
79
|
-
declare function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer }: Props$1): ReactNode;
|
|
85
|
+
declare function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer }: Props$1): ReactNode;
|
|
80
86
|
declare namespace MutationKey {
|
|
81
87
|
var getParams: ({}: GetParamsProps$1) => FunctionParams;
|
|
82
88
|
var getTransformer: Transformer;
|
|
@@ -87,17 +93,19 @@ type Props = {
|
|
|
87
93
|
clientName: string;
|
|
88
94
|
queryKeyName: string;
|
|
89
95
|
typeSchemas: OperationSchemas;
|
|
96
|
+
paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing'];
|
|
90
97
|
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
91
98
|
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
92
99
|
};
|
|
93
100
|
type GetParamsProps = {
|
|
101
|
+
paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing'];
|
|
94
102
|
paramsType: PluginSvelteQuery['resolvedOptions']['paramsType'];
|
|
95
103
|
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType'];
|
|
96
104
|
typeSchemas: OperationSchemas;
|
|
97
105
|
};
|
|
98
|
-
declare function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType, queryKeyName }: Props): ReactNode;
|
|
106
|
+
declare function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }: Props): ReactNode;
|
|
99
107
|
declare namespace QueryOptions {
|
|
100
|
-
var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
|
|
108
|
+
var getParams: ({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
|
|
101
109
|
}
|
|
102
110
|
|
|
103
111
|
export { Mutation, MutationKey, Query, QueryKey, QueryOptions };
|
package/dist/components.js
CHANGED
package/dist/generators.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkDJNDGHXY_cjs = require('./chunk-DJNDGHXY.cjs');
|
|
4
|
+
require('./chunk-YSVAGB5Y.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "mutationGenerator", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkDJNDGHXY_cjs.mutationGenerator; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "queryGenerator", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkDJNDGHXY_cjs.queryGenerator; }
|
|
15
15
|
});
|
|
16
16
|
//# sourceMappingURL=generators.cjs.map
|
|
17
17
|
//# sourceMappingURL=generators.cjs.map
|
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { mutationGenerator, queryGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { mutationGenerator, queryGenerator } from './chunk-BB5SCJJT.js';
|
|
2
|
+
import './chunk-EZRBBWGF.js';
|
|
3
3
|
//# sourceMappingURL=generators.js.map
|
|
4
4
|
//# sourceMappingURL=generators.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkDJNDGHXY_cjs = require('./chunk-DJNDGHXY.cjs');
|
|
4
|
+
var chunkYSVAGB5Y_cjs = require('./chunk-YSVAGB5Y.cjs');
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var core = require('@kubb/core');
|
|
7
7
|
var transformers = require('@kubb/core/transformers');
|
|
@@ -27,9 +27,10 @@ var pluginSvelteQuery = core.createPlugin((options) => {
|
|
|
27
27
|
pathParamsType = "inline",
|
|
28
28
|
mutation = {},
|
|
29
29
|
query = {},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
paramsCasing,
|
|
31
|
+
mutationKey = chunkYSVAGB5Y_cjs.MutationKey.getTransformer,
|
|
32
|
+
queryKey = chunkYSVAGB5Y_cjs.QueryKey.getTransformer,
|
|
33
|
+
generators = [chunkDJNDGHXY_cjs.queryGenerator, chunkDJNDGHXY_cjs.mutationGenerator].filter(Boolean)
|
|
33
34
|
} = options;
|
|
34
35
|
return {
|
|
35
36
|
name: pluginSvelteQueryName,
|
|
@@ -55,19 +56,26 @@ var pluginSvelteQuery = core.createPlugin((options) => {
|
|
|
55
56
|
},
|
|
56
57
|
paramsType,
|
|
57
58
|
pathParamsType: paramsType === "object" ? "object" : pathParamsType,
|
|
58
|
-
parser
|
|
59
|
+
parser,
|
|
60
|
+
paramsCasing,
|
|
61
|
+
group
|
|
59
62
|
},
|
|
60
63
|
pre: [pluginOas.pluginOasName, pluginTs.pluginTsName, parser === "zod" ? pluginZod.pluginZodName : void 0].filter(Boolean),
|
|
61
64
|
resolvePath(baseName, pathMode, options2) {
|
|
62
65
|
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
|
63
66
|
const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
|
|
64
|
-
if (options2?.tag && group?.type === "tag") {
|
|
65
|
-
const groupName = group?.name ? group.name : (ctx) => `${ctx.group}Controller`;
|
|
66
|
-
return path__default.default.resolve(root, output.path, groupName({ group: transformers.camelCase(options2.tag) }), baseName);
|
|
67
|
-
}
|
|
68
67
|
if (mode === "single") {
|
|
69
68
|
return path__default.default.resolve(root, output.path);
|
|
70
69
|
}
|
|
70
|
+
if (options2?.group && group) {
|
|
71
|
+
const groupName = group?.name ? group.name : (ctx) => {
|
|
72
|
+
if (group?.type === "path") {
|
|
73
|
+
return `${ctx.group.split("/")[1]}`;
|
|
74
|
+
}
|
|
75
|
+
return `${transformers.camelCase(ctx.group)}Controller`;
|
|
76
|
+
};
|
|
77
|
+
return path__default.default.resolve(root, output.path, groupName({ group: options2.group }), baseName);
|
|
78
|
+
}
|
|
71
79
|
return path__default.default.resolve(root, output.path, baseName);
|
|
72
80
|
},
|
|
73
81
|
resolveName(name, type) {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","MutationKey","QueryKey","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","pascalCase","PluginManager","OperationGenerator"],"mappings":";;;;;;;;;;;;;;;AAeO,IAAM,qB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A,QAAA,GAAW,QAAW,GAAA,cAAA;AAAA,MACrD;AAAA,KACF;AAAA,IACA,GAAA,EAAK,CAACC,uBAAA,EAAeC,qBAAc,EAAA,MAAA,KAAW,QAAQC,uBAAgB,GAAA,KAAA,CAAS,CAAE,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,IAC/F,WAAA,CAAY,QAAU,EAAA,QAAA,EAAUC,QAAS,EAAA;AACvC,MAAM,MAAA,IAAA,GAAOC,sBAAK,OAAQ,CAAA,IAAA,CAAK,OAAO,IAAM,EAAA,IAAA,CAAK,MAAO,CAAA,MAAA,CAAO,IAAI,CAAA;AACnE,MAAM,MAAA,IAAA,GAAO,YAAYC,gBAAY,CAAA,OAAA,CAAQD,sBAAK,OAAQ,CAAA,IAAA,EAAM,MAAO,CAAA,IAAI,CAAC,CAAA;AAE5E,MAAA,
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","MutationKey","QueryKey","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","pascalCase","PluginManager","OperationGenerator"],"mappings":";;;;;;;;;;;;;;;AAeO,IAAM,qBAAwB,GAAA;AAExB,IAAA,iBAAA,GAAoBA,iBAAgC,CAAA,CAAC,OAAY,KAAA;AAC5E,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAAY,OAAQ,EAAA;AAAA,IAC9C,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,kBACTC,iBAAe,EAAC;AAAA,IAChB,UAAa,GAAA,QAAA;AAAA,IACb,cAAiB,GAAA,QAAA;AAAA,IACjB,WAAW,EAAC;AAAA,IACZ,QAAQ,EAAC;AAAA,IACT,YAAA;AAAA,IACA,cAAcC,6BAAY,CAAA,cAAA;AAAA,IAC1B,WAAWC,0BAAS,CAAA,cAAA;AAAA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AAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,QACxD,IAAA,EAAM,OAAO,UAAc,IAAA,OAAA;AAAA,QAC3B,IAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,QACxB,IAAM,EAAA;AAAA,UACJ,SAAA,EAAW,KAAK,MAAO,CAAA;AAAA,SACzB;AAAA,QACA,QAAQ,IAAK,CAAA;AAAA,OACd,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAAA;AACnC,GACF;AACF,CAAC","file":"index.cjs","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSvelteQuery } from './types.ts'\n\nexport const pluginSvelteQueryName = 'plugin-svelte-query' satisfies PluginSvelteQuery['name']\n\nexport const pluginSvelteQuery = createPlugin<PluginSvelteQuery>((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 = 'inline',\n mutation = {},\n query = {},\n paramsCasing,\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n } = options\n\n return {\n name: pluginSvelteQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n pathParamsType: 'inline',\n ...options.client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/svelte-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/svelte-query',\n ...mutation,\n },\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : 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 ?? 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 (options?.group && group) {\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(root, output.path, groupName({ group: options.group }), baseName)\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: swaggerPlugin.context.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 files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"]}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { queryGenerator, mutationGenerator } from './chunk-
|
|
2
|
-
import { MutationKey, QueryKey } from './chunk-
|
|
1
|
+
import { queryGenerator, mutationGenerator } from './chunk-BB5SCJJT.js';
|
|
2
|
+
import { MutationKey, QueryKey } from './chunk-EZRBBWGF.js';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { createPlugin, FileManager, PluginManager } from '@kubb/core';
|
|
5
5
|
import { camelCase, pascalCase } from '@kubb/core/transformers';
|
|
@@ -21,6 +21,7 @@ var pluginSvelteQuery = createPlugin((options) => {
|
|
|
21
21
|
pathParamsType = "inline",
|
|
22
22
|
mutation = {},
|
|
23
23
|
query = {},
|
|
24
|
+
paramsCasing,
|
|
24
25
|
mutationKey = MutationKey.getTransformer,
|
|
25
26
|
queryKey = QueryKey.getTransformer,
|
|
26
27
|
generators = [queryGenerator, mutationGenerator].filter(Boolean)
|
|
@@ -49,19 +50,26 @@ var pluginSvelteQuery = createPlugin((options) => {
|
|
|
49
50
|
},
|
|
50
51
|
paramsType,
|
|
51
52
|
pathParamsType: paramsType === "object" ? "object" : pathParamsType,
|
|
52
|
-
parser
|
|
53
|
+
parser,
|
|
54
|
+
paramsCasing,
|
|
55
|
+
group
|
|
53
56
|
},
|
|
54
57
|
pre: [pluginOasName, pluginTsName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
|
|
55
58
|
resolvePath(baseName, pathMode, options2) {
|
|
56
59
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
57
60
|
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
|
|
58
|
-
if (options2?.tag && group?.type === "tag") {
|
|
59
|
-
const groupName = group?.name ? group.name : (ctx) => `${ctx.group}Controller`;
|
|
60
|
-
return path.resolve(root, output.path, groupName({ group: camelCase(options2.tag) }), baseName);
|
|
61
|
-
}
|
|
62
61
|
if (mode === "single") {
|
|
63
62
|
return path.resolve(root, output.path);
|
|
64
63
|
}
|
|
64
|
+
if (options2?.group && group) {
|
|
65
|
+
const groupName = group?.name ? group.name : (ctx) => {
|
|
66
|
+
if (group?.type === "path") {
|
|
67
|
+
return `${ctx.group.split("/")[1]}`;
|
|
68
|
+
}
|
|
69
|
+
return `${camelCase(ctx.group)}Controller`;
|
|
70
|
+
};
|
|
71
|
+
return path.resolve(root, output.path, groupName({ group: options2.group }), baseName);
|
|
72
|
+
}
|
|
65
73
|
return path.resolve(root, output.path, baseName);
|
|
66
74
|
},
|
|
67
75
|
resolveName(name, type) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;AAeO,IAAM,qBAAwB,GAAA;AAExB,IAAA,iBAAA,GAAoB,YAAgC,CAAA,CAAC,OAAY,KAAA;AAC5E,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAAY,OAAQ,EAAA;AAAA,IAC9C,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,IACT,eAAe,EAAC;AAAA,IAChB,UAAa,GAAA,QAAA;AAAA,IACb,cAAiB,GAAA,QAAA;AAAA,IACjB,WAAW,EAAC;AAAA,IACZ,QAAQ,EAAC;AAAA,IACT,cAAc,WAAY,CAAA,cAAA;AAAA,IAC1B,WAAW,QAAS,CAAA,cAAA;AAAA,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AS,EAAA;AACX,QAAK,IAAA,CAAA,MAAA,CAAO,OAAQ,CAAA,MAAA,CAAO,OAAU,GAAA,OAAA;AAAA;AAGvC,MAAA,MAAM,kBAAqB,GAAA,IAAI,kBAAmB,CAAA,IAAA,CAAK,OAAO,OAAS,EAAA;AAAA,QACrE,GAAA;AAAA,QACA,eAAe,IAAK,CAAA,aAAA;AAAA,QACpB,QAAQ,IAAK,CAAA,MAAA;AAAA,QACb,WAAA,EAAa,cAAc,OAAQ,CAAA,WAAA;AAAA,QACnC,OAAA;AAAA,QACA,OAAA;AAAA,QACA,QAAA;AAAA,QACA;AAAA,OACD,CAAA;AAED,MAAA,MAAM,KAAQ,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAM,GAAG,UAAU,CAAA;AAC1D,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,KAAK,CAAA;AAE3B,MAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,QACxD,IAAA,EAAM,OAAO,UAAc,IAAA,OAAA;AAAA,QAC3B,IAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,QACxB,IAAM,EAAA;AAAA,UACJ,SAAA,EAAW,KAAK,MAAO,CAAA;AAAA,SACzB;AAAA,QACA,QAAQ,IAAK,CAAA;AAAA,OACd,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAAA;AACnC,GACF;AACF,CAAC","file":"index.js","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSvelteQuery } from './types.ts'\n\nexport const pluginSvelteQueryName = 'plugin-svelte-query' satisfies PluginSvelteQuery['name']\n\nexport const pluginSvelteQuery = createPlugin<PluginSvelteQuery>((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 = 'inline',\n mutation = {},\n query = {},\n paramsCasing,\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n } = options\n\n return {\n name: pluginSvelteQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n pathParamsType: 'inline',\n ...options.client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/svelte-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/svelte-query',\n ...mutation,\n },\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : 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 ?? 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 (options?.group && group) {\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(root, output.path, groupName({ group: options.group }), baseName)\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: swaggerPlugin.context.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 files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"]}
|
|
@@ -47,6 +47,11 @@ type Options$2 = {
|
|
|
47
47
|
* @default 'data'
|
|
48
48
|
*/
|
|
49
49
|
dataReturnType?: 'data' | 'full';
|
|
50
|
+
/**
|
|
51
|
+
* How to style your params, by default no casing is applied
|
|
52
|
+
* - 'camelcase' will use camelcase for the params names
|
|
53
|
+
*/
|
|
54
|
+
paramsCasing?: 'camelcase';
|
|
50
55
|
/**
|
|
51
56
|
* How to pass your params
|
|
52
57
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -87,12 +92,14 @@ type ResolvedOptions$2 = {
|
|
|
87
92
|
dataReturnType: NonNullable<Options$2['dataReturnType']>;
|
|
88
93
|
pathParamsType: NonNullable<Options$2['pathParamsType']>;
|
|
89
94
|
paramsType: NonNullable<Options$2['paramsType']>;
|
|
95
|
+
paramsCasing: Options$2['paramsCasing'];
|
|
90
96
|
};
|
|
91
97
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$2, ResolvedOptions$2, never, ResolvePathOptions>;
|
|
92
98
|
|
|
93
99
|
type TransformerProps$1 = {
|
|
94
100
|
operation: Operation;
|
|
95
101
|
schemas: OperationSchemas;
|
|
102
|
+
casing: 'camelcase' | undefined;
|
|
96
103
|
};
|
|
97
104
|
type Transformer$1 = (props: TransformerProps$1) => unknown[];
|
|
98
105
|
type Suspense = object;
|
|
@@ -173,6 +180,11 @@ type Options$1 = {
|
|
|
173
180
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
174
181
|
*/
|
|
175
182
|
override?: Array<Override<ResolvedOptions$1>>;
|
|
183
|
+
/**
|
|
184
|
+
* How to style your params, by default no casing is applied
|
|
185
|
+
* - 'camelcase' will use camelcase for the params names
|
|
186
|
+
*/
|
|
187
|
+
paramsCasing?: 'camelcase';
|
|
176
188
|
/**
|
|
177
189
|
* How to pass your params
|
|
178
190
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -223,11 +235,13 @@ type Options$1 = {
|
|
|
223
235
|
};
|
|
224
236
|
type ResolvedOptions$1 = {
|
|
225
237
|
output: Output;
|
|
238
|
+
group: Options$1['group'];
|
|
226
239
|
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
227
240
|
baseURL?: string;
|
|
228
241
|
};
|
|
229
242
|
parser: Required<NonNullable<Options$1['parser']>>;
|
|
230
243
|
pathParamsType: NonNullable<Options$1['pathParamsType']>;
|
|
244
|
+
paramsCasing: Options$1['paramsCasing'];
|
|
231
245
|
paramsType: NonNullable<Options$1['paramsType']>;
|
|
232
246
|
/**
|
|
233
247
|
* Only used of infinite
|
|
@@ -244,6 +258,7 @@ type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, Re
|
|
|
244
258
|
type TransformerProps = {
|
|
245
259
|
operation: Operation;
|
|
246
260
|
schemas: OperationSchemas;
|
|
261
|
+
casing: 'camelcase' | undefined;
|
|
247
262
|
};
|
|
248
263
|
type Transformer = (props: TransformerProps) => unknown[];
|
|
249
264
|
/**
|
|
@@ -307,6 +322,11 @@ type Options = {
|
|
|
307
322
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
308
323
|
*/
|
|
309
324
|
override?: Array<Override<ResolvedOptions>>;
|
|
325
|
+
/**
|
|
326
|
+
* How to style your params, by default no casing is applied
|
|
327
|
+
* - 'camelcase' will use camelcase for the params names
|
|
328
|
+
*/
|
|
329
|
+
paramsCasing?: 'camelcase';
|
|
310
330
|
/**
|
|
311
331
|
* How to pass your params
|
|
312
332
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -349,10 +369,12 @@ type Options = {
|
|
|
349
369
|
};
|
|
350
370
|
type ResolvedOptions = {
|
|
351
371
|
output: Output;
|
|
372
|
+
group: Options['group'];
|
|
352
373
|
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
353
374
|
baseURL?: string;
|
|
354
375
|
};
|
|
355
376
|
parser: Required<NonNullable<Options['parser']>>;
|
|
377
|
+
paramsCasing: Options['paramsCasing'];
|
|
356
378
|
paramsType: NonNullable<Options['paramsType']>;
|
|
357
379
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
358
380
|
queryKey: QueryKey | undefined;
|
|
@@ -47,6 +47,11 @@ type Options$2 = {
|
|
|
47
47
|
* @default 'data'
|
|
48
48
|
*/
|
|
49
49
|
dataReturnType?: 'data' | 'full';
|
|
50
|
+
/**
|
|
51
|
+
* How to style your params, by default no casing is applied
|
|
52
|
+
* - 'camelcase' will use camelcase for the params names
|
|
53
|
+
*/
|
|
54
|
+
paramsCasing?: 'camelcase';
|
|
50
55
|
/**
|
|
51
56
|
* How to pass your params
|
|
52
57
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -87,12 +92,14 @@ type ResolvedOptions$2 = {
|
|
|
87
92
|
dataReturnType: NonNullable<Options$2['dataReturnType']>;
|
|
88
93
|
pathParamsType: NonNullable<Options$2['pathParamsType']>;
|
|
89
94
|
paramsType: NonNullable<Options$2['paramsType']>;
|
|
95
|
+
paramsCasing: Options$2['paramsCasing'];
|
|
90
96
|
};
|
|
91
97
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$2, ResolvedOptions$2, never, ResolvePathOptions>;
|
|
92
98
|
|
|
93
99
|
type TransformerProps$1 = {
|
|
94
100
|
operation: Operation;
|
|
95
101
|
schemas: OperationSchemas;
|
|
102
|
+
casing: 'camelcase' | undefined;
|
|
96
103
|
};
|
|
97
104
|
type Transformer$1 = (props: TransformerProps$1) => unknown[];
|
|
98
105
|
type Suspense = object;
|
|
@@ -173,6 +180,11 @@ type Options$1 = {
|
|
|
173
180
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
174
181
|
*/
|
|
175
182
|
override?: Array<Override<ResolvedOptions$1>>;
|
|
183
|
+
/**
|
|
184
|
+
* How to style your params, by default no casing is applied
|
|
185
|
+
* - 'camelcase' will use camelcase for the params names
|
|
186
|
+
*/
|
|
187
|
+
paramsCasing?: 'camelcase';
|
|
176
188
|
/**
|
|
177
189
|
* How to pass your params
|
|
178
190
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -223,11 +235,13 @@ type Options$1 = {
|
|
|
223
235
|
};
|
|
224
236
|
type ResolvedOptions$1 = {
|
|
225
237
|
output: Output;
|
|
238
|
+
group: Options$1['group'];
|
|
226
239
|
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
227
240
|
baseURL?: string;
|
|
228
241
|
};
|
|
229
242
|
parser: Required<NonNullable<Options$1['parser']>>;
|
|
230
243
|
pathParamsType: NonNullable<Options$1['pathParamsType']>;
|
|
244
|
+
paramsCasing: Options$1['paramsCasing'];
|
|
231
245
|
paramsType: NonNullable<Options$1['paramsType']>;
|
|
232
246
|
/**
|
|
233
247
|
* Only used of infinite
|
|
@@ -244,6 +258,7 @@ type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, Re
|
|
|
244
258
|
type TransformerProps = {
|
|
245
259
|
operation: Operation;
|
|
246
260
|
schemas: OperationSchemas;
|
|
261
|
+
casing: 'camelcase' | undefined;
|
|
247
262
|
};
|
|
248
263
|
type Transformer = (props: TransformerProps) => unknown[];
|
|
249
264
|
/**
|
|
@@ -307,6 +322,11 @@ type Options = {
|
|
|
307
322
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
308
323
|
*/
|
|
309
324
|
override?: Array<Override<ResolvedOptions>>;
|
|
325
|
+
/**
|
|
326
|
+
* How to style your params, by default no casing is applied
|
|
327
|
+
* - 'camelcase' will use camelcase for the params names
|
|
328
|
+
*/
|
|
329
|
+
paramsCasing?: 'camelcase';
|
|
310
330
|
/**
|
|
311
331
|
* How to pass your params
|
|
312
332
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -349,10 +369,12 @@ type Options = {
|
|
|
349
369
|
};
|
|
350
370
|
type ResolvedOptions = {
|
|
351
371
|
output: Output;
|
|
372
|
+
group: Options['group'];
|
|
352
373
|
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
353
374
|
baseURL?: string;
|
|
354
375
|
};
|
|
355
376
|
parser: Required<NonNullable<Options['parser']>>;
|
|
377
|
+
paramsCasing: Options['paramsCasing'];
|
|
356
378
|
paramsType: NonNullable<Options['paramsType']>;
|
|
357
379
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
358
380
|
queryKey: QueryKey | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-svelte-query",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Generator svelte-query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"faker",
|
|
@@ -63,21 +63,21 @@
|
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"remeda": "^2.17.4",
|
|
66
|
-
"@kubb/core": "3.0
|
|
67
|
-
"@kubb/fs": "3.0
|
|
68
|
-
"@kubb/oas": "3.0
|
|
69
|
-
"@kubb/plugin-oas": "3.0
|
|
70
|
-
"@kubb/plugin-ts": "3.0
|
|
71
|
-
"@kubb/plugin-zod": "3.0
|
|
72
|
-
"@kubb/react": "3.0
|
|
66
|
+
"@kubb/core": "3.2.0",
|
|
67
|
+
"@kubb/fs": "3.2.0",
|
|
68
|
+
"@kubb/oas": "3.2.0",
|
|
69
|
+
"@kubb/plugin-oas": "3.2.0",
|
|
70
|
+
"@kubb/plugin-ts": "3.2.0",
|
|
71
|
+
"@kubb/plugin-zod": "3.2.0",
|
|
72
|
+
"@kubb/react": "3.2.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@types/react": "^18.3.
|
|
75
|
+
"@types/react": "^18.3.16",
|
|
76
76
|
"react": "^18.3.1",
|
|
77
77
|
"tsup": "^8.3.5",
|
|
78
78
|
"typescript": "^5.7.2",
|
|
79
|
-
"@kubb/config-ts": "3.0
|
|
80
|
-
"@kubb/config-tsup": "3.0
|
|
79
|
+
"@kubb/config-ts": "3.2.0",
|
|
80
|
+
"@kubb/config-tsup": "3.2.0"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"@kubb/react": "^3.0.0"
|