@kubb/plugin-svelte-query 3.0.0 → 3.0.2

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/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,IACpB,aAAa,CAAC,cAAA,EAAgB,iBAAiB,CAAA,CAAE,OAAO,OAAO;AAAA,GAC7D,GAAA,OAAA;AAEJ,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,qBAAA;AAAA,IACN,OAAS,EAAA;AAAA,MACP,MAAA;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,UAAY,EAAA,4BAAA;AAAA,QACZ,cAAgB,EAAA,MAAA;AAAA,QAChB,cAAgB,EAAA,QAAA;AAAA,QAChB,GAAG,OAAQ,CAAA;AAAA,OACb;AAAA,MACA,QAAA;AAAA,MACA,KAAO,EAAA;AAAA,QACL,OAAA,EAAS,CAAC,KAAK,CAAA;AAAA,QACf,UAAY,EAAA,wBAAA;AAAA,QACZ,GAAG;AAAA,OACL;AAAA,MACA,WAAA;AAAA,MACA,QAAU,EAAA;AAAA,QACR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I,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 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
+ {"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,IACpB,aAAa,CAAC,cAAA,EAAgB,iBAAiB,CAAA,CAAE,OAAO,OAAO;AAAA,GAC7D,GAAA,OAAA;AAEJ,EAAO,O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A,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 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 },\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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-svelte-query",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Generator svelte-query hooks",
5
5
  "keywords": [
6
6
  "faker",
@@ -62,24 +62,25 @@
62
62
  "!/**/__tests__/**"
63
63
  ],
64
64
  "dependencies": {
65
- "@kubb/core": "3.0.0",
66
- "@kubb/fs": "3.0.0",
67
- "@kubb/oas": "3.0.0",
68
- "@kubb/plugin-oas": "3.0.0",
69
- "@kubb/plugin-ts": "3.0.0",
70
- "@kubb/plugin-zod": "3.0.0",
71
- "@kubb/react": "3.0.0"
65
+ "remeda": "^2.17.0",
66
+ "@kubb/core": "3.0.2",
67
+ "@kubb/fs": "3.0.2",
68
+ "@kubb/oas": "3.0.2",
69
+ "@kubb/plugin-oas": "3.0.2",
70
+ "@kubb/plugin-ts": "3.0.2",
71
+ "@kubb/plugin-zod": "3.0.2",
72
+ "@kubb/react": "3.0.2"
72
73
  },
73
74
  "devDependencies": {
74
75
  "@types/react": "^18.3.12",
75
76
  "react": "^18.3.1",
76
77
  "tsup": "^8.3.5",
77
78
  "typescript": "^5.6.3",
78
- "@kubb/config-ts": "3.0.0",
79
- "@kubb/config-tsup": "3.0.0"
79
+ "@kubb/config-ts": "3.0.2",
80
+ "@kubb/config-tsup": "3.0.2"
80
81
  },
81
82
  "peerDependencies": {
82
- "@kubb/react": "3.0.0"
83
+ "@kubb/react": "3.0.2"
83
84
  },
84
85
  "engines": {
85
86
  "node": ">=20"
@@ -5,6 +5,7 @@ import { useOperationManager } from '@kubb/plugin-oas/hooks'
5
5
  import { pluginTsName } from '@kubb/plugin-ts'
6
6
  import { pluginZodName } from '@kubb/plugin-zod'
7
7
  import { File, useApp } from '@kubb/react'
8
+ import { difference } from 'remeda'
8
9
  import { Mutation, MutationKey } from '../components'
9
10
  import type { PluginSvelteQuery } from '../types'
10
11
 
@@ -18,8 +19,10 @@ export const mutationGenerator = createReactGenerator<PluginSvelteQuery>({
18
19
  } = useApp<PluginSvelteQuery>()
19
20
  const { getSchemas, getName, getFile } = useOperationManager()
20
21
 
21
- const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)
22
- const isMutation = !isQuery && options.mutation && options.mutation.methods.some((method) => operation.method === method)
22
+ const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method)
23
+ const isMutation =
24
+ !isQuery &&
25
+ difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method)
23
26
 
