@kubb/plugin-client 4.11.1 → 4.11.3
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 +1 -0
- 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 +1 -0
- package/dist/index.js.map +1 -1
- package/dist/{types-Dj6Awn0U.d.cts → types-CvjnC2Dp.d.cts} +61 -28
- package/dist/{types-CrTjCX6k.d.ts → types-HFFrUUbA.d.ts} +61 -28
- package/package.json +6 -6
- package/src/plugin.ts +1 -0
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-CvjnC2Dp.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-HFFrUUbA.js";
|
|
2
2
|
import { FunctionParams } from "@kubb/react-fabric";
|
|
3
3
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
4
4
|
|
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-CvjnC2Dp.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-HFFrUUbA.js";
|
|
2
2
|
|
|
3
3
|
//#region src/generators/classClientGenerator.d.ts
|
|
4
4
|
declare const classClientGenerator: ReactGenerator<PluginClient>;
|
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":";;;;;;;;;;;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,YACb,SAAS,UACT,SAAS,SACT,YACA,aACA,SAAS,UACP;CAEJ,MAAM,qBAAqB,eAAe,CAAC,SAAS,+BAA+B,WAAW;CAC9F,MAAM,oBAAoB;EACxB,eAAe,UAAUA,0CAAuBC;EAChD,SAAS,eAAe,UAAUC,4CAAyB;EAC3D,aAAaC,yCAAsB;EACpC,CAAC,OAAO,QAAQ;CAEjB,MAAM,aAAa,QAAQ,cAAc;AAEzC,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA,YAAY;GACZ;GACA;GACA;GACA;GACA;GACD;EACD,KAAK,CAACC,iCAAe,WAAW,QAAQC,kCAAgB,OAAU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8CAC1F,CAAC;KACF,cAAc;KACd,aAAa;KACd,CACF;IACF,CAAC;AAGJ,SAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAMA,kBAAK,QAAQ,MAAM,kBAAkB;IAC3C,SAAS,CACP;KACE,MAAM;KACN,kDAA2B,uCAAuC,CAAC;KACnE,cAAc;KACd,aAAa;KACd,CACF;IACF,CAAC;
|
|
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 logger: this.logger,\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,WAAW,QAAQ,kBAAkB,UAChF,aAAa,OACb,SACA,cACA,aAAa,YACb,SAAS,UACT,SAAS,SACT,YACA,aACA,SAAS,UACP;CAEJ,MAAM,qBAAqB,eAAe,CAAC,SAAS,+BAA+B,WAAW;CAC9F,MAAM,oBAAoB;EACxB,eAAe,UAAUA,0CAAuBC;EAChD,SAAS,eAAe,UAAUC,4CAAyB;EAC3D,aAAaC,yCAAsB;EACpC,CAAC,OAAO,QAAQ;CAEjB,MAAM,aAAa,QAAQ,cAAc;AAEzC,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA,YAAY;GACZ;GACA;GACA;GACA;GACA;GACD;EACD,KAAK,CAACC,iCAAe,WAAW,QAAQC,kCAAgB,OAAU,CAAC,OAAO,QAAQ;EAClF,YAAY,UAAU,UAAU,WAAS;GACvC,M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AGJ,SAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAMA,kBAAK,QAAQ,MAAM,kBAAkB;IAC3C,SAAS,CACP;KACE,MAAM;KACN,kDAA2B,uCAAuC,CAAC;KACnE,cAAc;KACd,aAAa;KACd,CACF;IACF,CAAC;GAuBF,MAAM,QAAQ,MArBa,IAAII,qCAC7BD,YACI;IACE,GAAG,KAAK,OAAO;IACf;IACD,GACD,KAAK,OAAO,SAChB;IACE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CACF,CAEsC,MAAM,GAAG,WAAW;AAE3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,sCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
package/dist/index.d.cts
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-CvjnC2Dp.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-HFFrUUbA.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginClientName = "plugin-client";
|
package/dist/index.js
CHANGED
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":";;;;;;;;;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,WAAW,WAAW,QAAQ,kBAAkB,UAChF,aAAa,OACb,SACA,cACA,aAAa,YACb,SAAS,UACT,SAAS,SACT,YACA,aACA,SAAS,UACP;CAEJ,MAAM,qBAAqB,eAAe,CAAC,SAAS,+BAA+B,WAAW;CAC9F,MAAM,oBAAoB;EACxB,eAAe,UAAU,uBAAuB;EAChD,SAAS,eAAe,UAAU,yBAAyB;EAC3D,aAAa,sBAAsB;EACpC,CAAC,OAAO,QAAQ;CAEjB,MAAM,aAAa,QAAQ,cAAc;AAEzC,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACA,YAAY;GACZ;GACA;GACA;GACA;GACA;GACD;EACD,KAAK,CAAC,eAAe,WAAW,QAAQ,gBAAgB,OAAU,CAAC,OAAO,QAAQ;EAClF,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAO,KAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUA,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;AAEjC,YAAO,GAAG,UAAU,IAAI,MAAM,CAAC;;AAGrC,WAAO,KAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASD,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAO,KAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,MAAM,eAAe,UAAU,MAAM,EAAE,QAAQ,SAAS,QAAQ,CAAC;AAEjE,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,UAAU;GACd,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAC/B,MAAME,YAAU,MAAM,KAAK,YAAY;AAGvC,OAAI,UAAU,CAAC,KAAK,OAAO,QAAQ,WACjC,OAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,CACP;KACE,MAAM;KACN,OAAO,oBACL,KAAK,OAAO,QAAQ,WAAW,UAAU,gDAAgD,8CAC1F,CAAC;KACF,cAAc;KACd,aAAa;KACd,CACF;IACF,CAAC;AAGJ,SAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,kBAAkB;IAC3C,SAAS,CACP;KACE,MAAM;KACN,OAAO,oBAAoB,uCAAuC,CAAC;KACnE,cAAc;KACd,aAAa;KACd,CACF;IACF,CAAC;
|
|
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 logger: this.logger,\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":";;;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;GAE/B,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
@@ -73,13 +73,35 @@ type DebugEvent = {
|
|
|
73
73
|
date: Date;
|
|
74
74
|
logs: string[];
|
|
75
75
|
fileName?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Category of the debug log, used for GitHub Actions grouping
|
|
78
|
+
* - 'setup': Initial configuration and environment setup
|
|
79
|
+
* - 'plugin': Plugin installation and execution
|
|
80
|
+
* - 'hook': Plugin hook execution details
|
|
81
|
+
* - 'schema': Schema parsing and generation
|
|
82
|
+
* - 'file': File operations (read/write/generate)
|
|
83
|
+
* - 'error': Error details and stack traces
|
|
84
|
+
* - undefined: Generic logs (always inline)
|
|
85
|
+
*/
|
|
86
|
+
category?: 'setup' | 'plugin' | 'hook' | 'schema' | 'file' | 'error';
|
|
87
|
+
/**
|
|
88
|
+
* Plugin name for grouping plugin-specific logs together
|
|
89
|
+
*/
|
|
90
|
+
pluginName?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Indicates if this is the start or end of a plugin's execution
|
|
93
|
+
* - 'start': Start of plugin execution group
|
|
94
|
+
* - 'end': End of plugin execution group
|
|
95
|
+
*/
|
|
96
|
+
pluginGroupMarker?: 'start' | 'end';
|
|
76
97
|
};
|
|
77
98
|
type Events$1 = {
|
|
78
99
|
start: [message: string];
|
|
79
100
|
success: [message: string];
|
|
80
|
-
error: [message: string,
|
|
101
|
+
error: [message: string, error: Error];
|
|
81
102
|
warning: [message: string];
|
|
82
103
|
debug: [DebugEvent];
|
|
104
|
+
verbose: [DebugEvent];
|
|
83
105
|
info: [message: string];
|
|
84
106
|
progress_start: [{
|
|
85
107
|
id: string;
|
|
@@ -103,7 +125,7 @@ type Logger = {
|
|
|
103
125
|
consola?: ConsolaInstance;
|
|
104
126
|
on: EventEmitter<Events$1>['on'];
|
|
105
127
|
emit: EventEmitter<Events$1>['emit'];
|
|
106
|
-
writeLogs: () => Promise<
|
|
128
|
+
writeLogs: () => Promise<void>;
|
|
107
129
|
};
|
|
108
130
|
//#endregion
|
|
109
131
|
//#region ../core/src/utils/types.d.ts
|
|
@@ -414,14 +436,35 @@ type Group = {
|
|
|
414
436
|
//#region ../core/src/PluginManager.d.ts
|
|
415
437
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
416
438
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
417
|
-
type
|
|
418
|
-
message: string;
|
|
439
|
+
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
419
440
|
strategy: Strategy;
|
|
420
441
|
hookName: H;
|
|
421
442
|
plugin: Plugin;
|
|
422
443
|
parameters?: unknown[] | undefined;
|
|
423
444
|
output?: unknown;
|
|
424
445
|
};
|
|
446
|
+
type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
447
|
+
duration: number;
|
|
448
|
+
strategy: Strategy;
|
|
449
|
+
hookName: H;
|
|
450
|
+
plugin: Plugin;
|
|
451
|
+
parameters?: unknown[] | undefined;
|
|
452
|
+
output?: unknown;
|
|
453
|
+
};
|
|
454
|
+
type ErrorMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
455
|
+
hookName: H;
|
|
456
|
+
duration: number;
|
|
457
|
+
strategy: Strategy;
|
|
458
|
+
parameters?: unknown[] | undefined;
|
|
459
|
+
plugin: Plugin;
|
|
460
|
+
};
|
|
461
|
+
type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
462
|
+
hookName: H;
|
|
463
|
+
plugins: Array<Plugin>;
|
|
464
|
+
};
|
|
465
|
+
type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
466
|
+
hookName: H;
|
|
467
|
+
};
|
|
425
468
|
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
426
469
|
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
427
470
|
result: Result;
|
|
@@ -436,9 +479,11 @@ type Options$1 = {
|
|
|
436
479
|
concurrency?: number;
|
|
437
480
|
};
|
|
438
481
|
type Events = {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
482
|
+
progress_start: [meta: ProgressStartMeta];
|
|
483
|
+
progress_stop: [meta: ProgressStopMeta];
|
|
484
|
+
executing: [meta: ExecutingMeta];
|
|
485
|
+
executed: [meta: ExecutedMeta];
|
|
486
|
+
error: [error: Error, meta: ErrorMeta];
|
|
442
487
|
};
|
|
443
488
|
type GetFileProps<TOptions = object> = {
|
|
444
489
|
name: string;
|
|
@@ -451,8 +496,6 @@ declare class PluginManager {
|
|
|
451
496
|
#private;
|
|
452
497
|
readonly events: EventEmitter<Events>;
|
|
453
498
|
readonly config: Config;
|
|
454
|
-
readonly executed: Array<Executer>;
|
|
455
|
-
readonly logger: Logger;
|
|
456
499
|
readonly options: Options$1;
|
|
457
500
|
constructor(config: Config, options: Options$1);
|
|
458
501
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
@@ -478,13 +521,11 @@ declare class PluginManager {
|
|
|
478
521
|
hookForPlugin<H extends PluginLifecycleHooks>({
|
|
479
522
|
pluginKey,
|
|
480
523
|
hookName,
|
|
481
|
-
parameters
|
|
482
|
-
message
|
|
524
|
+
parameters
|
|
483
525
|
}: {
|
|
484
526
|
pluginKey: Plugin['key'];
|
|
485
527
|
hookName: H;
|
|
486
528
|
parameters: PluginParameter<H>;
|
|
487
|
-
message: string;
|
|
488
529
|
}): Promise<Array<ReturnType<ParseResult<H>> | null>>;
|
|
489
530
|
/**
|
|
490
531
|
* Run a specific hookName for plugin x.
|
|
@@ -492,13 +533,11 @@ declare class PluginManager {
|
|
|
492
533
|
hookForPluginSync<H extends PluginLifecycleHooks>({
|
|
493
534
|
pluginKey,
|
|
494
535
|
hookName,
|
|
495
|
-
parameters
|
|
496
|
-
message
|
|
536
|
+
parameters
|
|
497
537
|
}: {
|
|
498
538
|
pluginKey: Plugin['key'];
|
|
499
539
|
hookName: H;
|
|
500
540
|
parameters: PluginParameter<H>;
|
|
501
|
-
message: string;
|
|
502
541
|
}): Array<ReturnType<ParseResult<H>>> | null;
|
|
503
542
|
/**
|
|
504
543
|
* First non-null result stops and will return it's value.
|
|
@@ -506,13 +545,11 @@ declare class PluginManager {
|
|
|
506
545
|
hookFirst<H extends PluginLifecycleHooks>({
|
|
507
546
|
hookName,
|
|
508
547
|
parameters,
|
|
509
|
-
skipped
|
|
510
|
-
message
|
|
548
|
+
skipped
|
|
511
549
|
}: {
|
|
512
550
|
hookName: H;
|
|
513
551
|
parameters: PluginParameter<H>;
|
|
514
552
|
skipped?: ReadonlySet<Plugin> | null;
|
|
515
|
-
message: string;
|
|
516
553
|
}): Promise<SafeParseResult<H>>;
|
|
517
554
|
/**
|
|
518
555
|
* First non-null result stops and will return it's value.
|
|
@@ -520,37 +557,31 @@ declare class PluginManager {
|
|
|
520
557
|
hookFirstSync<H extends PluginLifecycleHooks>({
|
|
521
558
|
hookName,
|
|
522
559
|
parameters,
|
|
523
|
-
skipped
|
|
524
|
-
message
|
|
560
|
+
skipped
|
|
525
561
|
}: {
|
|
526
562
|
hookName: H;
|
|
527
563
|
parameters: PluginParameter<H>;
|
|
528
564
|
skipped?: ReadonlySet<Plugin> | null;
|
|
529
|
-
message: string;
|
|
530
565
|
}): SafeParseResult<H>;
|
|
531
566
|
/**
|
|
532
567
|
* Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
|
|
533
568
|
*/
|
|
534
569
|
hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
|
|
535
570
|
hookName,
|
|
536
|
-
parameters
|
|
537
|
-
message
|
|
571
|
+
parameters
|
|
538
572
|
}: {
|
|
539
573
|
hookName: H;
|
|
540
574
|
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
|
|
541
|
-
message: string;
|
|
542
575
|
}): Promise<Awaited<TOuput>[]>;
|
|
543
576
|
/**
|
|
544
577
|
* Chains plugins
|
|
545
578
|
*/
|
|
546
579
|
hookSeq<H extends PluginLifecycleHooks>({
|
|
547
580
|
hookName,
|
|
548
|
-
parameters
|
|
549
|
-
message
|
|
581
|
+
parameters
|
|
550
582
|
}: {
|
|
551
583
|
hookName: H;
|
|
552
584
|
parameters?: PluginParameter<H>;
|
|
553
|
-
message: string;
|
|
554
585
|
}): Promise<void>;
|
|
555
586
|
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
556
587
|
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
@@ -667,6 +698,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
667
698
|
override: Array<Override<TOptions>> | undefined;
|
|
668
699
|
contentType: contentType | undefined;
|
|
669
700
|
pluginManager: PluginManager;
|
|
701
|
+
logger?: Logger;
|
|
670
702
|
/**
|
|
671
703
|
* Current plugin
|
|
672
704
|
*/
|
|
@@ -910,6 +942,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
910
942
|
fabric: Fabric;
|
|
911
943
|
oas: Oas;
|
|
912
944
|
pluginManager: PluginManager;
|
|
945
|
+
logger?: Logger;
|
|
913
946
|
/**
|
|
914
947
|
* Current plugin
|
|
915
948
|
*/
|
|
@@ -1137,4 +1170,4 @@ type ResolvedOptions = {
|
|
|
1137
1170
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1138
1171
|
//#endregion
|
|
1139
1172
|
export { UserPluginWithLifeCycle as a, OperationSchemas as i, PluginClient as n, Operation$1 as o, ReactGenerator as r, Options as t };
|
|
1140
|
-
//# sourceMappingURL=types-
|
|
1173
|
+
//# sourceMappingURL=types-CvjnC2Dp.d.cts.map
|
|
@@ -73,13 +73,35 @@ type DebugEvent = {
|
|
|
73
73
|
date: Date;
|
|
74
74
|
logs: string[];
|
|
75
75
|
fileName?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Category of the debug log, used for GitHub Actions grouping
|
|
78
|
+
* - 'setup': Initial configuration and environment setup
|
|
79
|
+
* - 'plugin': Plugin installation and execution
|
|
80
|
+
* - 'hook': Plugin hook execution details
|
|
81
|
+
* - 'schema': Schema parsing and generation
|
|
82
|
+
* - 'file': File operations (read/write/generate)
|
|
83
|
+
* - 'error': Error details and stack traces
|
|
84
|
+
* - undefined: Generic logs (always inline)
|
|
85
|
+
*/
|
|
86
|
+
category?: 'setup' | 'plugin' | 'hook' | 'schema' | 'file' | 'error';
|
|
87
|
+
/**
|
|
88
|
+
* Plugin name for grouping plugin-specific logs together
|
|
89
|
+
*/
|
|
90
|
+
pluginName?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Indicates if this is the start or end of a plugin's execution
|
|
93
|
+
* - 'start': Start of plugin execution group
|
|
94
|
+
* - 'end': End of plugin execution group
|
|
95
|
+
*/
|
|
96
|
+
pluginGroupMarker?: 'start' | 'end';
|
|
76
97
|
};
|
|
77
98
|
type Events$1 = {
|
|
78
99
|
start: [message: string];
|
|
79
100
|
success: [message: string];
|
|
80
|
-
error: [message: string,
|
|
101
|
+
error: [message: string, error: Error];
|
|
81
102
|
warning: [message: string];
|
|
82
103
|
debug: [DebugEvent];
|
|
104
|
+
verbose: [DebugEvent];
|
|
83
105
|
info: [message: string];
|
|
84
106
|
progress_start: [{
|
|
85
107
|
id: string;
|
|
@@ -103,7 +125,7 @@ type Logger = {
|
|
|
103
125
|
consola?: ConsolaInstance;
|
|
104
126
|
on: EventEmitter<Events$1>['on'];
|
|
105
127
|
emit: EventEmitter<Events$1>['emit'];
|
|
106
|
-
writeLogs: () => Promise<
|
|
128
|
+
writeLogs: () => Promise<void>;
|
|
107
129
|
};
|
|
108
130
|
//#endregion
|
|
109
131
|
//#region ../core/src/utils/types.d.ts
|
|
@@ -414,14 +436,35 @@ type Group = {
|
|
|
414
436
|
//#region ../core/src/PluginManager.d.ts
|
|
415
437
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
416
438
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
417
|
-
type
|
|
418
|
-
message: string;
|
|
439
|
+
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
419
440
|
strategy: Strategy;
|
|
420
441
|
hookName: H;
|
|
421
442
|
plugin: Plugin;
|
|
422
443
|
parameters?: unknown[] | undefined;
|
|
423
444
|
output?: unknown;
|
|
424
445
|
};
|
|
446
|
+
type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
447
|
+
duration: number;
|
|
448
|
+
strategy: Strategy;
|
|
449
|
+
hookName: H;
|
|
450
|
+
plugin: Plugin;
|
|
451
|
+
parameters?: unknown[] | undefined;
|
|
452
|
+
output?: unknown;
|
|
453
|
+
};
|
|
454
|
+
type ErrorMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
455
|
+
hookName: H;
|
|
456
|
+
duration: number;
|
|
457
|
+
strategy: Strategy;
|
|
458
|
+
parameters?: unknown[] | undefined;
|
|
459
|
+
plugin: Plugin;
|
|
460
|
+
};
|
|
461
|
+
type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
462
|
+
hookName: H;
|
|
463
|
+
plugins: Array<Plugin>;
|
|
464
|
+
};
|
|
465
|
+
type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
466
|
+
hookName: H;
|
|
467
|
+
};
|
|
425
468
|
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
426
469
|
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
427
470
|
result: Result;
|
|
@@ -436,9 +479,11 @@ type Options$1 = {
|
|
|
436
479
|
concurrency?: number;
|
|
437
480
|
};
|
|
438
481
|
type Events = {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
482
|
+
progress_start: [meta: ProgressStartMeta];
|
|
483
|
+
progress_stop: [meta: ProgressStopMeta];
|
|
484
|
+
executing: [meta: ExecutingMeta];
|
|
485
|
+
executed: [meta: ExecutedMeta];
|
|
486
|
+
error: [error: Error, meta: ErrorMeta];
|
|
442
487
|
};
|
|
443
488
|
type GetFileProps<TOptions = object> = {
|
|
444
489
|
name: string;
|
|
@@ -451,8 +496,6 @@ declare class PluginManager {
|
|
|
451
496
|
#private;
|
|
452
497
|
readonly events: EventEmitter<Events>;
|
|
453
498
|
readonly config: Config;
|
|
454
|
-
readonly executed: Array<Executer>;
|
|
455
|
-
readonly logger: Logger;
|
|
456
499
|
readonly options: Options$1;
|
|
457
500
|
constructor(config: Config, options: Options$1);
|
|
458
501
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
@@ -478,13 +521,11 @@ declare class PluginManager {
|
|
|
478
521
|
hookForPlugin<H extends PluginLifecycleHooks>({
|
|
479
522
|
pluginKey,
|
|
480
523
|
hookName,
|
|
481
|
-
parameters
|
|
482
|
-
message
|
|
524
|
+
parameters
|
|
483
525
|
}: {
|
|
484
526
|
pluginKey: Plugin['key'];
|
|
485
527
|
hookName: H;
|
|
486
528
|
parameters: PluginParameter<H>;
|
|
487
|
-
message: string;
|
|
488
529
|
}): Promise<Array<ReturnType<ParseResult<H>> | null>>;
|
|
489
530
|
/**
|
|
490
531
|
* Run a specific hookName for plugin x.
|
|
@@ -492,13 +533,11 @@ declare class PluginManager {
|
|
|
492
533
|
hookForPluginSync<H extends PluginLifecycleHooks>({
|
|
493
534
|
pluginKey,
|
|
494
535
|
hookName,
|
|
495
|
-
parameters
|
|
496
|
-
message
|
|
536
|
+
parameters
|
|
497
537
|
}: {
|
|
498
538
|
pluginKey: Plugin['key'];
|
|
499
539
|
hookName: H;
|
|
500
540
|
parameters: PluginParameter<H>;
|
|
501
|
-
message: string;
|
|
502
541
|
}): Array<ReturnType<ParseResult<H>>> | null;
|
|
503
542
|
/**
|
|
504
543
|
* First non-null result stops and will return it's value.
|
|
@@ -506,13 +545,11 @@ declare class PluginManager {
|
|
|
506
545
|
hookFirst<H extends PluginLifecycleHooks>({
|
|
507
546
|
hookName,
|
|
508
547
|
parameters,
|
|
509
|
-
skipped
|
|
510
|
-
message
|
|
548
|
+
skipped
|
|
511
549
|
}: {
|
|
512
550
|
hookName: H;
|
|
513
551
|
parameters: PluginParameter<H>;
|
|
514
552
|
skipped?: ReadonlySet<Plugin> | null;
|
|
515
|
-
message: string;
|
|
516
553
|
}): Promise<SafeParseResult<H>>;
|
|
517
554
|
/**
|
|
518
555
|
* First non-null result stops and will return it's value.
|
|
@@ -520,37 +557,31 @@ declare class PluginManager {
|
|
|
520
557
|
hookFirstSync<H extends PluginLifecycleHooks>({
|
|
521
558
|
hookName,
|
|
522
559
|
parameters,
|
|
523
|
-
skipped
|
|
524
|
-
message
|
|
560
|
+
skipped
|
|
525
561
|
}: {
|
|
526
562
|
hookName: H;
|
|
527
563
|
parameters: PluginParameter<H>;
|
|
528
564
|
skipped?: ReadonlySet<Plugin> | null;
|
|
529
|
-
message: string;
|
|
530
565
|
}): SafeParseResult<H>;
|
|
531
566
|
/**
|
|
532
567
|
* Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
|
|
533
568
|
*/
|
|
534
569
|
hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
|
|
535
570
|
hookName,
|
|
536
|
-
parameters
|
|
537
|
-
message
|
|
571
|
+
parameters
|
|
538
572
|
}: {
|
|
539
573
|
hookName: H;
|
|
540
574
|
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
|
|
541
|
-
message: string;
|
|
542
575
|
}): Promise<Awaited<TOuput>[]>;
|
|
543
576
|
/**
|
|
544
577
|
* Chains plugins
|
|
545
578
|
*/
|
|
546
579
|
hookSeq<H extends PluginLifecycleHooks>({
|
|
547
580
|
hookName,
|
|
548
|
-
parameters
|
|
549
|
-
message
|
|
581
|
+
parameters
|
|
550
582
|
}: {
|
|
551
583
|
hookName: H;
|
|
552
584
|
parameters?: PluginParameter<H>;
|
|
553
|
-
message: string;
|
|
554
585
|
}): Promise<void>;
|
|
555
586
|
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
556
587
|
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
@@ -667,6 +698,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
667
698
|
override: Array<Override<TOptions>> | undefined;
|
|
668
699
|
contentType: contentType | undefined;
|
|
669
700
|
pluginManager: PluginManager;
|
|
701
|
+
logger?: Logger;
|
|
670
702
|
/**
|
|
671
703
|
* Current plugin
|
|
672
704
|
*/
|
|
@@ -910,6 +942,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
910
942
|
fabric: Fabric;
|
|
911
943
|
oas: Oas;
|
|
912
944
|
pluginManager: PluginManager;
|
|
945
|
+
logger?: Logger;
|
|
913
946
|
/**
|
|
914
947
|
* Current plugin
|
|
915
948
|
*/
|
|
@@ -1137,4 +1170,4 @@ type ResolvedOptions = {
|
|
|
1137
1170
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1138
1171
|
//#endregion
|
|
1139
1172
|
export { UserPluginWithLifeCycle as a, OperationSchemas as i, PluginClient as n, Operation$1 as o, ReactGenerator as r, Options as t };
|
|
1140
|
-
//# sourceMappingURL=types-
|
|
1173
|
+
//# sourceMappingURL=types-HFFrUUbA.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-client",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.3",
|
|
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.11.
|
|
92
|
-
"@kubb/oas": "4.11.
|
|
93
|
-
"@kubb/plugin-oas": "4.11.
|
|
94
|
-
"@kubb/plugin-ts": "4.11.
|
|
95
|
-
"@kubb/plugin-zod": "4.11.
|
|
91
|
+
"@kubb/core": "4.11.3",
|
|
92
|
+
"@kubb/oas": "4.11.3",
|
|
93
|
+
"@kubb/plugin-oas": "4.11.3",
|
|
94
|
+
"@kubb/plugin-ts": "4.11.3",
|
|
95
|
+
"@kubb/plugin-zod": "4.11.3"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"axios": "^1.13.2"
|