@kubb/plugin-ts 5.0.0-alpha.2 → 5.0.0-alpha.20
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/Type-B70QnSzH.cjs +688 -0
- package/dist/Type-B70QnSzH.cjs.map +1 -0
- package/dist/Type-CMC7L-38.js +671 -0
- package/dist/Type-CMC7L-38.js.map +1 -0
- package/dist/casing-Cp-jbC_k.js +84 -0
- package/dist/casing-Cp-jbC_k.js.map +1 -0
- package/dist/casing-D2uQKLWS.cjs +144 -0
- package/dist/casing-D2uQKLWS.cjs.map +1 -0
- package/dist/components.cjs +3 -2
- package/dist/components.d.ts +41 -11
- package/dist/components.js +2 -2
- package/dist/generators-BFkr7ecU.js +556 -0
- package/dist/generators-BFkr7ecU.js.map +1 -0
- package/dist/generators-xHWQCNd9.cjs +560 -0
- package/dist/generators-xHWQCNd9.cjs.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.ts +3 -491
- package/dist/generators.js +1 -1
- package/dist/index.cjs +146 -3
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +145 -1
- package/dist/index.js.map +1 -0
- package/dist/resolvers-DsKabI0F.js +184 -0
- package/dist/resolvers-DsKabI0F.js.map +1 -0
- package/dist/resolvers-YIpeP5YD.cjs +194 -0
- package/dist/resolvers-YIpeP5YD.cjs.map +1 -0
- package/dist/resolvers.cjs +4 -0
- package/dist/resolvers.d.ts +52 -0
- package/dist/resolvers.js +2 -0
- package/dist/types-zqLMbIqZ.d.ts +340 -0
- package/package.json +15 -8
- package/src/components/Enum.tsx +83 -0
- package/src/components/Type.tsx +25 -144
- package/src/components/index.ts +1 -0
- package/src/constants.ts +29 -0
- package/src/factory.ts +14 -16
- package/src/generators/typeGenerator.tsx +221 -414
- package/src/generators/utils.ts +308 -0
- package/src/index.ts +1 -1
- package/src/plugin.ts +74 -87
- package/src/presets.ts +23 -0
- package/src/printer.ts +256 -92
- package/src/resolvers/index.ts +2 -0
- package/src/resolvers/resolverTs.ts +104 -0
- package/src/resolvers/resolverTsLegacy.ts +87 -0
- package/src/types.ts +234 -63
- package/dist/components-9wydyqUx.cjs +0 -848
- package/dist/components-9wydyqUx.cjs.map +0 -1
- package/dist/components-LmqJfxMv.js +0 -721
- package/dist/components-LmqJfxMv.js.map +0 -1
- package/dist/plugin-CNkzbtpl.cjs +0 -508
- package/dist/plugin-CNkzbtpl.cjs.map +0 -1
- package/dist/plugin-DoLrDl9P.js +0 -476
- package/dist/plugin-DoLrDl9P.js.map +0 -1
- package/dist/types-BpeKGgCn.d.ts +0 -170
- package/src/parser.ts +0 -396
package/dist/index.js
CHANGED
|
@@ -1,2 +1,146 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
+
import { t as camelCase } from "./casing-Cp-jbC_k.js";
|
|
3
|
+
import { t as typeGenerator } from "./generators-BFkr7ecU.js";
|
|
4
|
+
import { n as resolverTs, t as resolverTsLegacy } from "./resolvers-DsKabI0F.js";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { walk } from "@kubb/ast";
|
|
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
|
|
23
|
+
//#region src/plugin.ts
|
|
24
|
+
const pluginTsName = "plugin-ts";
|
|
25
|
+
const pluginTs = createPlugin((options) => {
|
|
26
|
+
const { output = {
|
|
27
|
+
path: "types",
|
|
28
|
+
barrelType: "named"
|
|
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
|
+
});
|
|
34
|
+
let resolveNameWarning = false;
|
|
35
|
+
return {
|
|
36
|
+
name: pluginTsName,
|
|
37
|
+
options: {
|
|
38
|
+
output,
|
|
39
|
+
optionalType,
|
|
40
|
+
arrayType,
|
|
41
|
+
enumType,
|
|
42
|
+
enumKeyCasing,
|
|
43
|
+
syntaxType,
|
|
44
|
+
group,
|
|
45
|
+
override,
|
|
46
|
+
paramsCasing,
|
|
47
|
+
compatibilityPreset,
|
|
48
|
+
baseResolver,
|
|
49
|
+
resolver,
|
|
50
|
+
transformers
|
|
51
|
+
},
|
|
52
|
+
resolvePath(baseName, pathMode, options) {
|
|
53
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
54
|
+
if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
|
|
55
|
+
/**
|
|
56
|
+
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
57
|
+
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
58
|
+
*/
|
|
59
|
+
return path.resolve(root, output.path);
|
|
60
|
+
if (group && (options?.group?.path || options?.group?.tag)) {
|
|
61
|
+
const groupName = group?.name ? group.name : (ctx) => {
|
|
62
|
+
if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
63
|
+
return `${camelCase(ctx.group)}Controller`;
|
|
64
|
+
};
|
|
65
|
+
return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
|
|
66
|
+
}
|
|
67
|
+
return path.resolve(root, output.path, baseName);
|
|
68
|
+
},
|
|
69
|
+
resolveName(name, type) {
|
|
70
|
+
if (!resolveNameWarning) {
|
|
71
|
+
this.driver.events.emit("warn", "Do not use resolveName for pluginTs, use resolverTs instead");
|
|
72
|
+
resolveNameWarning = true;
|
|
73
|
+
}
|
|
74
|
+
return resolver.default(name, type);
|
|
75
|
+
},
|
|
76
|
+
async install() {
|
|
77
|
+
const { config, fabric, plugin, adapter, rootNode, driver, openInStudio } = this;
|
|
78
|
+
const root = path.resolve(config.root, config.output.path);
|
|
79
|
+
const mode = getMode(path.resolve(root, output.path));
|
|
80
|
+
if (!adapter) throw new Error("Plugin cannot work without adapter being set");
|
|
81
|
+
await openInStudio({ ast: true });
|
|
82
|
+
await walk(rootNode, {
|
|
83
|
+
depth: "shallow",
|
|
84
|
+
async schema(schemaNode) {
|
|
85
|
+
const writeTasks = generators.map(async (generator) => {
|
|
86
|
+
if (generator.type === "react" && generator.version === "2") {
|
|
87
|
+
const options = resolver.resolveOptions(schemaNode, {
|
|
88
|
+
options: plugin.options,
|
|
89
|
+
exclude,
|
|
90
|
+
include,
|
|
91
|
+
override
|
|
92
|
+
});
|
|
93
|
+
if (options === null) return;
|
|
94
|
+
await renderSchema(schemaNode, {
|
|
95
|
+
options,
|
|
96
|
+
adapter,
|
|
97
|
+
config,
|
|
98
|
+
fabric,
|
|
99
|
+
Component: generator.Schema,
|
|
100
|
+
plugin,
|
|
101
|
+
driver,
|
|
102
|
+
mode
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
await Promise.all(writeTasks);
|
|
107
|
+
},
|
|
108
|
+
async operation(operationNode) {
|
|
109
|
+
const writeTasks = generators.map(async (generator) => {
|
|
110
|
+
if (generator.type === "react" && generator.version === "2") {
|
|
111
|
+
const options = resolver.resolveOptions(operationNode, {
|
|
112
|
+
options: plugin.options,
|
|
113
|
+
exclude,
|
|
114
|
+
include,
|
|
115
|
+
override
|
|
116
|
+
});
|
|
117
|
+
if (options === null) return;
|
|
118
|
+
await renderOperation(operationNode, {
|
|
119
|
+
options,
|
|
120
|
+
adapter,
|
|
121
|
+
config,
|
|
122
|
+
fabric,
|
|
123
|
+
Component: generator.Operation,
|
|
124
|
+
plugin,
|
|
125
|
+
driver,
|
|
126
|
+
mode
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
await Promise.all(writeTasks);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
const barrelFiles = await getBarrelFiles(this.fabric.files, {
|
|
134
|
+
type: output.barrelType ?? "named",
|
|
135
|
+
root,
|
|
136
|
+
output,
|
|
137
|
+
meta: { pluginName: this.plugin.name }
|
|
138
|
+
});
|
|
139
|
+
await this.upsertFile(...barrelFiles);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
//#endregion
|
|
2
144
|
export { pluginTs, pluginTsName };
|
|
145
|
+
|
|
146
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,WAAW,CAAC,WAAW,EAAE,CAAC;CAC7D,QAAQ,aAAa,UAAU,EAAE,WAAW,CAAC,iBAAiB,EAAE,CAAC;CAClE,CAAC;AAOF,SAAgBA,YAAU,QAA6B,EAAE,WAAW,iBAAmC,EAAE,EAAE;AACzG,QAAOC,UA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,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"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
import { n as pascalCase } from "./casing-Cp-jbC_k.js";
|
|
3
|
+
import { defineResolver } from "@kubb/core";
|
|
4
|
+
//#region src/resolvers/resolverTs.ts
|
|
5
|
+
function resolveName(name, type) {
|
|
6
|
+
return pascalCase(name, { isFile: type === "file" });
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolver for `@kubb/plugin-ts` that provides the default naming and path-resolution
|
|
10
|
+
* helpers used by the plugin. Import this in other plugins to resolve the exact names and
|
|
11
|
+
* paths that `plugin-ts` generates without hardcoding the conventions.
|
|
12
|
+
*
|
|
13
|
+
* The `default` method is automatically injected by `defineResolver` — it uses `camelCase`
|
|
14
|
+
* for identifiers/files and `pascalCase` for type names.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { resolver } from '@kubb/plugin-ts'
|
|
19
|
+
*
|
|
20
|
+
* resolver.default('list pets', 'type') // → 'ListPets'
|
|
21
|
+
* resolver.resolveName('list pets status 200') // → 'listPetsStatus200'
|
|
22
|
+
* resolver.resolveTypedName('list pets status 200') // → 'ListPetsStatus200'
|
|
23
|
+
* resolver.resolvePathName('list pets', 'file') // → 'listPets'
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
const resolverTs = defineResolver(() => {
|
|
27
|
+
return {
|
|
28
|
+
name: "default",
|
|
29
|
+
default(name, type) {
|
|
30
|
+
return resolveName(name, type);
|
|
31
|
+
},
|
|
32
|
+
resolveName(name) {
|
|
33
|
+
return this.default(name, "function");
|
|
34
|
+
},
|
|
35
|
+
resolveTypedName(name) {
|
|
36
|
+
return this.default(name, "type");
|
|
37
|
+
},
|
|
38
|
+
resolvePathName(name, type) {
|
|
39
|
+
return this.default(name, type);
|
|
40
|
+
},
|
|
41
|
+
resolveParamName(node, param) {
|
|
42
|
+
return this.resolveName(`${node.operationId} ${this.default(param.in)} ${param.name}`);
|
|
43
|
+
},
|
|
44
|
+
resolveParamTypedName(node, param) {
|
|
45
|
+
return this.resolveTypedName(`${node.operationId} ${this.default(param.in)} ${param.name}`);
|
|
46
|
+
},
|
|
47
|
+
resolveResponseStatusName(node, statusCode) {
|
|
48
|
+
return this.resolveName(`${node.operationId} Status ${statusCode}`);
|
|
49
|
+
},
|
|
50
|
+
resolveResponseStatusTypedName(node, statusCode) {
|
|
51
|
+
return this.resolveTypedName(`${node.operationId} Status ${statusCode}`);
|
|
52
|
+
},
|
|
53
|
+
resolveDataName(node) {
|
|
54
|
+
return this.resolveName(`${node.operationId} Data`);
|
|
55
|
+
},
|
|
56
|
+
resolveDataTypedName(node) {
|
|
57
|
+
return this.resolveTypedName(`${node.operationId} Data`);
|
|
58
|
+
},
|
|
59
|
+
resolveRequestConfigName(node) {
|
|
60
|
+
return this.resolveName(`${node.operationId} RequestConfig`);
|
|
61
|
+
},
|
|
62
|
+
resolveRequestConfigTypedName(node) {
|
|
63
|
+
return this.resolveTypedName(`${node.operationId} RequestConfig`);
|
|
64
|
+
},
|
|
65
|
+
resolveResponsesName(node) {
|
|
66
|
+
return this.resolveName(`${node.operationId} Responses`);
|
|
67
|
+
},
|
|
68
|
+
resolveResponsesTypedName(node) {
|
|
69
|
+
return this.resolveTypedName(`${node.operationId} Responses`);
|
|
70
|
+
},
|
|
71
|
+
resolveResponseName(node) {
|
|
72
|
+
return this.resolveName(`${node.operationId} Response`);
|
|
73
|
+
},
|
|
74
|
+
resolveResponseTypedName(node) {
|
|
75
|
+
return this.resolveTypedName(`${node.operationId} Response`);
|
|
76
|
+
},
|
|
77
|
+
resolveEnumKeyTypedName(node) {
|
|
78
|
+
return `${this.resolveTypedName(node.name ?? "")}Key`;
|
|
79
|
+
},
|
|
80
|
+
resolvePathParamsName(_node) {
|
|
81
|
+
throw new Error("resolvePathParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.");
|
|
82
|
+
},
|
|
83
|
+
resolvePathParamsTypedName(_node) {
|
|
84
|
+
throw new Error("resolvePathParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.");
|
|
85
|
+
},
|
|
86
|
+
resolveQueryParamsName(node) {
|
|
87
|
+
return this.resolveName(`${node.operationId} QueryParams`);
|
|
88
|
+
},
|
|
89
|
+
resolveQueryParamsTypedName(node) {
|
|
90
|
+
return this.resolveTypedName(`${node.operationId} QueryParams`);
|
|
91
|
+
},
|
|
92
|
+
resolveHeaderParamsName(_node) {
|
|
93
|
+
throw new Error("resolveHeaderParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.");
|
|
94
|
+
},
|
|
95
|
+
resolveHeaderParamsTypedName(_node) {
|
|
96
|
+
throw new Error("resolveHeaderParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.");
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/resolvers/resolverTsLegacy.ts
|
|
102
|
+
/**
|
|
103
|
+
* Legacy resolver for `@kubb/plugin-ts` that reproduces the naming conventions
|
|
104
|
+
* used before the v2 resolver refactor. Enable via `compatibilityPreset: 'kubbV4'`
|
|
105
|
+
* (or by composing this resolver manually).
|
|
106
|
+
*
|
|
107
|
+
* Key differences from the default resolver:
|
|
108
|
+
* - Response status types: `<OperationId><StatusCode>` (e.g. `CreatePets201`) instead of `<OperationId>Status201`
|
|
109
|
+
* - Default/error responses: `<OperationId>Error` instead of `<OperationId>StatusDefault`
|
|
110
|
+
* - Request body: `<OperationId>MutationRequest` (non-GET) / `<OperationId>QueryRequest` (GET)
|
|
111
|
+
* - Combined responses type: `<OperationId>Mutation` / `<OperationId>Query`
|
|
112
|
+
* - Response union: `<OperationId>MutationResponse` / `<OperationId>QueryResponse`
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* import { resolverTsLegacy } from '@kubb/plugin-ts'
|
|
117
|
+
*
|
|
118
|
+
* resolverTsLegacy.resolveResponseStatusTypedName(node, 201) // → 'CreatePets201'
|
|
119
|
+
* resolverTsLegacy.resolveResponseStatusTypedName(node, 'default') // → 'CreatePetsError'
|
|
120
|
+
* resolverTsLegacy.resolveDataTypedName(node) // → 'CreatePetsMutationRequest' (POST)
|
|
121
|
+
* resolverTsLegacy.resolveResponsesTypedName(node) // → 'CreatePetsMutation' (POST)
|
|
122
|
+
* resolverTsLegacy.resolveResponseTypedName(node) // → 'CreatePetsMutationResponse' (POST)
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
const resolverTsLegacy = defineResolver(() => {
|
|
126
|
+
return {
|
|
127
|
+
...resolverTs,
|
|
128
|
+
name: "legacy",
|
|
129
|
+
resolveResponseStatusName(node, statusCode) {
|
|
130
|
+
if (statusCode === "default") return this.resolveName(`${node.operationId} Error`);
|
|
131
|
+
return this.resolveName(`${node.operationId} ${statusCode}`);
|
|
132
|
+
},
|
|
133
|
+
resolveResponseStatusTypedName(node, statusCode) {
|
|
134
|
+
if (statusCode === "default") return this.resolveTypedName(`${node.operationId} Error`);
|
|
135
|
+
return this.resolveTypedName(`${node.operationId} ${statusCode}`);
|
|
136
|
+
},
|
|
137
|
+
resolveDataName(node) {
|
|
138
|
+
const suffix = node.method === "GET" ? "QueryRequest" : "MutationRequest";
|
|
139
|
+
return this.resolveName(`${node.operationId} ${suffix}`);
|
|
140
|
+
},
|
|
141
|
+
resolveDataTypedName(node) {
|
|
142
|
+
const suffix = node.method === "GET" ? "QueryRequest" : "MutationRequest";
|
|
143
|
+
return this.resolveTypedName(`${node.operationId} ${suffix}`);
|
|
144
|
+
},
|
|
145
|
+
resolveResponsesName(node) {
|
|
146
|
+
const suffix = node.method === "GET" ? "Query" : "Mutation";
|
|
147
|
+
return `${this.default(node.operationId, "function")}${suffix}`;
|
|
148
|
+
},
|
|
149
|
+
resolveResponsesTypedName(node) {
|
|
150
|
+
const suffix = node.method === "GET" ? "Query" : "Mutation";
|
|
151
|
+
return `${this.default(node.operationId, "type")}${suffix}`;
|
|
152
|
+
},
|
|
153
|
+
resolveResponseName(node) {
|
|
154
|
+
const suffix = node.method === "GET" ? "QueryResponse" : "MutationResponse";
|
|
155
|
+
return this.resolveName(`${node.operationId} ${suffix}`);
|
|
156
|
+
},
|
|
157
|
+
resolveResponseTypedName(node) {
|
|
158
|
+
const suffix = node.method === "GET" ? "QueryResponse" : "MutationResponse";
|
|
159
|
+
return this.resolveTypedName(`${node.operationId} ${suffix}`);
|
|
160
|
+
},
|
|
161
|
+
resolvePathParamsName(node) {
|
|
162
|
+
return this.resolveName(`${node.operationId} PathParams`);
|
|
163
|
+
},
|
|
164
|
+
resolvePathParamsTypedName(node) {
|
|
165
|
+
return this.resolveTypedName(`${node.operationId} PathParams`);
|
|
166
|
+
},
|
|
167
|
+
resolveQueryParamsName(node) {
|
|
168
|
+
return this.resolveName(`${node.operationId} QueryParams`);
|
|
169
|
+
},
|
|
170
|
+
resolveQueryParamsTypedName(node) {
|
|
171
|
+
return this.resolveTypedName(`${node.operationId} QueryParams`);
|
|
172
|
+
},
|
|
173
|
+
resolveHeaderParamsName(node) {
|
|
174
|
+
return this.resolveName(`${node.operationId} HeaderParams`);
|
|
175
|
+
},
|
|
176
|
+
resolveHeaderParamsTypedName(node) {
|
|
177
|
+
return this.resolveTypedName(`${node.operationId} HeaderParams`);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
//#endregion
|
|
182
|
+
export { resolverTs as n, resolverTsLegacy as t };
|
|
183
|
+
|
|
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,WAAW,MAAM,EAAE,QAAQ,SAAS,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;AAqBtD,MAAa,aAAa,qBAA+B;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,GAAG,MAAM,OAAO;;EAE7F,0BAA0B,MAAM,YAAY;AAC1C,UAAO,KAAK,YAAY,GAAG,KAAK,YAAY,UAAU,aAAa;;EAErE,+BAA+B,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AY,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"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
const require_casing = require("./casing-D2uQKLWS.cjs");
|
|
2
|
+
let _kubb_core = require("@kubb/core");
|
|
3
|
+
//#region src/resolvers/resolverTs.ts
|
|
4
|
+
function resolveName(name, type) {
|
|
5
|
+
return require_casing.pascalCase(name, { isFile: type === "file" });
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Resolver for `@kubb/plugin-ts` that provides the default naming and path-resolution
|
|
9
|
+
* helpers used by the plugin. Import this in other plugins to resolve the exact names and
|
|
10
|
+
* paths that `plugin-ts` generates without hardcoding the conventions.
|
|
11
|
+
*
|
|
12
|
+
* The `default` method is automatically injected by `defineResolver` — it uses `camelCase`
|
|
13
|
+
* for identifiers/files and `pascalCase` for type names.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { resolver } from '@kubb/plugin-ts'
|
|
18
|
+
*
|
|
19
|
+
* resolver.default('list pets', 'type') // → 'ListPets'
|
|
20
|
+
* resolver.resolveName('list pets status 200') // → 'listPetsStatus200'
|
|
21
|
+
* resolver.resolveTypedName('list pets status 200') // → 'ListPetsStatus200'
|
|
22
|
+
* resolver.resolvePathName('list pets', 'file') // → 'listPets'
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
const resolverTs = (0, _kubb_core.defineResolver)(() => {
|
|
26
|
+
return {
|
|
27
|
+
name: "default",
|
|
28
|
+
default(name, type) {
|
|
29
|
+
return resolveName(name, type);
|
|
30
|
+
},
|
|
31
|
+
resolveName(name) {
|
|
32
|
+
return this.default(name, "function");
|
|
33
|
+
},
|
|
34
|
+
resolveTypedName(name) {
|
|
35
|
+
return this.default(name, "type");
|
|
36
|
+
},
|
|
37
|
+
resolvePathName(name, type) {
|
|
38
|
+
return this.default(name, type);
|
|
39
|
+
},
|
|
40
|
+
resolveParamName(node, param) {
|
|
41
|
+
return this.resolveName(`${node.operationId} ${this.default(param.in)} ${param.name}`);
|
|
42
|
+
},
|
|
43
|
+
resolveParamTypedName(node, param) {
|
|
44
|
+
return this.resolveTypedName(`${node.operationId} ${this.default(param.in)} ${param.name}`);
|
|
45
|
+
},
|
|
46
|
+
resolveResponseStatusName(node, statusCode) {
|
|
47
|
+
return this.resolveName(`${node.operationId} Status ${statusCode}`);
|
|
48
|
+
},
|
|
49
|
+
resolveResponseStatusTypedName(node, statusCode) {
|
|
50
|
+
return this.resolveTypedName(`${node.operationId} Status ${statusCode}`);
|
|
51
|
+
},
|
|
52
|
+
resolveDataName(node) {
|
|
53
|
+
return this.resolveName(`${node.operationId} Data`);
|
|
54
|
+
},
|
|
55
|
+
resolveDataTypedName(node) {
|
|
56
|
+
return this.resolveTypedName(`${node.operationId} Data`);
|
|
57
|
+
},
|
|
58
|
+
resolveRequestConfigName(node) {
|
|
59
|
+
return this.resolveName(`${node.operationId} RequestConfig`);
|
|
60
|
+
},
|
|
61
|
+
resolveRequestConfigTypedName(node) {
|
|
62
|
+
return this.resolveTypedName(`${node.operationId} RequestConfig`);
|
|
63
|
+
},
|
|
64
|
+
resolveResponsesName(node) {
|
|
65
|
+
return this.resolveName(`${node.operationId} Responses`);
|
|
66
|
+
},
|
|
67
|
+
resolveResponsesTypedName(node) {
|
|
68
|
+
return this.resolveTypedName(`${node.operationId} Responses`);
|
|
69
|
+
},
|
|
70
|
+
resolveResponseName(node) {
|
|
71
|
+
return this.resolveName(`${node.operationId} Response`);
|
|
72
|
+
},
|
|
73
|
+
resolveResponseTypedName(node) {
|
|
74
|
+
return this.resolveTypedName(`${node.operationId} Response`);
|
|
75
|
+
},
|
|
76
|
+
resolveEnumKeyTypedName(node) {
|
|
77
|
+
return `${this.resolveTypedName(node.name ?? "")}Key`;
|
|
78
|
+
},
|
|
79
|
+
resolvePathParamsName(_node) {
|
|
80
|
+
throw new Error("resolvePathParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.");
|
|
81
|
+
},
|
|
82
|
+
resolvePathParamsTypedName(_node) {
|
|
83
|
+
throw new Error("resolvePathParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.");
|
|
84
|
+
},
|
|
85
|
+
resolveQueryParamsName(node) {
|
|
86
|
+
return this.resolveName(`${node.operationId} QueryParams`);
|
|
87
|
+
},
|
|
88
|
+
resolveQueryParamsTypedName(node) {
|
|
89
|
+
return this.resolveTypedName(`${node.operationId} QueryParams`);
|
|
90
|
+
},
|
|
91
|
+
resolveHeaderParamsName(_node) {
|
|
92
|
+
throw new Error("resolveHeaderParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.");
|
|
93
|
+
},
|
|
94
|
+
resolveHeaderParamsTypedName(_node) {
|
|
95
|
+
throw new Error("resolveHeaderParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.");
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/resolvers/resolverTsLegacy.ts
|
|
101
|
+
/**
|
|
102
|
+
* Legacy resolver for `@kubb/plugin-ts` that reproduces the naming conventions
|
|
103
|
+
* used before the v2 resolver refactor. Enable via `compatibilityPreset: 'kubbV4'`
|
|
104
|
+
* (or by composing this resolver manually).
|
|
105
|
+
*
|
|
106
|
+
* Key differences from the default resolver:
|
|
107
|
+
* - Response status types: `<OperationId><StatusCode>` (e.g. `CreatePets201`) instead of `<OperationId>Status201`
|
|
108
|
+
* - Default/error responses: `<OperationId>Error` instead of `<OperationId>StatusDefault`
|
|
109
|
+
* - Request body: `<OperationId>MutationRequest` (non-GET) / `<OperationId>QueryRequest` (GET)
|
|
110
|
+
* - Combined responses type: `<OperationId>Mutation` / `<OperationId>Query`
|
|
111
|
+
* - Response union: `<OperationId>MutationResponse` / `<OperationId>QueryResponse`
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* import { resolverTsLegacy } from '@kubb/plugin-ts'
|
|
116
|
+
*
|
|
117
|
+
* resolverTsLegacy.resolveResponseStatusTypedName(node, 201) // → 'CreatePets201'
|
|
118
|
+
* resolverTsLegacy.resolveResponseStatusTypedName(node, 'default') // → 'CreatePetsError'
|
|
119
|
+
* resolverTsLegacy.resolveDataTypedName(node) // → 'CreatePetsMutationRequest' (POST)
|
|
120
|
+
* resolverTsLegacy.resolveResponsesTypedName(node) // → 'CreatePetsMutation' (POST)
|
|
121
|
+
* resolverTsLegacy.resolveResponseTypedName(node) // → 'CreatePetsMutationResponse' (POST)
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
const resolverTsLegacy = (0, _kubb_core.defineResolver)(() => {
|
|
125
|
+
return {
|
|
126
|
+
...resolverTs,
|
|
127
|
+
name: "legacy",
|
|
128
|
+
resolveResponseStatusName(node, statusCode) {
|
|
129
|
+
if (statusCode === "default") return this.resolveName(`${node.operationId} Error`);
|
|
130
|
+
return this.resolveName(`${node.operationId} ${statusCode}`);
|
|
131
|
+
},
|
|
132
|
+
resolveResponseStatusTypedName(node, statusCode) {
|
|
133
|
+
if (statusCode === "default") return this.resolveTypedName(`${node.operationId} Error`);
|
|
134
|
+
return this.resolveTypedName(`${node.operationId} ${statusCode}`);
|
|
135
|
+
},
|
|
136
|
+
resolveDataName(node) {
|
|
137
|
+
const suffix = node.method === "GET" ? "QueryRequest" : "MutationRequest";
|
|
138
|
+
return this.resolveName(`${node.operationId} ${suffix}`);
|
|
139
|
+
},
|
|
140
|
+
resolveDataTypedName(node) {
|
|
141
|
+
const suffix = node.method === "GET" ? "QueryRequest" : "MutationRequest";
|
|
142
|
+
return this.resolveTypedName(`${node.operationId} ${suffix}`);
|
|
143
|
+
},
|
|
144
|
+
resolveResponsesName(node) {
|
|
145
|
+
const suffix = node.method === "GET" ? "Query" : "Mutation";
|
|
146
|
+
return `${this.default(node.operationId, "function")}${suffix}`;
|
|
147
|
+
},
|
|
148
|
+
resolveResponsesTypedName(node) {
|
|
149
|
+
const suffix = node.method === "GET" ? "Query" : "Mutation";
|
|
150
|
+
return `${this.default(node.operationId, "type")}${suffix}`;
|
|
151
|
+
},
|
|
152
|
+
resolveResponseName(node) {
|
|
153
|
+
const suffix = node.method === "GET" ? "QueryResponse" : "MutationResponse";
|
|
154
|
+
return this.resolveName(`${node.operationId} ${suffix}`);
|
|
155
|
+
},
|
|
156
|
+
resolveResponseTypedName(node) {
|
|
157
|
+
const suffix = node.method === "GET" ? "QueryResponse" : "MutationResponse";
|
|
158
|
+
return this.resolveTypedName(`${node.operationId} ${suffix}`);
|
|
159
|
+
},
|
|
160
|
+
resolvePathParamsName(node) {
|
|
161
|
+
return this.resolveName(`${node.operationId} PathParams`);
|
|
162
|
+
},
|
|
163
|
+
resolvePathParamsTypedName(node) {
|
|
164
|
+
return this.resolveTypedName(`${node.operationId} PathParams`);
|
|
165
|
+
},
|
|
166
|
+
resolveQueryParamsName(node) {
|
|
167
|
+
return this.resolveName(`${node.operationId} QueryParams`);
|
|
168
|
+
},
|
|
169
|
+
resolveQueryParamsTypedName(node) {
|
|
170
|
+
return this.resolveTypedName(`${node.operationId} QueryParams`);
|
|
171
|
+
},
|
|
172
|
+
resolveHeaderParamsName(node) {
|
|
173
|
+
return this.resolveName(`${node.operationId} HeaderParams`);
|
|
174
|
+
},
|
|
175
|
+
resolveHeaderParamsTypedName(node) {
|
|
176
|
+
return this.resolveTypedName(`${node.operationId} HeaderParams`);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
//#endregion
|
|
181
|
+
Object.defineProperty(exports, "resolverTs", {
|
|
182
|
+
enumerable: true,
|
|
183
|
+
get: function() {
|
|
184
|
+
return resolverTs;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
Object.defineProperty(exports, "resolverTsLegacy", {
|
|
188
|
+
enumerable: true,
|
|
189
|
+
get: function() {
|
|
190
|
+
return resolverTsLegacy;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
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,U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,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"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|