@kubb/plugin-svelte-query 3.0.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +123 -0
  3. package/dist/chunk-QPJYCH77.js +376 -0
  4. package/dist/chunk-QPJYCH77.js.map +1 -0
  5. package/dist/chunk-RE36BJQW.cjs +384 -0
  6. package/dist/chunk-RE36BJQW.cjs.map +1 -0
  7. package/dist/chunk-TD7H4OF4.cjs +376 -0
  8. package/dist/chunk-TD7H4OF4.cjs.map +1 -0
  9. package/dist/chunk-V5DEG2OQ.js +369 -0
  10. package/dist/chunk-V5DEG2OQ.js.map +1 -0
  11. package/dist/components.cjs +24 -0
  12. package/dist/components.cjs.map +1 -0
  13. package/dist/components.d.cts +78 -0
  14. package/dist/components.d.ts +78 -0
  15. package/dist/components.js +3 -0
  16. package/dist/components.js.map +1 -0
  17. package/dist/generators.cjs +17 -0
  18. package/dist/generators.cjs.map +1 -0
  19. package/dist/generators.d.cts +10 -0
  20. package/dist/generators.d.ts +10 -0
  21. package/dist/generators.js +4 -0
  22. package/dist/generators.js.map +1 -0
  23. package/dist/index.cjs +131 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +9 -0
  26. package/dist/index.d.ts +9 -0
  27. package/dist/index.js +124 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/types-64YHTP7S.d.cts +148 -0
  30. package/dist/types-64YHTP7S.d.ts +148 -0
  31. package/package.json +102 -0
  32. package/src/components/Mutation.tsx +133 -0
  33. package/src/components/Query.tsx +120 -0
  34. package/src/components/QueryKey.tsx +73 -0
  35. package/src/components/QueryOptions.tsx +84 -0
  36. package/src/components/index.ts +4 -0
  37. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +50 -0
  38. package/src/generators/__snapshots__/clientGetImportPath.ts +50 -0
  39. package/src/generators/__snapshots__/clientPostImportPath.ts +38 -0
  40. package/src/generators/__snapshots__/findByTags.ts +50 -0
  41. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +50 -0
  42. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +50 -0
  43. package/src/generators/__snapshots__/findByTagsWithZod.ts +50 -0
  44. package/src/generators/__snapshots__/postAsQuery.ts +48 -0
  45. package/src/generators/__snapshots__/updatePetById.ts +38 -0
  46. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +40 -0
  47. package/src/generators/index.ts +2 -0
  48. package/src/generators/mutationGenerator.tsx +96 -0
  49. package/src/generators/queryGenerator.tsx +122 -0
  50. package/src/index.ts +2 -0
  51. package/src/plugin.ts +143 -0
  52. package/src/types.ts +153 -0
