@kubb/plugin-ts 5.0.0-alpha.22 → 5.0.0-alpha.24
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/index.cjs +1680 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +529 -4
- package/dist/index.js +1653 -52
- package/dist/index.js.map +1 -1
- package/package.json +3 -42
- package/src/components/Enum.tsx +2 -7
- package/src/components/Type.tsx +11 -5
- package/src/generators/typeGenerator.tsx +36 -24
- package/src/generators/typeGeneratorLegacy.tsx +28 -38
- package/src/index.ts +13 -1
- package/src/plugin.ts +42 -23
- package/src/presets.ts +16 -34
- package/src/printers/functionPrinter.ts +194 -0
- package/src/printers/printerTs.ts +23 -7
- package/src/resolvers/resolverTs.ts +10 -47
- package/src/resolvers/resolverTsLegacy.ts +4 -31
- package/src/types.ts +169 -254
- package/src/utils.ts +103 -0
- package/dist/Type-Bf8raoQX.cjs +0 -124
- package/dist/Type-Bf8raoQX.cjs.map +0 -1
- package/dist/Type-BpXxT4l_.js +0 -113
- package/dist/Type-BpXxT4l_.js.map +0 -1
- package/dist/builderTs-COUg3xtQ.cjs +0 -135
- package/dist/builderTs-COUg3xtQ.cjs.map +0 -1
- package/dist/builderTs-DPpkJKd1.js +0 -131
- package/dist/builderTs-DPpkJKd1.js.map +0 -1
- package/dist/builders.cjs +0 -3
- package/dist/builders.d.ts +0 -23
- package/dist/builders.js +0 -2
- package/dist/casing-BJHFg-zZ.js +0 -84
- package/dist/casing-BJHFg-zZ.js.map +0 -1
- package/dist/casing-DHfdqpLi.cjs +0 -107
- package/dist/casing-DHfdqpLi.cjs.map +0 -1
- package/dist/chunk-ByKO4r7w.cjs +0 -38
- package/dist/components.cjs +0 -4
- package/dist/components.d.ts +0 -71
- package/dist/components.js +0 -2
- package/dist/generators-DFDut8o-.js +0 -555
- package/dist/generators-DFDut8o-.js.map +0 -1
- package/dist/generators-DKd7MYbx.cjs +0 -567
- package/dist/generators-DKd7MYbx.cjs.map +0 -1
- package/dist/generators.cjs +0 -4
- package/dist/generators.d.ts +0 -12
- package/dist/generators.js +0 -2
- package/dist/printerTs-BcHudagv.cjs +0 -594
- package/dist/printerTs-BcHudagv.cjs.map +0 -1
- package/dist/printerTs-CMBCOuqd.js +0 -558
- package/dist/printerTs-CMBCOuqd.js.map +0 -1
- package/dist/printers.cjs +0 -3
- package/dist/printers.d.ts +0 -81
- package/dist/printers.js +0 -2
- package/dist/resolverTsLegacy-CPiqqsO6.js +0 -185
- package/dist/resolverTsLegacy-CPiqqsO6.js.map +0 -1
- package/dist/resolverTsLegacy-CuR9XbKk.cjs +0 -196
- package/dist/resolverTsLegacy-CuR9XbKk.cjs.map +0 -1
- package/dist/resolvers.cjs +0 -4
- package/dist/resolvers.d.ts +0 -52
- package/dist/resolvers.js +0 -2
- package/dist/types-CRtcZOCz.d.ts +0 -374
- package/src/builders/builderTs.ts +0 -107
- package/src/builders/index.ts +0 -1
- package/src/components/index.ts +0 -2
- package/src/generators/index.ts +0 -2
- package/src/printers/index.ts +0 -1
- package/src/resolvers/index.ts +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolverTsLegacy-CuR9XbKk.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 pluginName: 'plugin-ts',\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, enumTypeSuffix = 'key') {\n return `${this.resolveTypedName(node.name ?? '')}${enumTypeSuffix}`\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 throw new Error(\"resolveQueryParamsName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamName per individual parameter instead.\")\n },\n resolveQueryParamsTypedName(_node) {\n throw new Error(\n \"resolveQueryParamsTypedName is only available with compatibilityPreset: 'kubbV4'. Use resolveParamTypedName per individual parameter instead.\",\n )\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 pluginName: 'plugin-ts',\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} He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olverTsLegacy = require("./resolverTsLegacy-CuR9XbKk.cjs");
|
|
3
|
-
exports.resolverTs = require_resolverTsLegacy.resolverTs;
|
|
4
|
-
exports.resolverTsLegacy = require_resolverTsLegacy.resolverTsLegacy;
|
package/dist/resolvers.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { i as ResolverTs } from "./types-CRtcZOCz.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
DELETED
package/dist/types-CRtcZOCz.d.ts
DELETED
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { Builder, CompatibilityPreset, Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, ResolvePathOptions, Resolver } from "@kubb/core";
|
|
3
|
-
import { OperationNode, ParameterNode, SchemaNode, StatusCode, Visitor } from "@kubb/ast/types";
|
|
4
|
-
|
|
5
|
-
//#region src/types.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* The concrete resolver type for `@kubb/plugin-ts`.
|
|
8
|
-
* Extends the base `Resolver` (which provides `default` and `resolveOptions`) with
|
|
9
|
-
* plugin-specific naming helpers for operations, parameters, responses, and schemas.
|
|
10
|
-
*/
|
|
11
|
-
type ResolverTs = Resolver & {
|
|
12
|
-
/**
|
|
13
|
-
* Resolves the variable/function name for a given raw name (equivalent to `default(name, 'function')`).
|
|
14
|
-
* Use this shorthand when matching the `name` field produced by the v2 TypeGenerator,
|
|
15
|
-
* so call-sites don't need to repeat the `'function'` type literal.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* resolver.resolveName('list pets status 200') // → 'listPetsStatus200'
|
|
19
|
-
*/
|
|
20
|
-
resolveName(name: string): string;
|
|
21
|
-
/**
|
|
22
|
-
* Resolves the TypeScript type name for a given raw name (equivalent to `default(name, 'type')`).
|
|
23
|
-
* Use this shorthand when matching the `typedName` field produced by the v2 TypeGenerator,
|
|
24
|
-
* so call-sites don't need to repeat the `'type'` type literal.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* resolver.resolveTypedName('list pets status 200') // → 'ListPetsStatus200'
|
|
28
|
-
*/
|
|
29
|
-
resolveTypedName(name: string): string;
|
|
30
|
-
/**
|
|
31
|
-
* Resolves the file/path name for a given identifier using PascalCase.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* resolver.resolvePathName('list pets', 'file') // → 'ListPets'
|
|
35
|
-
*/
|
|
36
|
-
resolvePathName(name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
|
|
37
|
-
/**
|
|
38
|
-
* Resolves the variable/function name for an operation parameter.
|
|
39
|
-
* Encapsulates the `<operationId> <PascalCase(paramIn)> <paramName>` naming convention.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* resolver.resolveParamName(node, param) // → 'ListPetsQueryLimit'
|
|
43
|
-
*/
|
|
44
|
-
resolveParamName(node: OperationNode, param: ParameterNode): string;
|
|
45
|
-
/**
|
|
46
|
-
* Resolves the TypeScript type alias name for an operation parameter
|
|
47
|
-
* (equivalent to `resolveParamName` with `type: 'type'`).
|
|
48
|
-
* In the default implementation both return the same PascalCase string;
|
|
49
|
-
* the distinction is preserved so overrides can diverge the two forms.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* resolver.resolveParamTypedName(node, param) // → 'ListPetsQueryLimit'
|
|
53
|
-
*/
|
|
54
|
-
resolveParamTypedName(node: OperationNode, param: ParameterNode): string;
|
|
55
|
-
/**
|
|
56
|
-
* Resolves the variable/function name for an operation response by status code.
|
|
57
|
-
* Encapsulates the `<operationId> Status <statusCode>` template with PascalCase applied to the result.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* resolver.resolveResponseStatusName(node, 200) // → 'ListPetsStatus200'
|
|
61
|
-
*/
|
|
62
|
-
resolveResponseStatusName(node: OperationNode, statusCode: StatusCode): string;
|
|
63
|
-
/**
|
|
64
|
-
* Resolves the TypeScript type alias name for an operation response by status code.
|
|
65
|
-
* Encapsulates the `<operationId> Status <statusCode>` template with PascalCase applied to the result.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* resolver.resolveResponseStatusTypedName(node, 200) // → 'ListPetsStatus200'
|
|
69
|
-
*/
|
|
70
|
-
resolveResponseStatusTypedName(node: OperationNode, statusCode: StatusCode): string;
|
|
71
|
-
/**
|
|
72
|
-
* Resolves the variable/function name for an operation's request body (`Data`).
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* resolver.resolveDataName(node) // → 'ListPetsData'
|
|
76
|
-
*/
|
|
77
|
-
resolveDataName(node: OperationNode): string;
|
|
78
|
-
/**
|
|
79
|
-
* Resolves the TypeScript type alias name for an operation's request body (`Data`).
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* resolver.resolveDataTypedName(node) // → 'ListPetsData'
|
|
83
|
-
*/
|
|
84
|
-
resolveDataTypedName(node: OperationNode): string;
|
|
85
|
-
/**
|
|
86
|
-
* Resolves the variable/function name for an operation's request config (`RequestConfig`).
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* resolver.resolveRequestConfigName(node) // → 'ListPetsRequestConfig'
|
|
90
|
-
*/
|
|
91
|
-
resolveRequestConfigName(node: OperationNode): string;
|
|
92
|
-
/**
|
|
93
|
-
* Resolves the TypeScript type alias name for an operation's request config (`RequestConfig`).
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* resolver.resolveRequestConfigTypedName(node) // → 'ListPetsRequestConfig'
|
|
97
|
-
*/
|
|
98
|
-
resolveRequestConfigTypedName(node: OperationNode): string;
|
|
99
|
-
/**
|
|
100
|
-
* Resolves the variable/function name for the collection of all operation responses (`Responses`).
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* resolver.resolveResponsesName(node) // → 'ListPetsResponses'
|
|
104
|
-
*/
|
|
105
|
-
resolveResponsesName(node: OperationNode): string;
|
|
106
|
-
/**
|
|
107
|
-
* Resolves the TypeScript type alias name for the collection of all operation responses.
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* resolver.resolveResponsesTypedName(node) // → 'ListPetsResponses'
|
|
111
|
-
*/
|
|
112
|
-
resolveResponsesTypedName(node: OperationNode): string;
|
|
113
|
-
/**
|
|
114
|
-
* Resolves the variable/function name for the union of all operation responses (`Response`).
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* resolver.resolveResponseName(node) // → 'ListPetsResponse'
|
|
118
|
-
*/
|
|
119
|
-
resolveResponseName(node: OperationNode): string;
|
|
120
|
-
/**
|
|
121
|
-
* Resolves the TypeScript type alias name for the union of all operation responses.
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* resolver.resolveResponseTypedName(node) // → 'ListPetsResponse'
|
|
125
|
-
*/
|
|
126
|
-
resolveResponseTypedName(node: OperationNode): string;
|
|
127
|
-
/**
|
|
128
|
-
* Resolves the TypeScript type alias name for an enum schema's key variant.
|
|
129
|
-
* Appends `enumTypeSuffix` (default `'Key'`) after applying the default naming convention.
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* resolver.resolveEnumKeyTypedName(node, 'Key') // → 'PetStatusKey'
|
|
133
|
-
* resolver.resolveEnumKeyTypedName(node, 'Value') // → 'PetStatusValue'
|
|
134
|
-
* resolver.resolveEnumKeyTypedName(node, '') // → 'PetStatus'
|
|
135
|
-
*/
|
|
136
|
-
resolveEnumKeyTypedName(node: SchemaNode, enumTypeSuffix: string): string;
|
|
137
|
-
/**
|
|
138
|
-
* Resolves the variable/function name for an operation's grouped path parameters type.
|
|
139
|
-
* Only available with `compatibilityPreset: 'kubbV4'`.
|
|
140
|
-
*
|
|
141
|
-
* @deprecated Kubb v4 compatibility only — use `resolveParamName` per individual parameter instead.
|
|
142
|
-
* @example
|
|
143
|
-
* resolver.resolvePathParamsName(node) // → 'GetPetByIdPathParams'
|
|
144
|
-
*/
|
|
145
|
-
resolvePathParamsName?(node: OperationNode): string;
|
|
146
|
-
/**
|
|
147
|
-
* Resolves the TypeScript type alias name for an operation's grouped path parameters type.
|
|
148
|
-
* Only available with `compatibilityPreset: 'kubbV4'`.
|
|
149
|
-
*
|
|
150
|
-
* @deprecated Kubb v4 compatibility only — use `resolveParamTypedName` per individual parameter instead.
|
|
151
|
-
* @example
|
|
152
|
-
* resolver.resolvePathParamsTypedName(node) // → 'GetPetByIdPathParams'
|
|
153
|
-
*/
|
|
154
|
-
resolvePathParamsTypedName?(node: OperationNode): string;
|
|
155
|
-
/**
|
|
156
|
-
* Resolves the variable/function name for an operation's grouped query parameters type.
|
|
157
|
-
* Only available with `compatibilityPreset: 'kubbV4'`.
|
|
158
|
-
*
|
|
159
|
-
* @deprecated Kubb v4 compatibility only — use `resolveParamName` per individual parameter instead.
|
|
160
|
-
* @example
|
|
161
|
-
* resolver.resolveQueryParamsName(node) // → 'FindPetsByStatusQueryParams'
|
|
162
|
-
*/
|
|
163
|
-
resolveQueryParamsName?(node: OperationNode): string;
|
|
164
|
-
/**
|
|
165
|
-
* Resolves the TypeScript type alias name for an operation's grouped query parameters type.
|
|
166
|
-
* Only available with `compatibilityPreset: 'kubbV4'`.
|
|
167
|
-
*
|
|
168
|
-
* @deprecated Kubb v4 compatibility only — use `resolveParamTypedName` per individual parameter instead.
|
|
169
|
-
* @example
|
|
170
|
-
* resolver.resolveQueryParamsTypedName(node) // → 'FindPetsByStatusQueryParams'
|
|
171
|
-
*/
|
|
172
|
-
resolveQueryParamsTypedName?(node: OperationNode): string;
|
|
173
|
-
/**
|
|
174
|
-
* Resolves the variable/function name for an operation's grouped header parameters type.
|
|
175
|
-
* Only available with `compatibilityPreset: 'kubbV4'`.
|
|
176
|
-
*
|
|
177
|
-
* @deprecated Kubb v4 compatibility only — use `resolveParamName` per individual parameter instead.
|
|
178
|
-
* @example
|
|
179
|
-
* resolver.resolveHeaderParamsName(node) // → 'DeletePetHeaderParams'
|
|
180
|
-
*/
|
|
181
|
-
resolveHeaderParamsName?(node: OperationNode): string;
|
|
182
|
-
/**
|
|
183
|
-
* Resolves the TypeScript type alias name for an operation's grouped header parameters type.
|
|
184
|
-
* Only available with `compatibilityPreset: 'kubbV4'`.
|
|
185
|
-
*
|
|
186
|
-
* @deprecated Kubb v4 compatibility only — use `resolveParamTypedName` per individual parameter instead.
|
|
187
|
-
* @example
|
|
188
|
-
* resolver.resolveHeaderParamsTypedName(node) // → 'DeletePetHeaderParams'
|
|
189
|
-
*/
|
|
190
|
-
resolveHeaderParamsTypedName?(node: OperationNode): string;
|
|
191
|
-
};
|
|
192
|
-
/**
|
|
193
|
-
* Options for building a grouped parameter schema (`pathParams`, `queryParams`, `headerParams`).
|
|
194
|
-
*/
|
|
195
|
-
type BuildParamsSchemaOptions = {
|
|
196
|
-
params: Array<ParameterNode>;
|
|
197
|
-
node: OperationNode;
|
|
198
|
-
resolver: ResolverTs;
|
|
199
|
-
};
|
|
200
|
-
/**
|
|
201
|
-
* Options for building an operation-level schema (`data`, `responses`, `responseUnion`).
|
|
202
|
-
*/
|
|
203
|
-
type BuildOperationSchemaOptions = {
|
|
204
|
-
node: OperationNode;
|
|
205
|
-
resolver: ResolverTs;
|
|
206
|
-
};
|
|
207
|
-
/**
|
|
208
|
-
* The concrete builder type for `@kubb/plugin-ts`.
|
|
209
|
-
* Extends the base `Builder` with schema-building helpers used by the v5 type generator.
|
|
210
|
-
*/
|
|
211
|
-
type BuilderTs = Builder & {
|
|
212
|
-
/**
|
|
213
|
-
* Builds an object schema that groups the given parameters by name.
|
|
214
|
-
*/
|
|
215
|
-
buildParams(options: BuildParamsSchemaOptions): SchemaNode;
|
|
216
|
-
/**
|
|
217
|
-
* Builds the combined data schema containing `pathParams`, `queryParams`, `headerParams`, `data`, and `url`.
|
|
218
|
-
*/
|
|
219
|
-
buildData(options: BuildOperationSchemaOptions): SchemaNode;
|
|
220
|
-
/**
|
|
221
|
-
* Builds an object schema that maps each response status code to its type reference, or `null` when there are no responses.
|
|
222
|
-
*/
|
|
223
|
-
buildResponses(options: BuildOperationSchemaOptions): SchemaNode | null;
|
|
224
|
-
/**
|
|
225
|
-
* Builds a union schema of all response status types, or `null` when no responses have a schema.
|
|
226
|
-
*/
|
|
227
|
-
buildResponseUnion(options: BuildOperationSchemaOptions): SchemaNode | null;
|
|
228
|
-
};
|
|
229
|
-
type Options = {
|
|
230
|
-
/**
|
|
231
|
-
* Specify the export location for the files and define the behavior of the output
|
|
232
|
-
* @default { path: 'types', barrelType: 'named' }
|
|
233
|
-
*/
|
|
234
|
-
output?: Output;
|
|
235
|
-
/**
|
|
236
|
-
* Define which contentType should be used.
|
|
237
|
-
* By default, uses the first valid JSON media type.
|
|
238
|
-
*/
|
|
239
|
-
contentType?: 'application/json' | (string & {});
|
|
240
|
-
/**
|
|
241
|
-
* Group the clients based on the provided name.
|
|
242
|
-
*/
|
|
243
|
-
group?: Group;
|
|
244
|
-
/**
|
|
245
|
-
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
246
|
-
*/
|
|
247
|
-
exclude?: Array<Exclude>;
|
|
248
|
-
/**
|
|
249
|
-
* Array containing include parameters to include tags/operations/methods/paths.
|
|
250
|
-
*/
|
|
251
|
-
include?: Array<Include>;
|
|
252
|
-
/**
|
|
253
|
-
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
254
|
-
*/
|
|
255
|
-
override?: Array<Override<ResolvedOptions>>;
|
|
256
|
-
/**
|
|
257
|
-
* Choose to use enum, asConst, asPascalConst, constEnum, literal, or inlineLiteral for enums.
|
|
258
|
-
* - 'enum' generates TypeScript enum declarations.
|
|
259
|
-
* - 'asConst' generates const objects with camelCase names and as const assertion.
|
|
260
|
-
* - 'asPascalConst' generates const objects with PascalCase names and as const assertion.
|
|
261
|
-
* - 'constEnum' generates TypeScript const enum declarations.
|
|
262
|
-
* - 'literal' generates literal union types.
|
|
263
|
-
* - 'inlineLiteral' inline enum values directly into the type (default in v5).
|
|
264
|
-
* @default 'asConst'
|
|
265
|
-
* @note In Kubb v5, 'inlineLiteral' becomes the default.
|
|
266
|
-
*/
|
|
267
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
|
|
268
|
-
/**
|
|
269
|
-
* Suffix appended to the generated type alias name when `enumType` is `asConst` or `asPascalConst`.
|
|
270
|
-
*
|
|
271
|
-
* Only affects the type alias — the const object name is unchanged.
|
|
272
|
-
*
|
|
273
|
-
* @default 'Key'
|
|
274
|
-
* @example enumTypeSuffix: 'Value' → `export type PetStatusValue = …`
|
|
275
|
-
*/
|
|
276
|
-
enumTypeSuffix?: string;
|
|
277
|
-
/**
|
|
278
|
-
* Choose the casing for enum key names.
|
|
279
|
-
* - 'screamingSnakeCase' generates keys in SCREAMING_SNAKE_CASE format.
|
|
280
|
-
* - 'snakeCase' generates keys in snake_case format.
|
|
281
|
-
* - 'pascalCase' generates keys in PascalCase format.
|
|
282
|
-
* - 'camelCase' generates keys in camelCase format.
|
|
283
|
-
* - 'none' uses the enum value as-is without transformation.
|
|
284
|
-
* @default 'none'
|
|
285
|
-
*/
|
|
286
|
-
enumKeyCasing?: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none';
|
|
287
|
-
/**
|
|
288
|
-
* Switch between type or interface for creating TypeScript types.
|
|
289
|
-
* - 'type' generates type alias declarations.
|
|
290
|
-
* - 'interface' generates interface declarations.
|
|
291
|
-
* @default 'type'
|
|
292
|
-
*/
|
|
293
|
-
syntaxType?: 'type' | 'interface';
|
|
294
|
-
/**
|
|
295
|
-
* Choose what to use as mode for an optional value.
|
|
296
|
-
* - 'questionToken' marks the property as optional with ? (e.g., type?: string).
|
|
297
|
-
* - 'undefined' adds undefined to the type union (e.g., type: string | undefined).
|
|
298
|
-
* - 'questionTokenAndUndefined' combines both approaches (e.g., type?: string | undefined).
|
|
299
|
-
* @default 'questionToken'
|
|
300
|
-
*/
|
|
301
|
-
optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined';
|
|
302
|
-
/**
|
|
303
|
-
* Choose between Array<string> or string[] for array types.
|
|
304
|
-
* - 'generic' generates Array<Type> syntax.
|
|
305
|
-
* - 'array' generates Type[] syntax.
|
|
306
|
-
* @default 'array'
|
|
307
|
-
*/
|
|
308
|
-
arrayType?: 'generic' | 'array';
|
|
309
|
-
/**
|
|
310
|
-
* How to style your params, by default no casing is applied
|
|
311
|
-
* - 'camelcase' uses camelCase for pathParams, queryParams and headerParams property names
|
|
312
|
-
* @default undefined
|
|
313
|
-
* @note response types (data/body) are NOT affected by this option
|
|
314
|
-
*/
|
|
315
|
-
paramsCasing?: 'camelcase';
|
|
316
|
-
/**
|
|
317
|
-
* Define some generators next to the ts generators
|
|
318
|
-
*/
|
|
319
|
-
generators?: Array<Generator<PluginTs>>;
|
|
320
|
-
/**
|
|
321
|
-
* Apply a compatibility naming preset.
|
|
322
|
-
* Use `kubbV4` for strict v4 type-generation compatibility.
|
|
323
|
-
* You can further customize naming with `resolvers`.
|
|
324
|
-
* @default 'default'
|
|
325
|
-
*/
|
|
326
|
-
compatibilityPreset?: CompatibilityPreset;
|
|
327
|
-
/**
|
|
328
|
-
* Array of named resolvers that control naming conventions.
|
|
329
|
-
* Later entries override earlier ones (last wins).
|
|
330
|
-
* Built-in: `resolverTs` (default), `resolverTsLegacy`.
|
|
331
|
-
* @default [resolverTs]
|
|
332
|
-
*/
|
|
333
|
-
resolvers?: Array<ResolverTs>;
|
|
334
|
-
/**
|
|
335
|
-
* Array of AST visitors applied to each SchemaNode/OperationNode before printing.
|
|
336
|
-
* Uses `transform()` from `@kubb/ast` — visitors can modify, replace, or annotate nodes.
|
|
337
|
-
*
|
|
338
|
-
* @example Remove writeOnly properties from response types
|
|
339
|
-
* ```ts
|
|
340
|
-
* transformers: [{
|
|
341
|
-
* property(node) {
|
|
342
|
-
* if (node.schema.writeOnly) return undefined
|
|
343
|
-
* }
|
|
344
|
-
* }]
|
|
345
|
-
* ```
|
|
346
|
-
*
|
|
347
|
-
* @example Force all dates to plain strings
|
|
348
|
-
* ```ts
|
|
349
|
-
* transformers: [{
|
|
350
|
-
* schema(node) {
|
|
351
|
-
* if (node.type === 'date') return { ...node, type: 'string' }
|
|
352
|
-
* }
|
|
353
|
-
* }]
|
|
354
|
-
* ```
|
|
355
|
-
*/
|
|
356
|
-
transformers?: Array<Visitor>;
|
|
357
|
-
};
|
|
358
|
-
type ResolvedOptions = {
|
|
359
|
-
output: Output;
|
|
360
|
-
group: Options['group'];
|
|
361
|
-
enumType: NonNullable<Options['enumType']>;
|
|
362
|
-
enumTypeSuffix: NonNullable<Options['enumTypeSuffix']>;
|
|
363
|
-
enumKeyCasing: NonNullable<Options['enumKeyCasing']>;
|
|
364
|
-
optionalType: NonNullable<Options['optionalType']>;
|
|
365
|
-
arrayType: NonNullable<Options['arrayType']>;
|
|
366
|
-
syntaxType: NonNullable<Options['syntaxType']>;
|
|
367
|
-
paramsCasing: Options['paramsCasing'];
|
|
368
|
-
resolver: ResolverTs;
|
|
369
|
-
transformers: Array<Visitor>;
|
|
370
|
-
};
|
|
371
|
-
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions, ResolverTs, BuilderTs>;
|
|
372
|
-
//#endregion
|
|
373
|
-
export { ResolverTs as i, Options as n, PluginTs as r, BuilderTs as t };
|
|
374
|
-
//# sourceMappingURL=types-CRtcZOCz.d.ts.map
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { createProperty, createSchema } from '@kubb/ast'
|
|
2
|
-
import { defineBuilder } from '@kubb/core'
|
|
3
|
-
import type { PluginTs } from '../types.ts'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Default schema builder for `@kubb/plugin-ts`.
|
|
7
|
-
*
|
|
8
|
-
* Implements the `buildParams`, `buildData`, `buildResponses`, and `buildResponseUnion` helpers
|
|
9
|
-
* used by the TypeScript type generator to construct AST schema nodes for operation parameters,
|
|
10
|
-
* request bodies, and responses.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* import { builderTs } from '@kubb/plugin-ts'
|
|
15
|
-
*
|
|
16
|
-
* builderTs.buildData({ node, resolver })
|
|
17
|
-
* // → object schema with pathParams, queryParams, headerParams, data, url properties
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export const builderTs = defineBuilder<PluginTs>(() => ({
|
|
21
|
-
name: 'default',
|
|
22
|
-
buildParams({ params, node, resolver }) {
|
|
23
|
-
return createSchema({
|
|
24
|
-
type: 'object',
|
|
25
|
-
properties: params.map((param) =>
|
|
26
|
-
createProperty({
|
|
27
|
-
name: param.name,
|
|
28
|
-
required: param.required,
|
|
29
|
-
schema: createSchema({
|
|
30
|
-
type: 'ref',
|
|
31
|
-
name: resolver.resolveParamName(node, param),
|
|
32
|
-
}),
|
|
33
|
-
}),
|
|
34
|
-
),
|
|
35
|
-
})
|
|
36
|
-
},
|
|
37
|
-
buildData({ node, resolver }) {
|
|
38
|
-
const pathParams = node.parameters.filter((p) => p.in === 'path')
|
|
39
|
-
const queryParams = node.parameters.filter((p) => p.in === 'query')
|
|
40
|
-
const headerParams = node.parameters.filter((p) => p.in === 'header')
|
|
41
|
-
|
|
42
|
-
return createSchema({
|
|
43
|
-
type: 'object',
|
|
44
|
-
deprecated: node.deprecated,
|
|
45
|
-
properties: [
|
|
46
|
-
createProperty({
|
|
47
|
-
name: 'data',
|
|
48
|
-
schema: node.requestBody?.schema
|
|
49
|
-
? createSchema({ type: 'ref', name: resolver.resolveDataTypedName(node), optional: true })
|
|
50
|
-
: createSchema({ type: 'never', optional: true }),
|
|
51
|
-
}),
|
|
52
|
-
createProperty({
|
|
53
|
-
name: 'pathParams',
|
|
54
|
-
required: pathParams.length > 0,
|
|
55
|
-
schema: pathParams.length > 0 ? this.buildParams({ params: pathParams, node, resolver }) : createSchema({ type: 'never' }),
|
|
56
|
-
}),
|
|
57
|
-
createProperty({
|
|
58
|
-
name: 'queryParams',
|
|
59
|
-
schema:
|
|
60
|
-
queryParams.length > 0
|
|
61
|
-
? createSchema({ ...this.buildParams({ params: queryParams, node, resolver }), optional: true })
|
|
62
|
-
: createSchema({ type: 'never', optional: true }),
|
|
63
|
-
}),
|
|
64
|
-
createProperty({
|
|
65
|
-
name: 'headerParams',
|
|
66
|
-
schema:
|
|
67
|
-
headerParams.length > 0
|
|
68
|
-
? createSchema({ ...this.buildParams({ params: headerParams, node, resolver }), optional: true })
|
|
69
|
-
: createSchema({ type: 'never', optional: true }),
|
|
70
|
-
}),
|
|
71
|
-
createProperty({
|
|
72
|
-
name: 'url',
|
|
73
|
-
required: true,
|
|
74
|
-
schema: createSchema({ type: 'url', path: node.path }),
|
|
75
|
-
}),
|
|
76
|
-
],
|
|
77
|
-
})
|
|
78
|
-
},
|
|
79
|
-
buildResponses({ node, resolver }) {
|
|
80
|
-
if (node.responses.length === 0) {
|
|
81
|
-
return null
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return createSchema({
|
|
85
|
-
type: 'object',
|
|
86
|
-
properties: node.responses.map((res) =>
|
|
87
|
-
createProperty({
|
|
88
|
-
name: String(res.statusCode),
|
|
89
|
-
required: true,
|
|
90
|
-
schema: createSchema({ type: 'ref', name: resolver.resolveResponseStatusTypedName(node, res.statusCode) }),
|
|
91
|
-
}),
|
|
92
|
-
),
|
|
93
|
-
})
|
|
94
|
-
},
|
|
95
|
-
buildResponseUnion({ node, resolver }) {
|
|
96
|
-
const responsesWithSchema = node.responses.filter((res) => res.schema)
|
|
97
|
-
|
|
98
|
-
if (responsesWithSchema.length === 0) {
|
|
99
|
-
return null
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return createSchema({
|
|
103
|
-
type: 'union',
|
|
104
|
-
members: responsesWithSchema.map((res) => createSchema({ type: 'ref', name: resolver.resolveResponseStatusTypedName(node, res.statusCode) })),
|
|
105
|
-
})
|
|
106
|
-
},
|
|
107
|
-
}))
|
package/src/builders/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { builderTs } from './builderTs.ts'
|
package/src/components/index.ts
DELETED
package/src/generators/index.ts
DELETED
package/src/printers/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { printerTs } from './printerTs.ts'
|
package/src/resolvers/index.ts
DELETED