@kubb/plugin-svelte-query 3.0.0-beta.11 → 3.0.0-beta.12
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-C3XFYLKR.cjs → chunk-CDRGJAED.cjs} +53 -47
- package/dist/chunk-CDRGJAED.cjs.map +1 -0
- package/dist/{chunk-PCNLFEZJ.js → chunk-JGITTOE5.js} +47 -41
- package/dist/chunk-JGITTOE5.js.map +1 -0
- package/dist/{chunk-HUR476BL.cjs → chunk-KRGCKSGR.cjs} +22 -10
- package/dist/chunk-KRGCKSGR.cjs.map +1 -0
- package/dist/{chunk-LSV2AJSI.js → chunk-R6ZVBNG7.js} +22 -10
- package/dist/chunk-R6ZVBNG7.js.map +1 -0
- package/dist/components.cjs +6 -6
- package/dist/components.d.cts +7 -5
- package/dist/components.d.ts +7 -5
- 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 +7 -5
- 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 +6 -4
- package/dist/index.js.map +1 -1
- package/dist/{types-Co8a9Sr5.d.ts → types-B9W9aYra.d.cts} +37 -19
- package/dist/{types-Co8a9Sr5.d.cts → types-B9W9aYra.d.ts} +37 -19
- package/package.json +11 -11
- package/src/components/MutationKey.tsx +11 -5
- package/src/components/QueryKey.tsx +17 -7
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +1 -1
- package/src/generators/__snapshots__/clientGetImportPath.ts +1 -1
- package/src/generators/__snapshots__/findByTags.ts +1 -1
- package/src/generators/__snapshots__/findByTagsObject.ts +1 -1
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +1 -1
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +2 -2
- package/src/generators/__snapshots__/findByTagsWithZod.ts +1 -1
- package/src/generators/__snapshots__/postAsQuery.ts +1 -1
- package/src/generators/mutationGenerator.tsx +23 -15
- package/src/generators/queryGenerator.tsx +22 -16
- package/src/plugin.ts +5 -2
- package/src/types.ts +23 -10
- package/dist/chunk-C3XFYLKR.cjs.map +0 -1
- package/dist/chunk-HUR476BL.cjs.map +0 -1
- package/dist/chunk-LSV2AJSI.js.map +0 -1
- package/dist/chunk-PCNLFEZJ.js.map +0 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","pascalCase","PluginManager","OperationGenerator"],"mappings":";;;;;;;;;;;;;;;
|
|
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,cAAcC,6BAAY,CAAA,cAAA;AAAA,IAC1B,WAAWC,0BAAS,CAAA,cAAA;AAAA,IACpB,aAAa,CAACC,gCAAA,EAAgBC,mCAAiB,CAAA,CAAE,OAAO,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AA,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 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 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 },\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 (options?.tag && group?.type === 'tag') {\n const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller`\n\n return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName)\n }\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 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 './chunk-
|
|
1
|
+
import { queryGenerator, mutationGenerator } from './chunk-JGITTOE5.js';
|
|
2
|
+
import { MutationKey, QueryKey } from './chunk-R6ZVBNG7.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,8 @@ var pluginSvelteQuery = createPlugin((options) => {
|
|
|
21
21
|
pathParamsType = "inline",
|
|
22
22
|
mutation = {},
|
|
23
23
|
query = {},
|
|
24
|
+
mutationKey = MutationKey.getTransformer,
|
|
25
|
+
queryKey = QueryKey.getTransformer,
|
|
24
26
|
generators = [queryGenerator, mutationGenerator].filter(Boolean)
|
|
25
27
|
} = options;
|
|
26
28
|
return {
|
|
@@ -33,14 +35,14 @@ var pluginSvelteQuery = createPlugin((options) => {
|
|
|
33
35
|
pathParamsType: "inline",
|
|
34
36
|
...options.client
|
|
35
37
|
},
|
|
38
|
+
queryKey,
|
|
36
39
|
query: {
|
|
37
|
-
key: (key) => key,
|
|
38
40
|
methods: ["get"],
|
|
39
41
|
importPath: "@tanstack/svelte-query",
|
|
40
42
|
...query
|
|
41
43
|
},
|
|
44
|
+
mutationKey,
|
|
42
45
|
mutation: {
|
|
43
|
-
key: (key) => key,
|
|
44
46
|
methods: ["post", "put", "patch", "delete"],
|
|
45
47
|
importPath: "@tanstack/svelte-query",
|
|
46
48
|
...mutation
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;
|
|
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,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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 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 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 },\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 (options?.tag && group?.type === 'tag') {\n const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller`\n\n return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName)\n }\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 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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
|
|
2
|
-
import { HttpMethod } from '@kubb/oas';
|
|
3
|
-
import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
|
|
2
|
+
import { HttpMethod, Operation } from '@kubb/oas';
|
|
3
|
+
import { ResolvePathOptions, Exclude, Include, Override, Generator, OperationSchemas } from '@kubb/plugin-oas';
|
|
4
4
|
|
|
5
5
|
type Options$2 = {
|
|
6
6
|
/**
|
|
@@ -90,12 +90,21 @@ type ResolvedOptions$2 = {
|
|
|
90
90
|
};
|
|
91
91
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$2, ResolvedOptions$2, never, ResolvePathOptions>;
|
|
92
92
|
|
|
93
|
+
type TransformerProps$1 = {
|
|
94
|
+
operation: Operation;
|
|
95
|
+
schemas: OperationSchemas;
|
|
96
|
+
};
|
|
97
|
+
type Transformer$1 = (props: TransformerProps$1) => unknown[];
|
|
93
98
|
type Suspense = object;
|
|
99
|
+
/**
|
|
100
|
+
* Customize the queryKey
|
|
101
|
+
*/
|
|
102
|
+
type QueryKey$1 = Transformer$1;
|
|
103
|
+
/**
|
|
104
|
+
* Customize the mutationKey
|
|
105
|
+
*/
|
|
106
|
+
type MutationKey$1 = Transformer$1;
|
|
94
107
|
type Query$1 = {
|
|
95
|
-
/**
|
|
96
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
97
|
-
*/
|
|
98
|
-
key: (key: unknown[]) => unknown[];
|
|
99
108
|
/**
|
|
100
109
|
* Define which HttpMethods can be used for queries
|
|
101
110
|
* @default ['get']
|
|
@@ -111,10 +120,6 @@ type Query$1 = {
|
|
|
111
120
|
importPath?: string;
|
|
112
121
|
};
|
|
113
122
|
type Mutation$1 = {
|
|
114
|
-
/**
|
|
115
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
116
|
-
*/
|
|
117
|
-
key: (key: unknown[]) => unknown[];
|
|
118
123
|
/**
|
|
119
124
|
* Define which HttpMethods can be used for mutations
|
|
120
125
|
* @default ['post', 'put', 'delete']
|
|
@@ -190,10 +195,12 @@ type Options$1 = {
|
|
|
190
195
|
* When set, a suspenseQuery hooks will be added.
|
|
191
196
|
*/
|
|
192
197
|
suspense?: Partial<Suspense> | false;
|
|
198
|
+
queryKey?: QueryKey$1;
|
|
193
199
|
/**
|
|
194
200
|
* Override some useQuery behaviours.
|
|
195
201
|
*/
|
|
196
202
|
query?: Partial<Query$1> | false;
|
|
203
|
+
mutationKey?: MutationKey$1;
|
|
197
204
|
/**
|
|
198
205
|
* Override some useMutation behaviours.
|
|
199
206
|
*/
|
|
@@ -227,16 +234,27 @@ type ResolvedOptions$1 = {
|
|
|
227
234
|
*/
|
|
228
235
|
infinite: NonNullable<Infinite> | false;
|
|
229
236
|
suspense: Suspense | false;
|
|
237
|
+
queryKey: QueryKey$1 | undefined;
|
|
230
238
|
query: NonNullable<Required<Query$1>> | false;
|
|
239
|
+
mutationKey: MutationKey$1 | undefined;
|
|
231
240
|
mutation: NonNullable<Required<Mutation$1>> | false;
|
|
232
241
|
};
|
|
233
242
|
type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
|
|
234
243
|
|
|
244
|
+
type TransformerProps = {
|
|
245
|
+
operation: Operation;
|
|
246
|
+
schemas: OperationSchemas;
|
|
247
|
+
};
|
|
248
|
+
type Transformer = (props: TransformerProps) => unknown[];
|
|
249
|
+
/**
|
|
250
|
+
* Customize the queryKey
|
|
251
|
+
*/
|
|
252
|
+
type QueryKey = Transformer;
|
|
253
|
+
/**
|
|
254
|
+
* Customize the mutationKey
|
|
255
|
+
*/
|
|
256
|
+
type MutationKey = Transformer;
|
|
235
257
|
type Query = {
|
|
236
|
-
/**
|
|
237
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
238
|
-
*/
|
|
239
|
-
key: (key: unknown[]) => unknown[];
|
|
240
258
|
/**
|
|
241
259
|
* Define which HttpMethods can be used for queries
|
|
242
260
|
* @default ['get']
|
|
@@ -252,10 +270,6 @@ type Query = {
|
|
|
252
270
|
importPath?: string;
|
|
253
271
|
};
|
|
254
272
|
type Mutation = {
|
|
255
|
-
/**
|
|
256
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
257
|
-
*/
|
|
258
|
-
key: (key: unknown[]) => unknown[];
|
|
259
273
|
/**
|
|
260
274
|
* Define which HttpMethods can be used for mutations
|
|
261
275
|
* @default ['post', 'put', 'delete']
|
|
@@ -307,10 +321,12 @@ type Options = {
|
|
|
307
321
|
* @default 'inline'
|
|
308
322
|
*/
|
|
309
323
|
pathParamsType?: PluginClient['options']['pathParamsType'];
|
|
324
|
+
queryKey?: QueryKey;
|
|
310
325
|
/**
|
|
311
326
|
* Override some useQuery behaviours.
|
|
312
327
|
*/
|
|
313
328
|
query?: Partial<Query> | false;
|
|
329
|
+
mutationKey?: MutationKey;
|
|
314
330
|
/**
|
|
315
331
|
* Override some useMutation behaviours.
|
|
316
332
|
*/
|
|
@@ -339,9 +355,11 @@ type ResolvedOptions = {
|
|
|
339
355
|
parser: Required<NonNullable<Options['parser']>>;
|
|
340
356
|
paramsType: NonNullable<Options['paramsType']>;
|
|
341
357
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
358
|
+
queryKey: QueryKey | undefined;
|
|
342
359
|
query: NonNullable<Required<Query>> | false;
|
|
360
|
+
mutationKey: MutationKey | undefined;
|
|
343
361
|
mutation: NonNullable<Required<Mutation>> | false;
|
|
344
362
|
};
|
|
345
363
|
type PluginSvelteQuery = PluginFactoryOptions<'plugin-svelte-query', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
346
364
|
|
|
347
|
-
export type { Options as O, PluginSvelteQuery as P };
|
|
365
|
+
export type { Options as O, PluginSvelteQuery as P, Transformer as T };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
|
|
2
|
-
import { HttpMethod } from '@kubb/oas';
|
|
3
|
-
import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
|
|
2
|
+
import { HttpMethod, Operation } from '@kubb/oas';
|
|
3
|
+
import { ResolvePathOptions, Exclude, Include, Override, Generator, OperationSchemas } from '@kubb/plugin-oas';
|
|
4
4
|
|
|
5
5
|
type Options$2 = {
|
|
6
6
|
/**
|
|
@@ -90,12 +90,21 @@ type ResolvedOptions$2 = {
|
|
|
90
90
|
};
|
|
91
91
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$2, ResolvedOptions$2, never, ResolvePathOptions>;
|
|
92
92
|
|
|
93
|
+
type TransformerProps$1 = {
|
|
94
|
+
operation: Operation;
|
|
95
|
+
schemas: OperationSchemas;
|
|
96
|
+
};
|
|
97
|
+
type Transformer$1 = (props: TransformerProps$1) => unknown[];
|
|
93
98
|
type Suspense = object;
|
|
99
|
+
/**
|
|
100
|
+
* Customize the queryKey
|
|
101
|
+
*/
|
|
102
|
+
type QueryKey$1 = Transformer$1;
|
|
103
|
+
/**
|
|
104
|
+
* Customize the mutationKey
|
|
105
|
+
*/
|
|
106
|
+
type MutationKey$1 = Transformer$1;
|
|
94
107
|
type Query$1 = {
|
|
95
|
-
/**
|
|
96
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
97
|
-
*/
|
|
98
|
-
key: (key: unknown[]) => unknown[];
|
|
99
108
|
/**
|
|
100
109
|
* Define which HttpMethods can be used for queries
|
|
101
110
|
* @default ['get']
|
|
@@ -111,10 +120,6 @@ type Query$1 = {
|
|
|
111
120
|
importPath?: string;
|
|
112
121
|
};
|
|
113
122
|
type Mutation$1 = {
|
|
114
|
-
/**
|
|
115
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
116
|
-
*/
|
|
117
|
-
key: (key: unknown[]) => unknown[];
|
|
118
123
|
/**
|
|
119
124
|
* Define which HttpMethods can be used for mutations
|
|
120
125
|
* @default ['post', 'put', 'delete']
|
|
@@ -190,10 +195,12 @@ type Options$1 = {
|
|
|
190
195
|
* When set, a suspenseQuery hooks will be added.
|
|
191
196
|
*/
|
|
192
197
|
suspense?: Partial<Suspense> | false;
|
|
198
|
+
queryKey?: QueryKey$1;
|
|
193
199
|
/**
|
|
194
200
|
* Override some useQuery behaviours.
|
|
195
201
|
*/
|
|
196
202
|
query?: Partial<Query$1> | false;
|
|
203
|
+
mutationKey?: MutationKey$1;
|
|
197
204
|
/**
|
|
198
205
|
* Override some useMutation behaviours.
|
|
199
206
|
*/
|
|
@@ -227,16 +234,27 @@ type ResolvedOptions$1 = {
|
|
|
227
234
|
*/
|
|
228
235
|
infinite: NonNullable<Infinite> | false;
|
|
229
236
|
suspense: Suspense | false;
|
|
237
|
+
queryKey: QueryKey$1 | undefined;
|
|
230
238
|
query: NonNullable<Required<Query$1>> | false;
|
|
239
|
+
mutationKey: MutationKey$1 | undefined;
|
|
231
240
|
mutation: NonNullable<Required<Mutation$1>> | false;
|
|
232
241
|
};
|
|
233
242
|
type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
|
|
234
243
|
|
|
244
|
+
type TransformerProps = {
|
|
245
|
+
operation: Operation;
|
|
246
|
+
schemas: OperationSchemas;
|
|
247
|
+
};
|
|
248
|
+
type Transformer = (props: TransformerProps) => unknown[];
|
|
249
|
+
/**
|
|
250
|
+
* Customize the queryKey
|
|
251
|
+
*/
|
|
252
|
+
type QueryKey = Transformer;
|
|
253
|
+
/**
|
|
254
|
+
* Customize the mutationKey
|
|
255
|
+
*/
|
|
256
|
+
type MutationKey = Transformer;
|
|
235
257
|
type Query = {
|
|
236
|
-
/**
|
|
237
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
238
|
-
*/
|
|
239
|
-
key: (key: unknown[]) => unknown[];
|
|
240
258
|
/**
|
|
241
259
|
* Define which HttpMethods can be used for queries
|
|
242
260
|
* @default ['get']
|
|
@@ -252,10 +270,6 @@ type Query = {
|
|
|
252
270
|
importPath?: string;
|
|
253
271
|
};
|
|
254
272
|
type Mutation = {
|
|
255
|
-
/**
|
|
256
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
257
|
-
*/
|
|
258
|
-
key: (key: unknown[]) => unknown[];
|
|
259
273
|
/**
|
|
260
274
|
* Define which HttpMethods can be used for mutations
|
|
261
275
|
* @default ['post', 'put', 'delete']
|
|
@@ -307,10 +321,12 @@ type Options = {
|
|
|
307
321
|
* @default 'inline'
|
|
308
322
|
*/
|
|
309
323
|
pathParamsType?: PluginClient['options']['pathParamsType'];
|
|
324
|
+
queryKey?: QueryKey;
|
|
310
325
|
/**
|
|
311
326
|
* Override some useQuery behaviours.
|
|
312
327
|
*/
|
|
313
328
|
query?: Partial<Query> | false;
|
|
329
|
+
mutationKey?: MutationKey;
|
|
314
330
|
/**
|
|
315
331
|
* Override some useMutation behaviours.
|
|
316
332
|
*/
|
|
@@ -339,9 +355,11 @@ type ResolvedOptions = {
|
|
|
339
355
|
parser: Required<NonNullable<Options['parser']>>;
|
|
340
356
|
paramsType: NonNullable<Options['paramsType']>;
|
|
341
357
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
358
|
+
queryKey: QueryKey | undefined;
|
|
342
359
|
query: NonNullable<Required<Query>> | false;
|
|
360
|
+
mutationKey: MutationKey | undefined;
|
|
343
361
|
mutation: NonNullable<Required<Mutation>> | false;
|
|
344
362
|
};
|
|
345
363
|
type PluginSvelteQuery = PluginFactoryOptions<'plugin-svelte-query', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
346
364
|
|
|
347
|
-
export type { Options as O, PluginSvelteQuery as P };
|
|
365
|
+
export type { Options as O, PluginSvelteQuery as P, Transformer as T };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-svelte-query",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.12",
|
|
4
4
|
"description": "Generator svelte-query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"faker",
|
|
@@ -62,24 +62,24 @@
|
|
|
62
62
|
"!/**/__tests__/**"
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@kubb/core": "3.0.0-beta.
|
|
66
|
-
"@kubb/fs": "3.0.0-beta.
|
|
67
|
-
"@kubb/oas": "3.0.0-beta.
|
|
68
|
-
"@kubb/plugin-oas": "3.0.0-beta.
|
|
69
|
-
"@kubb/plugin-ts": "3.0.0-beta.
|
|
70
|
-
"@kubb/plugin-zod": "3.0.0-beta.
|
|
71
|
-
"@kubb/react": "3.0.0-beta.
|
|
65
|
+
"@kubb/core": "3.0.0-beta.12",
|
|
66
|
+
"@kubb/fs": "3.0.0-beta.12",
|
|
67
|
+
"@kubb/oas": "3.0.0-beta.12",
|
|
68
|
+
"@kubb/plugin-oas": "3.0.0-beta.12",
|
|
69
|
+
"@kubb/plugin-ts": "3.0.0-beta.12",
|
|
70
|
+
"@kubb/plugin-zod": "3.0.0-beta.12",
|
|
71
|
+
"@kubb/react": "3.0.0-beta.12"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/react": "^18.3.12",
|
|
75
75
|
"react": "^18.3.1",
|
|
76
76
|
"tsup": "^8.3.5",
|
|
77
77
|
"typescript": "^5.6.3",
|
|
78
|
-
"@kubb/config-ts": "3.0.0-beta.
|
|
79
|
-
"@kubb/config-tsup": "3.0.0-beta.
|
|
78
|
+
"@kubb/config-ts": "3.0.0-beta.12",
|
|
79
|
+
"@kubb/config-tsup": "3.0.0-beta.12"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
|
-
"@kubb/react": "3.0.0-beta.
|
|
82
|
+
"@kubb/react": "3.0.0-beta.12"
|
|
83
83
|
},
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": ">=20"
|
|
@@ -4,7 +4,7 @@ import { File, Function, FunctionParams, Type } from '@kubb/react'
|
|
|
4
4
|
import type { Operation } from '@kubb/oas'
|
|
5
5
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
6
6
|
import type { ReactNode } from 'react'
|
|
7
|
-
import type { PluginSvelteQuery } from '../types'
|
|
7
|
+
import type { PluginSvelteQuery, Transformer } from '../types'
|
|
8
8
|
|
|
9
9
|
type Props = {
|
|
10
10
|
name: string
|
|
@@ -12,7 +12,7 @@ type Props = {
|
|
|
12
12
|
typeSchemas: OperationSchemas
|
|
13
13
|
operation: Operation
|
|
14
14
|
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
|
|
15
|
-
|
|
15
|
+
transformer: Transformer | undefined
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
type GetParamsProps = {
|
|
@@ -24,16 +24,21 @@ function getParams({}: GetParamsProps) {
|
|
|
24
24
|
return FunctionParams.factory({})
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const getTransformer: Transformer = ({ operation }) => {
|
|
28
28
|
const path = new URLPath(operation.path)
|
|
29
|
+
|
|
30
|
+
return [JSON.stringify({ url: path.path })].filter(Boolean)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
|
|
29
34
|
const params = getParams({ pathParamsType, typeSchemas })
|
|
30
|
-
const keys =
|
|
35
|
+
const keys = transformer({ operation, schemas: typeSchemas })
|
|
31
36
|
|
|
32
37
|
return (
|
|
33
38
|
<>
|
|
34
39
|
<File.Source name={name} isExportable isIndexable>
|
|
35
40
|
<Function.Arrow name={name} export params={params.toConstructor()} singleLine>
|
|
36
|
-
{`[${
|
|
41
|
+
{`[${keys.join(', ')}] as const`}
|
|
37
42
|
</Function.Arrow>
|
|
38
43
|
</File.Source>
|
|
39
44
|
<File.Source name={typeName} isExportable isIndexable isTypeOnly>
|
|
@@ -46,3 +51,4 @@ export function MutationKey({ name, typeSchemas, pathParamsType, operation, type
|
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
MutationKey.getParams = getParams
|
|
54
|
+
MutationKey.getTransformer = getTransformer
|
|
@@ -5,7 +5,7 @@ import { File, Function, FunctionParams, Type } from '@kubb/react'
|
|
|
5
5
|
import { type Operation, isOptional } from '@kubb/oas'
|
|
6
6
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
7
7
|
import type { ReactNode } from 'react'
|
|
8
|
-
import type { PluginSvelteQuery } from '../types'
|
|
8
|
+
import type { PluginSvelteQuery, Transformer } from '../types'
|
|
9
9
|
|
|
10
10
|
type Props = {
|
|
11
11
|
name: string
|
|
@@ -13,7 +13,7 @@ type Props = {
|
|
|
13
13
|
typeSchemas: OperationSchemas
|
|
14
14
|
operation: Operation
|
|
15
15
|
pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
|
|
16
|
-
|
|
16
|
+
transformer: Transformer | undefined
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
type GetParamsProps = {
|
|
@@ -42,23 +42,32 @@ function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
|
|
|
42
42
|
})
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
const getTransformer: Transformer = ({ operation, schemas }) => {
|
|
46
46
|
const path = new URLPath(operation.path)
|
|
47
|
-
const params = getParams({ pathParamsType, typeSchemas })
|
|
48
47
|
const keys = [
|
|
49
48
|
path.toObject({
|
|
50
49
|
type: 'path',
|
|
51
50
|
stringify: true,
|
|
52
51
|
}),
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,
|
|
53
|
+
schemas.request?.name ? '...(data ? [data] : [])' : undefined,
|
|
55
54
|
].filter(Boolean)
|
|
56
55
|
|
|
56
|
+
return keys
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
|
|
60
|
+
const params = getParams({ pathParamsType, typeSchemas })
|
|
61
|
+
const keys = transformer({
|
|
62
|
+
operation,
|
|
63
|
+
schemas: typeSchemas,
|
|
64
|
+
})
|
|
65
|
+
|
|
57
66
|
return (
|
|
58
67
|
<>
|
|
59
68
|
<File.Source name={name} isExportable isIndexable>
|
|
60
69
|
<Function.Arrow name={name} export params={params.toConstructor()} singleLine>
|
|
61
|
-
{`[${
|
|
70
|
+
{`[${keys.join(', ')}] as const`}
|
|
62
71
|
</Function.Arrow>
|
|
63
72
|
</File.Source>
|
|
64
73
|
<File.Source name={typeName} isExportable isIndexable isTypeOnly>
|
|
@@ -71,3 +80,4 @@ export function QueryKey({ name, typeSchemas, pathParamsType, operation, typeNam
|
|
|
71
80
|
}
|
|
72
81
|
|
|
73
82
|
QueryKey.getParams = getParams
|
|
83
|
+
QueryKey.getTransformer = getTransformer
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig, ResponseConfig } from "@kubb/plugin-client/client";
|
|
3
3
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
|
|
4
|
-
import {
|
|
4
|
+
import { queryOptions, createQuery } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
6
6
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import client from "axios";
|
|
2
2
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
|
|
3
3
|
import type { RequestConfig } from "axios";
|
|
4
|
-
import {
|
|
4
|
+
import { queryOptions, createQuery } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
6
6
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
3
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
|
|
4
|
-
import {
|
|
4
|
+
import { queryOptions, createQuery } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
6
6
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
3
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
|
|
4
|
-
import {
|
|
4
|
+
import { queryOptions, createQuery } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
6
6
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
3
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
|
|
4
|
-
import {
|
|
4
|
+
import { queryOptions, createQuery } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
6
6
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
7
7
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
3
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/react-query";
|
|
4
|
-
import {
|
|
4
|
+
import { queryOptions, createQuery } from "@tanstack/react-query";
|
|
5
5
|
|
|
6
|
-
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [test, { url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
6
|
+
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => ["test", { url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
7
7
|
|
|
8
8
|
export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
|
|
9
9
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
3
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
|
|
4
|
-
import {
|
|
4
|
+
import { queryOptions, createQuery } from "@tanstack/svelte-query";
|
|
5
5
|
|
|
6
6
|
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
3
|
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "custom-query";
|
|
4
|
-
import {
|
|
4
|
+
import { queryOptions, createQuery } from "custom-query";
|
|
5
5
|
|
|
6
6
|
export const updatePetWithFormQueryKey = (petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams) => [{ url: "/pet/:petId", params: { petId: petId } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const;
|
|
7
7
|
|