24
27
  const importPath = options.mutation ? options.mutation.importPath : '@tanstack/svelte-query'
25
28
 
@@ -41,7 +44,7 @@ export const mutationGenerator = createReactGenerator<PluginSvelteQuery>({
41
44
  }
42
45
 
43
46
  const client = {
44
- name: getName(operation, { type: 'function', pluginKey: [pluginClientName] }),
47
+ name: getName(operation, { type: 'function' }),
45
48
  }
46
49
 
47
50
  const mutationKey = {
@@ -5,6 +5,7 @@ import { useOperationManager } from '@kubb/plugin-oas/hooks'
5
5
  import { pluginTsName } from '@kubb/plugin-ts'
6
6
  import { pluginZodName } from '@kubb/plugin-zod'
7
7
  import { File, useApp } from '@kubb/react'
8
+ import { difference } from 'remeda'
8
9
  import { Query, QueryKey, QueryOptions } from '../components'
9
10
  import type { PluginSvelteQuery } from '../types'
10
11
 
@@ -19,6 +20,9 @@ export const queryGenerator = createReactGenerator<PluginSvelteQuery>({
19
20
  const { getSchemas, getName, getFile } = useOperationManager()
20
21
 
21
22
  const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)
23
+ const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
24
+ (method) => operation.method === method,
25
+ )
22
26
  const importPath = options.query ? options.query.importPath : '@tanstack/svelte-query'
23
27
 
24
28
  const query = {
@@ -28,7 +32,7 @@ export const queryGenerator = createReactGenerator<PluginSvelteQuery>({
28
32
  }
29
33
 
30
34
  const client = {
31
- name: getName(operation, { type: 'function', pluginKey: [pluginClientName] }),
35
+ name: getName(operation, { type: 'function' }),
32
36
  }
33
37
 
34
38
  const queryOptions = {
@@ -51,7 +55,7 @@ export const queryGenerator = createReactGenerator<PluginSvelteQuery>({
51
55
  schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),
52
56
  }
53
57
 
54
- if (!isQuery) {
58
+ if (!isQuery || isMutation) {
55
59
  return null
56
60
  }
57
61
 
package/src/plugin.ts CHANGED
@@ -44,11 +44,14 @@ export const pluginSvelteQuery = createPlugin<PluginSvelteQuery>((options) => {
44
44
  ...options.client,
45
45
  },
46
46
  queryKey,
47
- query: {
48
- methods: ['get'],
49
- importPath: '@tanstack/svelte-query',
50
- ...query,
51
- },
47
+ query:
48
+ query === false
49
+ ? false
50
+ : {
51
+ methods: ['get'],
52
+ importPath: '@tanstack/svelte-query',
53
+ ...query,
54
+ },
52
55
  mutationKey,
53
56
  mutation: {
54
57
  methods: ['post', 'put', 'patch', 'delete'],
@@ -1,452 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkKRGCKSGR_cjs = require('./chunk-KRGCKSGR.cjs');
4
- var path = require('path');
5
- var core = require('@kubb/core');
6
- var transformers = require('@kubb/core/transformers');
7
- var pluginOas = require('@kubb/plugin-oas');
8
- var pluginZod = require('@kubb/plugin-zod');
9
- var hooks = require('@kubb/plugin-oas/hooks');
10
- var pluginTs = require('@kubb/plugin-ts');
11
- var react = require('@kubb/react');
12
- var jsxRuntime = require('@kubb/react/jsx-runtime');
13
-
14
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
-
16
- var path__default = /*#__PURE__*/_interopDefault(path);
17
-
18
- var clientGenerator = pluginOas.createReactGenerator({
19
- name: "client",
20
- Operation({ options, operation }) {
21
- const {
22
- plugin: {
23
- options: { output }
24
- }
25
- } = react.useApp();
26
- const { getSchemas, getName, getFile } = hooks.useOperationManager();
27
- const client = {
28
- name: getName(operation, { type: "function" }),
29
- file: getFile(operation)
30
- };
31
- const type = {
32
- file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
33
- schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
34
- };
35
- const zod = {
36
- file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
37
- schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
38
- };
39
- return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: client.file.baseName, path: client.file.path, meta: client.file.meta, banner: output?.banner, footer: output?.footer, children: [
40
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.importPath }),
41
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig"], path: options.importPath, isTypeOnly: true }),
42
- options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: client.file.path, path: zod.file.path }),
43
- /* @__PURE__ */ jsxRuntime.jsx(
44
- react.File.Import,
45
- {
46
- name: [
47
- type.schemas.request?.name,
48
- type.schemas.response.name,
49
- type.schemas.pathParams?.name,
50
- type.schemas.queryParams?.name,
51
- type.schemas.headerParams?.name,
52
- ...type.schemas.statusCodes?.map((item) => item.name) || []
53
- ].filter(Boolean),
54
- root: client.file.path,
55
- path: type.file.path,
56
- isTypeOnly: true
57
- }
58
- ),
59
- /* @__PURE__ */ jsxRuntime.jsx(
60
- chunkKRGCKSGR_cjs.Client,
61
- {
62
- name: client.name,
63
- baseURL: options.baseURL,
64
- dataReturnType: options.dataReturnType,
65
- pathParamsType: options.pathParamsType,
66
- paramsType: options.paramsType,
67
- typeSchemas: type.schemas,
68
- operation,
69
- parser: options.parser,
70
- zodSchemas: zod.schemas
71
- }
72
- )
73
- ] });
74
- }
75
- });
76
- var operationsGenerator = pluginOas.createReactGenerator({
77
- name: "client",
78
- Operations({ operations }) {
79
- const {
80
- pluginManager,
81
- plugin: {
82
- options: { output }
83
- }
84
- } = react.useApp();
85
- const name = "operations";
86
- const file = pluginManager.getFile({ name, extname: ".ts", pluginKey: [pluginClientName] });
87
- return /* @__PURE__ */ jsxRuntime.jsx(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, banner: output?.banner, footer: output?.footer, children: /* @__PURE__ */ jsxRuntime.jsx(chunkKRGCKSGR_cjs.Operations, { name, operations }) });
88
- }
89
- });
90
- var groupedClientGenerator = pluginOas.createReactGenerator({
91
- name: "groupedClient",
92
- Operations({ operations }) {
93
- const {
94
- pluginManager,
95
- plugin: { options }
96
- } = react.useApp();
97
- const { getName, getFile } = hooks.useOperationManager();
98
- const controllers = operations.reduce(
99
- (acc, operation) => {
100
- if (options.group?.type === "tag") {
101
- const tag = operation.getTags().at(0)?.name;
102
- const name = tag ? options.group?.name?.({ group: transformers.camelCase(tag) }) : void 0;
103
- if (!tag || !name) {
104
- return acc;
105
- }
106
- const file = pluginManager.getFile({
107
- name,
108
- extname: ".ts",
109
- pluginKey: [pluginClientName],
110
- options: { tag }
111
- });
112
- const client = {
113
- name: getName(operation, { type: "function" }),
114
- file: getFile(operation)
115
- };
116
- const previousFile = acc.find((item) => item.file.path === file.path);
117
- if (previousFile) {
118
- previousFile.clients.push(client);
119
- } else {
120
- acc.push({ name, file, clients: [client] });
121
- }
122
- }
123
- return acc;
124
- },
125
- []
126
- );
127
- return controllers.map(({ name, file, clients }) => {
128
- return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, banner: options.output?.banner, footer: options.output?.footer, children: [
129
- clients.map((client) => /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [client.name], root: file.path, path: client.file.path }, client.name)),
130
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function, { export: true, name, children: `return { ${clients.map((client) => client.name).join(", ")} }` }) })
131
- ] }, file.path);
132
- });
133
- }
134
- });
135
-
136
- // ../plugin-client/src/plugin.ts
137
- var pluginClientName = "plugin-client";
138
- core.createPlugin((options) => {
139
- const {
140
- output = { path: "clients", barrelType: "named" },
141
- group,
142
- exclude = [],
143
- include,
144
- override = [],
145
- transformers: transformers$1 = {},
146
- dataReturnType = "data",
147
- pathParamsType = "inline",
148
- paramsType = "inline",
149
- operations = false,
150
- baseURL,
151
- generators = [clientGenerator, group ? groupedClientGenerator : void 0, operations ? operationsGenerator : void 0].filter(Boolean),
152
- importPath = "@kubb/plugin-client/client",
153
- parser = "client"
154
- } = options;
155
- return {
156
- name: pluginClientName,
157
- options: {
158
- output,
159
- group,
160
- parser,
161
- dataReturnType,
162
- importPath,
163
- paramsType,
164
- pathParamsType: paramsType === "object" ? "object" : pathParamsType,
165
- baseURL
166
- },
167
- pre: [pluginOas.pluginOasName, parser === "zod" ? pluginZod.pluginZodName : void 0].filter(Boolean),
168
- resolvePath(baseName, pathMode, options2) {
169
- const root = path__default.default.resolve(this.config.root, this.config.output.path);
170
- const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
171
- if (options2?.tag && group?.type === "tag") {
172
- const groupName = group?.name ? group.name : (ctx) => `${ctx.group}Controller`;
173
- return path__default.default.resolve(root, output.path, groupName({ group: transformers.camelCase(options2.tag) }), baseName);
174
- }
175
- if (mode === "single") {
176
- return path__default.default.resolve(root, output.path);
177
- }
178
- return path__default.default.resolve(root, output.path, baseName);
179
- },
180
- resolveName(name, type) {
181
- const resolvedName = transformers.camelCase(name, { isFile: type === "file" });
182
- if (type) {
183
- return transformers$1?.name?.(resolvedName, type) || resolvedName;
184
- }
185
- return resolvedName;
186
- },
187
- async buildStart() {
188
- const [swaggerPlugin] = core.PluginManager.getDependedPlugins(this.plugins, [pluginOas.pluginOasName]);
189
- const oas = await swaggerPlugin.context.getOas();
190
- const root = path__default.default.resolve(this.config.root, this.config.output.path);
191
- const mode = core.FileManager.getMode(path__default.default.resolve(root, output.path));
192
- const baseURL2 = await swaggerPlugin.context.getBaseURL();
193
- const operationGenerator = new pluginOas.OperationGenerator(
194
- baseURL2 ? {
195
- ...this.plugin.options,
196
- baseURL: baseURL2
197
- } : this.plugin.options,
198
- {
199
- oas,
200
- pluginManager: this.pluginManager,
201
- plugin: this.plugin,
202
- contentType: swaggerPlugin.context.contentType,
203
- exclude,
204
- include,
205
- override,
206
- mode
207
- }
208
- );
209
- const files = await operationGenerator.build(...generators);
210
- await this.addFile(...files);
211
- const barrelFiles = await this.fileManager.getBarrelFiles({
212
- type: output.barrelType ?? "named",
213
- root,
214
- output,
215
- files: this.fileManager.files,
216
- meta: {
217
- pluginKey: this.plugin.key
218
- },
219
- logger: this.logger
220
- });
221
- await this.addFile(...barrelFiles);
222
- }
223
- };
224
- });
225
- var queryGenerator = pluginOas.createReactGenerator({
226
- name: "svelte-query",
227
- Operation({ options, operation }) {
228
- const {
229
- plugin: {
230
- options: { output }
231
- }
232
- } = react.useApp();
233
- const { getSchemas, getName, getFile } = hooks.useOperationManager();
234
- const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
235
- const importPath = options.query ? options.query.importPath : "@tanstack/svelte-query";
236
- const query = {
237
- name: getName(operation, { type: "function", prefix: "create" }),
238
- typeName: getName(operation, { type: "type" }),
239
- file: getFile(operation, { prefix: "create" })
240
- };
241
- const client = {
242
- name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
243
- };
244
- const queryOptions = {
245
- name: getName(operation, { type: "function", suffix: "QueryOptions" })
246
- };
247
- const queryKey = {
248
- name: getName(operation, { type: "const", suffix: "QueryKey" }),
249
- typeName: getName(operation, { type: "type", suffix: "QueryKey" })
250
- };
251
- const type = {
252
- file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
253
- //todo remove type?
254
- schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
255
- };
256
- const zod = {
257
- file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
258
- schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
259
- };
260
- if (!isQuery) {
261
- return null;
262
- }
263
- return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
264
- options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
265
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
266
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
267
- options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
268
- /* @__PURE__ */ jsxRuntime.jsx(
269
- react.File.Import,
270
- {
271
- name: [
272
- type.schemas.request?.name,
273
- type.schemas.response.name,
274
- type.schemas.pathParams?.name,
275
- type.schemas.queryParams?.name,
276
- type.schemas.headerParams?.name,
277
- ...type.schemas.statusCodes?.map((item) => item.name) || []
278
- ].filter(Boolean),
279
- root: query.file.path,
280
- path: type.file.path,
281
- isTypeOnly: true
282
- }
283
- ),
284
- /* @__PURE__ */ jsxRuntime.jsx(
285
- chunkKRGCKSGR_cjs.QueryKey,
286
- {
287
- name: queryKey.name,
288
- typeName: queryKey.typeName,
289
- operation,
290
- pathParamsType: options.pathParamsType,
291
- typeSchemas: type.schemas,
292
- transformer: options.queryKey
293
- }
294
- ),
295
- /* @__PURE__ */ jsxRuntime.jsx(
296
- chunkKRGCKSGR_cjs.Client,
297
- {
298
- name: client.name,
299
- isExportable: false,
300
- isIndexable: false,
301
- baseURL: options.client.baseURL,
302
- operation,
303
- typeSchemas: type.schemas,
304
- zodSchemas: zod.schemas,
305
- dataReturnType: options.client.dataReturnType,
306
- paramsType: options.paramsType,
307
- pathParamsType: options.pathParamsType,
308
- parser: options.parser
309
- }
310
- ),
311
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["queryOptions"], path: importPath }),
312
- /* @__PURE__ */ jsxRuntime.jsx(
313
- chunkKRGCKSGR_cjs.QueryOptions,
314
- {
315
- name: queryOptions.name,
316
- clientName: client.name,
317
- queryKeyName: queryKey.name,
318
- typeSchemas: type.schemas,
319
- paramsType: options.paramsType,
320
- pathParamsType: options.pathParamsType
321
- }
322
- ),
323
- options.query && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
324
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["createQuery"], path: importPath }),
325
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "CreateBaseQueryOptions", "CreateQueryResult"], path: importPath, isTypeOnly: true }),
326
- /* @__PURE__ */ jsxRuntime.jsx(
327
- chunkKRGCKSGR_cjs.Query,
328
- {
329
- name: query.name,
330
- queryOptionsName: queryOptions.name,
331
- typeSchemas: type.schemas,
332
- pathParamsType: options.pathParamsType,
333
- operation,
334
- paramsType: options.paramsType,
335
- dataReturnType: options.client.dataReturnType,
336
- queryKeyName: queryKey.name,
337
- queryKeyTypeName: queryKey.typeName
338
- }
339
- )
340
- ] })
341
- ] });
342
- }
343
- });
344
- var mutationGenerator = pluginOas.createReactGenerator({
345
- name: "svelte-query",
346
- Operation({ options, operation }) {
347
- const {
348
- plugin: {
349
- options: { output }
350
- }
351
- } = react.useApp();
352
- const { getSchemas, getName, getFile } = hooks.useOperationManager();
353
- const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
354
- const isMutation = !isQuery && options.mutation && options.mutation.methods.some((method) => operation.method === method);
355
- const importPath = options.mutation ? options.mutation.importPath : "@tanstack/svelte-query";
356
- const mutation = {
357
- name: getName(operation, { type: "function", prefix: "create" }),
358
- typeName: getName(operation, { type: "type" }),
359
- file: getFile(operation, { prefix: "create" })
360
- };
361
- const type = {
362
- file: getFile(operation, { pluginKey: [pluginTs.pluginTsName] }),
363
- //todo remove type?
364
- schemas: getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" })
365
- };
366
- const zod = {
367
- file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
368
- schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
369
- };
370
- const client = {
371
- name: getName(operation, { type: "function", pluginKey: [pluginClientName] })
372
- };
373
- const mutationKey = {
374
- name: getName(operation, { type: "const", suffix: "MutationKey" }),
375
- typeName: getName(operation, { type: "type", suffix: "MutationKey" })
376
- };
377
- if (!isMutation) {
378
- return null;
379
- }
380
- return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: mutation.file.baseName, path: mutation.file.path, meta: mutation.file.meta, banner: output?.banner, footer: output?.footer, children: [
381
- options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: mutation.file.path, path: zod.file.path }),
382
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
383
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
384
- /* @__PURE__ */ jsxRuntime.jsx(
385
- react.File.Import,
386
- {
387
- name: [
388
- type.schemas.request?.name,
389
- type.schemas.response.name,
390
- type.schemas.pathParams?.name,
391
- type.schemas.queryParams?.name,
392
- type.schemas.headerParams?.name,
393
- ...type.schemas.statusCodes?.map((item) => item.name) || []
394
- ].filter(Boolean),
395
- root: mutation.file.path,
396
- path: type.file.path,
397
- isTypeOnly: true
398
- }
399
- ),
400
- /* @__PURE__ */ jsxRuntime.jsx(
401
- chunkKRGCKSGR_cjs.MutationKey,
402
- {
403
- name: mutationKey.name,
404
- typeName: mutationKey.typeName,
405
- operation,
406
- pathParamsType: options.pathParamsType,
407
- typeSchemas: type.schemas,
408
- transformer: options.mutationKey
409
- }
410
- ),
411
- /* @__PURE__ */ jsxRuntime.jsx(
412
- chunkKRGCKSGR_cjs.Client,
413
- {
414
- name: client.name,
415
- isExportable: false,
416
- isIndexable: false,
417
- baseURL: options.client.baseURL,
418
- operation,
419
- typeSchemas: type.schemas,
420
- zodSchemas: zod.schemas,
421
- dataReturnType: options.client.dataReturnType,
422
- paramsType: options.paramsType,
423
- pathParamsType: options.pathParamsType,
424
- parser: options.parser
425
- }
426
- ),
427
- options.mutation && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
428
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["createMutation"], path: importPath }),
429
- /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["CreateMutationOptions", "CreateMutationResult"], path: importPath, isTypeOnly: true }),
430
- /* @__PURE__ */ jsxRuntime.jsx(
431
- chunkKRGCKSGR_cjs.Mutation,
432
- {
433
- name: mutation.name,
434
- clientName: client.name,
435
- typeName: mutation.typeName,
436
- typeSchemas: type.schemas,
437
- operation,
438
- dataReturnType: options.client.dataReturnType,
439
- paramsType: options.paramsType,
440
- pathParamsType: options.pathParamsType,
441
- mutationKeyName: mutationKey.name
442
- }
443
- )
444
- ] })
445
- ] });
446
- }
447
- });
448
-
449
- exports.mutationGenerator = mutationGenerator;
450
- exports.queryGenerator = queryGenerator;
451
- //# sourceMappingURL=chunk-CDRGJAED.cjs.map
452
- //# sourceMappingURL=chunk-CDRGJAED.cjs.map