@kubb/plugin-ts 5.0.0-alpha.15 → 5.0.0-alpha.16
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.ts +1 -1
- package/dist/{generators-BTTcjgbY.js → generators-BZQhvuc5.js} +10 -8
- package/dist/{generators-BTTcjgbY.js.map → generators-BZQhvuc5.js.map} +1 -1
- package/dist/{generators-B6JGhHkV.cjs → generators-Dtzlpp2D.cjs} +10 -8
- package/dist/{generators-B6JGhHkV.cjs.map → generators-Dtzlpp2D.cjs.map} +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +1 -1
- package/dist/index.cjs +23 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +27 -10
- package/dist/index.js.map +1 -1
- package/dist/{resolvers-C_vYX56l.js → resolvers-DsKabI0F.js} +7 -6
- package/dist/resolvers-DsKabI0F.js.map +1 -0
- package/dist/{resolvers-DDZC7d43.cjs → resolvers-YIpeP5YD.cjs} +7 -6
- package/dist/resolvers-YIpeP5YD.cjs.map +1 -0
- package/dist/resolvers.cjs +1 -1
- package/dist/resolvers.d.ts +52 -2
- package/dist/resolvers.js +1 -1
- package/dist/{types-D9zzvE0V.d.ts → types-zqLMbIqZ.d.ts} +20 -18
- package/package.json +5 -5
- package/src/generators/typeGenerator.tsx +21 -7
- package/src/index.ts +0 -1
- package/src/plugin.ts +10 -8
- package/src/presets.ts +23 -0
- package/src/resolvers/resolverTs.ts +6 -4
- package/src/resolvers/resolverTsLegacy.ts +2 -1
- package/src/types.ts +19 -17
- package/dist/index-B5pSjbZv.d.ts +0 -51
- package/dist/resolvers-C_vYX56l.js.map +0 -1
- package/dist/resolvers-DDZC7d43.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
|
-
import "./chunk--u3MIqq1.js";
|
|
1
|
+
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { t as camelCase } from "./casing-Cp-jbC_k.js";
|
|
3
|
-
import { t as typeGenerator } from "./generators-
|
|
4
|
-
import { n as resolverTs, t as resolverTsLegacy } from "./resolvers-
|
|
3
|
+
import { t as typeGenerator } from "./generators-BZQhvuc5.js";
|
|
4
|
+
import { n as resolverTs, t as resolverTsLegacy } from "./resolvers-DsKabI0F.js";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { walk } from "@kubb/ast";
|
|
7
|
-
import { createPlugin, getBarrelFiles, getMode,
|
|
7
|
+
import { createPlugin, definePreset, definePresets, getBarrelFiles, getMode, getPreset, renderOperation, renderSchema } from "@kubb/core";
|
|
8
|
+
//#region src/presets.ts
|
|
9
|
+
const presets = definePresets({
|
|
10
|
+
default: definePreset("default", { resolvers: [resolverTs] }),
|
|
11
|
+
kubbV4: definePreset("kubbV4", { resolvers: [resolverTsLegacy] })
|
|
12
|
+
});
|
|
13
|
+
function getPreset$1(preset, { resolvers, transformers } = {}) {
|
|
14
|
+
return getPreset({
|
|
15
|
+
preset,
|
|
16
|
+
presets,
|
|
17
|
+
resolvers: [resolverTs, ...resolvers ?? []],
|
|
18
|
+
transformers
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
__name(getPreset$1, "getPreset");
|
|
22
|
+
//#endregion
|
|
8
23
|
//#region src/plugin.ts
|
|
9
24
|
const pluginTsName = "plugin-ts";
|
|
10
25
|
const pluginTs = createPlugin((options) => {
|
|
11
26
|
const { output = {
|
|
12
27
|
path: "types",
|
|
13
28
|
barrelType: "named"
|
|
14
|
-
}, group, exclude = [], include, override = [], enumType = "asConst", enumKeyCasing = "none", optionalType = "questionToken", arrayType = "array", syntaxType = "type", paramsCasing, generators = [typeGenerator].filter(Boolean),
|
|
15
|
-
const baseResolver
|
|
16
|
-
|
|
29
|
+
}, group, exclude = [], include, override = [], enumType = "asConst", enumKeyCasing = "none", optionalType = "questionToken", arrayType = "array", syntaxType = "type", paramsCasing, generators = [typeGenerator].filter(Boolean), compatibilityPreset = "default", resolvers: userResolvers, transformers: userTransformers = [] } = options;
|
|
30
|
+
const { baseResolver, resolver, transformers } = getPreset$1(compatibilityPreset, {
|
|
31
|
+
resolvers: userResolvers,
|
|
32
|
+
transformers: userTransformers
|
|
33
|
+
});
|
|
17
34
|
let resolveNameWarning = false;
|
|
18
35
|
return {
|
|
19
36
|
name: pluginTsName,
|
|
@@ -27,9 +44,9 @@ const pluginTs = createPlugin((options) => {
|
|
|
27
44
|
group,
|
|
28
45
|
override,
|
|
29
46
|
paramsCasing,
|
|
30
|
-
|
|
31
|
-
resolver,
|
|
47
|
+
compatibilityPreset,
|
|
32
48
|
baseResolver,
|
|
49
|
+
resolver,
|
|
33
50
|
transformers
|
|
34
51
|
},
|
|
35
52
|
resolvePath(baseName, pathMode, options) {
|
|
@@ -124,6 +141,6 @@ const pluginTs = createPlugin((options) => {
|
|
|
124
141
|
};
|
|
125
142
|
});
|
|
126
143
|
//#endregion
|
|
127
|
-
export { pluginTs, pluginTsName
|
|
144
|
+
export { pluginTs, pluginTsName };
|
|
128
145
|
|
|
129
146
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { walk } from '@kubb/ast'\nimport { createPlugin, type Group, getBarrelFiles, getMode,
|
|
1
|
+
{"version":3,"file":"index.js","names":["getPreset","getCorePreset","getPreset"],"sources":["../src/presets.ts","../src/plugin.ts"],"sourcesContent":["import type { Visitor } from '@kubb/ast/types'\nimport { type CompatibilityPreset, definePreset, definePresets, getPreset as getCorePreset } from '@kubb/core'\nimport { resolverTs, resolverTsLegacy } from './resolvers/index.ts'\nimport type { ResolverTs } from './types.ts'\n\nexport const presets = definePresets<ResolverTs>({\n default: definePreset('default', { resolvers: [resolverTs] }),\n kubbV4: definePreset('kubbV4', { resolvers: [resolverTsLegacy] }),\n})\n\ntype GetPresetOptions = {\n resolvers?: Array<ResolverTs>\n transformers?: Array<Visitor>\n}\n\nexport function getPreset(preset: CompatibilityPreset, { resolvers, transformers }: GetPresetOptions = {}) {\n return getCorePreset({\n preset,\n presets,\n resolvers: [resolverTs, ...(resolvers ?? [])],\n transformers,\n })\n}\n","import path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { walk } from '@kubb/ast'\nimport { createPlugin, type Group, getBarrelFiles, getMode, renderOperation, renderSchema } from '@kubb/core'\nimport { typeGenerator } from './generators/index.ts'\nimport { getPreset } from './presets.ts'\nimport type { PluginTs } from './types.ts'\n\nexport const pluginTsName = 'plugin-ts' satisfies PluginTs['name']\n\nexport const pluginTs = createPlugin<PluginTs>((options) => {\n const {\n output = { path: 'types', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n enumKeyCasing = 'none',\n optionalType = 'questionToken',\n arrayType = 'array',\n syntaxType = 'type',\n paramsCasing,\n generators = [typeGenerator].filter(Boolean),\n compatibilityPreset = 'default',\n resolvers: userResolvers,\n transformers: userTransformers = [],\n } = options\n\n const { baseResolver, resolver, transformers } = getPreset(compatibilityPreset, {\n resolvers: userResolvers,\n transformers: userTransformers,\n })\n\n let resolveNameWarning = false\n\n return {\n name: pluginTsName,\n options: {\n output,\n optionalType,\n arrayType,\n enumType,\n enumKeyCasing,\n syntaxType,\n group,\n override,\n paramsCasing,\n compatibilityPreset,\n baseResolver,\n resolver,\n transformers,\n },\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 if (!resolveNameWarning) {\n this.driver.events.emit('warn', 'Do not use resolveName for pluginTs, use resolverTs instead')\n resolveNameWarning = true\n }\n\n return resolver.default(name, type)\n },\n async install() {\n const { config, fabric, plugin, adapter, rootNode, driver, openInStudio } = this\n\n const root = path.resolve(config.root, config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n if (!adapter) {\n throw new Error('Plugin cannot work without adapter being set')\n }\n\n await openInStudio({ ast: true })\n\n await walk(rootNode, {\n depth: 'shallow',\n async schema(schemaNode) {\n const writeTasks = generators.map(async (generator) => {\n if (generator.type === 'react' && generator.version === '2') {\n const options = resolver.resolveOptions(schemaNode, { options: plugin.options, exclude, include, override })\n\n if (options === null) {\n return\n }\n\n await renderSchema(schemaNode, {\n options,\n adapter,\n config,\n fabric,\n Component: generator.Schema,\n plugin,\n driver,\n mode,\n })\n }\n })\n\n await Promise.all(writeTasks)\n },\n async operation(operationNode) {\n const writeTasks = generators.map(async (generator) => {\n if (generator.type === 'react' && generator.version === '2') {\n const options = resolver.resolveOptions(operationNode, { options: plugin.options, exclude, include, override })\n\n if (options === null) {\n return\n }\n\n await renderOperation(operationNode, {\n options,\n adapter,\n config,\n fabric,\n Component: generator.Operation,\n plugin,\n driver,\n mode,\n })\n }\n })\n\n await Promise.all(writeTasks)\n },\n })\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;AAKA,MAAa,UAAU,cAA0B;CAC/C,SAAS,aAAa,WAAW,EAAE,WAA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CAAC;AAE/G,WAAI,YAAY,KACd;AAGF,aAAM,gBAAgB,eAAe;QACnC;QACA;QACA;QACA;QACA,WAAW,UAAU;QACrB;QACA;QACA;QACD,CAAC;;OAEJ;AAEF,WAAM,QAAQ,IAAI,WAAW;;IAEhC,CAAC;GAEF,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
@@ -78,10 +78,10 @@ const resolverTs = defineResolver(() => {
|
|
|
78
78
|
return `${this.resolveTypedName(node.name ?? "")}Key`;
|
|
79
79
|
},
|
|
80
80
|
resolvePathParamsName(_node) {
|
|
81
|
-
throw new Error("resolvePathParamsName is only available
|
|
81
|
+
throw new Error("resolvePathParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.");
|
|
82
82
|
},
|
|
83
83
|
resolvePathParamsTypedName(_node) {
|
|
84
|
-
throw new Error("resolvePathParamsTypedName is only available
|
|
84
|
+
throw new Error("resolvePathParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.");
|
|
85
85
|
},
|
|
86
86
|
resolveQueryParamsName(node) {
|
|
87
87
|
return this.resolveName(`${node.operationId} QueryParams`);
|
|
@@ -90,10 +90,10 @@ const resolverTs = defineResolver(() => {
|
|
|
90
90
|
return this.resolveTypedName(`${node.operationId} QueryParams`);
|
|
91
91
|
},
|
|
92
92
|
resolveHeaderParamsName(_node) {
|
|
93
|
-
throw new Error("resolveHeaderParamsName is only available
|
|
93
|
+
throw new Error("resolveHeaderParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.");
|
|
94
94
|
},
|
|
95
95
|
resolveHeaderParamsTypedName(_node) {
|
|
96
|
-
throw new Error("resolveHeaderParamsTypedName is only available
|
|
96
|
+
throw new Error("resolveHeaderParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.");
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
99
|
});
|
|
@@ -101,7 +101,8 @@ const resolverTs = defineResolver(() => {
|
|
|
101
101
|
//#region src/resolvers/resolverTsLegacy.ts
|
|
102
102
|
/**
|
|
103
103
|
* Legacy resolver for `@kubb/plugin-ts` that reproduces the naming conventions
|
|
104
|
-
* used before the v2 resolver refactor. Enable via `
|
|
104
|
+
* used before the v2 resolver refactor. Enable via `compatibilityPreset: 'kubbV4'`
|
|
105
|
+
* (or by composing this resolver manually).
|
|
105
106
|
*
|
|
106
107
|
* Key differences from the default resolver:
|
|
107
108
|
* - Response status types: `<OperationId><StatusCode>` (e.g. `CreatePets201`) instead of `<OperationId>Status201`
|
|
@@ -180,4 +181,4 @@ const resolverTsLegacy = defineResolver(() => {
|
|
|
180
181
|
//#endregion
|
|
181
182
|
export { resolverTs as n, resolverTsLegacy as t };
|
|
182
183
|
|
|
183
|
-
//# sourceMappingURL=resolvers-
|
|
184
|
+
//# sourceMappingURL=resolvers-DsKabI0F.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvers-DsKabI0F.js","names":[],"sources":["../src/resolvers/resolverTs.ts","../src/resolvers/resolverTsLegacy.ts"],"sourcesContent":["import { pascalCase } from '@internals/utils'\nimport { defineResolver } from '@kubb/core'\nimport type { PluginTs } from '../types.ts'\n\nfunction resolveName(name: string, type?: 'file' | 'function' | 'type' | 'const'): string {\n return pascalCase(name, { isFile: type === 'file' })\n}\n\n/**\n * Resolver for `@kubb/plugin-ts` that provides the default naming and path-resolution\n * helpers used by the plugin. Import this in other plugins to resolve the exact names and\n * paths that `plugin-ts` generates without hardcoding the conventions.\n *\n * The `default` method is automatically injected by `defineResolver` — it uses `camelCase`\n * for identifiers/files and `pascalCase` for type names.\n *\n * @example\n * ```ts\n * import { resolver } from '@kubb/plugin-ts'\n *\n * resolver.default('list pets', 'type') // → 'ListPets'\n * resolver.resolveName('list pets status 200') // → 'listPetsStatus200'\n * resolver.resolveTypedName('list pets status 200') // → 'ListPetsStatus200'\n * resolver.resolvePathName('list pets', 'file') // → 'listPets'\n * ```\n */\nexport const resolverTs = defineResolver<PluginTs>(() => {\n return {\n name: 'default',\n default(name, type) {\n return resolveName(name, type)\n },\n resolveName(name) {\n return this.default(name, 'function')\n },\n resolveTypedName(name) {\n return this.default(name, 'type')\n },\n resolvePathName(name, type) {\n return this.default(name, type)\n },\n resolveParamName(node, param) {\n return this.resolveName(`${node.operationId} ${this.default(param.in)} ${param.name}`)\n },\n resolveParamTypedName(node, param) {\n return this.resolveTypedName(`${node.operationId} ${this.default(param.in)} ${param.name}`)\n },\n resolveResponseStatusName(node, statusCode) {\n return this.resolveName(`${node.operationId} Status ${statusCode}`)\n },\n resolveResponseStatusTypedName(node, statusCode) {\n return this.resolveTypedName(`${node.operationId} Status ${statusCode}`)\n },\n resolveDataName(node) {\n return this.resolveName(`${node.operationId} Data`)\n },\n resolveDataTypedName(node) {\n return this.resolveTypedName(`${node.operationId} Data`)\n },\n resolveRequestConfigName(node) {\n return this.resolveName(`${node.operationId} RequestConfig`)\n },\n resolveRequestConfigTypedName(node) {\n return this.resolveTypedName(`${node.operationId} RequestConfig`)\n },\n resolveResponsesName(node) {\n return this.resolveName(`${node.operationId} Responses`)\n },\n resolveResponsesTypedName(node) {\n return this.resolveTypedName(`${node.operationId} Responses`)\n },\n resolveResponseName(node) {\n return this.resolveName(`${node.operationId} Response`)\n },\n resolveResponseTypedName(node) {\n return this.resolveTypedName(`${node.operationId} Response`)\n },\n resolveEnumKeyTypedName(node) {\n return `${this.resolveTypedName(node.name ?? '')}Key`\n },\n resolvePathParamsName(_node) {\n throw new Error(\"resolvePathParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.\")\n },\n resolvePathParamsTypedName(_node) {\n throw new Error(\n \"resolvePathParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.\",\n )\n },\n resolveQueryParamsName(node) {\n return this.resolveName(`${node.operationId} QueryParams`)\n },\n resolveQueryParamsTypedName(node) {\n return this.resolveTypedName(`${node.operationId} QueryParams`)\n },\n resolveHeaderParamsName(_node) {\n throw new Error(\"resolveHeaderParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.\")\n },\n resolveHeaderParamsTypedName(_node) {\n throw new Error(\n \"resolveHeaderParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.\",\n )\n },\n }\n})\n","import { defineResolver } from '@kubb/core'\nimport type { PluginTs } from '../types.ts'\nimport { resolverTs } from './resolverTs.ts'\n\n/**\n * Legacy resolver for `@kubb/plugin-ts` that reproduces the naming conventions\n * used before the v2 resolver refactor. Enable via `compatibilityPreset: 'kubbV4'`\n * (or by composing this resolver manually).\n *\n * Key differences from the default resolver:\n * - Response status types: `<OperationId><StatusCode>` (e.g. `CreatePets201`) instead of `<OperationId>Status201`\n * - Default/error responses: `<OperationId>Error` instead of `<OperationId>StatusDefault`\n * - Request body: `<OperationId>MutationRequest` (non-GET) / `<OperationId>QueryRequest` (GET)\n * - Combined responses type: `<OperationId>Mutation` / `<OperationId>Query`\n * - Response union: `<OperationId>MutationResponse` / `<OperationId>QueryResponse`\n *\n * @example\n * ```ts\n * import { resolverTsLegacy } from '@kubb/plugin-ts'\n *\n * resolverTsLegacy.resolveResponseStatusTypedName(node, 201) // → 'CreatePets201'\n * resolverTsLegacy.resolveResponseStatusTypedName(node, 'default') // → 'CreatePetsError'\n * resolverTsLegacy.resolveDataTypedName(node) // → 'CreatePetsMutationRequest' (POST)\n * resolverTsLegacy.resolveResponsesTypedName(node) // → 'CreatePetsMutation' (POST)\n * resolverTsLegacy.resolveResponseTypedName(node) // → 'CreatePetsMutationResponse' (POST)\n * ```\n */\nexport const resolverTsLegacy = defineResolver<PluginTs>(() => {\n return {\n ...resolverTs,\n name: 'legacy',\n resolveResponseStatusName(node, statusCode) {\n if (statusCode === 'default') {\n return this.resolveName(`${node.operationId} Error`)\n }\n return this.resolveName(`${node.operationId} ${statusCode}`)\n },\n resolveResponseStatusTypedName(node, statusCode) {\n if (statusCode === 'default') {\n return this.resolveTypedName(`${node.operationId} Error`)\n }\n return this.resolveTypedName(`${node.operationId} ${statusCode}`)\n },\n resolveDataName(node) {\n const suffix = node.method === 'GET' ? 'QueryRequest' : 'MutationRequest'\n return this.resolveName(`${node.operationId} ${suffix}`)\n },\n resolveDataTypedName(node) {\n const suffix = node.method === 'GET' ? 'QueryRequest' : 'MutationRequest'\n return this.resolveTypedName(`${node.operationId} ${suffix}`)\n },\n resolveResponsesName(node) {\n const suffix = node.method === 'GET' ? 'Query' : 'Mutation'\n return `${this.default(node.operationId, 'function')}${suffix}`\n },\n resolveResponsesTypedName(node) {\n const suffix = node.method === 'GET' ? 'Query' : 'Mutation'\n return `${this.default(node.operationId, 'type')}${suffix}`\n },\n resolveResponseName(node) {\n const suffix = node.method === 'GET' ? 'QueryResponse' : 'MutationResponse'\n return this.resolveName(`${node.operationId} ${suffix}`)\n },\n resolveResponseTypedName(node) {\n const suffix = node.method === 'GET' ? 'QueryResponse' : 'MutationResponse'\n return this.resolveTypedName(`${node.operationId} ${suffix}`)\n },\n resolvePathParamsName(node) {\n return this.resolveName(`${node.operationId} PathParams`)\n },\n resolvePathParamsTypedName(node) {\n return this.resolveTypedName(`${node.operationId} PathParams`)\n },\n resolveQueryParamsName(node) {\n return this.resolveName(`${node.operationId} QueryParams`)\n },\n resolveQueryParamsTypedName(node) {\n return this.resolveTypedName(`${node.operationId} QueryParams`)\n },\n resolveHeaderParamsName(node) {\n return this.resolveName(`${node.operationId} HeaderParams`)\n },\n resolveHeaderParamsTypedName(node) {\n return this.resolveTypedName(`${node.operationId} HeaderParams`)\n },\n }\n})\n"],"mappings":";;;;AAIA,SAAS,YAAY,MAAc,MAAuD;AACxF,QAAO,WAA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G,SAAS;;EAE/D,qBAAqB,MAAM;GACzB,MAAM,SAAS,KAAK,WAAW,QAAQ,UAAU;AACjD,UAAO,GAAG,KAAK,QAAQ,KAAK,aAAa,WAAW,GAAG;;EAEzD,0BAA0B,MAAM;GAC9B,MAAM,SAAS,KAAK,WAAW,QAAQ,UAAU;AACjD,UAAO,GAAG,KAAK,QAAQ,KAAK,aAAa,OAAO,GAAG;;EAErD,oBAAoB,MAAM;GACxB,MAAM,SAAS,KAAK,WAAW,QAAQ,kBAAkB;AACzD,UAAO,KAAK,YAAY,GAAG,KAAK,YAAY,GAAG,SAAS;;EAE1D,yBAAyB,MAAM;GAC7B,MAAM,SAAS,KAAK,WAAW,QAAQ,kBAAkB;AACzD,UAAO,KAAK,iBAAiB,GAAG,KAAK,YAAY,GAAG,SAAS;;EAE/D,sBAAsB,MAAM;AAC1B,UAAO,KAAK,YAAY,GAAG,KAAK,YAAY,aAAa;;EAE3D,2BAA2B,MAAM;AAC/B,UAAO,KAAK,iBAAiB,GAAG,KAAK,YAAY,aAAa;;EAEhE,uBAAuB,MAAM;AAC3B,UAAO,KAAK,YAAY,GAAG,KAAK,YAAY,cAAc;;EAE5D,4BAA4B,MAAM;AAChC,UAAO,KAAK,iBAAiB,GAAG,KAAK,YAAY,cAAc;;EAEjE,wBAAwB,MAAM;AAC5B,UAAO,KAAK,YAAY,GAAG,KAAK,YAAY,eAAe;;EAE7D,6BAA6B,MAAM;AACjC,UAAO,KAAK,iBAAiB,GAAG,KAAK,YAAY,eAAe;;EAEnE;EACD"}
|
|
@@ -77,10 +77,10 @@ const resolverTs = (0, _kubb_core.defineResolver)(() => {
|
|
|
77
77
|
return `${this.resolveTypedName(node.name ?? "")}Key`;
|
|
78
78
|
},
|
|
79
79
|
resolvePathParamsName(_node) {
|
|
80
|
-
throw new Error("resolvePathParamsName is only available
|
|
80
|
+
throw new Error("resolvePathParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.");
|
|
81
81
|
},
|
|
82
82
|
resolvePathParamsTypedName(_node) {
|
|
83
|
-
throw new Error("resolvePathParamsTypedName is only available
|
|
83
|
+
throw new Error("resolvePathParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.");
|
|
84
84
|
},
|
|
85
85
|
resolveQueryParamsName(node) {
|
|
86
86
|
return this.resolveName(`${node.operationId} QueryParams`);
|
|
@@ -89,10 +89,10 @@ const resolverTs = (0, _kubb_core.defineResolver)(() => {
|
|
|
89
89
|
return this.resolveTypedName(`${node.operationId} QueryParams`);
|
|
90
90
|
},
|
|
91
91
|
resolveHeaderParamsName(_node) {
|
|
92
|
-
throw new Error("resolveHeaderParamsName is only available
|
|
92
|
+
throw new Error("resolveHeaderParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.");
|
|
93
93
|
},
|
|
94
94
|
resolveHeaderParamsTypedName(_node) {
|
|
95
|
-
throw new Error("resolveHeaderParamsTypedName is only available
|
|
95
|
+
throw new Error("resolveHeaderParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.");
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
98
|
});
|
|
@@ -100,7 +100,8 @@ const resolverTs = (0, _kubb_core.defineResolver)(() => {
|
|
|
100
100
|
//#region src/resolvers/resolverTsLegacy.ts
|
|
101
101
|
/**
|
|
102
102
|
* Legacy resolver for `@kubb/plugin-ts` that reproduces the naming conventions
|
|
103
|
-
* used before the v2 resolver refactor. Enable via `
|
|
103
|
+
* used before the v2 resolver refactor. Enable via `compatibilityPreset: 'kubbV4'`
|
|
104
|
+
* (or by composing this resolver manually).
|
|
104
105
|
*
|
|
105
106
|
* Key differences from the default resolver:
|
|
106
107
|
* - Response status types: `<OperationId><StatusCode>` (e.g. `CreatePets201`) instead of `<OperationId>Status201`
|
|
@@ -190,4 +191,4 @@ Object.defineProperty(exports, "resolverTsLegacy", {
|
|
|
190
191
|
}
|
|
191
192
|
});
|
|
192
193
|
|
|
193
|
-
//# sourceMappingURL=resolvers-
|
|
194
|
+
//# sourceMappingURL=resolvers-YIpeP5YD.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvers-YIpeP5YD.cjs","names":["pascalCase"],"sources":["../src/resolvers/resolverTs.ts","../src/resolvers/resolverTsLegacy.ts"],"sourcesContent":["import { pascalCase } from '@internals/utils'\nimport { defineResolver } from '@kubb/core'\nimport type { PluginTs } from '../types.ts'\n\nfunction resolveName(name: string, type?: 'file' | 'function' | 'type' | 'const'): string {\n return pascalCase(name, { isFile: type === 'file' })\n}\n\n/**\n * Resolver for `@kubb/plugin-ts` that provides the default naming and path-resolution\n * helpers used by the plugin. Import this in other plugins to resolve the exact names and\n * paths that `plugin-ts` generates without hardcoding the conventions.\n *\n * The `default` method is automatically injected by `defineResolver` — it uses `camelCase`\n * for identifiers/files and `pascalCase` for type names.\n *\n * @example\n * ```ts\n * import { resolver } from '@kubb/plugin-ts'\n *\n * resolver.default('list pets', 'type') // → 'ListPets'\n * resolver.resolveName('list pets status 200') // → 'listPetsStatus200'\n * resolver.resolveTypedName('list pets status 200') // → 'ListPetsStatus200'\n * resolver.resolvePathName('list pets', 'file') // → 'listPets'\n * ```\n */\nexport const resolverTs = defineResolver<PluginTs>(() => {\n return {\n name: 'default',\n default(name, type) {\n return resolveName(name, type)\n },\n resolveName(name) {\n return this.default(name, 'function')\n },\n resolveTypedName(name) {\n return this.default(name, 'type')\n },\n resolvePathName(name, type) {\n return this.default(name, type)\n },\n resolveParamName(node, param) {\n return this.resolveName(`${node.operationId} ${this.default(param.in)} ${param.name}`)\n },\n resolveParamTypedName(node, param) {\n return this.resolveTypedName(`${node.operationId} ${this.default(param.in)} ${param.name}`)\n },\n resolveResponseStatusName(node, statusCode) {\n return this.resolveName(`${node.operationId} Status ${statusCode}`)\n },\n resolveResponseStatusTypedName(node, statusCode) {\n return this.resolveTypedName(`${node.operationId} Status ${statusCode}`)\n },\n resolveDataName(node) {\n return this.resolveName(`${node.operationId} Data`)\n },\n resolveDataTypedName(node) {\n return this.resolveTypedName(`${node.operationId} Data`)\n },\n resolveRequestConfigName(node) {\n return this.resolveName(`${node.operationId} RequestConfig`)\n },\n resolveRequestConfigTypedName(node) {\n return this.resolveTypedName(`${node.operationId} RequestConfig`)\n },\n resolveResponsesName(node) {\n return this.resolveName(`${node.operationId} Responses`)\n },\n resolveResponsesTypedName(node) {\n return this.resolveTypedName(`${node.operationId} Responses`)\n },\n resolveResponseName(node) {\n return this.resolveName(`${node.operationId} Response`)\n },\n resolveResponseTypedName(node) {\n return this.resolveTypedName(`${node.operationId} Response`)\n },\n resolveEnumKeyTypedName(node) {\n return `${this.resolveTypedName(node.name ?? '')}Key`\n },\n resolvePathParamsName(_node) {\n throw new Error(\"resolvePathParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.\")\n },\n resolvePathParamsTypedName(_node) {\n throw new Error(\n \"resolvePathParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.\",\n )\n },\n resolveQueryParamsName(node) {\n return this.resolveName(`${node.operationId} QueryParams`)\n },\n resolveQueryParamsTypedName(node) {\n return this.resolveTypedName(`${node.operationId} QueryParams`)\n },\n resolveHeaderParamsName(_node) {\n throw new Error(\"resolveHeaderParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.\")\n },\n resolveHeaderParamsTypedName(_node) {\n throw new Error(\n \"resolveHeaderParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.\",\n )\n },\n }\n})\n","import { defineResolver } from '@kubb/core'\nimport type { PluginTs } from '../types.ts'\nimport { resolverTs } from './resolverTs.ts'\n\n/**\n * Legacy resolver for `@kubb/plugin-ts` that reproduces the naming conventions\n * used before the v2 resolver refactor. Enable via `compatibilityPreset: 'kubbV4'`\n * (or by composing this resolver manually).\n *\n * Key differences from the default resolver:\n * - Response status types: `<OperationId><StatusCode>` (e.g. `CreatePets201`) instead of `<OperationId>Status201`\n * - Default/error responses: `<OperationId>Error` instead of `<OperationId>StatusDefault`\n * - Request body: `<OperationId>MutationRequest` (non-GET) / `<OperationId>QueryRequest` (GET)\n * - Combined responses type: `<OperationId>Mutation` / `<OperationId>Query`\n * - Response union: `<OperationId>MutationResponse` / `<OperationId>QueryResponse`\n *\n * @example\n * ```ts\n * import { resolverTsLegacy } from '@kubb/plugin-ts'\n *\n * resolverTsLegacy.resolveResponseStatusTypedName(node, 201) // → 'CreatePets201'\n * resolverTsLegacy.resolveResponseStatusTypedName(node, 'default') // → 'CreatePetsError'\n * resolverTsLegacy.resolveDataTypedName(node) // → 'CreatePetsMutationRequest' (POST)\n * resolverTsLegacy.resolveResponsesTypedName(node) // → 'CreatePetsMutation' (POST)\n * resolverTsLegacy.resolveResponseTypedName(node) // → 'CreatePetsMutationResponse' (POST)\n * ```\n */\nexport const resolverTsLegacy = defineResolver<PluginTs>(() => {\n return {\n ...resolverTs,\n name: 'legacy',\n resolveResponseStatusName(node, statusCode) {\n if (statusCode === 'default') {\n return this.resolveName(`${node.operationId} Error`)\n }\n return this.resolveName(`${node.operationId} ${statusCode}`)\n },\n resolveResponseStatusTypedName(node, statusCode) {\n if (statusCode === 'default') {\n return this.resolveTypedName(`${node.operationId} Error`)\n }\n return this.resolveTypedName(`${node.operationId} ${statusCode}`)\n },\n resolveDataName(node) {\n const suffix = node.method === 'GET' ? 'QueryRequest' : 'MutationRequest'\n return this.resolveName(`${node.operationId} ${suffix}`)\n },\n resolveDataTypedName(node) {\n const suffix = node.method === 'GET' ? 'QueryRequest' : 'MutationRequest'\n return this.resolveTypedName(`${node.operationId} ${suffix}`)\n },\n resolveResponsesName(node) {\n const suffix = node.method === 'GET' ? 'Query' : 'Mutation'\n return `${this.default(node.operationId, 'function')}${suffix}`\n },\n resolveResponsesTypedName(node) {\n const suffix = node.method === 'GET' ? 'Query' : 'Mutation'\n return `${this.default(node.operationId, 'type')}${suffix}`\n },\n resolveResponseName(node) {\n const suffix = node.method === 'GET' ? 'QueryResponse' : 'MutationResponse'\n return this.resolveName(`${node.operationId} ${suffix}`)\n },\n resolveResponseTypedName(node) {\n const suffix = node.method === 'GET' ? 'QueryResponse' : 'MutationResponse'\n return this.resolveTypedName(`${node.operationId} ${suffix}`)\n },\n resolvePathParamsName(node) {\n return this.resolveName(`${node.operationId} PathParams`)\n },\n resolvePathParamsTypedName(node) {\n return this.resolveTypedName(`${node.operationId} PathParams`)\n },\n resolveQueryParamsName(node) {\n return this.resolveName(`${node.operationId} QueryParams`)\n },\n resolveQueryParamsTypedName(node) {\n return this.resolveTypedName(`${node.operationId} QueryParams`)\n },\n resolveHeaderParamsName(node) {\n return this.resolveName(`${node.operationId} HeaderParams`)\n },\n resolveHeaderParamsTypedName(node) {\n return this.resolveTypedName(`${node.operationId} HeaderParams`)\n },\n }\n})\n"],"mappings":";;;AAIA,SAAS,YAAY,MAAc,MAAuD;AACxF,QAAOA,eAAAA,WAAW,MAAM,EAAE,QAAQ,SAAS,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;AAqBtD,MAAa,cAAA,GAAA,WAAA,sBAA4C;AACvD,QAAO;EACL,MAAM;EACN,QAAQ,MAAM,MAAM;AAClB,UAAO,YAAY,MAAM,KAAK;;EAEhC,YAAY,MAAM;AAChB,UAAO,KAAK,QAAQ,MAAM,WAAW;;EAEvC,iBAAiB,MAAM;AACrB,UAAO,KAAK,QAAQ,MAAM,OAAO;;EAEnC,gBAAgB,MAAM,MAAM;AAC1B,UAAO,KAAK,QAAQ,MAAM,KAAK;;EAEjC,iBAAiB,MAAM,OAAO;AAC5B,UAAO,KAAK,YAAY,GAAG,KAAK,YAAY,GAAG,KAAK,QAAQ,MAAM,GAAG,CAAC,GAAG,MAAM,OAAO;;EAExF,sBAAsB,MAAM,OAAO;AACjC,UAAO,KAAK,iBAAiB,GAAG,KAAK,YAAY,GAAG,KAAK,QAAQ,MAAM,GAAG,CAAC,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2BAA2B,MAAM;AAC/B,UAAO,KAAK,iBAAiB,GAAG,KAAK,YAAY,aAAa;;EAEhE,uBAAuB,MAAM;AAC3B,UAAO,KAAK,YAAY,GAAG,KAAK,YAAY,cAAc;;EAE5D,4BAA4B,MAAM;AAChC,UAAO,KAAK,iBAAiB,GAAG,KAAK,YAAY,cAAc;;EAEjE,wBAAwB,MAAM;AAC5B,UAAO,KAAK,YAAY,GAAG,KAAK,YAAY,eAAe;;EAE7D,6BAA6B,MAAM;AACjC,UAAO,KAAK,iBAAiB,GAAG,KAAK,YAAY,eAAe;;EAEnE;EACD"}
|
package/dist/resolvers.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_resolvers = require("./resolvers-
|
|
2
|
+
const require_resolvers = require("./resolvers-YIpeP5YD.cjs");
|
|
3
3
|
exports.resolverTs = require_resolvers.resolverTs;
|
|
4
4
|
exports.resolverTsLegacy = require_resolvers.resolverTsLegacy;
|
package/dist/resolvers.d.ts
CHANGED
|
@@ -1,2 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
+
import { r as ResolverTs } from "./types-zqLMbIqZ.js";
|
|
3
|
+
|
|
4
|
+
//#region src/resolvers/resolverTs.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolver for `@kubb/plugin-ts` that provides the default naming and path-resolution
|
|
7
|
+
* helpers used by the plugin. Import this in other plugins to resolve the exact names and
|
|
8
|
+
* paths that `plugin-ts` generates without hardcoding the conventions.
|
|
9
|
+
*
|
|
10
|
+
* The `default` method is automatically injected by `defineResolver` — it uses `camelCase`
|
|
11
|
+
* for identifiers/files and `pascalCase` for type names.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { resolver } from '@kubb/plugin-ts'
|
|
16
|
+
*
|
|
17
|
+
* resolver.default('list pets', 'type') // → 'ListPets'
|
|
18
|
+
* resolver.resolveName('list pets status 200') // → 'listPetsStatus200'
|
|
19
|
+
* resolver.resolveTypedName('list pets status 200') // → 'ListPetsStatus200'
|
|
20
|
+
* resolver.resolvePathName('list pets', 'file') // → 'listPets'
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare const resolverTs: ResolverTs;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/resolvers/resolverTsLegacy.d.ts
|
|
26
|
+
/**
|
|
27
|
+
* Legacy resolver for `@kubb/plugin-ts` that reproduces the naming conventions
|
|
28
|
+
* used before the v2 resolver refactor. Enable via `compatibilityPreset: 'kubbV4'`
|
|
29
|
+
* (or by composing this resolver manually).
|
|
30
|
+
*
|
|
31
|
+
* Key differences from the default resolver:
|
|
32
|
+
* - Response status types: `<OperationId><StatusCode>` (e.g. `CreatePets201`) instead of `<OperationId>Status201`
|
|
33
|
+
* - Default/error responses: `<OperationId>Error` instead of `<OperationId>StatusDefault`
|
|
34
|
+
* - Request body: `<OperationId>MutationRequest` (non-GET) / `<OperationId>QueryRequest` (GET)
|
|
35
|
+
* - Combined responses type: `<OperationId>Mutation` / `<OperationId>Query`
|
|
36
|
+
* - Response union: `<OperationId>MutationResponse` / `<OperationId>QueryResponse`
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { resolverTsLegacy } from '@kubb/plugin-ts'
|
|
41
|
+
*
|
|
42
|
+
* resolverTsLegacy.resolveResponseStatusTypedName(node, 201) // → 'CreatePets201'
|
|
43
|
+
* resolverTsLegacy.resolveResponseStatusTypedName(node, 'default') // → 'CreatePetsError'
|
|
44
|
+
* resolverTsLegacy.resolveDataTypedName(node) // → 'CreatePetsMutationRequest' (POST)
|
|
45
|
+
* resolverTsLegacy.resolveResponsesTypedName(node) // → 'CreatePetsMutation' (POST)
|
|
46
|
+
* resolverTsLegacy.resolveResponseTypedName(node) // → 'CreatePetsMutationResponse' (POST)
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
declare const resolverTsLegacy: ResolverTs;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { resolverTs, resolverTsLegacy };
|
|
52
|
+
//# sourceMappingURL=resolvers.d.ts.map
|
package/dist/resolvers.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as resolverTs, t as resolverTsLegacy } from "./resolvers-
|
|
1
|
+
import { n as resolverTs, t as resolverTsLegacy } from "./resolvers-DsKabI0F.js";
|
|
2
2
|
export { resolverTs, resolverTsLegacy };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { Group, Output, PluginFactoryOptions, Resolver } from "@kubb/core";
|
|
2
|
+
import { CompatibilityPreset, Group, Output, PluginFactoryOptions, Resolver } from "@kubb/core";
|
|
3
3
|
import { OperationNode, ParameterNode, SchemaNode, StatusCode, Visitor } from "@kubb/ast/types";
|
|
4
4
|
import { Oas, contentType } from "@kubb/oas";
|
|
5
5
|
import { Exclude, Include, Override, ResolvePathOptions } from "@kubb/plugin-oas";
|
|
@@ -137,54 +137,54 @@ type ResolverTs = Resolver & {
|
|
|
137
137
|
resolveEnumKeyTypedName(node: SchemaNode): string;
|
|
138
138
|
/**
|
|
139
139
|
* Resolves the variable/function name for an operation's grouped path parameters type.
|
|
140
|
-
* Only available
|
|
140
|
+
* Only available with `compatibilityPreset: 'kubbV4'`.
|
|
141
141
|
*
|
|
142
|
-
* @deprecated
|
|
142
|
+
* @deprecated Kubb v4 compatibility only — use `resolveParamName` per individual parameter instead.
|
|
143
143
|
* @example
|
|
144
144
|
* resolver.resolvePathParamsName(node) // → 'GetPetByIdPathParams'
|
|
145
145
|
*/
|
|
146
146
|
resolvePathParamsName?(node: OperationNode): string;
|
|
147
147
|
/**
|
|
148
148
|
* Resolves the TypeScript type alias name for an operation's grouped path parameters type.
|
|
149
|
-
* Only available
|
|
149
|
+
* Only available with `compatibilityPreset: 'kubbV4'`.
|
|
150
150
|
*
|
|
151
|
-
* @deprecated
|
|
151
|
+
* @deprecated Kubb v4 compatibility only — use `resolveParamTypedName` per individual parameter instead.
|
|
152
152
|
* @example
|
|
153
153
|
* resolver.resolvePathParamsTypedName(node) // → 'GetPetByIdPathParams'
|
|
154
154
|
*/
|
|
155
155
|
resolvePathParamsTypedName?(node: OperationNode): string;
|
|
156
156
|
/**
|
|
157
157
|
* Resolves the variable/function name for an operation's grouped query parameters type.
|
|
158
|
-
* Only available
|
|
158
|
+
* Only available with `compatibilityPreset: 'kubbV4'`.
|
|
159
159
|
*
|
|
160
|
-
* @deprecated
|
|
160
|
+
* @deprecated Kubb v4 compatibility only — use `resolveParamName` per individual parameter instead.
|
|
161
161
|
* @example
|
|
162
162
|
* resolver.resolveQueryParamsName(node) // → 'FindPetsByStatusQueryParams'
|
|
163
163
|
*/
|
|
164
164
|
resolveQueryParamsName?(node: OperationNode): string;
|
|
165
165
|
/**
|
|
166
166
|
* Resolves the TypeScript type alias name for an operation's grouped query parameters type.
|
|
167
|
-
* Only available
|
|
167
|
+
* Only available with `compatibilityPreset: 'kubbV4'`.
|
|
168
168
|
*
|
|
169
|
-
* @deprecated
|
|
169
|
+
* @deprecated Kubb v4 compatibility only — use `resolveParamTypedName` per individual parameter instead.
|
|
170
170
|
* @example
|
|
171
171
|
* resolver.resolveQueryParamsTypedName(node) // → 'FindPetsByStatusQueryParams'
|
|
172
172
|
*/
|
|
173
173
|
resolveQueryParamsTypedName?(node: OperationNode): string;
|
|
174
174
|
/**
|
|
175
175
|
* Resolves the variable/function name for an operation's grouped header parameters type.
|
|
176
|
-
* Only available
|
|
176
|
+
* Only available with `compatibilityPreset: 'kubbV4'`.
|
|
177
177
|
*
|
|
178
|
-
* @deprecated
|
|
178
|
+
* @deprecated Kubb v4 compatibility only — use `resolveParamName` per individual parameter instead.
|
|
179
179
|
* @example
|
|
180
180
|
* resolver.resolveHeaderParamsName(node) // → 'DeletePetHeaderParams'
|
|
181
181
|
*/
|
|
182
182
|
resolveHeaderParamsName?(node: OperationNode): string;
|
|
183
183
|
/**
|
|
184
184
|
* Resolves the TypeScript type alias name for an operation's grouped header parameters type.
|
|
185
|
-
* Only available
|
|
185
|
+
* Only available with `compatibilityPreset: 'kubbV4'`.
|
|
186
186
|
*
|
|
187
|
-
* @deprecated
|
|
187
|
+
* @deprecated Kubb v4 compatibility only — use `resolveParamTypedName` per individual parameter instead.
|
|
188
188
|
* @example
|
|
189
189
|
* resolver.resolveHeaderParamsTypedName(node) // → 'DeletePetHeaderParams'
|
|
190
190
|
*/
|
|
@@ -277,10 +277,12 @@ type Options = {
|
|
|
277
277
|
*/
|
|
278
278
|
UNSTABLE_NAMING?: true;
|
|
279
279
|
/**
|
|
280
|
-
*
|
|
281
|
-
*
|
|
280
|
+
* Apply a compatibility naming preset.
|
|
281
|
+
* Use `kubbV4` for strict v4 type-generation compatibility.
|
|
282
|
+
* You can further customize naming with `resolvers`.
|
|
283
|
+
* @default 'default'
|
|
282
284
|
*/
|
|
283
|
-
|
|
285
|
+
compatibilityPreset?: CompatibilityPreset;
|
|
284
286
|
/**
|
|
285
287
|
* Array of named resolvers that control naming conventions.
|
|
286
288
|
* Later entries override earlier ones (last wins).
|
|
@@ -322,7 +324,7 @@ type ResolvedOptions = {
|
|
|
322
324
|
arrayType: NonNullable<Options['arrayType']>;
|
|
323
325
|
syntaxType: NonNullable<Options['syntaxType']>;
|
|
324
326
|
paramsCasing: Options['paramsCasing'];
|
|
325
|
-
|
|
327
|
+
compatibilityPreset: NonNullable<CompatibilityPreset>;
|
|
326
328
|
resolver: ResolverTs;
|
|
327
329
|
/**
|
|
328
330
|
* The resolver without user naming overrides applied.
|
|
@@ -335,4 +337,4 @@ type ResolvedOptions = {
|
|
|
335
337
|
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions, ResolverTs>;
|
|
336
338
|
//#endregion
|
|
337
339
|
export { PluginTs as n, ResolverTs as r, Options as t };
|
|
338
|
-
//# sourceMappingURL=types-
|
|
340
|
+
//# sourceMappingURL=types-zqLMbIqZ.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-ts",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.16",
|
|
4
4
|
"description": "TypeScript code generation plugin for Kubb, transforming OpenAPI schemas into TypeScript interfaces, types, and utility functions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -78,10 +78,10 @@
|
|
|
78
78
|
"@kubb/react-fabric": "0.14.0",
|
|
79
79
|
"remeda": "^2.33.6",
|
|
80
80
|
"typescript": "5.9.3",
|
|
81
|
-
"@kubb/
|
|
82
|
-
"@kubb/
|
|
83
|
-
"@kubb/
|
|
84
|
-
"@kubb/
|
|
81
|
+
"@kubb/ast": "5.0.0-alpha.16",
|
|
82
|
+
"@kubb/core": "5.0.0-alpha.16",
|
|
83
|
+
"@kubb/plugin-oas": "5.0.0-alpha.16",
|
|
84
|
+
"@kubb/oas": "5.0.0-alpha.16"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"@kubb/react-fabric": "0.14.0"
|
|
@@ -21,7 +21,20 @@ export const typeGenerator = defineGenerator<PluginTs>({
|
|
|
21
21
|
name: 'typescript',
|
|
22
22
|
type: 'react',
|
|
23
23
|
Operation({ node, adapter, options }) {
|
|
24
|
-
const {
|
|
24
|
+
const {
|
|
25
|
+
enumType,
|
|
26
|
+
enumKeyCasing,
|
|
27
|
+
optionalType,
|
|
28
|
+
arrayType,
|
|
29
|
+
syntaxType,
|
|
30
|
+
paramsCasing,
|
|
31
|
+
group,
|
|
32
|
+
resolver,
|
|
33
|
+
baseResolver,
|
|
34
|
+
compatibilityPreset,
|
|
35
|
+
transformers = [],
|
|
36
|
+
} = options
|
|
37
|
+
const isKubbV4Compatibility = compatibilityPreset === 'kubbV4'
|
|
25
38
|
const { mode, getFile, resolveBanner, resolveFooter } = useKubb<PluginTs>()
|
|
26
39
|
|
|
27
40
|
const file = getFile({
|
|
@@ -74,13 +87,13 @@ export const typeGenerator = defineGenerator<PluginTs>({
|
|
|
74
87
|
syntaxType={syntaxType}
|
|
75
88
|
resolver={resolver}
|
|
76
89
|
keysToOmit={keysToOmit}
|
|
77
|
-
legacy={
|
|
90
|
+
legacy={isKubbV4Compatibility}
|
|
78
91
|
/>
|
|
79
92
|
</>
|
|
80
93
|
)
|
|
81
94
|
}
|
|
82
95
|
|
|
83
|
-
const responseTypes =
|
|
96
|
+
const responseTypes = isKubbV4Compatibility
|
|
84
97
|
? node.responses.map((res) => {
|
|
85
98
|
const responseName = resolver.resolveResponseStatusName(node, res.statusCode)
|
|
86
99
|
const baseResponseName = baseResolver.resolveResponseStatusName(node, res.statusCode)
|
|
@@ -105,7 +118,7 @@ export const typeGenerator = defineGenerator<PluginTs>({
|
|
|
105
118
|
|
|
106
119
|
const requestType = node.requestBody?.schema
|
|
107
120
|
? renderSchemaType({
|
|
108
|
-
node:
|
|
121
|
+
node: isKubbV4Compatibility ? nameUnnamedEnums(node.requestBody.schema, baseResolver.resolveDataName(node)) : node.requestBody.schema,
|
|
109
122
|
name: resolver.resolveDataName(node),
|
|
110
123
|
typedName: resolver.resolveDataTypedName(node),
|
|
111
124
|
description: node.requestBody.description ?? node.requestBody.schema.description,
|
|
@@ -113,7 +126,7 @@ export const typeGenerator = defineGenerator<PluginTs>({
|
|
|
113
126
|
})
|
|
114
127
|
: null
|
|
115
128
|
|
|
116
|
-
if (
|
|
129
|
+
if (isKubbV4Compatibility) {
|
|
117
130
|
const pathParams = params.filter((p) => p.in === 'path')
|
|
118
131
|
const queryParams = params.filter((p) => p.in === 'query')
|
|
119
132
|
const headerParams = params.filter((p) => p.in === 'header')
|
|
@@ -215,7 +228,8 @@ export const typeGenerator = defineGenerator<PluginTs>({
|
|
|
215
228
|
)
|
|
216
229
|
},
|
|
217
230
|
Schema({ node, adapter, options }) {
|
|
218
|
-
const { enumType, enumKeyCasing, syntaxType, optionalType, arrayType, resolver,
|
|
231
|
+
const { enumType, enumKeyCasing, syntaxType, optionalType, arrayType, resolver, compatibilityPreset, transformers = [] } = options
|
|
232
|
+
const isKubbV4Compatibility = compatibilityPreset === 'kubbV4'
|
|
219
233
|
const { mode, getFile, resolveBanner, resolveFooter } = useKubb<PluginTs>()
|
|
220
234
|
|
|
221
235
|
if (!node.name) {
|
|
@@ -255,7 +269,7 @@ export const typeGenerator = defineGenerator<PluginTs>({
|
|
|
255
269
|
arrayType={arrayType}
|
|
256
270
|
syntaxType={syntaxType}
|
|
257
271
|
resolver={resolver}
|
|
258
|
-
legacy={
|
|
272
|
+
legacy={isKubbV4Compatibility}
|
|
259
273
|
/>
|
|
260
274
|
</File>
|
|
261
275
|
)
|
package/src/index.ts
CHANGED
package/src/plugin.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
import { camelCase } from '@internals/utils'
|
|
3
3
|
import { walk } from '@kubb/ast'
|
|
4
|
-
import { createPlugin, type Group, getBarrelFiles, getMode,
|
|
4
|
+
import { createPlugin, type Group, getBarrelFiles, getMode, renderOperation, renderSchema } from '@kubb/core'
|
|
5
5
|
import { typeGenerator } from './generators/index.ts'
|
|
6
|
-
import {
|
|
6
|
+
import { getPreset } from './presets.ts'
|
|
7
7
|
import type { PluginTs } from './types.ts'
|
|
8
8
|
|
|
9
9
|
export const pluginTsName = 'plugin-ts' satisfies PluginTs['name']
|
|
@@ -22,13 +22,15 @@ export const pluginTs = createPlugin<PluginTs>((options) => {
|
|
|
22
22
|
syntaxType = 'type',
|
|
23
23
|
paramsCasing,
|
|
24
24
|
generators = [typeGenerator].filter(Boolean),
|
|
25
|
-
|
|
25
|
+
compatibilityPreset = 'default',
|
|
26
26
|
resolvers: userResolvers,
|
|
27
|
-
transformers = [],
|
|
27
|
+
transformers: userTransformers = [],
|
|
28
28
|
} = options
|
|
29
29
|
|
|
30
|
-
const baseResolver
|
|
31
|
-
|
|
30
|
+
const { baseResolver, resolver, transformers } = getPreset(compatibilityPreset, {
|
|
31
|
+
resolvers: userResolvers,
|
|
32
|
+
transformers: userTransformers,
|
|
33
|
+
})
|
|
32
34
|
|
|
33
35
|
let resolveNameWarning = false
|
|
34
36
|
|
|
@@ -44,9 +46,9 @@ export const pluginTs = createPlugin<PluginTs>((options) => {
|
|
|
44
46
|
group,
|
|
45
47
|
override,
|
|
46
48
|
paramsCasing,
|
|
47
|
-
|
|
48
|
-
resolver,
|
|
49
|
+
compatibilityPreset,
|
|
49
50
|
baseResolver,
|
|
51
|
+
resolver,
|
|
50
52
|
transformers,
|
|
51
53
|
},
|
|
52
54
|
resolvePath(baseName, pathMode, options) {
|
package/src/presets.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Visitor } from '@kubb/ast/types'
|
|
2
|
+
import { type CompatibilityPreset, definePreset, definePresets, getPreset as getCorePreset } from '@kubb/core'
|
|
3
|
+
import { resolverTs, resolverTsLegacy } from './resolvers/index.ts'
|
|
4
|
+
import type { ResolverTs } from './types.ts'
|
|
5
|
+
|
|
6
|
+
export const presets = definePresets<ResolverTs>({
|
|
7
|
+
default: definePreset('default', { resolvers: [resolverTs] }),
|
|
8
|
+
kubbV4: definePreset('kubbV4', { resolvers: [resolverTsLegacy] }),
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
type GetPresetOptions = {
|
|
12
|
+
resolvers?: Array<ResolverTs>
|
|
13
|
+
transformers?: Array<Visitor>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getPreset(preset: CompatibilityPreset, { resolvers, transformers }: GetPresetOptions = {}) {
|
|
17
|
+
return getCorePreset({
|
|
18
|
+
preset,
|
|
19
|
+
presets,
|
|
20
|
+
resolvers: [resolverTs, ...(resolvers ?? [])],
|
|
21
|
+
transformers,
|
|
22
|
+
})
|
|
23
|
+
}
|
|
@@ -79,10 +79,12 @@ export const resolverTs = defineResolver<PluginTs>(() => {
|
|
|
79
79
|
return `${this.resolveTypedName(node.name ?? '')}Key`
|
|
80
80
|
},
|
|
81
81
|
resolvePathParamsName(_node) {
|
|
82
|
-
throw new Error(
|
|
82
|
+
throw new Error("resolvePathParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.")
|
|
83
83
|
},
|
|
84
84
|
resolvePathParamsTypedName(_node) {
|
|
85
|
-
throw new Error(
|
|
85
|
+
throw new Error(
|
|
86
|
+
"resolvePathParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.",
|
|
87
|
+
)
|
|
86
88
|
},
|
|
87
89
|
resolveQueryParamsName(node) {
|
|
88
90
|
return this.resolveName(`${node.operationId} QueryParams`)
|
|
@@ -91,11 +93,11 @@ export const resolverTs = defineResolver<PluginTs>(() => {
|
|
|
91
93
|
return this.resolveTypedName(`${node.operationId} QueryParams`)
|
|
92
94
|
},
|
|
93
95
|
resolveHeaderParamsName(_node) {
|
|
94
|
-
throw new Error(
|
|
96
|
+
throw new Error("resolveHeaderParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.")
|
|
95
97
|
},
|
|
96
98
|
resolveHeaderParamsTypedName(_node) {
|
|
97
99
|
throw new Error(
|
|
98
|
-
|
|
100
|
+
"resolveHeaderParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.",
|
|
99
101
|
)
|
|
100
102
|
},
|
|
101
103
|
}
|