@kubb/plugin-vue-query 4.11.3 → 4.12.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.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/index.cjs +2 -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 +2 -3
- package/dist/index.js.map +1 -1
- package/dist/{types-Bt5VIopi.d.ts → types-DW7JFPyZ.d.cts} +216 -103
- package/dist/{types-BbcLVl7P.d.cts → types-Dp-tPB5l.d.ts} +216 -103
- package/package.json +9 -9
- package/src/generators/__snapshots__/findByTagsTemplateString.ts +90 -0
- package/src/plugin.ts +1 -2
package/dist/components.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as Operation, i as Transformer, o as OperationSchemas, r as PluginVueQuery, t as Infinite } from "./types-
|
|
1
|
+
import { c as Operation, i as Transformer, o as OperationSchemas, r as PluginVueQuery, t as Infinite } from "./types-DW7JFPyZ.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 { c as Operation, i as Transformer, o as OperationSchemas, r as PluginVueQuery, t as Infinite } from "./types-
|
|
1
|
+
import { c as Operation, i as Transformer, o as OperationSchemas, r as PluginVueQuery, t as Infinite } from "./types-Dp-tPB5l.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 { a as ReactGenerator, r as PluginVueQuery } from "./types-
|
|
1
|
+
import { a as ReactGenerator, r as PluginVueQuery } from "./types-DW7JFPyZ.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/generators/infiniteQueryGenerator.d.ts
|
|
4
4
|
declare const infiniteQueryGenerator: ReactGenerator<PluginVueQuery>;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ReactGenerator, r as PluginVueQuery } from "./types-
|
|
1
|
+
import { a as ReactGenerator, r as PluginVueQuery } from "./types-Dp-tPB5l.js";
|
|
2
2
|
|
|
3
3
|
//#region src/generators/infiniteQueryGenerator.d.ts
|
|
4
4
|
declare const infiniteQueryGenerator: ReactGenerator<PluginVueQuery>;
|
package/dist/index.cjs
CHANGED
|
@@ -126,7 +126,7 @@ const pluginVueQuery = (0, __kubb_core.definePlugin)((options) => {
|
|
|
126
126
|
fabric: this.fabric,
|
|
127
127
|
oas,
|
|
128
128
|
pluginManager: this.pluginManager,
|
|
129
|
-
|
|
129
|
+
events: this.events,
|
|
130
130
|
plugin: this.plugin,
|
|
131
131
|
contentType,
|
|
132
132
|
exclude,
|
|
@@ -139,8 +139,7 @@ const pluginVueQuery = (0, __kubb_core.definePlugin)((options) => {
|
|
|
139
139
|
type: output.barrelType ?? "named",
|
|
140
140
|
root,
|
|
141
141
|
output,
|
|
142
|
-
meta: { pluginKey: this.plugin.key }
|
|
143
|
-
logger: this.logger
|
|
142
|
+
meta: { pluginKey: this.plugin.key }
|
|
144
143
|
});
|
|
145
144
|
await this.upsertFile(...barrelFiles);
|
|
146
145
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["MutationKey","QueryKey","queryGenerator","infiniteQueryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","path","options","groupName: Group['name']","pluginClientName","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey, QueryKey } from './components'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './generators'\nimport type { PluginVueQuery } from './types.ts'\n\nexport const pluginVueQueryName = 'plugin-vue-query' satisfies PluginVueQuery['name']\n\nexport const pluginVueQuery = definePlugin<PluginVueQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n infinite,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutation = {},\n query = {},\n paramsCasing,\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),\n contentType,\n client,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginVueQueryName,\n options: {\n output,\n client: {\n ...options.client,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n dataReturnType: client?.dataReturnType ?? 'data',\n pathParamsType,\n importPath: clientImportPath,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n nextParam: undefined,\n previousParam: undefined,\n ...infinite,\n }\n : false,\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/vue-query',\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/vue-query',\n ...mutation,\n },\n paramsType,\n pathParamsType,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async 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 if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled\n await this.upsertFile({\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.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 if (!hasClientPlugin) {\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["MutationKey","QueryKey","queryGenerator","infiniteQueryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","path","options","groupName: Group['name']","pluginClientName","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey, QueryKey } from './components'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './generators'\nimport type { PluginVueQuery } from './types.ts'\n\nexport const pluginVueQueryName = 'plugin-vue-query' satisfies PluginVueQuery['name']\n\nexport const pluginVueQuery = definePlugin<PluginVueQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n infinite,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutation = {},\n query = {},\n paramsCasing,\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),\n contentType,\n client,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginVueQueryName,\n options: {\n output,\n client: {\n ...options.client,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n dataReturnType: client?.dataReturnType ?? 'data',\n pathParamsType,\n importPath: clientImportPath,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n nextParam: undefined,\n previousParam: undefined,\n ...infinite,\n }\n : false,\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/vue-query',\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/vue-query',\n ...mutation,\n },\n paramsType,\n pathParamsType,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async 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 if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled\n await this.upsertFile({\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.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 if (!hasClientPlugin) {\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,qBAAqB;AAElC,MAAa,gDAA+C,YAAY;CACtE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,UACA,eAAe,EAAE,EACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,WAAW,EAAE,EACb,QAAQ,EAAE,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AAc;KACd,aAAa;KACd,CACF;IACF,CAAC;GAgBJ,MAAM,QAAQ,MAba,IAAII,qCAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,sCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as Options, r as PluginVueQuery, s as UserPluginWithLifeCycle } from "./types-
|
|
1
|
+
import { n as Options, r as PluginVueQuery, s as UserPluginWithLifeCycle } from "./types-DW7JFPyZ.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginVueQueryName = "plugin-vue-query";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as Options, r as PluginVueQuery, s as UserPluginWithLifeCycle } from "./types-
|
|
1
|
+
import { n as Options, r as PluginVueQuery, s as UserPluginWithLifeCycle } from "./types-Dp-tPB5l.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginVueQueryName = "plugin-vue-query";
|
package/dist/index.js
CHANGED
|
@@ -125,7 +125,7 @@ const pluginVueQuery = definePlugin((options) => {
|
|
|
125
125
|
fabric: this.fabric,
|
|
126
126
|
oas,
|
|
127
127
|
pluginManager: this.pluginManager,
|
|
128
|
-
|
|
128
|
+
events: this.events,
|
|
129
129
|
plugin: this.plugin,
|
|
130
130
|
contentType,
|
|
131
131
|
exclude,
|
|
@@ -138,8 +138,7 @@ const pluginVueQuery = definePlugin((options) => {
|
|
|
138
138
|
type: output.barrelType ?? "named",
|
|
139
139
|
root,
|
|
140
140
|
output,
|
|
141
|
-
meta: { pluginKey: this.plugin.key }
|
|
142
|
-
logger: this.logger
|
|
141
|
+
meta: { pluginKey: this.plugin.key }
|
|
143
142
|
});
|
|
144
143
|
await this.upsertFile(...barrelFiles);
|
|
145
144
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey, QueryKey } from './components'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './generators'\nimport type { PluginVueQuery } from './types.ts'\n\nexport const pluginVueQueryName = 'plugin-vue-query' satisfies PluginVueQuery['name']\n\nexport const pluginVueQuery = definePlugin<PluginVueQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n infinite,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutation = {},\n query = {},\n paramsCasing,\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),\n contentType,\n client,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginVueQueryName,\n options: {\n output,\n client: {\n ...options.client,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n dataReturnType: client?.dataReturnType ?? 'data',\n pathParamsType,\n importPath: clientImportPath,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n nextParam: undefined,\n previousParam: undefined,\n ...infinite,\n }\n : false,\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/vue-query',\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/vue-query',\n ...mutation,\n },\n paramsType,\n pathParamsType,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async 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 if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled\n await this.upsertFile({\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.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 if (!hasClientPlugin) {\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey, QueryKey } from './components'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './generators'\nimport type { PluginVueQuery } from './types.ts'\n\nexport const pluginVueQueryName = 'plugin-vue-query' satisfies PluginVueQuery['name']\n\nexport const pluginVueQuery = definePlugin<PluginVueQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n infinite,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutation = {},\n query = {},\n paramsCasing,\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),\n contentType,\n client,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginVueQueryName,\n options: {\n output,\n client: {\n ...options.client,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n dataReturnType: client?.dataReturnType ?? 'data',\n pathParamsType,\n importPath: clientImportPath,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n nextParam: undefined,\n previousParam: undefined,\n ...infinite,\n }\n : false,\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/vue-query',\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/vue-query',\n ...mutation,\n },\n paramsType,\n pathParamsType,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async 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 if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByKey([pluginClientName])\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled\n await this.upsertFile({\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.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 if (!hasClientPlugin) {\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: resolveModuleSource('@kubb/plugin-client/templates/config').source,\n isExportable: false,\n isIndexable: false,\n },\n ],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: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AK,WAAW;IACpB,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,CACP;KACE,MAAM;KACN,OAAO,oBACL,KAAK,OAAO,QAAQ,OAAO,WAAW,UAAU,gDAAgD,8CACjG,CAAC;KACF,cAAc;KACd,aAAa;KACd,CACF;IACF,CAAC;AAGJ,OAAI,CAAC,gBACH,OAAM,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;GAgBJ,MAAM,QAAQ,MAba,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Fabric } from "@kubb/react-fabric";
|
|
2
1
|
import * as OasTypes from "oas/types";
|
|
3
2
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
4
3
|
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
@@ -6,7 +5,7 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
6
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
7
6
|
import BaseOas from "oas";
|
|
8
7
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
9
|
-
import {
|
|
8
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
10
9
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
11
10
|
|
|
12
11
|
//#region ../oas/src/types.d.ts
|
|
@@ -58,75 +57,229 @@ declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
|
58
57
|
abstract build(...params: unknown[]): unknown;
|
|
59
58
|
}
|
|
60
59
|
//#endregion
|
|
61
|
-
//#region ../core/src/
|
|
62
|
-
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
63
|
-
#private;
|
|
64
|
-
constructor();
|
|
65
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
66
|
-
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
67
|
-
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
68
|
-
removeAll(): void;
|
|
69
|
-
}
|
|
70
|
-
//#endregion
|
|
71
|
-
//#region ../core/src/logger.d.ts
|
|
60
|
+
//#region ../core/src/Kubb.d.ts
|
|
72
61
|
type DebugEvent = {
|
|
73
62
|
date: Date;
|
|
74
63
|
logs: string[];
|
|
75
64
|
fileName?: string;
|
|
65
|
+
};
|
|
66
|
+
type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
67
|
+
hookName: H;
|
|
68
|
+
plugins: Array<Plugin>;
|
|
69
|
+
};
|
|
70
|
+
type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
71
|
+
hookName: H;
|
|
72
|
+
};
|
|
73
|
+
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
74
|
+
strategy: Strategy;
|
|
75
|
+
hookName: H;
|
|
76
|
+
plugin: Plugin;
|
|
77
|
+
parameters?: unknown[] | undefined;
|
|
78
|
+
output?: unknown;
|
|
79
|
+
};
|
|
80
|
+
type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
81
|
+
duration: number;
|
|
82
|
+
strategy: Strategy;
|
|
83
|
+
hookName: H;
|
|
84
|
+
plugin: Plugin;
|
|
85
|
+
parameters?: unknown[] | undefined;
|
|
86
|
+
output?: unknown;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Events emitted during the Kubb code generation lifecycle.
|
|
90
|
+
* These events can be listened to for logging, progress tracking, and custom integrations.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* import type { AsyncEventEmitter } from '@kubb/core'
|
|
95
|
+
* import type { KubbEvents } from '@kubb/core'
|
|
96
|
+
*
|
|
97
|
+
* const events: AsyncEventEmitter<KubbEvents> = new AsyncEventEmitter()
|
|
98
|
+
*
|
|
99
|
+
* events.on('lifecycle:start', () => {
|
|
100
|
+
* console.log('Starting Kubb generation')
|
|
101
|
+
* })
|
|
102
|
+
*
|
|
103
|
+
* events.on('plugin:end', (plugin, duration) => {
|
|
104
|
+
* console.log(`Plugin ${plugin.name} completed in ${duration}ms`)
|
|
105
|
+
* })
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
interface KubbEvents {
|
|
76
109
|
/**
|
|
77
|
-
*
|
|
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)
|
|
110
|
+
* Emitted at the beginning of the Kubb lifecycle, before any code generation starts.
|
|
85
111
|
*/
|
|
86
|
-
|
|
112
|
+
'lifecycle:start': [version: string];
|
|
87
113
|
/**
|
|
88
|
-
*
|
|
114
|
+
* Emitted at the end of the Kubb lifecycle, after all code generation is complete.
|
|
89
115
|
*/
|
|
90
|
-
|
|
116
|
+
'lifecycle:end': [];
|
|
91
117
|
/**
|
|
92
|
-
*
|
|
93
|
-
* - 'start': Start of plugin execution group
|
|
94
|
-
* - 'end': End of plugin execution group
|
|
118
|
+
* Emitted when configuration loading starts.
|
|
95
119
|
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
'config:start': [];
|
|
121
|
+
/**
|
|
122
|
+
* Emitted when configuration loading is complete.
|
|
123
|
+
*/
|
|
124
|
+
'config:end': [configs: Array<Config>];
|
|
125
|
+
/**
|
|
126
|
+
* Emitted when code generation phase starts.
|
|
127
|
+
*/
|
|
128
|
+
'generation:start': [config: Config];
|
|
129
|
+
/**
|
|
130
|
+
* Emitted when code generation phase completes.
|
|
131
|
+
*/
|
|
132
|
+
'generation:end': [Config: Config];
|
|
133
|
+
/**
|
|
134
|
+
* Emitted with a summary of the generation results.
|
|
135
|
+
* Contains summary lines, title, and success status.
|
|
136
|
+
*/
|
|
137
|
+
'generation:summary': [Config: Config, {
|
|
138
|
+
failedPlugins: Set<{
|
|
139
|
+
plugin: Plugin;
|
|
140
|
+
error: Error;
|
|
141
|
+
}>;
|
|
142
|
+
status: 'success' | 'failed';
|
|
143
|
+
hrStart: [number, number];
|
|
144
|
+
filesCreated: number;
|
|
145
|
+
pluginTimings?: Map<string, number>;
|
|
114
146
|
}];
|
|
115
|
-
|
|
116
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Emitted when code formatting starts (e.g., running Biome or Prettier).
|
|
149
|
+
*/
|
|
150
|
+
'format:start': [];
|
|
151
|
+
/**
|
|
152
|
+
* Emitted when code formatting completes.
|
|
153
|
+
*/
|
|
154
|
+
'format:end': [];
|
|
155
|
+
/**
|
|
156
|
+
* Emitted when linting starts.
|
|
157
|
+
*/
|
|
158
|
+
'lint:start': [];
|
|
159
|
+
/**
|
|
160
|
+
* Emitted when linting completes.
|
|
161
|
+
*/
|
|
162
|
+
'lint:end': [];
|
|
163
|
+
/**
|
|
164
|
+
* Emitted when plugin hooks execution starts.
|
|
165
|
+
*/
|
|
166
|
+
'hooks:start': [];
|
|
167
|
+
/**
|
|
168
|
+
* Emitted when plugin hooks execution completes.
|
|
169
|
+
*/
|
|
170
|
+
'hooks:end': [];
|
|
171
|
+
/**
|
|
172
|
+
* Emitted when a single hook execution starts.
|
|
173
|
+
*/
|
|
174
|
+
'hook:start': [command: string];
|
|
175
|
+
/**
|
|
176
|
+
* Emitted to execute a hook command (e.g., format or lint).
|
|
177
|
+
* The callback should be invoked when the command completes.
|
|
178
|
+
*/
|
|
179
|
+
'hook:execute': [{
|
|
180
|
+
command: string | URL;
|
|
181
|
+
args?: readonly string[];
|
|
182
|
+
}, cb: () => void];
|
|
183
|
+
/**
|
|
184
|
+
* Emitted when a single hook execution completes.
|
|
185
|
+
*/
|
|
186
|
+
'hook:end': [command: string];
|
|
187
|
+
/**
|
|
188
|
+
* Emitted when a new version of Kubb is available.
|
|
189
|
+
*/
|
|
190
|
+
'version:new': [currentVersion: string, latestVersion: string];
|
|
191
|
+
/**
|
|
192
|
+
* Informational message event.
|
|
193
|
+
*/
|
|
194
|
+
info: [message: string, info?: string];
|
|
195
|
+
/**
|
|
196
|
+
* Error event. Emitted when an error occurs during code generation.
|
|
197
|
+
*/
|
|
198
|
+
error: [error: Error, meta?: Record<string, unknown>];
|
|
199
|
+
/**
|
|
200
|
+
* Success message event.
|
|
201
|
+
*/
|
|
202
|
+
success: [message: string, info?: string];
|
|
203
|
+
/**
|
|
204
|
+
* Warning message event.
|
|
205
|
+
*/
|
|
206
|
+
warn: [message: string, info?: string];
|
|
207
|
+
/**
|
|
208
|
+
* Debug event for detailed logging.
|
|
209
|
+
* Contains timestamp, log messages, and optional filename.
|
|
210
|
+
*/
|
|
211
|
+
debug: [meta: DebugEvent];
|
|
212
|
+
/**
|
|
213
|
+
* Emitted when file processing starts.
|
|
214
|
+
* Contains the list of files to be processed.
|
|
215
|
+
*/
|
|
216
|
+
'files:processing:start': [files: Array<KubbFile.ResolvedFile>];
|
|
217
|
+
/**
|
|
218
|
+
* Emitted for each file being processed, providing progress updates.
|
|
219
|
+
* Contains processed count, total count, percentage, and file details.
|
|
220
|
+
*/
|
|
221
|
+
'file:processing:update': [{
|
|
222
|
+
/** Number of files processed so far */
|
|
223
|
+
processed: number;
|
|
224
|
+
/** Total number of files to process */
|
|
225
|
+
total: number;
|
|
226
|
+
/** Processing percentage (0-100) */
|
|
227
|
+
percentage: number;
|
|
228
|
+
/** Optional source identifier */
|
|
229
|
+
source?: string;
|
|
230
|
+
/** The file being processed */
|
|
231
|
+
file: KubbFile.ResolvedFile;
|
|
232
|
+
/**
|
|
233
|
+
* Kubb configuration (not present in Fabric).
|
|
234
|
+
* Provides access to the current config during file processing.
|
|
235
|
+
*/
|
|
236
|
+
config: Config;
|
|
117
237
|
}];
|
|
118
|
-
};
|
|
119
|
-
type Logger = {
|
|
120
238
|
/**
|
|
121
|
-
*
|
|
239
|
+
* Emitted when file processing completes.
|
|
240
|
+
* Contains the list of processed files.
|
|
122
241
|
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
242
|
+
'files:processing:end': [files: KubbFile.ResolvedFile[]];
|
|
243
|
+
/**
|
|
244
|
+
* Emitted when a plugin starts executing.
|
|
245
|
+
*/
|
|
246
|
+
'plugin:start': [plugin: Plugin];
|
|
247
|
+
/**
|
|
248
|
+
* Emitted when a plugin completes execution.
|
|
249
|
+
*/
|
|
250
|
+
'plugin:end': [plugin: Plugin, duration: number];
|
|
251
|
+
/**
|
|
252
|
+
* Emitted when plugin hook progress tracking starts.
|
|
253
|
+
* Contains the hook name and list of plugins to execute.
|
|
254
|
+
*/
|
|
255
|
+
'plugins:hook:progress:start': [meta: ProgressStartMeta];
|
|
256
|
+
/**
|
|
257
|
+
* Emitted when plugin hook progress tracking ends.
|
|
258
|
+
* Contains the hook name that completed.
|
|
259
|
+
*/
|
|
260
|
+
'plugins:hook:progress:end': [meta: ProgressStopMeta];
|
|
261
|
+
/**
|
|
262
|
+
* Emitted when a plugin hook starts processing.
|
|
263
|
+
* Contains strategy, hook name, plugin, parameters, and output.
|
|
264
|
+
*/
|
|
265
|
+
'plugins:hook:processing:start': [meta: ExecutingMeta];
|
|
266
|
+
/**
|
|
267
|
+
* Emitted when a plugin hook completes processing.
|
|
268
|
+
* Contains duration, strategy, hook name, plugin, parameters, and output.
|
|
269
|
+
*/
|
|
270
|
+
'plugins:hook:processing:end': [meta: ExecutedMeta];
|
|
271
|
+
}
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region ../core/src/utils/AsyncEventEmitter.d.ts
|
|
274
|
+
declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
|
|
275
|
+
#private;
|
|
276
|
+
constructor(maxListener?: number);
|
|
277
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
|
|
278
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
279
|
+
onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
|
|
280
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
281
|
+
removeAll(): void;
|
|
282
|
+
}
|
|
130
283
|
//#endregion
|
|
131
284
|
//#region ../core/src/utils/types.d.ts
|
|
132
285
|
type PossiblePromise<T> = Promise<T> | T;
|
|
@@ -390,7 +543,7 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
390
543
|
* merging multiple sources into the same output file
|
|
391
544
|
*/
|
|
392
545
|
upsertFile: (...file: Array<KubbFile.File>) => Promise<void>;
|
|
393
|
-
|
|
546
|
+
events: AsyncEventEmitter<KubbEvents>;
|
|
394
547
|
mode: KubbFile.Mode;
|
|
395
548
|
/**
|
|
396
549
|
* Current plugin
|
|
@@ -436,35 +589,6 @@ type Group = {
|
|
|
436
589
|
//#region ../core/src/PluginManager.d.ts
|
|
437
590
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
438
591
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
439
|
-
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
440
|
-
strategy: Strategy;
|
|
441
|
-
hookName: H;
|
|
442
|
-
plugin: Plugin;
|
|
443
|
-
parameters?: unknown[] | undefined;
|
|
444
|
-
output?: unknown;
|
|
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
|
-
};
|
|
468
592
|
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
469
593
|
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
470
594
|
result: Result;
|
|
@@ -472,19 +596,12 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
472
596
|
};
|
|
473
597
|
type Options$2 = {
|
|
474
598
|
fabric: Fabric;
|
|
475
|
-
|
|
599
|
+
events: AsyncEventEmitter<KubbEvents>;
|
|
476
600
|
/**
|
|
477
601
|
* @default Number.POSITIVE_INFINITY
|
|
478
602
|
*/
|
|
479
603
|
concurrency?: number;
|
|
480
604
|
};
|
|
481
|
-
type Events = {
|
|
482
|
-
progress_start: [meta: ProgressStartMeta];
|
|
483
|
-
progress_stop: [meta: ProgressStopMeta];
|
|
484
|
-
executing: [meta: ExecutingMeta];
|
|
485
|
-
executed: [meta: ExecutedMeta];
|
|
486
|
-
error: [error: Error, meta: ErrorMeta];
|
|
487
|
-
};
|
|
488
605
|
type GetFileProps<TOptions = object> = {
|
|
489
606
|
name: string;
|
|
490
607
|
mode?: KubbFile.Mode;
|
|
@@ -494,10 +611,10 @@ type GetFileProps<TOptions = object> = {
|
|
|
494
611
|
};
|
|
495
612
|
declare class PluginManager {
|
|
496
613
|
#private;
|
|
497
|
-
readonly events: EventEmitter<Events>;
|
|
498
614
|
readonly config: Config;
|
|
499
615
|
readonly options: Options$2;
|
|
500
616
|
constructor(config: Config, options: Options$2);
|
|
617
|
+
get events(): AsyncEventEmitter<KubbEvents>;
|
|
501
618
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
502
619
|
get plugins(): Array<Plugin>;
|
|
503
620
|
getFile<TOptions = object>({
|
|
@@ -511,10 +628,6 @@ declare class PluginManager {
|
|
|
511
628
|
}>;
|
|
512
629
|
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
|
|
513
630
|
resolveName: (params: ResolveNameParams) => string;
|
|
514
|
-
/**
|
|
515
|
-
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
516
|
-
*/
|
|
517
|
-
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
518
631
|
/**
|
|
519
632
|
* Run a specific hookName for plugin x.
|
|
520
633
|
*/
|
|
@@ -698,7 +811,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
698
811
|
override: Array<Override<TOptions>> | undefined;
|
|
699
812
|
contentType: contentType | undefined;
|
|
700
813
|
pluginManager: PluginManager;
|
|
701
|
-
|
|
814
|
+
events?: AsyncEventEmitter<KubbEvents>;
|
|
702
815
|
/**
|
|
703
816
|
* Current plugin
|
|
704
817
|
*/
|
|
@@ -942,7 +1055,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
942
1055
|
fabric: Fabric;
|
|
943
1056
|
oas: Oas;
|
|
944
1057
|
pluginManager: PluginManager;
|
|
945
|
-
|
|
1058
|
+
events?: AsyncEventEmitter<KubbEvents>;
|
|
946
1059
|
/**
|
|
947
1060
|
* Current plugin
|
|
948
1061
|
*/
|
|
@@ -1338,4 +1451,4 @@ type ResolvedOptions = {
|
|
|
1338
1451
|
type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1339
1452
|
//#endregion
|
|
1340
1453
|
export { ReactGenerator as a, Operation$1 as c, Transformer as i, Options as n, OperationSchemas as o, PluginVueQuery as r, UserPluginWithLifeCycle as s, Infinite as t };
|
|
1341
|
-
//# sourceMappingURL=types-
|
|
1454
|
+
//# sourceMappingURL=types-DW7JFPyZ.d.cts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
1
2
|
import * as OasTypes from "oas/types";
|
|
2
3
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
3
4
|
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
@@ -5,8 +6,6 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
5
6
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
7
|
import BaseOas from "oas";
|
|
7
8
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
8
|
-
import { Fabric } from "@kubb/react-fabric";
|
|
9
|
-
import { ConsolaInstance, LogLevel } from "consola";
|
|
10
9
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
11
10
|
|
|
12
11
|
//#region ../oas/src/types.d.ts
|
|
@@ -58,75 +57,229 @@ declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
|
58
57
|
abstract build(...params: unknown[]): unknown;
|
|
59
58
|
}
|
|
60
59
|
//#endregion
|
|
61
|
-
//#region ../core/src/
|
|
62
|
-
declare class EventEmitter<TEvents extends Record<string, any>> {
|
|
63
|
-
#private;
|
|
64
|
-
constructor();
|
|
65
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
|
|
66
|
-
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
67
|
-
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
68
|
-
removeAll(): void;
|
|
69
|
-
}
|
|
70
|
-
//#endregion
|
|
71
|
-
//#region ../core/src/logger.d.ts
|
|
60
|
+
//#region ../core/src/Kubb.d.ts
|
|
72
61
|
type DebugEvent = {
|
|
73
62
|
date: Date;
|
|
74
63
|
logs: string[];
|
|
75
64
|
fileName?: string;
|
|
65
|
+
};
|
|
66
|
+
type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
67
|
+
hookName: H;
|
|
68
|
+
plugins: Array<Plugin>;
|
|
69
|
+
};
|
|
70
|
+
type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
71
|
+
hookName: H;
|
|
72
|
+
};
|
|
73
|
+
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
74
|
+
strategy: Strategy;
|
|
75
|
+
hookName: H;
|
|
76
|
+
plugin: Plugin;
|
|
77
|
+
parameters?: unknown[] | undefined;
|
|
78
|
+
output?: unknown;
|
|
79
|
+
};
|
|
80
|
+
type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
81
|
+
duration: number;
|
|
82
|
+
strategy: Strategy;
|
|
83
|
+
hookName: H;
|
|
84
|
+
plugin: Plugin;
|
|
85
|
+
parameters?: unknown[] | undefined;
|
|
86
|
+
output?: unknown;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Events emitted during the Kubb code generation lifecycle.
|
|
90
|
+
* These events can be listened to for logging, progress tracking, and custom integrations.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* import type { AsyncEventEmitter } from '@kubb/core'
|
|
95
|
+
* import type { KubbEvents } from '@kubb/core'
|
|
96
|
+
*
|
|
97
|
+
* const events: AsyncEventEmitter<KubbEvents> = new AsyncEventEmitter()
|
|
98
|
+
*
|
|
99
|
+
* events.on('lifecycle:start', () => {
|
|
100
|
+
* console.log('Starting Kubb generation')
|
|
101
|
+
* })
|
|
102
|
+
*
|
|
103
|
+
* events.on('plugin:end', (plugin, duration) => {
|
|
104
|
+
* console.log(`Plugin ${plugin.name} completed in ${duration}ms`)
|
|
105
|
+
* })
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
interface KubbEvents {
|
|
76
109
|
/**
|
|
77
|
-
*
|
|
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)
|
|
110
|
+
* Emitted at the beginning of the Kubb lifecycle, before any code generation starts.
|
|
85
111
|
*/
|
|
86
|
-
|
|
112
|
+
'lifecycle:start': [version: string];
|
|
87
113
|
/**
|
|
88
|
-
*
|
|
114
|
+
* Emitted at the end of the Kubb lifecycle, after all code generation is complete.
|
|
89
115
|
*/
|
|
90
|
-
|
|
116
|
+
'lifecycle:end': [];
|
|
91
117
|
/**
|
|
92
|
-
*
|
|
93
|
-
* - 'start': Start of plugin execution group
|
|
94
|
-
* - 'end': End of plugin execution group
|
|
118
|
+
* Emitted when configuration loading starts.
|
|
95
119
|
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
'config:start': [];
|
|
121
|
+
/**
|
|
122
|
+
* Emitted when configuration loading is complete.
|
|
123
|
+
*/
|
|
124
|
+
'config:end': [configs: Array<Config>];
|
|
125
|
+
/**
|
|
126
|
+
* Emitted when code generation phase starts.
|
|
127
|
+
*/
|
|
128
|
+
'generation:start': [config: Config];
|
|
129
|
+
/**
|
|
130
|
+
* Emitted when code generation phase completes.
|
|
131
|
+
*/
|
|
132
|
+
'generation:end': [Config: Config];
|
|
133
|
+
/**
|
|
134
|
+
* Emitted with a summary of the generation results.
|
|
135
|
+
* Contains summary lines, title, and success status.
|
|
136
|
+
*/
|
|
137
|
+
'generation:summary': [Config: Config, {
|
|
138
|
+
failedPlugins: Set<{
|
|
139
|
+
plugin: Plugin;
|
|
140
|
+
error: Error;
|
|
141
|
+
}>;
|
|
142
|
+
status: 'success' | 'failed';
|
|
143
|
+
hrStart: [number, number];
|
|
144
|
+
filesCreated: number;
|
|
145
|
+
pluginTimings?: Map<string, number>;
|
|
114
146
|
}];
|
|
115
|
-
|
|
116
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Emitted when code formatting starts (e.g., running Biome or Prettier).
|
|
149
|
+
*/
|
|
150
|
+
'format:start': [];
|
|
151
|
+
/**
|
|
152
|
+
* Emitted when code formatting completes.
|
|
153
|
+
*/
|
|
154
|
+
'format:end': [];
|
|
155
|
+
/**
|
|
156
|
+
* Emitted when linting starts.
|
|
157
|
+
*/
|
|
158
|
+
'lint:start': [];
|
|
159
|
+
/**
|
|
160
|
+
* Emitted when linting completes.
|
|
161
|
+
*/
|
|
162
|
+
'lint:end': [];
|
|
163
|
+
/**
|
|
164
|
+
* Emitted when plugin hooks execution starts.
|
|
165
|
+
*/
|
|
166
|
+
'hooks:start': [];
|
|
167
|
+
/**
|
|
168
|
+
* Emitted when plugin hooks execution completes.
|
|
169
|
+
*/
|
|
170
|
+
'hooks:end': [];
|
|
171
|
+
/**
|
|
172
|
+
* Emitted when a single hook execution starts.
|
|
173
|
+
*/
|
|
174
|
+
'hook:start': [command: string];
|
|
175
|
+
/**
|
|
176
|
+
* Emitted to execute a hook command (e.g., format or lint).
|
|
177
|
+
* The callback should be invoked when the command completes.
|
|
178
|
+
*/
|
|
179
|
+
'hook:execute': [{
|
|
180
|
+
command: string | URL;
|
|
181
|
+
args?: readonly string[];
|
|
182
|
+
}, cb: () => void];
|
|
183
|
+
/**
|
|
184
|
+
* Emitted when a single hook execution completes.
|
|
185
|
+
*/
|
|
186
|
+
'hook:end': [command: string];
|
|
187
|
+
/**
|
|
188
|
+
* Emitted when a new version of Kubb is available.
|
|
189
|
+
*/
|
|
190
|
+
'version:new': [currentVersion: string, latestVersion: string];
|
|
191
|
+
/**
|
|
192
|
+
* Informational message event.
|
|
193
|
+
*/
|
|
194
|
+
info: [message: string, info?: string];
|
|
195
|
+
/**
|
|
196
|
+
* Error event. Emitted when an error occurs during code generation.
|
|
197
|
+
*/
|
|
198
|
+
error: [error: Error, meta?: Record<string, unknown>];
|
|
199
|
+
/**
|
|
200
|
+
* Success message event.
|
|
201
|
+
*/
|
|
202
|
+
success: [message: string, info?: string];
|
|
203
|
+
/**
|
|
204
|
+
* Warning message event.
|
|
205
|
+
*/
|
|
206
|
+
warn: [message: string, info?: string];
|
|
207
|
+
/**
|
|
208
|
+
* Debug event for detailed logging.
|
|
209
|
+
* Contains timestamp, log messages, and optional filename.
|
|
210
|
+
*/
|
|
211
|
+
debug: [meta: DebugEvent];
|
|
212
|
+
/**
|
|
213
|
+
* Emitted when file processing starts.
|
|
214
|
+
* Contains the list of files to be processed.
|
|
215
|
+
*/
|
|
216
|
+
'files:processing:start': [files: Array<KubbFile.ResolvedFile>];
|
|
217
|
+
/**
|
|
218
|
+
* Emitted for each file being processed, providing progress updates.
|
|
219
|
+
* Contains processed count, total count, percentage, and file details.
|
|
220
|
+
*/
|
|
221
|
+
'file:processing:update': [{
|
|
222
|
+
/** Number of files processed so far */
|
|
223
|
+
processed: number;
|
|
224
|
+
/** Total number of files to process */
|
|
225
|
+
total: number;
|
|
226
|
+
/** Processing percentage (0-100) */
|
|
227
|
+
percentage: number;
|
|
228
|
+
/** Optional source identifier */
|
|
229
|
+
source?: string;
|
|
230
|
+
/** The file being processed */
|
|
231
|
+
file: KubbFile.ResolvedFile;
|
|
232
|
+
/**
|
|
233
|
+
* Kubb configuration (not present in Fabric).
|
|
234
|
+
* Provides access to the current config during file processing.
|
|
235
|
+
*/
|
|
236
|
+
config: Config;
|
|
117
237
|
}];
|
|
118
|
-
};
|
|
119
|
-
type Logger = {
|
|
120
238
|
/**
|
|
121
|
-
*
|
|
239
|
+
* Emitted when file processing completes.
|
|
240
|
+
* Contains the list of processed files.
|
|
122
241
|
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
242
|
+
'files:processing:end': [files: KubbFile.ResolvedFile[]];
|
|
243
|
+
/**
|
|
244
|
+
* Emitted when a plugin starts executing.
|
|
245
|
+
*/
|
|
246
|
+
'plugin:start': [plugin: Plugin];
|
|
247
|
+
/**
|
|
248
|
+
* Emitted when a plugin completes execution.
|
|
249
|
+
*/
|
|
250
|
+
'plugin:end': [plugin: Plugin, duration: number];
|
|
251
|
+
/**
|
|
252
|
+
* Emitted when plugin hook progress tracking starts.
|
|
253
|
+
* Contains the hook name and list of plugins to execute.
|
|
254
|
+
*/
|
|
255
|
+
'plugins:hook:progress:start': [meta: ProgressStartMeta];
|
|
256
|
+
/**
|
|
257
|
+
* Emitted when plugin hook progress tracking ends.
|
|
258
|
+
* Contains the hook name that completed.
|
|
259
|
+
*/
|
|
260
|
+
'plugins:hook:progress:end': [meta: ProgressStopMeta];
|
|
261
|
+
/**
|
|
262
|
+
* Emitted when a plugin hook starts processing.
|
|
263
|
+
* Contains strategy, hook name, plugin, parameters, and output.
|
|
264
|
+
*/
|
|
265
|
+
'plugins:hook:processing:start': [meta: ExecutingMeta];
|
|
266
|
+
/**
|
|
267
|
+
* Emitted when a plugin hook completes processing.
|
|
268
|
+
* Contains duration, strategy, hook name, plugin, parameters, and output.
|
|
269
|
+
*/
|
|
270
|
+
'plugins:hook:processing:end': [meta: ExecutedMeta];
|
|
271
|
+
}
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region ../core/src/utils/AsyncEventEmitter.d.ts
|
|
274
|
+
declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
|
|
275
|
+
#private;
|
|
276
|
+
constructor(maxListener?: number);
|
|
277
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
|
|
278
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
279
|
+
onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
|
|
280
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
|
|
281
|
+
removeAll(): void;
|
|
282
|
+
}
|
|
130
283
|
//#endregion
|
|
131
284
|
//#region ../core/src/utils/types.d.ts
|
|
132
285
|
type PossiblePromise<T> = Promise<T> | T;
|
|
@@ -390,7 +543,7 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
390
543
|
* merging multiple sources into the same output file
|
|
391
544
|
*/
|
|
392
545
|
upsertFile: (...file: Array<KubbFile.File>) => Promise<void>;
|
|
393
|
-
|
|
546
|
+
events: AsyncEventEmitter<KubbEvents>;
|
|
394
547
|
mode: KubbFile.Mode;
|
|
395
548
|
/**
|
|
396
549
|
* Current plugin
|
|
@@ -436,35 +589,6 @@ type Group = {
|
|
|
436
589
|
//#region ../core/src/PluginManager.d.ts
|
|
437
590
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
438
591
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
439
|
-
type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
440
|
-
strategy: Strategy;
|
|
441
|
-
hookName: H;
|
|
442
|
-
plugin: Plugin;
|
|
443
|
-
parameters?: unknown[] | undefined;
|
|
444
|
-
output?: unknown;
|
|
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
|
-
};
|
|
468
592
|
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
469
593
|
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
470
594
|
result: Result;
|
|
@@ -472,19 +596,12 @@ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseRe
|
|
|
472
596
|
};
|
|
473
597
|
type Options$2 = {
|
|
474
598
|
fabric: Fabric;
|
|
475
|
-
|
|
599
|
+
events: AsyncEventEmitter<KubbEvents>;
|
|
476
600
|
/**
|
|
477
601
|
* @default Number.POSITIVE_INFINITY
|
|
478
602
|
*/
|
|
479
603
|
concurrency?: number;
|
|
480
604
|
};
|
|
481
|
-
type Events = {
|
|
482
|
-
progress_start: [meta: ProgressStartMeta];
|
|
483
|
-
progress_stop: [meta: ProgressStopMeta];
|
|
484
|
-
executing: [meta: ExecutingMeta];
|
|
485
|
-
executed: [meta: ExecutedMeta];
|
|
486
|
-
error: [error: Error, meta: ErrorMeta];
|
|
487
|
-
};
|
|
488
605
|
type GetFileProps<TOptions = object> = {
|
|
489
606
|
name: string;
|
|
490
607
|
mode?: KubbFile.Mode;
|
|
@@ -494,10 +611,10 @@ type GetFileProps<TOptions = object> = {
|
|
|
494
611
|
};
|
|
495
612
|
declare class PluginManager {
|
|
496
613
|
#private;
|
|
497
|
-
readonly events: EventEmitter<Events>;
|
|
498
614
|
readonly config: Config;
|
|
499
615
|
readonly options: Options$2;
|
|
500
616
|
constructor(config: Config, options: Options$2);
|
|
617
|
+
get events(): AsyncEventEmitter<KubbEvents>;
|
|
501
618
|
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
502
619
|
get plugins(): Array<Plugin>;
|
|
503
620
|
getFile<TOptions = object>({
|
|
@@ -511,10 +628,6 @@ declare class PluginManager {
|
|
|
511
628
|
}>;
|
|
512
629
|
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
|
|
513
630
|
resolveName: (params: ResolveNameParams) => string;
|
|
514
|
-
/**
|
|
515
|
-
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
516
|
-
*/
|
|
517
|
-
on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
|
|
518
631
|
/**
|
|
519
632
|
* Run a specific hookName for plugin x.
|
|
520
633
|
*/
|
|
@@ -698,7 +811,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
698
811
|
override: Array<Override<TOptions>> | undefined;
|
|
699
812
|
contentType: contentType | undefined;
|
|
700
813
|
pluginManager: PluginManager;
|
|
701
|
-
|
|
814
|
+
events?: AsyncEventEmitter<KubbEvents>;
|
|
702
815
|
/**
|
|
703
816
|
* Current plugin
|
|
704
817
|
*/
|
|
@@ -942,7 +1055,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
942
1055
|
fabric: Fabric;
|
|
943
1056
|
oas: Oas;
|
|
944
1057
|
pluginManager: PluginManager;
|
|
945
|
-
|
|
1058
|
+
events?: AsyncEventEmitter<KubbEvents>;
|
|
946
1059
|
/**
|
|
947
1060
|
* Current plugin
|
|
948
1061
|
*/
|
|
@@ -1338,4 +1451,4 @@ type ResolvedOptions = {
|
|
|
1338
1451
|
type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1339
1452
|
//#endregion
|
|
1340
1453
|
export { ReactGenerator as a, Operation$1 as c, Transformer as i, Options as n, OperationSchemas as o, PluginVueQuery as r, UserPluginWithLifeCycle as s, Infinite as t };
|
|
1341
|
-
//# sourceMappingURL=types-
|
|
1454
|
+
//# sourceMappingURL=types-Dp-tPB5l.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-vue-query",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.1",
|
|
4
4
|
"description": "Vue Query hooks generator plugin for Kubb, creating type-safe API client hooks from OpenAPI specifications for Vue.js applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue-query",
|
|
@@ -68,17 +68,17 @@
|
|
|
68
68
|
}
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@kubb/react-fabric": "0.
|
|
71
|
+
"@kubb/react-fabric": "0.7.0",
|
|
72
72
|
"remeda": "^2.32.0",
|
|
73
|
-
"@kubb/core": "4.
|
|
74
|
-
"@kubb/oas": "4.
|
|
75
|
-
"@kubb/plugin-client": "4.
|
|
76
|
-
"@kubb/plugin-oas": "4.
|
|
77
|
-
"@kubb/plugin-ts": "4.
|
|
78
|
-
"@kubb/plugin-zod": "4.
|
|
73
|
+
"@kubb/core": "4.12.1",
|
|
74
|
+
"@kubb/oas": "4.12.1",
|
|
75
|
+
"@kubb/plugin-client": "4.12.1",
|
|
76
|
+
"@kubb/plugin-oas": "4.12.1",
|
|
77
|
+
"@kubb/plugin-ts": "4.12.1",
|
|
78
|
+
"@kubb/plugin-zod": "4.12.1"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"@kubb/react-fabric": "0.
|
|
81
|
+
"@kubb/react-fabric": "0.7.0"
|
|
82
82
|
},
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": ">=20"
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by Kubb (https://kubb.dev/).
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
|
|
6
|
+
import type { QueryKey, QueryClient, UseQueryOptions, UseQueryReturnType } from '@tanstack/react-query'
|
|
7
|
+
import type { MaybeRefOrGetter } from 'vue'
|
|
8
|
+
import { fetch } from './test/.kubb/fetch'
|
|
9
|
+
import { queryOptions, useQuery } from '@tanstack/react-query'
|
|
10
|
+
import { toValue } from 'vue'
|
|
11
|
+
|
|
12
|
+
export const findPetsByTagsQueryKey = (params?: MaybeRefOrGetter<FindPetsByTagsQueryParams>) =>
|
|
13
|
+
[{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
14
|
+
|
|
15
|
+
export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
19
|
+
* @summary Finds Pets by tags
|
|
20
|
+
* {@link /pet/findByTags}
|
|
21
|
+
*/
|
|
22
|
+
export async function findPetsByTags(
|
|
23
|
+
headers: FindPetsByTagsHeaderParams,
|
|
24
|
+
params?: FindPetsByTagsQueryParams,
|
|
25
|
+
config: Partial<RequestConfig> & { client?: typeof fetch } = {},
|
|
26
|
+
) {
|
|
27
|
+
const { client: request = fetch, ...requestConfig } = config
|
|
28
|
+
|
|
29
|
+
const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
|
|
30
|
+
method: 'GET',
|
|
31
|
+
url: `/pet/findByTags`,
|
|
32
|
+
baseURL: `${123456}`,
|
|
33
|
+
params,
|
|
34
|
+
...requestConfig,
|
|
35
|
+
headers: { ...headers, ...requestConfig.headers },
|
|
36
|
+
})
|
|
37
|
+
return findPetsByTagsQueryResponse.parse(res.data)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function findPetsByTagsQueryOptions(
|
|
41
|
+
headers: MaybeRefOrGetter<FindPetsByTagsQueryParams>,
|
|
42
|
+
params?: MaybeRefOrGetter<FindPetsByTagsQueryParams>,
|
|
43
|
+
config: Partial<RequestConfig> & { client?: typeof fetch } = {},
|
|
44
|
+
) {
|
|
45
|
+
const queryKey = findPetsByTagsQueryKey(params)
|
|
46
|
+
return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
|
|
47
|
+
queryKey,
|
|
48
|
+
queryFn: async ({ signal }) => {
|
|
49
|
+
config.signal = signal
|
|
50
|
+
return findPetsByTags(toValue(headers), toValue(params), toValue(config))
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
57
|
+
* @summary Finds Pets by tags
|
|
58
|
+
* {@link /pet/findByTags}
|
|
59
|
+
*/
|
|
60
|
+
export function useFindPetsByTags<
|
|
61
|
+
TData = FindPetsByTagsQueryResponse,
|
|
62
|
+
TQueryData = FindPetsByTagsQueryResponse,
|
|
63
|
+
TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
|
|
64
|
+
>(
|
|
65
|
+
headers: MaybeRefOrGetter<FindPetsByTagsHeaderParams>,
|
|
66
|
+
params?: MaybeRefOrGetter<FindPetsByTagsQueryParams>,
|
|
67
|
+
options: {
|
|
68
|
+
query?: Partial<UseQueryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, TData, TQueryData, TQueryKey>> & {
|
|
69
|
+
client?: QueryClient
|
|
70
|
+
}
|
|
71
|
+
client?: Partial<RequestConfig> & { client?: typeof fetch }
|
|
72
|
+
} = {},
|
|
73
|
+
) {
|
|
74
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
75
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
76
|
+
const queryKey = (queryOptions && 'queryKey' in queryOptions ? toValue(queryOptions.queryKey) : undefined) ?? findPetsByTagsQueryKey(params)
|
|
77
|
+
|
|
78
|
+
const query = useQuery(
|
|
79
|
+
{
|
|
80
|
+
...findPetsByTagsQueryOptions(headers, params, config),
|
|
81
|
+
...queryOptions,
|
|
82
|
+
queryKey,
|
|
83
|
+
} as unknown as UseQueryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, TData, FindPetsByTagsQueryResponse, TQueryKey>,
|
|
84
|
+
toValue(queryClient),
|
|
85
|
+
) as UseQueryReturnType<TData, ResponseErrorConfig<FindPetsByTags400>> & { queryKey: TQueryKey }
|
|
86
|
+
|
|
87
|
+
query.queryKey = queryKey as TQueryKey
|
|
88
|
+
|
|
89
|
+
return query
|
|
90
|
+
}
|
package/src/plugin.ts
CHANGED
|
@@ -185,7 +185,7 @@ export const pluginVueQuery = definePlugin<PluginVueQuery>((options) => {
|
|
|
185
185
|
fabric: this.fabric,
|
|
186
186
|
oas,
|
|
187
187
|
pluginManager: this.pluginManager,
|
|
188
|
-
|
|
188
|
+
events: this.events,
|
|
189
189
|
plugin: this.plugin,
|
|
190
190
|
contentType,
|
|
191
191
|
exclude,
|
|
@@ -204,7 +204,6 @@ export const pluginVueQuery = definePlugin<PluginVueQuery>((options) => {
|
|
|
204
204
|
meta: {
|
|
205
205
|
pluginKey: this.plugin.key,
|
|
206
206
|
},
|
|
207
|
-
logger: this.logger,
|
|
208
207
|
})
|
|
209
208
|
|
|
210
209
|
await this.upsertFile(...barrelFiles)
|