@kubb/plugin-svelte-query 4.2.0 → 4.2.1

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.
@@ -1,4 +1,4 @@
1
- import { a as OperationSchemas, n as PluginSvelteQuery, r as Transformer, s as Operation } from "./types-BZIs5xbl.cjs";
1
+ import { a as OperationSchemas, n as PluginSvelteQuery, r as Transformer, s as Operation } from "./types-B6RRaIal.cjs";
2
2
 
3
3
  //#region rolldown:runtime
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { a as OperationSchemas, n as PluginSvelteQuery, r as Transformer, s as Operation } from "./types-CKJMdEqY.js";
1
+ import { a as OperationSchemas, n as PluginSvelteQuery, r as Transformer, s as Operation } from "./types-Dpz1cgTk.js";
2
2
 
3
3
  //#region rolldown:runtime
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { i as Generator, n as PluginSvelteQuery } from "./types-BZIs5xbl.cjs";
1
+ import { i as Generator, n as PluginSvelteQuery } from "./types-B6RRaIal.cjs";
2
2
 
3
3
  //#region src/generators/queryGenerator.d.ts
4
4
  declare const queryGenerator: Generator<PluginSvelteQuery>;
@@ -1,4 +1,4 @@
1
- import { i as Generator, n as PluginSvelteQuery } from "./types-CKJMdEqY.js";
1
+ import { i as Generator, n as PluginSvelteQuery } from "./types-Dpz1cgTk.js";
2
2
 
3
3
  //#region src/generators/queryGenerator.d.ts
4
4
  declare const queryGenerator: Generator<PluginSvelteQuery>;
