@kubb/plugin-client 4.10.0 → 4.10.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.
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/generators.cjs +0 -1
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +0 -1
- package/dist/index.cjs +0 -1
- 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 +0 -1
- package/dist/index.js.map +1 -1
- package/dist/{types-DDd1VM_Z.d.ts → types-CrTjCX6k.d.ts} +21 -21
- package/dist/{types-MSth0FPg.d.cts → types-Dj6Awn0U.d.cts} +21 -21
- package/package.json +6 -6
package/dist/components.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as OperationSchemas, n as PluginClient, o as Operation } from "./types-
|
|
1
|
+
import { i as OperationSchemas, n as PluginClient, o as Operation } from "./types-Dj6Awn0U.cjs";
|
|
2
2
|
import { FunctionParams } from "@kubb/react-fabric";
|
|
3
3
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
4
4
|
|
package/dist/components.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as OperationSchemas, n as PluginClient, o as Operation } from "./types-
|
|
1
|
+
import { i as OperationSchemas, n as PluginClient, o as Operation } from "./types-CrTjCX6k.js";
|
|
2
2
|
import { FunctionParams } from "@kubb/react-fabric";
|
|
3
3
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
4
4
|
|
package/dist/generators.cjs
CHANGED
package/dist/generators.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as PluginClient, r as ReactGenerator } from "./types-
|
|
1
|
+
import { n as PluginClient, r as ReactGenerator } from "./types-Dj6Awn0U.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/generators/classClientGenerator.d.ts
|
|
4
4
|
declare const classClientGenerator: ReactGenerator<PluginClient>;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as PluginClient, r as ReactGenerator } from "./types-
|
|
1
|
+
import { n as PluginClient, r as ReactGenerator } from "./types-CrTjCX6k.js";
|
|
2
2
|
|
|
3
3
|
//#region src/generators/classClientGenerator.d.ts
|
|
4
4
|
declare const classClientGenerator: ReactGenerator<PluginClient>;
|
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "./Operations-B6I1tCOx.js";
|
|
2
1
|
import { i as classClientGenerator, n as groupedClientGenerator, r as clientGenerator, t as operationsGenerator } from "./generators-CsFgdAtO.js";
|
|
3
2
|
|
|
4
3
|
export { classClientGenerator, clientGenerator, groupedClientGenerator, operationsGenerator };
|
package/dist/index.cjs
CHANGED
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["classClientGenerator","clientGenerator","groupedClientGenerator","operationsGenerator","pluginOasName","pluginZodName","path","options","groupName: Group['name']","baseURL","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { classClientGenerator, 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 = definePlugin<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 clientType = 'function',\n parser = 'client',\n client = 'axios',\n importPath,\n contentType,\n bundle = false,\n } = options\n\n const resolvedImportPath = importPath ?? (!bundle ? `@kubb/plugin-client/clients/${client}` : undefined)\n const defaultGenerators = [\n clientType === 'class' ? classClientGenerator : clientGenerator,\n group && clientType !== 'class' ? groupedClientGenerator : undefined,\n operations ? operationsGenerator : undefined,\n ].filter(Boolean)\n\n const generators = options.generators ?? defaultGenerators\n\n return {\n name: pluginClientName,\n options: {\n client,\n clientType,\n bundle,\n output,\n group,\n parser,\n dataReturnType,\n importPath: resolvedImportPath,\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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n // pre add bundled fetch\n if (bundle && !this.plugin.options.importPath) {\n await this.addFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n })\n }\n\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n\n const operationGenerator = new OperationGenerator(\n baseURL\n ? {\n ...this.plugin.options,\n baseURL,\n }\n : this.plugin.options,\n {\n fabric: this.fabric,\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.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.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.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["classClientGenerator","clientGenerator","groupedClientGenerator","operationsGenerator","pluginOasName","pluginZodName","path","options","groupName: Group['name']","baseURL","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { classClientGenerator, 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 = definePlugin<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 clientType = 'function',\n parser = 'client',\n client = 'axios',\n importPath,\n contentType,\n bundle = false,\n } = options\n\n const resolvedImportPath = importPath ?? (!bundle ? `@kubb/plugin-client/clients/${client}` : undefined)\n const defaultGenerators = [\n clientType === 'class' ? classClientGenerator : clientGenerator,\n group && clientType !== 'class' ? groupedClientGenerator : undefined,\n operations ? operationsGenerator : undefined,\n ].filter(Boolean)\n\n const generators = options.generators ?? defaultGenerators\n\n return {\n name: pluginClientName,\n options: {\n client,\n clientType,\n bundle,\n output,\n group,\n parser,\n dataReturnType,\n importPath: resolvedImportPath,\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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n // pre add bundled fetch\n if (bundle && !this.plugin.options.importPath) {\n await this.addFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n })\n }\n\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n\n const operationGenerator = new OperationGenerator(\n baseURL\n ? {\n ...this.plugin.options,\n baseURL,\n }\n : this.plugin.options,\n {\n fabric: this.fabric,\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.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.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.upsertFile(...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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
|
-
import { a as UserPluginWithLifeCycle, n as PluginClient, t as Options } from "./types-
|
|
1
|
+
import { a as UserPluginWithLifeCycle, n as PluginClient, t as Options } from "./types-Dj6Awn0U.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 { a as UserPluginWithLifeCycle, n as PluginClient, t as Options } from "./types-
|
|
1
|
+
import { a as UserPluginWithLifeCycle, n as PluginClient, t as Options } from "./types-CrTjCX6k.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginClientName = "plugin-client";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "./Operations-B6I1tCOx.js";
|
|
2
1
|
import { i as classClientGenerator, n as groupedClientGenerator, r as clientGenerator, t as operationsGenerator } from "./generators-CsFgdAtO.js";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
|
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'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { classClientGenerator, 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 = definePlugin<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 clientType = 'function',\n parser = 'client',\n client = 'axios',\n importPath,\n contentType,\n bundle = false,\n } = options\n\n const resolvedImportPath = importPath ?? (!bundle ? `@kubb/plugin-client/clients/${client}` : undefined)\n const defaultGenerators = [\n clientType === 'class' ? classClientGenerator : clientGenerator,\n group && clientType !== 'class' ? groupedClientGenerator : undefined,\n operations ? operationsGenerator : undefined,\n ].filter(Boolean)\n\n const generators = options.generators ?? defaultGenerators\n\n return {\n name: pluginClientName,\n options: {\n client,\n clientType,\n bundle,\n output,\n group,\n parser,\n dataReturnType,\n importPath: resolvedImportPath,\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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n // pre add bundled fetch\n if (bundle && !this.plugin.options.importPath) {\n await this.addFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n })\n }\n\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n\n const operationGenerator = new OperationGenerator(\n baseURL\n ? {\n ...this.plugin.options,\n baseURL,\n }\n : this.plugin.options,\n {\n fabric: this.fabric,\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.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.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.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']","baseURL"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { classClientGenerator, 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 = definePlugin<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 clientType = 'function',\n parser = 'client',\n client = 'axios',\n importPath,\n contentType,\n bundle = false,\n } = options\n\n const resolvedImportPath = importPath ?? (!bundle ? `@kubb/plugin-client/clients/${client}` : undefined)\n const defaultGenerators = [\n clientType === 'class' ? classClientGenerator : clientGenerator,\n group && clientType !== 'class' ? groupedClientGenerator : undefined,\n operations ? operationsGenerator : undefined,\n ].filter(Boolean)\n\n const generators = options.generators ?? defaultGenerators\n\n return {\n name: pluginClientName,\n options: {\n client,\n clientType,\n bundle,\n output,\n group,\n parser,\n dataReturnType,\n importPath: resolvedImportPath,\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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n // pre add bundled fetch\n if (bundle && !this.plugin.options.importPath) {\n await this.addFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: resolveModuleSource(\n this.plugin.options.client === 'fetch' ? '@kubb/plugin-client/templates/clients/fetch' : '@kubb/plugin-client/templates/clients/axios',\n ).source,\n isExportable: true,\n isIndexable: true,\n },\n ],\n })\n }\n\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n\n const operationGenerator = new OperationGenerator(\n baseURL\n ? {\n ...this.plugin.options,\n baseURL,\n }\n : this.plugin.options,\n {\n fabric: this.fabric,\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.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.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.upsertFile(...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,EAAE,EACjB,iBAAiB,QACjB,aAAa,UACb,iBAAiB,eAAe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es.SchemaObject & {
|
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region ../oas/src/Oas.d.ts
|
|
20
|
-
type Options$
|
|
20
|
+
type Options$2 = {
|
|
21
21
|
contentType?: contentType;
|
|
22
22
|
discriminator?: 'strict' | 'inherit';
|
|
23
23
|
};
|
|
@@ -31,8 +31,8 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
31
31
|
oas: TOAS | OASDocument | string;
|
|
32
32
|
user?: User;
|
|
33
33
|
});
|
|
34
|
-
setOptions(options: Options$
|
|
35
|
-
get options(): Options$
|
|
34
|
+
setOptions(options: Options$2): void;
|
|
35
|
+
get options(): Options$2;
|
|
36
36
|
get($ref: string): any;
|
|
37
37
|
getKey($ref: string): string | undefined;
|
|
38
38
|
set($ref: string, value: unknown): false | undefined;
|
|
@@ -427,7 +427,7 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
427
427
|
result: Result;
|
|
428
428
|
plugin: Plugin;
|
|
429
429
|
};
|
|
430
|
-
type Options$
|
|
430
|
+
type Options$1 = {
|
|
431
431
|
fabric: Fabric;
|
|
432
432
|
logger: Logger;
|
|
433
433
|
/**
|
|
@@ -453,8 +453,8 @@ declare class PluginManager {
|
|
|
453
453
|
readonly config: Config;
|
|
454
454
|
readonly executed: Array<Executer>;
|
|
455
455
|
readonly logger: Logger;
|
|
456
|
-
readonly options: Options$
|
|
457
|
-
constructor(config: Config, options: Options$
|
|
456
|
+
readonly options: Options$1;
|
|
457
|
+
constructor(config: Config, options: Options$1);
|
|
458
458
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
459
459
|
get plugins(): Array<Plugin>;
|
|
460
460
|
getFile<TOptions = object>({
|
|
@@ -1006,7 +1006,7 @@ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
|
1006
1006
|
};
|
|
1007
1007
|
//#endregion
|
|
1008
1008
|
//#region src/types.d.ts
|
|
1009
|
-
type Options
|
|
1009
|
+
type Options = {
|
|
1010
1010
|
/**
|
|
1011
1011
|
* Specify the export location for the files and define the behavior of the output
|
|
1012
1012
|
* @default { path: 'clients', barrelType: 'named' }
|
|
@@ -1121,20 +1121,20 @@ type Options$1 = {
|
|
|
1121
1121
|
};
|
|
1122
1122
|
type ResolvedOptions = {
|
|
1123
1123
|
output: Output<Oas>;
|
|
1124
|
-
group?: Options
|
|
1124
|
+
group?: Options['group'];
|
|
1125
1125
|
baseURL: string | undefined;
|
|
1126
|
-
client: Options
|
|
1127
|
-
clientType: NonNullable<Options
|
|
1128
|
-
bundle: NonNullable<Options
|
|
1129
|
-
parser: NonNullable<Options
|
|
1130
|
-
urlType: NonNullable<Options
|
|
1131
|
-
importPath: Options
|
|
1132
|
-
dataReturnType: NonNullable<Options
|
|
1133
|
-
pathParamsType: NonNullable<Options
|
|
1134
|
-
paramsType: NonNullable<Options
|
|
1135
|
-
paramsCasing: Options
|
|
1126
|
+
client: Options['client'];
|
|
1127
|
+
clientType: NonNullable<Options['clientType']>;
|
|
1128
|
+
bundle: NonNullable<Options['bundle']>;
|
|
1129
|
+
parser: NonNullable<Options['parser']>;
|
|
1130
|
+
urlType: NonNullable<Options['urlType']>;
|
|
1131
|
+
importPath: Options['importPath'];
|
|
1132
|
+
dataReturnType: NonNullable<Options['dataReturnType']>;
|
|
1133
|
+
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
1134
|
+
paramsType: NonNullable<Options['paramsType']>;
|
|
1135
|
+
paramsCasing: Options['paramsCasing'];
|
|
1136
1136
|
};
|
|
1137
|
-
type PluginClient = PluginFactoryOptions<'plugin-client', Options
|
|
1137
|
+
type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1138
1138
|
//#endregion
|
|
1139
|
-
export { UserPluginWithLifeCycle as a, OperationSchemas as i, PluginClient as n, Operation$1 as o, ReactGenerator as r, Options
|
|
1140
|
-
//# sourceMappingURL=types-
|
|
1139
|
+
export { UserPluginWithLifeCycle as a, OperationSchemas as i, PluginClient as n, Operation$1 as o, ReactGenerator as r, Options as t };
|
|
1140
|
+
//# sourceMappingURL=types-CrTjCX6k.d.ts.map
|
|
@@ -17,7 +17,7 @@ type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region ../oas/src/Oas.d.ts
|
|
20
|
-
type Options$
|
|
20
|
+
type Options$2 = {
|
|
21
21
|
contentType?: contentType;
|
|
22
22
|
discriminator?: 'strict' | 'inherit';
|
|
23
23
|
};
|
|
@@ -31,8 +31,8 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
31
31
|
oas: TOAS | OASDocument | string;
|
|
32
32
|
user?: User;
|
|
33
33
|
});
|
|
34
|
-
setOptions(options: Options$
|
|
35
|
-
get options(): Options$
|
|
34
|
+
setOptions(options: Options$2): void;
|
|
35
|
+
get options(): Options$2;
|
|
36
36
|
get($ref: string): any;
|
|
37
37
|
getKey($ref: string): string | undefined;
|
|
38
38
|
set($ref: string, value: unknown): false | undefined;
|
|
@@ -427,7 +427,7 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
427
427
|
result: Result;
|
|
428
428
|
plugin: Plugin;
|
|
429
429
|
};
|
|
430
|
-
type Options$
|
|
430
|
+
type Options$1 = {
|
|
431
431
|
fabric: Fabric;
|
|
432
432
|
logger: Logger;
|
|
433
433
|
/**
|
|
@@ -453,8 +453,8 @@ declare class PluginManager {
|
|
|
453
453
|
readonly config: Config;
|
|
454
454
|
readonly executed: Array<Executer>;
|
|
455
455
|
readonly logger: Logger;
|
|
456
|
-
readonly options: Options$
|
|
457
|
-
constructor(config: Config, options: Options$
|
|
456
|
+
readonly options: Options$1;
|
|
457
|
+
constructor(config: Config, options: Options$1);
|
|
458
458
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
459
459
|
get plugins(): Array<Plugin>;
|
|
460
460
|
getFile<TOptions = object>({
|
|
@@ -1006,7 +1006,7 @@ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
|
1006
1006
|
};
|
|
1007
1007
|
//#endregion
|
|
1008
1008
|
//#region src/types.d.ts
|
|
1009
|
-
type Options
|
|
1009
|
+
type Options = {
|
|
1010
1010
|
/**
|
|
1011
1011
|
* Specify the export location for the files and define the behavior of the output
|
|
1012
1012
|
* @default { path: 'clients', barrelType: 'named' }
|
|
@@ -1121,20 +1121,20 @@ type Options$1 = {
|
|
|
1121
1121
|
};
|
|
1122
1122
|
type ResolvedOptions = {
|
|
1123
1123
|
output: Output<Oas>;
|
|
1124
|
-
group?: Options
|
|
1124
|
+
group?: Options['group'];
|
|
1125
1125
|
baseURL: string | undefined;
|
|
1126
|
-
client: Options
|
|
1127
|
-
clientType: NonNullable<Options
|
|
1128
|
-
bundle: NonNullable<Options
|
|
1129
|
-
parser: NonNullable<Options
|
|
1130
|
-
urlType: NonNullable<Options
|
|
1131
|
-
importPath: Options
|
|
1132
|
-
dataReturnType: NonNullable<Options
|
|
1133
|
-
pathParamsType: NonNullable<Options
|
|
1134
|
-
paramsType: NonNullable<Options
|
|
1135
|
-
paramsCasing: Options
|
|
1126
|
+
client: Options['client'];
|
|
1127
|
+
clientType: NonNullable<Options['clientType']>;
|
|
1128
|
+
bundle: NonNullable<Options['bundle']>;
|
|
1129
|
+
parser: NonNullable<Options['parser']>;
|
|
1130
|
+
urlType: NonNullable<Options['urlType']>;
|
|
1131
|
+
importPath: Options['importPath'];
|
|
1132
|
+
dataReturnType: NonNullable<Options['dataReturnType']>;
|
|
1133
|
+
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
1134
|
+
paramsType: NonNullable<Options['paramsType']>;
|
|
1135
|
+
paramsCasing: Options['paramsCasing'];
|
|
1136
1136
|
};
|
|
1137
|
-
type PluginClient = PluginFactoryOptions<'plugin-client', Options
|
|
1137
|
+
type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1138
1138
|
//#endregion
|
|
1139
|
-
export { UserPluginWithLifeCycle as a, OperationSchemas as i, PluginClient as n, Operation$1 as o, ReactGenerator as r, Options
|
|
1140
|
-
//# sourceMappingURL=types-
|
|
1139
|
+
export { UserPluginWithLifeCycle as a, OperationSchemas as i, PluginClient as n, Operation$1 as o, ReactGenerator as r, Options as t };
|
|
1140
|
+
//# sourceMappingURL=types-Dj6Awn0U.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-client",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.1",
|
|
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",
|
|
@@ -88,11 +88,11 @@
|
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@kubb/react-fabric": "0.5.4",
|
|
90
90
|
"jiti": "^2.6.1",
|
|
91
|
-
"@kubb/core": "4.10.
|
|
92
|
-
"@kubb/oas": "4.10.
|
|
93
|
-
"@kubb/plugin-oas": "4.10.
|
|
94
|
-
"@kubb/plugin-ts": "4.10.
|
|
95
|
-
"@kubb/plugin-zod": "4.10.
|
|
91
|
+
"@kubb/core": "4.10.1",
|
|
92
|
+
"@kubb/oas": "4.10.1",
|
|
93
|
+
"@kubb/plugin-oas": "4.10.1",
|
|
94
|
+
"@kubb/plugin-ts": "4.10.1",
|
|
95
|
+
"@kubb/plugin-zod": "4.10.1"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"axios": "^1.13.2"
|