@kubb/plugin-swr 5.0.0-alpha.30 → 5.0.0-alpha.32

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.cjs CHANGED
@@ -3,6 +3,7 @@ const require_components = require("./components-DNK5-nSp.cjs");
3
3
  const require_generators = require("./generators-DZWDtnAr.cjs");
4
4
  let node_path = require("node:path");
5
5
  node_path = require_components.__toESM(node_path);
6
+ let _kubb_ast = require("@kubb/ast");
6
7
  let _kubb_core = require("@kubb/core");
7
8
  let _kubb_plugin_client = require("@kubb/plugin-client");
8
9
  let _kubb_plugin_client_templates_clients_axios_source = require("@kubb/plugin-client/templates/clients/axios.source");
@@ -12,7 +13,7 @@ let _kubb_plugin_oas = require("@kubb/plugin-oas");
12
13
  let _kubb_plugin_ts = require("@kubb/plugin-ts");
13
14
  let _kubb_plugin_zod = require("@kubb/plugin-zod");
14
15
  //#region package.json
15
- var version = "5.0.0-alpha.30";
16
+ var version = "5.0.0-alpha.32";
16
17
  //#endregion
17
18
  //#region src/plugin.ts
18
19
  const pluginSwrName = "plugin-swr";
@@ -99,32 +100,27 @@ const pluginSwr = (0, _kubb_core.createPlugin)((options) => {
99
100
  const baseURL = await this.getBaseURL();
100
101
  if (baseURL) this.plugin.options.client.baseURL = baseURL;
101
102
  const hasClientPlugin = !!this.getPlugin(_kubb_plugin_client.pluginClientName);
102
- if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
103
+ if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile((0, _kubb_ast.createFile)({
103
104
  baseName: "fetch.ts",
104
105
  path: node_path.default.resolve(root, ".kubb/fetch.ts"),
105
- sources: [{
106
+ sources: [(0, _kubb_ast.createSource)({
106
107
  name: "fetch",
107
108
  value: this.plugin.options.client.client === "fetch" ? _kubb_plugin_client_templates_clients_fetch_source.source : _kubb_plugin_client_templates_clients_axios_source.source,
108
109
  isExportable: true,
109
110
  isIndexable: true
110
- }],
111
- imports: [],
112
- exports: []
113
- });
114
- if (!hasClientPlugin) await this.addFile({
111
+ })]
112
+ }));
113
+ if (!hasClientPlugin) await this.addFile((0, _kubb_ast.createFile)({
115
114
  baseName: "config.ts",
116
115
  path: node_path.default.resolve(root, ".kubb/config.ts"),
117
- sources: [{
116
+ sources: [(0, _kubb_ast.createSource)({
118
117
  name: "config",
119
118
  value: _kubb_plugin_client_templates_config_source.source,
120
119
  isExportable: false,
121
120
  isIndexable: false
122
- }],
123
- imports: [],
124
- exports: []
125
- });
121
+ })]
122
+ }));
126
123
  const files = await new _kubb_plugin_oas.OperationGenerator(this.plugin.options, {
127
- fabric: this.fabric,
128
124
  oas,
129
125
  driver: this.driver,
130
126
  events: this.events,
@@ -136,7 +132,7 @@ const pluginSwr = (0, _kubb_core.createPlugin)((options) => {
136
132
  mode
137
133
  }).build(...generators);
138
134
  await this.upsertFile(...files);
139
- const barrelFiles = await (0, _kubb_core.getBarrelFiles)(this.fabric.files, {
135
+ const barrelFiles = await (0, _kubb_core.getBarrelFiles)(this.driver.fileManager.files, {
140
136
  type: output.barrelType ?? "named",
141
137
  root,
142
138
  output,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["MutationKey","QueryKey","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","path","camelCase","pascalCase","pluginClientName","fetchClientSource","axiosClientSource","configSource","OperationGenerator"],"sources":["../package.json","../src/plugin.ts"],"sourcesContent":["","import path from 'node:path'\nimport { camelCase, pascalCase } from '@internals/utils'\nimport { createPlugin, getBarrelFiles, type UserGroup } from '@kubb/core'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'\nimport { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'\nimport { source as configSource } from '@kubb/plugin-client/templates/config.source'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { version } from '../package.json'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n query,\n mutation,\n client,\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n paramsCasing,\n contentType,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginSwrName,\n version,\n options: {\n output,\n client: {\n bundle: client?.bundle,\n baseURL: client?.baseURL,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n importPath: clientImportPath,\n dataReturnType: client?.dataReturnType ?? 'data',\n paramsCasing,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n importPath: 'swr',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n importPath: 'swr/mutation',\n methods: ['post', 'put', 'delete', 'patch'],\n ...mutation,\n },\n parser,\n paramsType,\n pathParamsType,\n paramsCasing,\n group,\n exclude,\n include,\n override,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = this.root\n const mode = pathMode ?? this.getMode(output)\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: UserGroup['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\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 root = this.root\n const mode = this.getMode(output)\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.getPlugin(pluginClientName)\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.upsertFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: this.plugin.options.client.client === 'fetch' ? fetchClientSource : axiosClientSource,\n isExportable: true,\n isIndexable: true,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n if (!hasClientPlugin) {\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: configSource,\n isExportable: false,\n isIndexable: false,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n driver: this.driver,\n events: this.events,\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.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;ACeA,MAAa,gBAAgB;AAE7B,MAAa,aAAA,GAAA,WAAA,eAAqC,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,eAAe,EAAE,EACjB,OACA,UACA,QACA,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,cAAcA,mBAAAA,YAAY,gBAC1B,WAAWC,mBAAAA,SAAS,gBACpB,aAAa,CAACC,mBAAAA,gBAAgBC,mBAAAA,kBAAkB,CAAC,OAAO,QAAQ,EAChE,cACA,gBACE;CAEJ,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,mBAAmB,QAAQ,eAAe,CAAC,QAAQ,SAAS,+BAA+B,eAAe,KAAA;AAEhH,QAAO;EACL,MAAM;EACN;EACA,SAAS;GACP;GACA,QAAQ;IACN,QAAQ,QAAQ;IAChB,SAAS,QAAQ;IACjB,QAAQ;IACR,YAAY,QAAQ,cAAc;IAClC,YAAY;IACZ,gBAAgB,QAAQ,kBAAkB;IAC1C;IACD;GACD;GACA,OACE,UAAU,QACN,QACA;IACE,YAAY;IACZ,SAAS,CAAC,MAAM;IAChB,GAAG;IACJ;GACP;GACA,UACE,aAAa,QACT,QACA;IACE,YAAY;IACZ,SAAS;KAAC;KAAQ;KAAO;KAAU;KAAQ;IAC3C,GAAG;IACJ;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD;EACD,KAAK;GAACC,iBAAAA;GAAeC,gBAAAA;GAAc,WAAW,QAAQC,iBAAAA,gBAAgB,KAAA;GAAU,CAAC,OAAO,QAAQ;EAChG,YAAY,UAAU,UAAU,SAAS;GACvC,MAAM,OAA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AAAA,QAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,CACP;KACE,MAAM;KACN,OAAO,KAAK,OAAO,QAAQ,OAAO,WAAW,UAAUI,mDAAAA,SAAoBC,mDAAAA;KAC3E,cAAc;KACd,aAAa;KACd,CACF;IACD,SAAS,EAAE;IACX,SAAS,EAAE;IACZ,CAAC;AAGJ,OAAI,CAAC,gBACH,OAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAML,UAAAA,QAAK,QAAQ,MAAM,kBAAkB;IAC3C,SAAS,CACP;KACE,MAAM;KACN,OAAOM,4CAAAA;KACP,cAAc;KACd,aAAa;KACd,CACF;IACD,SAAS,EAAE;IACX,SAAS,EAAE;IACZ,CAAC;GAgBJ,MAAM,QAAQ,MAba,IAAIC,iBAAAA,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,OAAA,GAAA,WAAA,gBAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
1
+ {"version":3,"file":"index.cjs","names":["MutationKey","QueryKey","queryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","path","camelCase","pascalCase","pluginClientName","fetchClientSource","axiosClientSource","configSource","OperationGenerator"],"sources":["../package.json","../src/plugin.ts"],"sourcesContent":["","import path from 'node:path'\nimport { camelCase, pascalCase } from '@internals/utils'\nimport { createFile, createSource } from '@kubb/ast'\nimport type { FileNode } from '@kubb/ast/types'\nimport { createPlugin, getBarrelFiles, type UserGroup } from '@kubb/core'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'\nimport { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'\nimport { source as configSource } from '@kubb/plugin-client/templates/config.source'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { version } from '../package.json'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n query,\n mutation,\n client,\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n paramsCasing,\n contentType,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginSwrName,\n version,\n options: {\n output,\n client: {\n bundle: client?.bundle,\n baseURL: client?.baseURL,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n importPath: clientImportPath,\n dataReturnType: client?.dataReturnType ?? 'data',\n paramsCasing,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n importPath: 'swr',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n importPath: 'swr/mutation',\n methods: ['post', 'put', 'delete', 'patch'],\n ...mutation,\n },\n parser,\n paramsType,\n pathParamsType,\n paramsCasing,\n group,\n exclude,\n include,\n override,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = this.root\n const mode = pathMode ?? this.getMode(output)\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: UserGroup['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\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 root = this.root\n const mode = this.getMode(output)\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.getPlugin(pluginClientName)\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.upsertFile(\n createFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n createSource({\n name: 'fetch',\n value: this.plugin.options.client.client === 'fetch' ? fetchClientSource : axiosClientSource,\n isExportable: true,\n isIndexable: true,\n }),\n ],\n }),\n )\n }\n\n if (!hasClientPlugin) {\n await this.addFile(\n createFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n createSource({\n name: 'config',\n value: configSource,\n isExportable: false,\n isIndexable: false,\n }),\n ],\n }),\n )\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n driver: this.driver,\n events: this.events,\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.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.driver.fileManager.files as unknown as FileNode[], {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;ACiBA,MAAa,gBAAgB;AAE7B,MAAa,aAAA,GAAA,WAAA,eAAqC,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,eAAe,EAAE,EACjB,OACA,UACA,QACA,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,cAAcA,mBAAAA,YAAY,gBAC1B,WAAWC,mBAAAA,SAAS,gBACpB,aAAa,CAACC,mBAAAA,gBAAgBC,mBAAAA,kBAAkB,CAAC,OAAO,QAAQ,EAChE,cACA,gBACE;CAEJ,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,mBAAmB,QAAQ,eAAe,CAAC,QAAQ,SAAS,+BAA+B,eAAe,KAAA;AAEhH,QAAO;EACL,MAAM;EACN;EACA,SAAS;GACP;GACA,QAAQ;IACN,QAAQ,QAAQ;IAChB,SAAS,QAAQ;IACjB,QAAQ;IACR,YAAY,QAAQ,cAAc;IAClC,YAAY;IACZ,gBAAgB,QAAQ,kBAAkB;IAC1C;IACD;GACD;GACA,OACE,UAAU,QACN,QACA;IACE,YAAY;IACZ,SAAS,CAAC,MAAM;IAChB,GAAG;IACJ;GACP;GACA,UACE,aAAa,QACT,QACA;IACE,YAAY;IACZ,SAAS;KAAC;KAAQ;KAAO;KAAU;KAAQ;IAC3C,GAAG;IACJ;G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AAM,kBAAkB,CAAC,CAAC,KAAK,UAAUC,oBAAAA,iBAAiB;AAE1D,OAAI,KAAK,OAAO,QAAQ,OAAO,UAAU,CAAC,mBAAmB,CAAC,KAAK,OAAO,QAAQ,OAAO,WAEvF,OAAM,KAAK,YAAA,GAAA,UAAA,YACE;IACT,UAAU;IACV,MAAMH,UAAAA,QAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,EAAA,GAAA,UAAA,cACM;KACX,MAAM;KACN,OAAO,KAAK,OAAO,QAAQ,OAAO,WAAW,UAAUI,mDAAAA,SAAoBC,mDAAAA;KAC3E,cAAc;KACd,aAAa;KACd,CAAC,CACH;IACF,CAAC,CACH;AAGH,OAAI,CAAC,gBACH,OAAM,KAAK,SAAA,GAAA,UAAA,YACE;IACT,UAAU;IACV,MAAML,UAAAA,QAAK,QAAQ,MAAM,kBAAkB;IAC3C,SAAS,EAAA,GAAA,UAAA,cACM;KACX,MAAM;KACN,OAAOM,4CAAAA;KACP,cAAc;KACd,aAAa;KACd,CAAC,CACH;IACF,CAAC,CACH;GAeH,MAAM,QAAQ,MAZa,IAAIC,iBAAAA,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,OAAA,GAAA,WAAA,gBAAqB,KAAK,OAAO,YAAY,OAAgC;IAC/F,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import "./chunk--u3MIqq1.js";
2
2
  import { a as MutationKey, i as QueryKey, o as camelCase, s as pascalCase } from "./components-Dx3TpD0e.js";
3
3
  import { n as mutationGenerator, t as queryGenerator } from "./generators-DgOGoKCg.js";
4
4
  import path from "node:path";
5
+ import { createFile, createSource } from "@kubb/ast";
5
6
  import { createPlugin, getBarrelFiles } from "@kubb/core";
6
7
  import { pluginClientName } from "@kubb/plugin-client";
7
8
  import { source } from "@kubb/plugin-client/templates/clients/axios.source";
@@ -11,7 +12,7 @@ import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
11
12
  import { pluginTsName } from "@kubb/plugin-ts";
12
13
  import { pluginZodName } from "@kubb/plugin-zod";
13
14
  //#region package.json
14
- var version = "5.0.0-alpha.30";
15
+ var version = "5.0.0-alpha.32";
15
16
  //#endregion
16
17
  //#region src/plugin.ts
17
18
  const pluginSwrName = "plugin-swr";
@@ -98,32 +99,27 @@ const pluginSwr = createPlugin((options) => {
98
99
  const baseURL = await this.getBaseURL();
99
100
  if (baseURL) this.plugin.options.client.baseURL = baseURL;
100
101
  const hasClientPlugin = !!this.getPlugin(pluginClientName);
101
- if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
102
+ if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile(createFile({
102
103
  baseName: "fetch.ts",
103
104
  path: path.resolve(root, ".kubb/fetch.ts"),
104
- sources: [{
105
+ sources: [createSource({
105
106
  name: "fetch",
106
107
  value: this.plugin.options.client.client === "fetch" ? source$1 : source,
107
108
  isExportable: true,
108
109
  isIndexable: true
109
- }],
110
- imports: [],
111
- exports: []
112
- });
113
- if (!hasClientPlugin) await this.addFile({
110
+ })]
111
+ }));
112
+ if (!hasClientPlugin) await this.addFile(createFile({
114
113
  baseName: "config.ts",
115
114
  path: path.resolve(root, ".kubb/config.ts"),
116
- sources: [{
115
+ sources: [createSource({
117
116
  name: "config",
118
117
  value: source$2,
119
118
  isExportable: false,
120
119
  isIndexable: false
121
- }],
122
- imports: [],
123
- exports: []
124
- });
120
+ })]
121
+ }));
125
122
  const files = await new OperationGenerator(this.plugin.options, {
126
- fabric: this.fabric,
127
123
  oas,
128
124
  driver: this.driver,
129
125
  events: this.events,
@@ -135,7 +131,7 @@ const pluginSwr = createPlugin((options) => {
135
131
  mode
136
132
  }).build(...generators);
137
133
  await this.upsertFile(...files);
138
- const barrelFiles = await getBarrelFiles(this.fabric.files, {
134
+ const barrelFiles = await getBarrelFiles(this.driver.fileManager.files, {
139
135
  type: output.barrelType ?? "named",
140
136
  root,
141
137
  output,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["fetchClientSource","axiosClientSource","configSource"],"sources":["../package.json","../src/plugin.ts"],"sourcesContent":["","import path from 'node:path'\nimport { camelCase, pascalCase } from '@internals/utils'\nimport { createPlugin, getBarrelFiles, type UserGroup } from '@kubb/core'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'\nimport { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'\nimport { source as configSource } from '@kubb/plugin-client/templates/config.source'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { version } from '../package.json'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n query,\n mutation,\n client,\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n paramsCasing,\n contentType,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginSwrName,\n version,\n options: {\n output,\n client: {\n bundle: client?.bundle,\n baseURL: client?.baseURL,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n importPath: clientImportPath,\n dataReturnType: client?.dataReturnType ?? 'data',\n paramsCasing,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n importPath: 'swr',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n importPath: 'swr/mutation',\n methods: ['post', 'put', 'delete', 'patch'],\n ...mutation,\n },\n parser,\n paramsType,\n pathParamsType,\n paramsCasing,\n group,\n exclude,\n include,\n override,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = this.root\n const mode = pathMode ?? this.getMode(output)\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: UserGroup['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\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 root = this.root\n const mode = this.getMode(output)\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.getPlugin(pluginClientName)\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.upsertFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: this.plugin.options.client.client === 'fetch' ? fetchClientSource : axiosClientSource,\n isExportable: true,\n isIndexable: true,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n if (!hasClientPlugin) {\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: configSource,\n isExportable: false,\n isIndexable: false,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n driver: this.driver,\n events: this.events,\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.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;ACeA,MAAa,gBAAgB;AAE7B,MAAa,YAAY,cAAyB,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,eAAe,EAAE,EACjB,OACA,UACA,QACA,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,cAAc,YAAY,gBAC1B,WAAW,SAAS,gBACpB,aAAa,CAAC,gBAAgB,kBAAkB,CAAC,OAAO,QAAQ,EAChE,cACA,gBACE;CAEJ,MAAM,aAAa,QAAQ,UAA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AO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
1
+ {"version":3,"file":"index.js","names":["fetchClientSource","axiosClientSource","configSource"],"sources":["../package.json","../src/plugin.ts"],"sourcesContent":["","import path from 'node:path'\nimport { camelCase, pascalCase } from '@internals/utils'\nimport { createFile, createSource } from '@kubb/ast'\nimport type { FileNode } from '@kubb/ast/types'\nimport { createPlugin, getBarrelFiles, type UserGroup } from '@kubb/core'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'\nimport { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'\nimport { source as configSource } from '@kubb/plugin-client/templates/config.source'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { version } from '../package.json'\nimport { MutationKey, QueryKey } from './components'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = createPlugin<PluginSwr>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n transformers = {},\n query,\n mutation,\n client,\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, mutationGenerator].filter(Boolean),\n paramsCasing,\n contentType,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginSwrName,\n version,\n options: {\n output,\n client: {\n bundle: client?.bundle,\n baseURL: client?.baseURL,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n importPath: clientImportPath,\n dataReturnType: client?.dataReturnType ?? 'data',\n paramsCasing,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n importPath: 'swr',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n importPath: 'swr/mutation',\n methods: ['post', 'put', 'delete', 'patch'],\n ...mutation,\n },\n parser,\n paramsType,\n pathParamsType,\n paramsCasing,\n group,\n exclude,\n include,\n override,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = this.root\n const mode = pathMode ?? this.getMode(output)\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: UserGroup['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\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 root = this.root\n const mode = this.getMode(output)\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.getPlugin(pluginClientName)\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.upsertFile(\n createFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n createSource({\n name: 'fetch',\n value: this.plugin.options.client.client === 'fetch' ? fetchClientSource : axiosClientSource,\n isExportable: true,\n isIndexable: true,\n }),\n ],\n }),\n )\n }\n\n if (!hasClientPlugin) {\n await this.addFile(\n createFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n createSource({\n name: 'config',\n value: configSource,\n isExportable: false,\n isIndexable: false,\n }),\n ],\n }),\n )\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n driver: this.driver,\n events: this.events,\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.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.driver.fileManager.files as unknown as FileNode[], {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;ACiBA,MAAa,gBAAgB;AAE7B,MAAa,YAAY,cAAyB,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,eAAe,EAAE,EACjB,OACA,UACA,QACA,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,cAAc,YAAY,gBAC1B,WAAW,SAAS,gBACpB,aAAa,CAAC,gBAAgB,kBAAkB,CAAC,OAAO,QAAQ,EAChE,cACA,gBACE;CAEJ,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,mBAAmB,QAAQ,eAAe,CAAC,QAAQ,SAAS,+BAA+B,eAAe,KAAA;AAEhH,QAAO;EACL,MAAM;EACN;EACA,SAA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@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-swr",
3
- "version": "5.0.0-alpha.30",
3
+ "version": "5.0.0-alpha.32",
4
4
  "description": "SWR hooks generator plugin for Kubb, creating type-safe data fetching hooks from OpenAPI specifications for React and Next.js applications.",
5
5
  "keywords": [
6
6
  "swr",
@@ -74,18 +74,17 @@
74
74
  }
75
75
  ],
76
76
  "dependencies": {
77
- "@kubb/fabric-core": "0.15.1",
78
77
  "@kubb/react-fabric": "0.15.1",
79
78
  "remeda": "^2.33.7",
80
- "@kubb/core": "5.0.0-alpha.30",
81
- "@kubb/oas": "5.0.0-alpha.30",
82
- "@kubb/plugin-client": "5.0.0-alpha.30",
83
- "@kubb/plugin-oas": "5.0.0-alpha.30",
84
- "@kubb/plugin-ts": "5.0.0-alpha.30",
85
- "@kubb/plugin-zod": "5.0.0-alpha.30"
79
+ "@kubb/ast": "5.0.0-alpha.32",
80
+ "@kubb/oas": "5.0.0-alpha.32",
81
+ "@kubb/core": "5.0.0-alpha.32",
82
+ "@kubb/plugin-client": "5.0.0-alpha.32",
83
+ "@kubb/plugin-oas": "5.0.0-alpha.32",
84
+ "@kubb/plugin-ts": "5.0.0-alpha.32",
85
+ "@kubb/plugin-zod": "5.0.0-alpha.32"
86
86
  },
87
87
  "peerDependencies": {
88
- "@kubb/fabric-core": "0.15.1",
89
88
  "@kubb/react-fabric": "0.15.1"
90
89
  },
91
90
  "engines": {
package/src/plugin.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import path from 'node:path'
2
2
  import { camelCase, pascalCase } from '@internals/utils'
3
+ import { createFile, createSource } from '@kubb/ast'
4
+ import type { FileNode } from '@kubb/ast/types'
3
5
  import { createPlugin, getBarrelFiles, type UserGroup } from '@kubb/core'
4
6
  import { pluginClientName } from '@kubb/plugin-client'
5
7
  import { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'
@@ -148,41 +150,40 @@ export const pluginSwr = createPlugin<PluginSwr>((options) => {
148
150
 
149
151
  if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {
150
152
  // pre add bundled fetch
151
- await this.upsertFile({
152
- baseName: 'fetch.ts',
153
- path: path.resolve(root, '.kubb/fetch.ts'),
154
- sources: [
155
- {
156
- name: 'fetch',
157
- value: this.plugin.options.client.client === 'fetch' ? fetchClientSource : axiosClientSource,
158
- isExportable: true,
159
- isIndexable: true,
160
- },
161
- ],
162
- imports: [],
163
- exports: [],
164
- })
153
+ await this.upsertFile(
154
+ createFile({
155
+ baseName: 'fetch.ts',
156
+ path: path.resolve(root, '.kubb/fetch.ts'),
157
+ sources: [
158
+ createSource({
159
+ name: 'fetch',
160
+ value: this.plugin.options.client.client === 'fetch' ? fetchClientSource : axiosClientSource,
161
+ isExportable: true,
162
+ isIndexable: true,
163
+ }),
164
+ ],
165
+ }),
166
+ )
165
167
  }
166
168
 
167
169
  if (!hasClientPlugin) {
168
- await this.addFile({
169
- baseName: 'config.ts',
170
- path: path.resolve(root, '.kubb/config.ts'),
171
- sources: [
172
- {
173
- name: 'config',
174
- value: configSource,
175
- isExportable: false,
176
- isIndexable: false,
177
- },
178
- ],
179
- imports: [],
180
- exports: [],
181
- })
170
+ await this.addFile(
171
+ createFile({
172
+ baseName: 'config.ts',
173
+ path: path.resolve(root, '.kubb/config.ts'),
174
+ sources: [
175
+ createSource({
176
+ name: 'config',
177
+ value: configSource,
178
+ isExportable: false,
179
+ isIndexable: false,
180
+ }),
181
+ ],
182
+ }),
183
+ )
182
184
  }
183
185
 
184
186
  const operationGenerator = new OperationGenerator(this.plugin.options, {
185
- fabric: this.fabric,
186
187
  oas,
187
188
  driver: this.driver,
188
189
  events: this.events,
@@ -197,7 +198,7 @@ export const pluginSwr = createPlugin<PluginSwr>((options) => {
197
198
  const files = await operationGenerator.build(...generators)
198
199
  await this.upsertFile(...files)
199
200
 
200
- const barrelFiles = await getBarrelFiles(this.fabric.files, {
201
+ const barrelFiles = await getBarrelFiles(this.driver.fileManager.files as unknown as FileNode[], {
201
202
  type: output.barrelType ?? 'named',
202
203
  root,
203
204
  output,