package/dist/index.cjs CHANGED
@@ -60,7 +60,7 @@ const pluginSvelteQuery = (0, __kubb_core.createPlugin)((options) => {
60
60
  ].filter(Boolean),
61
61
  resolvePath(baseName, pathMode, options$1) {
62
62
  const root = node_path.default.resolve(this.config.root, this.config.output.path);
63
- if ((pathMode ?? __kubb_core.FileManager.getMode(node_path.default.resolve(root, output.path))) === "single")
63
+ if ((pathMode ?? (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
64
64
  /**
65
65
  * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
66
66
  * Other plugins then need to call addOrAppend instead of just add from the fileManager class
@@ -86,7 +86,7 @@ const pluginSvelteQuery = (0, __kubb_core.createPlugin)((options) => {
86
86
  const [swaggerPlugin] = __kubb_core.PluginManager.getDependedPlugins(this.plugins, [__kubb_plugin_oas.pluginOasName]);
87
87
  const oas = await swaggerPlugin.context.getOas();
88
88
  const root = node_path.default.resolve(this.config.root, this.config.output.path);
89
- const mode = __kubb_core.FileManager.getMode(node_path.default.resolve(root, output.path));
89
+ const mode = (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path));
90
90
  const baseURL = await swaggerPlugin.context.getBaseURL();
91
91
  if (baseURL) this.plugin.options.client.baseURL = baseURL;
92
92
  const files = await new __kubb_plugin_oas.OperationGenerator(this.plugin.options, {
@@ -100,7 +100,7 @@ const pluginSvelteQuery = (0, __kubb_core.createPlugin)((options) => {
100
100
  mode
101
101
  }).build(...generators);
102
102
  await this.addFile(...files);
103
- const barrelFiles = await this.fileManager.getBarrelFiles({
103
+ const barrelFiles = await (0, __kubb_core.getBarrelFiles)(this.fileManager.files, {
104
104
  type: output.barrelType ?? "named",
105
105
  root,
106
106
  output,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["MutationKey","QueryKey","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","path","FileManager","options","groupName: Group['name']","PluginManager","OperationGenerator"],"sources":["../src/plugin.ts"],"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 = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutation = {},\n query = {},\n paramsCasing,\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n contentType,\n } = options\n\n return {\n name: pluginSvelteQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/clients/axios',\n dataReturnType: 'data',\n pathParamsType,\n ...options.client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/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,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,MAAa,wBAAwB;AAErC,MAAa,mDAAqD,YAAY;CAC5E,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,eAAe,EAAE,EACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,WAAW,EAAE,EACb,QAAQ,EAAE,EACV,cACA,cAAcA,+BAAY,gBAC1B,WAAWC,4BAAS,gBACpB,aAAa,CAACC,mCAAgBC,qCAAkB,CAAC,OAAO,QAAQ,EAChE,gBACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA,QAAQ;IACN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GACjB,MAAM,CAAC,iBAAsCI,0BAAc,mBAA8B,KAAK,SAAS,CAACP,gCAAc,CAAC;GAEvH,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAChD,MAAM,OAAOG,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAOC,wBAAY,QAAQD,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACjE,MAAM,UAAU,MAAM,cAAc,QAAQ,YAAY;AAExD,OAAI,QACF,MAAK,OAAO,QAAQ,OAAO,UAAU;GAcvC,MAAM,QAAQ,MAXa,IAAIK,qCAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,MAAM,KAAK,YAAY,eAAe;IACxD,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
1
+ {"version":3,"file":"index.cjs","names":["MutationKey","QueryKey","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","path","options","groupName: Group['name']","PluginManager","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { 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 = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutation = {},\n query = {},\n paramsCasing,\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n contentType,\n } = options\n\n return {\n name: pluginSvelteQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/clients/axios',\n dataReturnType: 'data',\n pathParamsType,\n ...options.client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/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,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAWA,MAAa,wBAAwB;AAErC,MAAa,mDAAqD,YAAY;CAC5E,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,eAAe,EAAE,EACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,WAAW,EAAE,EACb,QAAQ,EAAE,EACV,cACA,cAAcA,+BAAY,gBAC1B,WAAWC,4BAAS,gBACpB,aAAa,CAACC,mCAAgBC,qCAAkB,CAAC,OAAO,QAAQ,EAChE,gBACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA,QAAQ;IACN,YAAY;IACZ,gBAAgB;IACh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AA8B,KAAK,SAAS,CAACN,gCAAc,CAAC;GAEvH,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAChD,MAAM,OAAOG,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,gCAAeA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,UAAU,MAAM,cAAc,QAAQ,YAAY;AAExD,OAAI,QACF,MAAK,OAAO,QAAQ,OAAO,UAAU;GAcvC,MAAM,QAAQ,MAXa,IAAII,qCAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,sCAAqB,KAAK,YAAY,OAAO;IAC/D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as PluginSvelteQuery, o as UserPluginWithLifeCycle, t as Options } from "./types-BZIs5xbl.cjs";
1
+ import { n as PluginSvelteQuery, o as UserPluginWithLifeCycle, t as Options } from "./types-B6RRaIal.cjs";
2
2
 
3
3
  //#region src/plugin.d.ts
4
4
  declare const pluginSvelteQueryName = "plugin-svelte-query";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as PluginSvelteQuery, o as UserPluginWithLifeCycle, t as Options } from "./types-CKJMdEqY.js";
1
+ import { n as PluginSvelteQuery, o as UserPluginWithLifeCycle, t as Options } from "./types-Dpz1cgTk.js";
2
2
 
3
3
  //#region src/plugin.d.ts
4
4
  declare const pluginSvelteQueryName = "plugin-svelte-query";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { a as MutationKey, r as QueryKey } from "./components-Cq3A-AeW.js";
2
2
  import { n as queryGenerator, t as mutationGenerator } from "./generators-kIneZ9wV.js";
3
3
  import path from "node:path";
4
- import { FileManager, PluginManager, createPlugin } from "@kubb/core";
4
+ import { PluginManager, createPlugin, getBarrelFiles, getMode } from "@kubb/core";
5
5
  import { camelCase, pascalCase } from "@kubb/core/transformers";
6
6
  import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
7
7
  import { pluginTsName } from "@kubb/plugin-ts";
@@ -54,7 +54,7 @@ const pluginSvelteQuery = createPlugin((options) => {
54
54
  ].filter(Boolean),
55
55
  resolvePath(baseName, pathMode, options$1) {
56
56
  const root = path.resolve(this.config.root, this.config.output.path);
57
- if ((pathMode ?? FileManager.getMode(path.resolve(root, output.path))) === "single")
57
+ if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
58
58
  /**
59
59
  * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
60
60
  * Other plugins then need to call addOrAppend instead of just add from the fileManager class
@@ -80,7 +80,7 @@ const pluginSvelteQuery = createPlugin((options) => {
80
80
  const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
81
81
  const oas = await swaggerPlugin.context.getOas();
82
82
  const root = path.resolve(this.config.root, this.config.output.path);
83
- const mode = FileManager.getMode(path.resolve(root, output.path));
83
+ const mode = getMode(path.resolve(root, output.path));
84
84
  const baseURL = await swaggerPlugin.context.getBaseURL();
85
85
  if (baseURL) this.plugin.options.client.baseURL = baseURL;
86
86
  const files = await new OperationGenerator(this.plugin.options, {
@@ -94,7 +94,7 @@ const pluginSvelteQuery = createPlugin((options) => {
94
94
  mode
95
95
  }).build(...generators);
96
96
  await this.addFile(...files);
97
- const barrelFiles = await this.fileManager.getBarrelFiles({
97
+ const barrelFiles = await getBarrelFiles(this.fileManager.files, {
98
98
  type: output.barrelType ?? "named",
99
99
  root,
100
100
  output,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\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 = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutation = {},\n query = {},\n paramsCasing,\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n contentType,\n } = options\n\n return {\n name: pluginSvelteQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/clients/axios',\n dataReturnType: 'data',\n pathParamsType,\n ...options.client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/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,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;AAeA,MAAa,wBAAwB;AAErC,MAAa,oBAAoB,cAAiC,Y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,MAAM,SAAS,SAASD,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAO,KAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,IAAI,eAAe,UAAU,KAAK;AAElC,OAAI,SAAS,UAAU,SAAS,WAC9B,gBAAe,UAAU,MAAM,EAC7B,QAAQ,SAAS,QAClB,CAAC;AAEJ,OAAI,SAAS,OACX,gBAAe,WAAW,KAAK;AAGjC,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,aAAa;GACjB,MAAM,CAAC,iBAAsC,cAAc,mBAA8B,KAAK,SAAS,CAAC,cAAc,CAAC;GAEvH,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAChD,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACjE,MAAM,UAAU,MAAM,cAAc,QAAQ,YAAY;AAExD,OAAI,QACF,MAAK,OAAO,QAAQ,OAAO,UAAU;GAcvC,MAAM,QAAQ,MAXa,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,MAAM,KAAK,YAAY,eAAe;IACxD,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
1
+ {"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { 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 = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutation = {},\n query = {},\n paramsCasing,\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n contentType,\n } = options\n\n return {\n name: pluginSvelteQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/clients/axios',\n dataReturnType: 'data',\n pathParamsType,\n ...options.client,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/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,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;AAWA,MAAa,wBAAwB;AAErC,MAAa,oBAAoB,cAAiC,YAAY;CAC5E,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,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;;EAElD,YAAY,MAAM,MAAM;GACtB,IAAI,eAAe,UAAU,KAAK;AAElC,OAAI,SAAS,UAAU,SAAS,WAC9B,gBAAe,UAAU,MAAM,EAC7B,QAAQ,SAAS,QAClB,CAAC;AAEJ,OAAI,SAAS,OACX,gBAAe,WAAW,KAAK;AAGjC,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,aAAa;GACjB,MAAM,CAAC,iBAAsC,cAAc,mBAA8B,KAAK,SAAS,CAAC,cAAc,CAAC;GAEvH,MAAM,MAAM,MAAM,cAAc,QAAQ,QAAQ;GAChD,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,UAAU,MAAM,cAAc,QAAQ,YAAY;AAExD,OAAI,QACF,MAAK,OAAO,QAAQ,OAAO,UAAU;GAcvC,MAAM,QAAQ,MAXa,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,MAAM,eAAe,KAAK,YAAY,OAAO;IAC/D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
@@ -5,6 +5,7 @@ import { OpenAPIV3 } from "openapi-types";
5
5
  import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
6
6
  import BaseOas from "oas";
7
7
  import { ConsolaInstance, LogLevel } from "consola";
8
+ import { FileManager } from "@kubb/fabric-core";
8
9
 
9
10
  //#region ../oas/src/types.d.ts
10
11
  type contentType = 'application/json' | (string & {});
@@ -220,8 +221,6 @@ type Logger = {
220
221
  //#endregion
221
222
  //#region ../core/src/utils/types.d.ts
222
223
  type PossiblePromise<T$1> = Promise<T$1> | T$1;
223
- type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
224
- type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
225
224
  //#endregion
226
225
  //#region ../core/src/types.d.ts
227
226
  type InputPath = {
@@ -464,6 +463,9 @@ type ResolveNameParams = {
464
463
  };
465
464
  type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
466
465
  config: Config;
466
+ /**
467
+ * @deprecated
468
+ */
467
469
  fileManager: FileManager;
468
470
  pluginManager: PluginManager;
469
471
  addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
@@ -515,60 +517,6 @@ type Group = {
515
517
  name?: (context: GroupContext) => string;
516
518
  };
517
519
  //#endregion
518
- //#region ../core/src/FileManager.d.ts
519
- type FileMetaBase = {
520
- pluginKey?: Plugin['key'];
521
- };
522
- type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
523
- type AddIndexesProps = {
524
- type: BarrelType | false | undefined;
525
- /**
526
- * Root based on root and output.path specified in the config
527
- */
528
- root: string;
529
- /**
530
- * Output for plugin
531
- */
532
- output: {
533
- path: string;
534
- };
535
- group?: {
536
- output: string;
537
- exportAs: string;
538
- };
539
- logger?: Logger;
540
- meta?: FileMetaBase;
541
- };
542
- type WriteFilesProps = {
543
- root: Config['root'];
544
- extension?: Record<Extname, Extname | ''>;
545
- logger?: Logger;
546
- dryRun?: boolean;
547
- };
548
- declare class FileManager {
549
- #private;
550
- constructor();
551
- add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
552
- getByPath(path: Path): Promise<ResolvedFile | null>;
553
- deleteByPath(path: Path): Promise<void>;
554
- clear(): Promise<void>;
555
- getFiles(): Promise<Array<ResolvedFile>>;
556
- processFiles({
557
- dryRun,
558
- root,
559
- extension,
560
- logger
561
- }: WriteFilesProps): Promise<Array<ResolvedFile>>;
562
- getBarrelFiles({
563
- type,
564
- meta,
565
- root,
566
- output,
567
- logger
568
- }: AddIndexesProps): Promise<File[]>;
569
- static getMode(path: string | undefined | null): Mode;
570
- }
571
- //#endregion
572
520
  //#region ../core/src/PluginManager.d.ts
573
521
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
574
522
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
@@ -607,6 +555,9 @@ type GetFileProps<TOptions$1 = object> = {
607
555
  declare class PluginManager {
608
556
  #private;
609
557
  readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
558
+ /**
559
+ * @deprecated do not use from pluginManager
560
+ */
610
561
  readonly fileManager: FileManager;
611
562
  readonly events: EventEmitter<Events>;
612
563
  readonly config: Config;
@@ -715,6 +666,11 @@ declare class PluginManager {
715
666
  static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
716
667
  }
717
668
  //#endregion
669
+ //#region ../core/src/FileManager.d.ts
670
+ type FileMetaBase = {
671
+ pluginKey?: Plugin['key'];
672
+ };
673
+ //#endregion
718
674
  //#region ../plugin-oas/src/SchemaMapper.d.ts
719
675
  type SchemaKeywordMapper = {
720
676
  object: {
@@ -1379,4 +1335,4 @@ type ResolvedOptions = {
1379
1335
  type PluginSvelteQuery = PluginFactoryOptions<'plugin-svelte-query', Options$1, ResolvedOptions, never, ResolvePathOptions>;
1380
1336
  //#endregion
1381
1337
  export { OperationSchemas as a, Generator as i, PluginSvelteQuery as n, UserPluginWithLifeCycle as o, Transformer as r, Operation$1 as s, Options$1 as t };
1382
- //# sourceMappingURL=types-CKJMdEqY.d.ts.map
1338
+ //# sourceMappingURL=types-B6RRaIal.d.cts.map
@@ -5,6 +5,7 @@ import { OpenAPIV3 } from "openapi-types";
5
5
  import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
6
6
  import BaseOas from "oas";
7
7
  import { ConsolaInstance, LogLevel } from "consola";
8
+ import { FileManager } from "@kubb/fabric-core";
8
9
 
9
10
  //#region ../oas/src/types.d.ts
10
11
  type contentType = 'application/json' | (string & {});
@@ -220,8 +221,6 @@ type Logger = {
220
221
  //#endregion
221
222
  //#region ../core/src/utils/types.d.ts
222
223
  type PossiblePromise<T$1> = Promise<T$1> | T$1;
223
- type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
224
- type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
225
224
  //#endregion
226
225
  //#region ../core/src/types.d.ts
227
226
  type InputPath = {
@@ -464,6 +463,9 @@ type ResolveNameParams = {
464
463
  };
465
464
  type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
466
465
  config: Config;
466
+ /**
467
+ * @deprecated
468
+ */
467
469
  fileManager: FileManager;
468
470
  pluginManager: PluginManager;
469
471
  addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
@@ -515,60 +517,6 @@ type Group = {
515
517
  name?: (context: GroupContext) => string;
516
518
  };
517
519
  //#endregion
518
- //#region ../core/src/FileManager.d.ts
519
- type FileMetaBase = {
520
- pluginKey?: Plugin['key'];
521
- };
522
- type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
523
- type AddIndexesProps = {
524
- type: BarrelType | false | undefined;
525
- /**
526
- * Root based on root and output.path specified in the config
527
- */
528
- root: string;
529
- /**
530
- * Output for plugin
531
- */
532
- output: {
533
- path: string;
534
- };
535
- group?: {
536
- output: string;
537
- exportAs: string;
538
- };
539
- logger?: Logger;
540
- meta?: FileMetaBase;
541
- };
542
- type WriteFilesProps = {
543
- root: Config['root'];
544
- extension?: Record<Extname, Extname | ''>;
545
- logger?: Logger;
546
- dryRun?: boolean;
547
- };
548
- declare class FileManager {
549
- #private;
550
- constructor();
551
- add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
552
- getByPath(path: Path): Promise<ResolvedFile | null>;
553
- deleteByPath(path: Path): Promise<void>;
554
- clear(): Promise<void>;
555
- getFiles(): Promise<Array<ResolvedFile>>;
556
- processFiles({
557
- dryRun,
558
- root,
559
- extension,
560
- logger
561
- }: WriteFilesProps): Promise<Array<ResolvedFile>>;
562
- getBarrelFiles({
563
- type,
564
- meta,
565
- root,
566
- output,
567
- logger
568
- }: AddIndexesProps): Promise<File[]>;
569
- static getMode(path: string | undefined | null): Mode;
570
- }
571
- //#endregion
572
520
  //#region ../core/src/PluginManager.d.ts
573
521
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
574
522
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
@@ -607,6 +555,9 @@ type GetFileProps<TOptions$1 = object> = {
607
555
  declare class PluginManager {
608
556
  #private;
609
557
  readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
558
+ /**
559
+ * @deprecated do not use from pluginManager
560
+ */
610
561
  readonly fileManager: FileManager;
611
562
  readonly events: EventEmitter<Events>;
612
563
  readonly config: Config;
@@ -715,6 +666,11 @@ declare class PluginManager {
715
666
  static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
716
667
  }
717
668
  //#endregion
669
+ //#region ../core/src/FileManager.d.ts
670
+ type FileMetaBase = {
671
+ pluginKey?: Plugin['key'];
672
+ };
673
+ //#endregion
718
674
  //#region ../plugin-oas/src/SchemaMapper.d.ts
719
675
  type SchemaKeywordMapper = {
720
676
  object: {
@@ -1379,4 +1335,4 @@ type ResolvedOptions = {
1379
1335
  type PluginSvelteQuery = PluginFactoryOptions<'plugin-svelte-query', Options$1, ResolvedOptions, never, ResolvePathOptions>;
1380
1336
  //#endregion
1381
1337
  export { OperationSchemas as a, Generator as i, PluginSvelteQuery as n, UserPluginWithLifeCycle as o, Transformer as r, Operation$1 as s, Options$1 as t };
1382
- //# sourceMappingURL=types-BZIs5xbl.d.cts.map
1338
+ //# sourceMappingURL=types-Dpz1cgTk.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-svelte-query",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "Svelte Query hooks generator plugin for Kubb, creating type-safe API client hooks from OpenAPI specifications for Svelte applications.",
5
5
  "keywords": [
6
6
  "svelte-query",
@@ -61,13 +61,13 @@
61
61
  ],
62
62
  "dependencies": {
63
63
  "remeda": "^2.32.0",
64
- "@kubb/core": "4.2.0",
65
- "@kubb/oas": "4.2.0",
66
- "@kubb/plugin-client": "4.2.0",
67
- "@kubb/plugin-oas": "4.2.0",
68
- "@kubb/plugin-ts": "4.2.0",
69
- "@kubb/plugin-zod": "4.2.0",
70
- "@kubb/react": "4.2.0"
64
+ "@kubb/core": "4.2.1",
65
+ "@kubb/oas": "4.2.1",
66
+ "@kubb/plugin-client": "4.2.1",
67
+ "@kubb/plugin-oas": "4.2.1",
68
+ "@kubb/plugin-ts": "4.2.1",
69
+ "@kubb/plugin-zod": "4.2.1",
70
+ "@kubb/react": "4.2.1"
71
71
  },
72
72
  "devDependencies": {
73
73
  "tsdown": "^0.15.9",
package/src/plugin.ts CHANGED
@@ -1,14 +1,10 @@
1
1
  import path from 'node:path'
2
-
3
- import { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'
2
+ import { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'
4
3
  import { camelCase, pascalCase } from '@kubb/core/transformers'
4
+ import type { PluginOas } from '@kubb/plugin-oas'
5
5
  import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'
6
-
7
6
  import { pluginTsName } from '@kubb/plugin-ts'
8
7
  import { pluginZodName } from '@kubb/plugin-zod'
9
-
10
- import type { Plugin } from '@kubb/core'
11
- import type { PluginOas } from '@kubb/plugin-oas'
12
8
  import { MutationKey, QueryKey } from './components'
13
9
  import { mutationGenerator, queryGenerator } from './generators'
14
10
  import type { PluginSvelteQuery } from './types.ts'
@@ -69,7 +65,7 @@ export const pluginSvelteQuery = createPlugin<PluginSvelteQuery>((options) => {
69
65
  pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),
70
66
  resolvePath(baseName, pathMode, options) {
71
67
  const root = path.resolve(this.config.root, this.config.output.path)
72
- const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))
68
+ const mode = pathMode ?? getMode(path.resolve(root, output.path))
73
69
 
74
70
  if (mode === 'single') {
75
71
  /**
@@ -124,7 +120,7 @@ export const pluginSvelteQuery = createPlugin<PluginSvelteQuery>((options) => {
124
120
 
125
121
  const oas = await swaggerPlugin.context.getOas()
126
122
  const root = path.resolve(this.config.root, this.config.output.path)
127
- const mode = FileManager.getMode(path.resolve(root, output.path))
123
+ const mode = getMode(path.resolve(root, output.path))
128
124
  const baseURL = await swaggerPlugin.context.getBaseURL()
129
125
 
130
126
  if (baseURL) {
@@ -145,7 +141,7 @@ export const pluginSvelteQuery = createPlugin<PluginSvelteQuery>((options) => {
145
141
  const files = await operationGenerator.build(...generators)
146
142
  await this.addFile(...files)
147
143
 
148
- const barrelFiles = await this.fileManager.getBarrelFiles({
144
+ const barrelFiles = await getBarrelFiles(this.fileManager.files, {
149
145
  type: output.barrelType ?? 'named',
150
146
  root,
151
147
  output,