@@ -0,0 +1,10 @@
1
+ import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
+ import { P as PluginSvelteQuery } from './types-64YHTP7S.cjs';
3
+ import '@kubb/core';
4
+ import '@kubb/oas';
5
+
6
+ declare const queryGenerator: _kubb_plugin_oas.Generator<PluginSvelteQuery>;
7
+
8
+ declare const mutationGenerator: _kubb_plugin_oas.Generator<PluginSvelteQuery>;
9
+
10
+ export { mutationGenerator, queryGenerator };
@@ -0,0 +1,10 @@
1
+ import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
+ import { P as PluginSvelteQuery } from './types-64YHTP7S.js';
3
+ import '@kubb/core';
4
+ import '@kubb/oas';
5
+
6
+ declare const queryGenerator: _kubb_plugin_oas.Generator<PluginSvelteQuery>;
7
+
8
+ declare const mutationGenerator: _kubb_plugin_oas.Generator<PluginSvelteQuery>;
9
+
10
+ export { mutationGenerator, queryGenerator };
@@ -0,0 +1,4 @@
1
+ export { mutationGenerator, queryGenerator } from './chunk-QPJYCH77.js';
2
+ import './chunk-V5DEG2OQ.js';
3
+ //# sourceMappingURL=generators.js.map
4
+ //# sourceMappingURL=generators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.js"}
package/dist/index.cjs ADDED
@@ -0,0 +1,131 @@
1
+ 'use strict';
2
+
3
+ var chunkRE36BJQW_cjs = require('./chunk-RE36BJQW.cjs');
4
+ require('./chunk-TD7H4OF4.cjs');
5
+ var path = require('path');
6
+ var core = require('@kubb/core');
7
+ var transformers = require('@kubb/core/transformers');
8
+ var utils = require('@kubb/core/utils');
9
+ var pluginOas = require('@kubb/plugin-oas');
10
+ var pluginTs = require('@kubb/plugin-ts');
11
+ var pluginZod = require('@kubb/plugin-zod');
12
+
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
+
15
+ var path__default = /*#__PURE__*/_interopDefault(path);
16
+
17
+ var pluginSvelteQueryName = "plugin-svelte-query";
18
+ var pluginSvelteQuery = core.createPlugin((options) => {
19
+ const {
20
+ output = { path: "hooks" },
21
+ group,
22
+ exclude = [],
23
+ include,
24
+ override = [],
25
+ parser = "client",
26
+ transformers: transformers$1 = {},
27
+ pathParamsType = "inline",
28
+ mutation = {},
29
+ query = {}
30
+ } = options;
31
+ const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
32
+ return {
33
+ name: pluginSvelteQueryName,
34
+ options: {
35
+ output: {
36
+ exportType: "barrelNamed",
37
+ ...output
38
+ },
39
+ baseURL: void 0,
40
+ client: {
41
+ importPath: "@kubb/plugin-client/client",
42
+ dataReturnType: "data",
43
+ pathParamsType: "inline",
44
+ ...options.client
45
+ },
46
+ query: {
47
+ key: (key) => key,
48
+ methods: ["get"],
49
+ importPath: "@tanstack/svelte-query",
50
+ ...query
51
+ },
52
+ mutation: {
53
+ methods: ["post", "put", "patch", "delete"],
54
+ importPath: "@tanstack/svelte-query",
55
+ ...mutation
56
+ },
57
+ pathParamsType,
58
+ parser
59
+ },
60
+ pre: [pluginOas.pluginOasName, pluginTs.pluginTsName, parser === "zod" ? pluginZod.pluginZodName : void 0].filter(Boolean),
61
+ resolvePath(baseName, pathMode, options2) {
62
+ const root = path__default.default.resolve(this.config.root, this.config.output.path);
63
+ const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
64
+ if (mode === "single") {
65
+ return path__default.default.resolve(root, output.path);
66
+ }
67
+ if (options2?.tag && group?.type === "tag") {
68
+ const tag = transformers.camelCase(options2.tag);
69
+ return path__default.default.resolve(root, utils.renderTemplate(template, { tag }), baseName);
70
+ }
71
+ return path__default.default.resolve(root, output.path, baseName);
72
+ },
73
+ resolveName(name, type) {
74
+ let resolvedName = transformers.camelCase(name);
75
+ if (type === "file" || type === "function") {
76
+ resolvedName = transformers.camelCase(name, {
77
+ isFile: type === "file"
78
+ });
79
+ }
80
+ if (type === "type") {
81
+ resolvedName = transformers.pascalCase(name);
82
+ }
83
+ if (type) {
84
+ return transformers$1?.name?.(resolvedName, type) || resolvedName;
85
+ }
86
+ return resolvedName;
87
+ },
88
+ async buildStart() {
89
+ const [swaggerPlugin] = core.PluginManager.getDependedPlugins(this.plugins, [pluginOas.pluginOasName]);
90
+ const oas = await swaggerPlugin.context.getOas();
91
+ const root = path__default.default.resolve(this.config.root, this.config.output.path);
92
+ const mode = core.FileManager.getMode(path__default.default.resolve(root, output.path));
93
+ const baseURL = await swaggerPlugin.context.getBaseURL();
94
+ const operationGenerator = new pluginOas.OperationGenerator(
95
+ {
96
+ ...this.plugin.options,
97
+ baseURL
98
+ },
99
+ {
100
+ oas,
101
+ pluginManager: this.pluginManager,
102
+ plugin: this.plugin,
103
+ contentType: swaggerPlugin.context.contentType,
104
+ exclude,
105
+ include,
106
+ override,
107
+ mode
108
+ }
109
+ );
110
+ const files = await operationGenerator.build(chunkRE36BJQW_cjs.queryGenerator, chunkRE36BJQW_cjs.mutationGenerator);
111
+ await this.addFile(...files);
112
+ if (this.config.output.exportType) {
113
+ const barrelFiles = await this.fileManager.getBarrelFiles({
114
+ root,
115
+ output,
116
+ files: this.fileManager.files,
117
+ meta: {
118
+ pluginKey: this.plugin.key
119
+ },
120
+ logger: this.logger
121
+ });
122
+ await this.addFile(...barrelFiles);
123
+ }
124
+ }
125
+ };
126
+ });
127
+
128
+ exports.pluginSvelteQuery = pluginSvelteQuery;
129
+ exports.pluginSvelteQueryName = pluginSvelteQueryName;
130
+ //# sourceMappingURL=index.cjs.map
131
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","renderTemplate","pascalCase","PluginManager","OperationGenerator","queryGenerator","mutationGenerator"],"mappings":";;;;;;;;;;;;;;;;AAeO,IAAM,qBAAwB,GAAA,sBAAA;AAExB,IAAA,iBAAA,GAAoBA,iBAAgC,CAAA,CAAC,OAAY,KAAA;AAC5E,EAAM,MAAA;AAAA,IACJ,MAAA,GAAS,EAAE,IAAA,EAAM,OAAQ,EAAA;AAAA,IACzB,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,kBACTC,iBAAe,EAAC;AAAA,IAChB,cAAiB,GAAA,QAAA;AAAA,IACjB,WAAW,EAAC;AAAA,IACZ,QAAQ,EAAC;AAAA,GACP,GAAA,OAAA,CAAA;AACJ,EAAA,MAAM,WAAW,KAAO,EAAA,MAAA,GAAS,MAAM,MAAS,GAAA,CAAA,EAAG,OAAO,IAAI,CAAA,kBAAA,CAAA,CAAA;AAE9D,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,qBAAA;AAAA,IACN,OAAS,EAAA;AAAA,MACP,MAAQ,EAAA;AAAA,QACN,UAAY,EAAA,aAAA;AAAA,QACZ,GAAG,MAAA;AAAA,OACL;AAAA,MACA,OAAS,EAAA,KAAA,CAAA;AAAA,MACT,MAAQ,EAAA;AAAA,QACN,UAAY,EAAA,4BAAA;AAAA,QACZ,cAAgB,EAAA,MAAA;AAAA,QAChB,cAAgB,EAAA,QAAA;AAAA,QAChB,GAAG,OAAQ,CAAA,MAAA;AAAA,OACb;AAAA,MACA,KAAO,EAAA;A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AAQ,UAAW,EAAA,CAAA;AAEvD,MAAA,MAAM,qBAAqB,IAAIM,4BAAA;AAAA,QAC7B;AAAA,UACE,GAAG,KAAK,MAAO,CAAA,OAAA;AAAA,UACf,OAAA;AAAA,SACF;AAAA,QACA;AAAA,UACE,GAAA;AAAA,UACA,eAAe,IAAK,CAAA,aAAA;AAAA,UACpB,QAAQ,IAAK,CAAA,MAAA;AAAA,UACb,WAAA,EAAa,cAAc,OAAQ,CAAA,WAAA;AAAA,UACnC,OAAA;AAAA,UACA,OAAA;AAAA,UACA,QAAA;AAAA,UACA,IAAA;AAAA,SACF;AAAA,OACF,CAAA;AAEA,MAAA,MAAM,KAAQ,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAMC,kCAAgBC,mCAAiB,CAAA,CAAA;AAC9E,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,KAAK,CAAA,CAAA;AAE3B,MAAI,IAAA,IAAA,CAAK,MAAO,CAAA,MAAA,CAAO,UAAY,EAAA;AACjC,QAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,UACxD,IAAA;AAAA,UACA,MAAA;AAAA,UACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,UACxB,IAAM,EAAA;AAAA,YACJ,SAAA,EAAW,KAAK,MAAO,CAAA,GAAA;AAAA,WACzB;AAAA,UACA,QAAQ,IAAK,CAAA,MAAA;AAAA,SACd,CAAA,CAAA;AAED,QAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA,CAAA;AAAA,OACnC;AAAA,KACF;AAAA,GACF,CAAA;AACF,CAAC","file":"index.cjs","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\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 { 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' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n pathParamsType = 'inline',\n mutation = {},\n query = {},\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginSvelteQueryName,\n options: {\n output: {\n exportType: 'barrelNamed',\n ...output,\n },\n baseURL: undefined,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n pathParamsType: 'inline',\n ...options.client,\n },\n query: {\n key: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/svelte-query',\n ...query,\n },\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/svelte-query',\n ...mutation,\n },\n 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 (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?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), 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 const operationGenerator = new OperationGenerator(\n {\n ...this.plugin.options,\n baseURL,\n },\n {\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\n const files = await operationGenerator.build(queryGenerator, mutationGenerator)\n await this.addFile(...files)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\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})\n"]}
@@ -0,0 +1,9 @@
1
+ import * as _kubb_core from '@kubb/core';
2
+ import { O as Options, P as PluginSvelteQuery } from './types-64YHTP7S.cjs';
3
+ import '@kubb/oas';
4
+ import '@kubb/plugin-oas';
5
+
6
+ declare const pluginSvelteQueryName = "plugin-svelte-query";
7
+ declare const pluginSvelteQuery: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginSvelteQuery>;
8
+
9
+ export { PluginSvelteQuery, pluginSvelteQuery, pluginSvelteQueryName };
@@ -0,0 +1,9 @@
1
+ import * as _kubb_core from '@kubb/core';
2
+ import { O as Options, P as PluginSvelteQuery } from './types-64YHTP7S.js';
3
+ import '@kubb/oas';
4
+ import '@kubb/plugin-oas';
5
+
6
+ declare const pluginSvelteQueryName = "plugin-svelte-query";
7
+ declare const pluginSvelteQuery: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginSvelteQuery>;
8
+
9
+ export { PluginSvelteQuery, pluginSvelteQuery, pluginSvelteQueryName };
package/dist/index.js ADDED
@@ -0,0 +1,124 @@
1
+ import { queryGenerator, mutationGenerator } from './chunk-QPJYCH77.js';
2
+ import './chunk-V5DEG2OQ.js';
3
+ import path from 'node:path';
4
+ import { createPlugin, FileManager, PluginManager } from '@kubb/core';
5
+ import { camelCase, pascalCase } from '@kubb/core/transformers';
6
+ import { renderTemplate } from '@kubb/core/utils';
7
+ import { pluginOasName, OperationGenerator } from '@kubb/plugin-oas';
8
+ import { pluginTsName } from '@kubb/plugin-ts';
9
+ import { pluginZodName } from '@kubb/plugin-zod';
10
+
11
+ var pluginSvelteQueryName = "plugin-svelte-query";
12
+ var pluginSvelteQuery = createPlugin((options) => {
13
+ const {
14
+ output = { path: "hooks" },
15
+ group,
16
+ exclude = [],
17
+ include,
18
+ override = [],
19
+ parser = "client",
20
+ transformers = {},
21
+ pathParamsType = "inline",
22
+ mutation = {},
23
+ query = {}
24
+ } = options;
25
+ const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
26
+ return {
27
+ name: pluginSvelteQueryName,
28
+ options: {
29
+ output: {
30
+ exportType: "barrelNamed",
31
+ ...output
32
+ },
33
+ baseURL: void 0,
34
+ client: {
35
+ importPath: "@kubb/plugin-client/client",
36
+ dataReturnType: "data",
37
+ pathParamsType: "inline",
38
+ ...options.client
39
+ },
40
+ query: {
41
+ key: (key) => key,
42
+ methods: ["get"],
43
+ importPath: "@tanstack/svelte-query",
44
+ ...query
45
+ },
46
+ mutation: {
47
+ methods: ["post", "put", "patch", "delete"],
48
+ importPath: "@tanstack/svelte-query",
49
+ ...mutation
50
+ },
51
+ pathParamsType,
52
+ parser
53
+ },
54
+ pre: [pluginOasName, pluginTsName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
55
+ resolvePath(baseName, pathMode, options2) {
56
+ const root = path.resolve(this.config.root, this.config.output.path);
57
+ const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
58
+ if (mode === "single") {
59
+ return path.resolve(root, output.path);
60
+ }
61
+ if (options2?.tag && group?.type === "tag") {
62
+ const tag = camelCase(options2.tag);
63
+ return path.resolve(root, renderTemplate(template, { tag }), baseName);
64
+ }
65
+ return path.resolve(root, output.path, baseName);
66
+ },
67
+ resolveName(name, type) {
68
+ let resolvedName = camelCase(name);
69
+ if (type === "file" || type === "function") {
70
+ resolvedName = camelCase(name, {
71
+ isFile: type === "file"
72
+ });
73
+ }
74
+ if (type === "type") {
75
+ resolvedName = pascalCase(name);
76
+ }
77
+ if (type) {
78
+ return transformers?.name?.(resolvedName, type) || resolvedName;
79
+ }
80
+ return resolvedName;
81
+ },
82
+ async buildStart() {
83
+ const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
84
+ const oas = await swaggerPlugin.context.getOas();
85
+ const root = path.resolve(this.config.root, this.config.output.path);
86
+ const mode = FileManager.getMode(path.resolve(root, output.path));
87
+ const baseURL = await swaggerPlugin.context.getBaseURL();
88
+ const operationGenerator = new OperationGenerator(
89
+ {
90
+ ...this.plugin.options,
91
+ baseURL
92
+ },
93
+ {
94
+ oas,
95
+ pluginManager: this.pluginManager,
96
+ plugin: this.plugin,
97
+ contentType: swaggerPlugin.context.contentType,
98
+ exclude,
99
+ include,
100
+ override,
101
+ mode
102
+ }
103
+ );
104
+ const files = await operationGenerator.build(queryGenerator, mutationGenerator);
105
+ await this.addFile(...files);
106
+ if (this.config.output.exportType) {
107
+ const barrelFiles = await this.fileManager.getBarrelFiles({
108
+ root,
109
+ output,
110
+ files: this.fileManager.files,
111
+ meta: {
112
+ pluginKey: this.plugin.key
113
+ },
114
+ logger: this.logger
115
+ });
116
+ await this.addFile(...barrelFiles);
117
+ }
118
+ }
119
+ };
120
+ });
121
+
122
+ export { pluginSvelteQuery, pluginSvelteQueryName };
123
+ //# sourceMappingURL=index.js.map
124
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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ACA,OAAA;AAAA,UACA,QAAA;AAAA,UACA,IAAA;AAAA,SACF;AAAA,OACF,CAAA;AAEA,MAAA,MAAM,KAAQ,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAM,gBAAgB,iBAAiB,CAAA,CAAA;AAC9E,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,KAAK,CAAA,CAAA;AAE3B,MAAI,IAAA,IAAA,CAAK,MAAO,CAAA,MAAA,CAAO,UAAY,EAAA;AACjC,QAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,UACxD,IAAA;AAAA,UACA,MAAA;AAAA,UACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,UACxB,IAAM,EAAA;AAAA,YACJ,SAAA,EAAW,KAAK,MAAO,CAAA,GAAA;AAAA,WACzB;AAAA,UACA,QAAQ,IAAK,CAAA,MAAA;AAAA,SACd,CAAA,CAAA;AAED,QAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA,CAAA;AAAA,OACnC;AAAA,KACF;AAAA,GACF,CAAA;AACF,CAAC","file":"index.js","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\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 { 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' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n pathParamsType = 'inline',\n mutation = {},\n query = {},\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginSvelteQueryName,\n options: {\n output: {\n exportType: 'barrelNamed',\n ...output,\n },\n baseURL: undefined,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n pathParamsType: 'inline',\n ...options.client,\n },\n query: {\n key: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/svelte-query',\n ...query,\n },\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/svelte-query',\n ...mutation,\n },\n 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 (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?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), 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 const operationGenerator = new OperationGenerator(\n {\n ...this.plugin.options,\n baseURL,\n },\n {\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\n const files = await operationGenerator.build(queryGenerator, mutationGenerator)\n await this.addFile(...files)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\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})\n"]}
@@ -0,0 +1,148 @@
1
+ import { PluginFactoryOptions, Output, ResolveNameParams } from '@kubb/core';
2
+ import { HttpMethod } from '@kubb/oas';
3
+ import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
4
+
5
+ type Query = {
6
+ /**
7
+ * Customize the queryKey, here you can specify a suffix.
8
+ */
9
+ key: (key: unknown[]) => unknown[];
10
+ /**
11
+ * Define which HttpMethods can be used for queries
12
+ * @default ['get']
13
+ */
14
+ methods: Array<HttpMethod>;
15
+ /**
16
+ * Path to the useQuery that will be used to do the useQuery functionality.
17
+ * It will be used as `import { useQuery } from '${importPath}'`.
18
+ * It allows both relative and absolute path.
19
+ * the path will be applied as is, so relative path should be based on the file being generated.
20
+ * @default '@tanstack/svelte-query'
21
+ */
22
+ importPath?: string;
23
+ };
24
+ type Mutation = {
25
+ /**
26
+ * Define which HttpMethods can be used for mutations
27
+ * @default ['post', 'put', 'delete']
28
+ */
29
+ methods: Array<HttpMethod>;
30
+ /**
31
+ * Path to the useQuery that will be used to do the useQuery functionality.
32
+ * It will be used as `import { useQuery } from '${importPath}'`.
33
+ * It allows both relative and absolute path.
34
+ * the path will be applied as is, so relative path should be based on the file being generated.
35
+ * @default '@tanstack/svelte-query'
36
+ */
37
+ importPath?: string;
38
+ };
39
+ type Options = {
40
+ /**
41
+ * @default 'hooks'
42
+ */
43
+ output?: Output;
44
+ /**
45
+ * Group the @tanstack/query hooks based on the provided name.
46
+ */
47
+ group?: {
48
+ /**
49
+ * Tag will group based on the operation tag inside the Swagger file
50
+ */
51
+ type: 'tag';
52
+ /**
53
+ * Relative path to save the grouped @tanstack/query hooks.
54
+ *
55
+ * `{{tag}}` will be replaced by the current tagName.
56
+ * @example `${output}/{{tag}}Controller` => `hooks/PetController`
57
+ * @default `${output}/{{tag}}Controller`
58
+ */
59
+ output?: string;
60
+ /**
61
+ * Name to be used for the `export * as {{exportAs}} from './`
62
+ * @default `"{{tag}}Hooks"`
63
+ */
64
+ exportAs?: string;
65
+ };
66
+ client?: {
67
+ /**
68
+ * Path to the client that will be used to do the API calls.
69
+ * It will be used as `import client from '${client.importPath}'`.
70
+ * It allows both relative and absolute path.
71
+ * the path will be applied as is, so relative path should be based on the file being generated.
72
+ * @default '@kubb/plugin-client/client'
73
+ */
74
+ importPath?: string;
75
+ /**
76
+ * ReturnType that needs to be used when calling client().
77
+ *
78
+ * `Data` will return ResponseConfig[data].
79
+ *
80
+ * `Full` will return ResponseConfig.
81
+ * @default `'data'`
82
+ * @private
83
+ */
84
+ dataReturnType?: 'data' | 'full';
85
+ };
86
+ /**
87
+ * ReturnType that needs to be used when calling client().
88
+ *
89
+ * `Data` will return ResponseConfig[data].
90
+ *
91
+ * `Full` will return ResponseConfig.
92
+ * @default `'data'`
93
+ * @private
94
+ */
95
+ /**
96
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
97
+ */
98
+ exclude?: Array<Exclude>;
99
+ /**
100
+ * Array containing include parameters to include tags/operations/methods/paths.
101
+ */
102
+ include?: Array<Include>;
103
+ /**
104
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
105
+ */
106
+ override?: Array<Override<ResolvedOptions>>;
107
+ /**
108
+ * How to pass your pathParams.
109
+ *
110
+ * `object` will return the pathParams as an object.
111
+ *
112
+ * `inline` will return the pathParams as comma separated params.
113
+ * @default `'inline'`
114
+ * @private
115
+ */
116
+ pathParamsType?: 'object' | 'inline';
117
+ /**
118
+ * Override some useQuery behaviours.
119
+ */
120
+ query?: Partial<Query> | false;
121
+ /**
122
+ * Override some useMutation behaviours.
123
+ */
124
+ mutation?: Mutation | false;
125
+ /**
126
+ * Which parser can be used before returning the data to `@tanstack/query`.
127
+ * `'zod'` will use `@kubb/plugin-zod` to parse the data.
128
+ */
129
+ parser?: 'client' | 'zod';
130
+ transformers?: {
131
+ /**
132
+ * Customize the names based on the type that is provided by the plugin.
133
+ */
134
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
135
+ };
136
+ };
137
+ type ResolvedOptions = {
138
+ output: Output;
139
+ baseURL: string | undefined;
140
+ client: Required<NonNullable<PluginSvelteQuery['options']['client']>>;
141
+ parser: Required<NonNullable<Options['parser']>>;
142
+ pathParamsType: NonNullable<Options['pathParamsType']>;
143
+ query: NonNullable<Required<Query>> | false;
144
+ mutation: NonNullable<Required<Mutation>> | false;
145
+ };
146
+ type PluginSvelteQuery = PluginFactoryOptions<'plugin-svelte-query', Options, ResolvedOptions, never, ResolvePathOptions>;
147
+
148
+ export type { Options as O, PluginSvelteQuery as P };
@@ -0,0 +1,148 @@
1
+ import { PluginFactoryOptions, Output, ResolveNameParams } from '@kubb/core';
2
+ import { HttpMethod } from '@kubb/oas';
3
+ import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
4
+
5
+ type Query = {
6
+ /**
7
+ * Customize the queryKey, here you can specify a suffix.
8
+ */
9
+ key: (key: unknown[]) => unknown[];
10
+ /**
11
+ * Define which HttpMethods can be used for queries
12
+ * @default ['get']
13
+ */
14
+ methods: Array<HttpMethod>;
15
+ /**
16
+ * Path to the useQuery that will be used to do the useQuery functionality.
17
+ * It will be used as `import { useQuery } from '${importPath}'`.
18
+ * It allows both relative and absolute path.
19
+ * the path will be applied as is, so relative path should be based on the file being generated.
20
+ * @default '@tanstack/svelte-query'
21
+ */
22
+ importPath?: string;
23
+ };
24
+ type Mutation = {
25
+ /**
26
+ * Define which HttpMethods can be used for mutations
27
+ * @default ['post', 'put', 'delete']
28
+ */
29
+ methods: Array<HttpMethod>;
30
+ /**
31
+ * Path to the useQuery that will be used to do the useQuery functionality.
32
+ * It will be used as `import { useQuery } from '${importPath}'`.
33
+ * It allows both relative and absolute path.
34
+ * the path will be applied as is, so relative path should be based on the file being generated.
35
+ * @default '@tanstack/svelte-query'
36
+ */
37
+ importPath?: string;
38
+ };
39
+ type Options = {
40
+ /**
41
+ * @default 'hooks'
42
+ */
43
+ output?: Output;
44
+ /**
45
+ * Group the @tanstack/query hooks based on the provided name.
46
+ */
47
+ group?: {
48
+ /**
49
+ * Tag will group based on the operation tag inside the Swagger file
50
+ */
51
+ type: 'tag';
52
+ /**
53
+ * Relative path to save the grouped @tanstack/query hooks.
54
+ *
55
+ * `{{tag}}` will be replaced by the current tagName.
56
+ * @example `${output}/{{tag}}Controller` => `hooks/PetController`
57
+ * @default `${output}/{{tag}}Controller`
58
+ */
59
+ output?: string;
60
+ /**
61
+ * Name to be used for the `export * as {{exportAs}} from './`
62
+ * @default `"{{tag}}Hooks"`
63
+ */
64
+ exportAs?: string;
65
+ };
66
+ client?: {
67
+ /**
68
+ * Path to the client that will be used to do the API calls.
69
+ * It will be used as `import client from '${client.importPath}'`.
70
+ * It allows both relative and absolute path.
71
+ * the path will be applied as is, so relative path should be based on the file being generated.
72
+ * @default '@kubb/plugin-client/client'
73
+ */
74
+ importPath?: string;
75
+ /**
76
+ * ReturnType that needs to be used when calling client().
77
+ *
78
+ * `Data` will return ResponseConfig[data].
79
+ *
80
+ * `Full` will return ResponseConfig.
81
+ * @default `'data'`
82
+ * @private
83
+ */
84
+ dataReturnType?: 'data' | 'full';
85
+ };
86
+ /**
87
+ * ReturnType that needs to be used when calling client().
88
+ *
89
+ * `Data` will return ResponseConfig[data].
90
+ *
91
+ * `Full` will return ResponseConfig.
92
+ * @default `'data'`
93
+ * @private
94
+ */
95
+ /**
96
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
97
+ */
98
+ exclude?: Array<Exclude>;
99
+ /**
100
+ * Array containing include parameters to include tags/operations/methods/paths.
101
+ */
102
+ include?: Array<Include>;
103
+ /**
104
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
105
+ */
106
+ override?: Array<Override<ResolvedOptions>>;
107
+ /**
108
+ * How to pass your pathParams.
109
+ *
110
+ * `object` will return the pathParams as an object.
111
+ *
112
+ * `inline` will return the pathParams as comma separated params.
113
+ * @default `'inline'`
114
+ * @private
115
+ */
116
+ pathParamsType?: 'object' | 'inline';
117
+ /**
118
+ * Override some useQuery behaviours.
119
+ */
120
+ query?: Partial<Query> | false;
121
+ /**
122
+ * Override some useMutation behaviours.
123
+ */
124
+ mutation?: Mutation | false;
125
+ /**
126
+ * Which parser can be used before returning the data to `@tanstack/query`.
127
+ * `'zod'` will use `@kubb/plugin-zod` to parse the data.
128
+ */
129
+ parser?: 'client' | 'zod';
130
+ transformers?: {
131
+ /**
132
+ * Customize the names based on the type that is provided by the plugin.
133
+ */
134
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
135
+ };
136
+ };
137
+ type ResolvedOptions = {
138
+ output: Output;
139
+ baseURL: string | undefined;
140
+ client: Required<NonNullable<PluginSvelteQuery['options']['client']>>;
141
+ parser: Required<NonNullable<Options['parser']>>;
142
+ pathParamsType: NonNullable<Options['pathParamsType']>;
143
+ query: NonNullable<Required<Query>> | false;
144
+ mutation: NonNullable<Required<Mutation>> | false;
145
+ };
146
+ type PluginSvelteQuery = PluginFactoryOptions<'plugin-svelte-query', Options, ResolvedOptions, never, ResolvePathOptions>;
147
+
148
+ export type { Options as O, PluginSvelteQuery as P };