@kubb/plugin-client 4.2.0 → 4.2.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/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/{types-sBB-Ek3Z.d.ts → types-BfP2gAzn.d.cts} +13 -57
- package/dist/{types-BO1JodPd.d.cts → types-DIxcknRD.d.ts} +13 -57
- package/package.json +7 -7
- package/src/plugin.ts +5 -8
package/dist/components.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as types_d_exports, c as __reExport, i as OperationSchemas, n as PluginClient, s as Operation } from "./types-
|
|
1
|
+
import { a as types_d_exports, c as __reExport, i as OperationSchemas, n as PluginClient, s as Operation } from "./types-BfP2gAzn.cjs";
|
|
2
2
|
|
|
3
3
|
//#region ../react/src/index.d.ts
|
|
4
4
|
|
package/dist/components.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as types_d_exports, c as __reExport, i as OperationSchemas, n as PluginClient, s as Operation } from "./types-
|
|
1
|
+
import { a as types_d_exports, c as __reExport, i as OperationSchemas, n as PluginClient, s as Operation } from "./types-DIxcknRD.js";
|
|
2
2
|
|
|
3
3
|
//#region ../react/src/index.d.ts
|
|
4
4
|
|
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@ const pluginClient = (0, __kubb_core.createPlugin)((options) => {
|
|
|
40
40
|
pre: [__kubb_plugin_oas.pluginOasName, parser === "zod" ? __kubb_plugin_zod.pluginZodName : void 0].filter(Boolean),
|
|
41
41
|
resolvePath(baseName, pathMode, options$1) {
|
|
42
42
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
43
|
-
if ((pathMode ?? __kubb_core.
|
|
43
|
+
if ((pathMode ?? (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
|
|
44
44
|
/**
|
|
45
45
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
46
46
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -64,7 +64,7 @@ const pluginClient = (0, __kubb_core.createPlugin)((options) => {
|
|
|
64
64
|
const [swaggerPlugin] = __kubb_core.PluginManager.getDependedPlugins(this.plugins, [__kubb_plugin_oas.pluginOasName]);
|
|
65
65
|
const oas = await swaggerPlugin.context.getOas();
|
|
66
66
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
67
|
-
const mode = __kubb_core.
|
|
67
|
+
const mode = (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path));
|
|
68
68
|
const baseURL$1 = await swaggerPlugin.context.getBaseURL();
|
|
69
69
|
const files = await new __kubb_plugin_oas.OperationGenerator(baseURL$1 ? {
|
|
70
70
|
...this.plugin.options,
|
|
@@ -80,7 +80,7 @@ const pluginClient = (0, __kubb_core.createPlugin)((options) => {
|
|
|
80
80
|
mode
|
|
81
81
|
}).build(...generators);
|
|
82
82
|
await this.addFile(...files);
|
|
83
|
-
const barrelFiles = await this.fileManager.
|
|
83
|
+
const barrelFiles = await (0, __kubb_core.getBarrelFiles)(this.fileManager.files, {
|
|
84
84
|
type: output.barrelType ?? "named",
|
|
85
85
|
root,
|
|
86
86
|
output,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["clientGenerator","groupedClientGenerator","operationsGenerator","pluginOasName","pluginZodName","path","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["clientGenerator","groupedClientGenerator","operationsGenerator","pluginOasName","pluginZodName","path","options","groupName: Group['name']","PluginManager","baseURL","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 } from '@kubb/core/transformers'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { operationsGenerator } from './generators'\nimport { clientGenerator } from './generators/clientGenerator.tsx'\nimport { groupedClientGenerator } from './generators/groupedClientGenerator.tsx'\nimport type { PluginClient } from './types.ts'\n\nexport const pluginClientName = 'plugin-client' satisfies PluginClient['name']\n\nexport const pluginClient = createPlugin<PluginClient>((options) => {\n const {\n output = { path: 'clients', barrelType: 'named' },\n group,\n urlType = false,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n operations = false,\n baseURL,\n paramsCasing,\n generators = [clientGenerator, group ? groupedClientGenerator : undefined, operations ? operationsGenerator : undefined].filter(Boolean),\n parser = 'client',\n client = 'axios',\n importPath = client === 'fetch' ? '@kubb/plugin-client/clients/fetch' : '@kubb/plugin-client/clients/axios',\n contentType,\n } = options\n\n return {\n name: pluginClientName,\n options: {\n output,\n group,\n parser,\n dataReturnType,\n importPath,\n paramsType,\n paramsCasing,\n pathParamsType,\n baseURL,\n urlType,\n },\n pre: [pluginOasName, 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 const resolvedName = camelCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(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 const operationGenerator = new OperationGenerator(\n baseURL\n ? {\n ...this.plugin.options,\n baseURL,\n }\n : this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(...generators)\n\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,mBAAmB;AAEhC,MAAa,8CAA2C,YAAY;CAClE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,UAAU,OACV,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,iBAAiB,QACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,aAAa,OACb,SACA,cACA,aAAa;EAACA;EAAiB,QAAQC,4CAAyB;EAAW,aAAaC,yCAA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,OAAO,OAAO,KAAK;GACpE,MAAM,gCAAeA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAMI,YAAU,MAAM,cAAc,QAAQ,YAAY;GAqBxD,MAAM,QAAQ,MAnBa,IAAIC,qCAC7BD,YACI;IACE,GAAG,KAAK,OAAO;IACf;IACD,GACD,KAAK,OAAO,SAChB;IACE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CACF,CAEsC,MAAM,GAAG,WAAW;AAE3D,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 PluginClient, o as UserPluginWithLifeCycle, t as Options } from "./types-
|
|
1
|
+
import { n as PluginClient, o as UserPluginWithLifeCycle, t as Options } from "./types-BfP2gAzn.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginClientName = "plugin-client";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as PluginClient, o as UserPluginWithLifeCycle, t as Options } from "./types-
|
|
1
|
+
import { n as PluginClient, o as UserPluginWithLifeCycle, t as Options } from "./types-DIxcknRD.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginClientName = "plugin-client";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./Operations-ktPlsW1u.js";
|
|
2
2
|
import { n as operationsGenerator, r as clientGenerator, t as groupedClientGenerator } from "./generators-BqXV2IXC.js";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { PluginManager, createPlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
5
5
|
import { camelCase } from "@kubb/core/transformers";
|
|
6
6
|
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
7
7
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
@@ -34,7 +34,7 @@ const pluginClient = createPlugin((options) => {
|
|
|
34
34
|
pre: [pluginOasName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
|
|
35
35
|
resolvePath(baseName, pathMode, options$1) {
|
|
36
36
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
37
|
-
if ((pathMode ??
|
|
37
|
+
if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
|
|
38
38
|
/**
|
|
39
39
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
40
40
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -58,7 +58,7 @@ const pluginClient = createPlugin((options) => {
|
|
|
58
58
|
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
59
59
|
const oas = await swaggerPlugin.context.getOas();
|
|
60
60
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
61
|
-
const mode =
|
|
61
|
+
const mode = getMode(path.resolve(root, output.path));
|
|
62
62
|
const baseURL$1 = await swaggerPlugin.context.getBaseURL();
|
|
63
63
|
const files = await new OperationGenerator(baseURL$1 ? {
|
|
64
64
|
...this.plugin.options,
|
|
@@ -74,7 +74,7 @@ const pluginClient = createPlugin((options) => {
|
|
|
74
74
|
mode
|
|
75
75
|
}).build(...generators);
|
|
76
76
|
await this.addFile(...files);
|
|
77
|
-
const barrelFiles = await this.fileManager.
|
|
77
|
+
const barrelFiles = await getBarrelFiles(this.fileManager.files, {
|
|
78
78
|
type: output.barrelType ?? "named",
|
|
79
79
|
root,
|
|
80
80
|
output,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["options","groupName: Group['name']","baseURL"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']","baseURL"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { operationsGenerator } from './generators'\nimport { clientGenerator } from './generators/clientGenerator.tsx'\nimport { groupedClientGenerator } from './generators/groupedClientGenerator.tsx'\nimport type { PluginClient } from './types.ts'\n\nexport const pluginClientName = 'plugin-client' satisfies PluginClient['name']\n\nexport const pluginClient = createPlugin<PluginClient>((options) => {\n const {\n output = { path: 'clients', barrelType: 'named' },\n group,\n urlType = false,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n operations = false,\n baseURL,\n paramsCasing,\n generators = [clientGenerator, group ? groupedClientGenerator : undefined, operations ? operationsGenerator : undefined].filter(Boolean),\n parser = 'client',\n client = 'axios',\n importPath = client === 'fetch' ? '@kubb/plugin-client/clients/fetch' : '@kubb/plugin-client/clients/axios',\n contentType,\n } = options\n\n return {\n name: pluginClientName,\n options: {\n output,\n group,\n parser,\n dataReturnType,\n importPath,\n paramsType,\n paramsCasing,\n pathParamsType,\n baseURL,\n urlType,\n },\n pre: [pluginOasName, 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 const resolvedName = camelCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(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 const operationGenerator = new OperationGenerator(\n baseURL\n ? {\n ...this.plugin.options,\n baseURL,\n }\n : this.plugin.options,\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(...generators)\n\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,mBAAmB;AAEhC,MAAa,eAAe,cAA4B,YAAY;CAClE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,UAAU,OACV,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAA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iD,cAAc,mBAAyC,KAAK,SAAS,CAAC,cAAc,CAAC;GAE7I,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,MAAME,YAAU,MAAM,cAAc,QAAQ,YAAY;GAqBxD,MAAM,QAAQ,MAnBa,IAAI,mBAC7BA,YACI;IACE,GAAG,KAAK,OAAO;IACf;IACD,GACD,KAAK,OAAO,SAChB;IACE;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CACF,CAEsC,MAAM,GAAG,WAAW;AAE3D,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 rolldown:runtime
|
|
10
11
|
//#endregion
|
|
@@ -222,8 +223,6 @@ type Logger = {
|
|
|
222
223
|
//#endregion
|
|
223
224
|
//#region ../core/src/utils/types.d.ts
|
|
224
225
|
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
225
|
-
type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
|
|
226
|
-
type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
|
|
227
226
|
//#endregion
|
|
228
227
|
//#region ../core/src/types.d.ts
|
|
229
228
|
type InputPath = {
|
|
@@ -466,6 +465,9 @@ type ResolveNameParams = {
|
|
|
466
465
|
};
|
|
467
466
|
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
468
467
|
config: Config;
|
|
468
|
+
/**
|
|
469
|
+
* @deprecated
|
|
470
|
+
*/
|
|
469
471
|
fileManager: FileManager;
|
|
470
472
|
pluginManager: PluginManager;
|
|
471
473
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
@@ -517,60 +519,6 @@ type Group = {
|
|
|
517
519
|
name?: (context: GroupContext) => string;
|
|
518
520
|
};
|
|
519
521
|
//#endregion
|
|
520
|
-
//#region ../core/src/FileManager.d.ts
|
|
521
|
-
type FileMetaBase = {
|
|
522
|
-
pluginKey?: Plugin['key'];
|
|
523
|
-
};
|
|
524
|
-
type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
525
|
-
type AddIndexesProps = {
|
|
526
|
-
type: BarrelType | false | undefined;
|
|
527
|
-
/**
|
|
528
|
-
* Root based on root and output.path specified in the config
|
|
529
|
-
*/
|
|
530
|
-
root: string;
|
|
531
|
-
/**
|
|
532
|
-
* Output for plugin
|
|
533
|
-
*/
|
|
534
|
-
output: {
|
|
535
|
-
path: string;
|
|
536
|
-
};
|
|
537
|
-
group?: {
|
|
538
|
-
output: string;
|
|
539
|
-
exportAs: string;
|
|
540
|
-
};
|
|
541
|
-
logger?: Logger;
|
|
542
|
-
meta?: FileMetaBase;
|
|
543
|
-
};
|
|
544
|
-
type WriteFilesProps = {
|
|
545
|
-
root: Config['root'];
|
|
546
|
-
extension?: Record<Extname, Extname | ''>;
|
|
547
|
-
logger?: Logger;
|
|
548
|
-
dryRun?: boolean;
|
|
549
|
-
};
|
|
550
|
-
declare class FileManager {
|
|
551
|
-
#private;
|
|
552
|
-
constructor();
|
|
553
|
-
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
554
|
-
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
555
|
-
deleteByPath(path: Path): Promise<void>;
|
|
556
|
-
clear(): Promise<void>;
|
|
557
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
558
|
-
processFiles({
|
|
559
|
-
dryRun,
|
|
560
|
-
root,
|
|
561
|
-
extension,
|
|
562
|
-
logger
|
|
563
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
564
|
-
getBarrelFiles({
|
|
565
|
-
type,
|
|
566
|
-
meta,
|
|
567
|
-
root,
|
|
568
|
-
output,
|
|
569
|
-
logger
|
|
570
|
-
}: AddIndexesProps): Promise<File[]>;
|
|
571
|
-
static getMode(path: string | undefined | null): Mode;
|
|
572
|
-
}
|
|
573
|
-
//#endregion
|
|
574
522
|
//#region ../core/src/PluginManager.d.ts
|
|
575
523
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
576
524
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
@@ -609,6 +557,9 @@ type GetFileProps<TOptions$1 = object> = {
|
|
|
609
557
|
declare class PluginManager {
|
|
610
558
|
#private;
|
|
611
559
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
560
|
+
/**
|
|
561
|
+
* @deprecated do not use from pluginManager
|
|
562
|
+
*/
|
|
612
563
|
readonly fileManager: FileManager;
|
|
613
564
|
readonly events: EventEmitter<Events>;
|
|
614
565
|
readonly config: Config;
|
|
@@ -716,6 +667,11 @@ declare class PluginManager {
|
|
|
716
667
|
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = (T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>])>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
|
|
717
668
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
718
669
|
}
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region ../core/src/FileManager.d.ts
|
|
672
|
+
type FileMetaBase = {
|
|
673
|
+
pluginKey?: Plugin['key'];
|
|
674
|
+
};
|
|
719
675
|
import * as import___kubb_react_fabric_types from "@kubb/react-fabric/types";
|
|
720
676
|
//#endregion
|
|
721
677
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
@@ -1247,4 +1203,4 @@ type ResolvedOptions = {
|
|
|
1247
1203
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1248
1204
|
//#endregion
|
|
1249
1205
|
export { types_d_exports$1 as a, __reExport as c, OperationSchemas as i, PluginClient as n, UserPluginWithLifeCycle as o, Generator as r, Operation$1 as s, Options$1 as t };
|
|
1250
|
-
//# sourceMappingURL=types-
|
|
1206
|
+
//# sourceMappingURL=types-BfP2gAzn.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 rolldown:runtime
|
|
10
11
|
//#endregion
|
|
@@ -222,8 +223,6 @@ type Logger = {
|
|
|
222
223
|
//#endregion
|
|
223
224
|
//#region ../core/src/utils/types.d.ts
|
|
224
225
|
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
225
|
-
type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
|
|
226
|
-
type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
|
|
227
226
|
//#endregion
|
|
228
227
|
//#region ../core/src/types.d.ts
|
|
229
228
|
type InputPath = {
|
|
@@ -466,6 +465,9 @@ type ResolveNameParams = {
|
|
|
466
465
|
};
|
|
467
466
|
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
468
467
|
config: Config;
|
|
468
|
+
/**
|
|
469
|
+
* @deprecated
|
|
470
|
+
*/
|
|
469
471
|
fileManager: FileManager;
|
|
470
472
|
pluginManager: PluginManager;
|
|
471
473
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
@@ -517,60 +519,6 @@ type Group = {
|
|
|
517
519
|
name?: (context: GroupContext) => string;
|
|
518
520
|
};
|
|
519
521
|
//#endregion
|
|
520
|
-
//#region ../core/src/FileManager.d.ts
|
|
521
|
-
type FileMetaBase = {
|
|
522
|
-
pluginKey?: Plugin['key'];
|
|
523
|
-
};
|
|
524
|
-
type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
525
|
-
type AddIndexesProps = {
|
|
526
|
-
type: BarrelType | false | undefined;
|
|
527
|
-
/**
|
|
528
|
-
* Root based on root and output.path specified in the config
|
|
529
|
-
*/
|
|
530
|
-
root: string;
|
|
531
|
-
/**
|
|
532
|
-
* Output for plugin
|
|
533
|
-
*/
|
|
534
|
-
output: {
|
|
535
|
-
path: string;
|
|
536
|
-
};
|
|
537
|
-
group?: {
|
|
538
|
-
output: string;
|
|
539
|
-
exportAs: string;
|
|
540
|
-
};
|
|
541
|
-
logger?: Logger;
|
|
542
|
-
meta?: FileMetaBase;
|
|
543
|
-
};
|
|
544
|
-
type WriteFilesProps = {
|
|
545
|
-
root: Config['root'];
|
|
546
|
-
extension?: Record<Extname, Extname | ''>;
|
|
547
|
-
logger?: Logger;
|
|
548
|
-
dryRun?: boolean;
|
|
549
|
-
};
|
|
550
|
-
declare class FileManager {
|
|
551
|
-
#private;
|
|
552
|
-
constructor();
|
|
553
|
-
add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
|
|
554
|
-
getByPath(path: Path): Promise<ResolvedFile | null>;
|
|
555
|
-
deleteByPath(path: Path): Promise<void>;
|
|
556
|
-
clear(): Promise<void>;
|
|
557
|
-
getFiles(): Promise<Array<ResolvedFile>>;
|
|
558
|
-
processFiles({
|
|
559
|
-
dryRun,
|
|
560
|
-
root,
|
|
561
|
-
extension,
|
|
562
|
-
logger
|
|
563
|
-
}: WriteFilesProps): Promise<Array<ResolvedFile>>;
|
|
564
|
-
getBarrelFiles({
|
|
565
|
-
type,
|
|
566
|
-
meta,
|
|
567
|
-
root,
|
|
568
|
-
output,
|
|
569
|
-
logger
|
|
570
|
-
}: AddIndexesProps): Promise<File[]>;
|
|
571
|
-
static getMode(path: string | undefined | null): Mode;
|
|
572
|
-
}
|
|
573
|
-
//#endregion
|
|
574
522
|
//#region ../core/src/PluginManager.d.ts
|
|
575
523
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
576
524
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
@@ -609,6 +557,9 @@ type GetFileProps<TOptions$1 = object> = {
|
|
|
609
557
|
declare class PluginManager {
|
|
610
558
|
#private;
|
|
611
559
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
560
|
+
/**
|
|
561
|
+
* @deprecated do not use from pluginManager
|
|
562
|
+
*/
|
|
612
563
|
readonly fileManager: FileManager;
|
|
613
564
|
readonly events: EventEmitter<Events>;
|
|
614
565
|
readonly config: Config;
|
|
@@ -716,6 +667,11 @@ declare class PluginManager {
|
|
|
716
667
|
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = (T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>])>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
|
|
717
668
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
718
669
|
}
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region ../core/src/FileManager.d.ts
|
|
672
|
+
type FileMetaBase = {
|
|
673
|
+
pluginKey?: Plugin['key'];
|
|
674
|
+
};
|
|
719
675
|
import * as import___kubb_react_fabric_types from "@kubb/react-fabric/types";
|
|
720
676
|
//#endregion
|
|
721
677
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
@@ -1247,4 +1203,4 @@ type ResolvedOptions = {
|
|
|
1247
1203
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1248
1204
|
//#endregion
|
|
1249
1205
|
export { types_d_exports$1 as a, __reExport as c, OperationSchemas as i, PluginClient as n, UserPluginWithLifeCycle as o, Generator as r, Operation$1 as s, Options$1 as t };
|
|
1250
|
-
//# sourceMappingURL=types-
|
|
1206
|
+
//# sourceMappingURL=types-DIxcknRD.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-client",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "API client generator plugin for Kubb, creating type-safe HTTP clients (Axios, Fetch) from OpenAPI specifications for making API requests.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api-client",
|
|
@@ -77,12 +77,12 @@
|
|
|
77
77
|
"!/**/__tests__/**"
|
|
78
78
|
],
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@kubb/core": "4.2.
|
|
81
|
-
"@kubb/oas": "4.2.
|
|
82
|
-
"@kubb/plugin-oas": "4.2.
|
|
83
|
-
"@kubb/plugin-ts": "4.2.
|
|
84
|
-
"@kubb/plugin-zod": "4.2.
|
|
85
|
-
"@kubb/react": "4.2.
|
|
80
|
+
"@kubb/core": "4.2.2",
|
|
81
|
+
"@kubb/oas": "4.2.2",
|
|
82
|
+
"@kubb/plugin-oas": "4.2.2",
|
|
83
|
+
"@kubb/plugin-ts": "4.2.2",
|
|
84
|
+
"@kubb/plugin-zod": "4.2.2",
|
|
85
|
+
"@kubb/react": "4.2.2"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"axios": "^1.12.2",
|
package/src/plugin.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
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 } from '@kubb/core/transformers'
|
|
5
|
-
import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'
|
|
6
|
-
|
|
7
|
-
import type { Plugin } from '@kubb/core'
|
|
8
4
|
import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
|
|
5
|
+
import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'
|
|
9
6
|
import { pluginZodName } from '@kubb/plugin-zod'
|
|
10
7
|
import { operationsGenerator } from './generators'
|
|
11
8
|
import { clientGenerator } from './generators/clientGenerator.tsx'
|
|
@@ -53,7 +50,7 @@ export const pluginClient = createPlugin<PluginClient>((options) => {
|
|
|
53
50
|
pre: [pluginOasName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),
|
|
54
51
|
resolvePath(baseName, pathMode, options) {
|
|
55
52
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
56
|
-
const mode = pathMode ??
|
|
53
|
+
const mode = pathMode ?? getMode(path.resolve(root, output.path))
|
|
57
54
|
|
|
58
55
|
if (mode === 'single') {
|
|
59
56
|
/**
|
|
@@ -99,7 +96,7 @@ export const pluginClient = createPlugin<PluginClient>((options) => {
|
|
|
99
96
|
|
|
100
97
|
const oas = await swaggerPlugin.context.getOas()
|
|
101
98
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
102
|
-
const mode =
|
|
99
|
+
const mode = getMode(path.resolve(root, output.path))
|
|
103
100
|
const baseURL = await swaggerPlugin.context.getBaseURL()
|
|
104
101
|
|
|
105
102
|
const operationGenerator = new OperationGenerator(
|
|
@@ -125,7 +122,7 @@ export const pluginClient = createPlugin<PluginClient>((options) => {
|
|
|
125
122
|
|
|
126
123
|
await this.addFile(...files)
|
|
127
124
|
|
|
128
|
-
const barrelFiles = await this.fileManager.
|
|
125
|
+
const barrelFiles = await getBarrelFiles(this.fileManager.files, {
|
|
129
126
|
type: output.barrelType ?? 'named',
|
|
130
127
|
root,
|
|
131
128
|
output,
|