@kubb/plugin-ts 5.0.0-alpha.21 → 5.0.0-alpha.23

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.
Files changed (66) hide show
  1. package/dist/index.cjs +1698 -42
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.ts +485 -4
  4. package/dist/index.js +1667 -41
  5. package/dist/index.js.map +1 -1
  6. package/package.json +3 -42
  7. package/src/components/Enum.tsx +15 -11
  8. package/src/components/Type.tsx +18 -7
  9. package/src/generators/typeGenerator.tsx +12 -21
  10. package/src/generators/typeGeneratorLegacy.tsx +30 -37
  11. package/src/index.ts +13 -1
  12. package/src/plugin.ts +62 -22
  13. package/src/presets.ts +22 -23
  14. package/src/printers/functionPrinter.ts +194 -0
  15. package/src/printers/printerTs.ts +16 -8
  16. package/src/resolvers/resolverTs.ts +10 -47
  17. package/src/resolvers/resolverTsLegacy.ts +4 -31
  18. package/src/types.ts +95 -205
  19. package/src/utils.ts +103 -0
  20. package/dist/Type-B6fo0gSk.js +0 -120
  21. package/dist/Type-B6fo0gSk.js.map +0 -1
  22. package/dist/Type-oFwUfkZv.cjs +0 -131
  23. package/dist/Type-oFwUfkZv.cjs.map +0 -1
  24. package/dist/builderTs-Cd3juc2G.cjs +0 -120
  25. package/dist/builderTs-Cd3juc2G.cjs.map +0 -1
  26. package/dist/builderTs-DausqHpc.js +0 -116
  27. package/dist/builderTs-DausqHpc.js.map +0 -1
  28. package/dist/builders.cjs +0 -3
  29. package/dist/builders.d.ts +0 -8
  30. package/dist/builders.js +0 -2
  31. package/dist/casing-BJHFg-zZ.js +0 -84
  32. package/dist/casing-BJHFg-zZ.js.map +0 -1
  33. package/dist/casing-DHfdqpLi.cjs +0 -107
  34. package/dist/casing-DHfdqpLi.cjs.map +0 -1
  35. package/dist/chunk-ByKO4r7w.cjs +0 -38
  36. package/dist/components.cjs +0 -4
  37. package/dist/components.d.ts +0 -67
  38. package/dist/components.js +0 -2
  39. package/dist/generators-ByK18qUn.js +0 -551
  40. package/dist/generators-ByK18qUn.js.map +0 -1
  41. package/dist/generators-aSsiTfUO.cjs +0 -563
  42. package/dist/generators-aSsiTfUO.cjs.map +0 -1
  43. package/dist/generators.cjs +0 -4
  44. package/dist/generators.d.ts +0 -12
  45. package/dist/generators.js +0 -2
  46. package/dist/printerTs-BgZucv4T.js +0 -559
  47. package/dist/printerTs-BgZucv4T.js.map +0 -1
  48. package/dist/printerTs-CFXc_LpP.cjs +0 -595
  49. package/dist/printerTs-CFXc_LpP.cjs.map +0 -1
  50. package/dist/printers.cjs +0 -3
  51. package/dist/printers.d.ts +0 -75
  52. package/dist/printers.js +0 -2
  53. package/dist/resolverTsLegacy-DLl854-P.js +0 -185
  54. package/dist/resolverTsLegacy-DLl854-P.js.map +0 -1
  55. package/dist/resolverTsLegacy-sJ16Iqrl.cjs +0 -196
  56. package/dist/resolverTsLegacy-sJ16Iqrl.cjs.map +0 -1
  57. package/dist/resolvers.cjs +0 -4
  58. package/dist/resolvers.d.ts +0 -52
  59. package/dist/resolvers.js +0 -2
  60. package/dist/types-BcyuFDn9.d.ts +0 -344
  61. package/src/builders/builderTs.ts +0 -92
  62. package/src/builders/index.ts +0 -1
  63. package/src/components/index.ts +0 -2
  64. package/src/generators/index.ts +0 -2
  65. package/src/printers/index.ts +0 -1
  66. package/src/resolvers/index.ts +0 -2
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolverTsLegacy-sJ16Iqrl.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) {\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 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} 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,YAAY;EACZ,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,MAAM,YAAY;AAC/C,UAAO,KAAK,iBAAiB,GAAG,KAAK,YAAY,UAAU,aAAa;;EAE1E,gBAAgB,MAAM;AACpB,UAAO,KAAK,YAAY,GAAG,KAAK,YAAY,OAAO;;EAErD,qBAAqB,MAAM;AACzB,UAAO,KAAK,iBAAiB,GAAG,KAAK,YAAY,OAAO;;EAE1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@ -1,4 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_resolverTsLegacy = require("./resolverTsLegacy-sJ16Iqrl.cjs");
3
- exports.resolverTs = require_resolverTsLegacy.resolverTs;
4
- exports.resolverTsLegacy = require_resolverTsLegacy.resolverTsLegacy;
@@ -1,52 +0,0 @@
1
- import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { i as ResolverTs } from "./types-BcyuFDn9.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
@@ -1,2 +0,0 @@
1
- import { n as resolverTs, t as resolverTsLegacy } from "./resolverTsLegacy-DLl854-P.js";
2
- export { resolverTs, resolverTsLegacy };
@@ -1,344 +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 the `Key` suffix after applying the default naming convention.
130
- *
131
- * @example
132
- * resolver.resolveEnumKeyTypedName(node) // → 'PetStatusKey'
133
- */
134
- resolveEnumKeyTypedName(node: SchemaNode): string;
135
- /**
136
- * Resolves the variable/function name for an operation's grouped path parameters type.
137
- * Only available with `compatibilityPreset: 'kubbV4'`.
138
- *
139
- * @deprecated Kubb v4 compatibility only — use `resolveParamName` per individual parameter instead.
140
- * @example
141
- * resolver.resolvePathParamsName(node) // → 'GetPetByIdPathParams'
142
- */
143
- resolvePathParamsName?(node: OperationNode): string;
144
- /**
145
- * Resolves the TypeScript type alias name for an operation's grouped path parameters type.
146
- * Only available with `compatibilityPreset: 'kubbV4'`.
147
- *
148
- * @deprecated Kubb v4 compatibility only — use `resolveParamTypedName` per individual parameter instead.
149
- * @example
150
- * resolver.resolvePathParamsTypedName(node) // → 'GetPetByIdPathParams'
151
- */
152
- resolvePathParamsTypedName?(node: OperationNode): string;
153
- /**
154
- * Resolves the variable/function name for an operation's grouped query parameters type.
155
- * Only available with `compatibilityPreset: 'kubbV4'`.
156
- *
157
- * @deprecated Kubb v4 compatibility only — use `resolveParamName` per individual parameter instead.
158
- * @example
159
- * resolver.resolveQueryParamsName(node) // → 'FindPetsByStatusQueryParams'
160
- */
161
- resolveQueryParamsName?(node: OperationNode): string;
162
- /**
163
- * Resolves the TypeScript type alias name for an operation's grouped query parameters type.
164
- * Only available with `compatibilityPreset: 'kubbV4'`.
165
- *
166
- * @deprecated Kubb v4 compatibility only — use `resolveParamTypedName` per individual parameter instead.
167
- * @example
168
- * resolver.resolveQueryParamsTypedName(node) // → 'FindPetsByStatusQueryParams'
169
- */
170
- resolveQueryParamsTypedName?(node: OperationNode): string;
171
- /**
172
- * Resolves the variable/function name for an operation's grouped header parameters type.
173
- * Only available with `compatibilityPreset: 'kubbV4'`.
174
- *
175
- * @deprecated Kubb v4 compatibility only — use `resolveParamName` per individual parameter instead.
176
- * @example
177
- * resolver.resolveHeaderParamsName(node) // → 'DeletePetHeaderParams'
178
- */
179
- resolveHeaderParamsName?(node: OperationNode): string;
180
- /**
181
- * Resolves the TypeScript type alias name for an operation's grouped header parameters type.
182
- * Only available with `compatibilityPreset: 'kubbV4'`.
183
- *
184
- * @deprecated Kubb v4 compatibility only — use `resolveParamTypedName` per individual parameter instead.
185
- * @example
186
- * resolver.resolveHeaderParamsTypedName(node) // → 'DeletePetHeaderParams'
187
- */
188
- resolveHeaderParamsTypedName?(node: OperationNode): string;
189
- };
190
- type BuildParamsSchemaOptions = {
191
- params: Array<ParameterNode>;
192
- node: OperationNode;
193
- resolver: ResolverTs;
194
- };
195
- type BuildOperationSchemaOptions = {
196
- node: OperationNode;
197
- resolver: ResolverTs;
198
- };
199
- /**
200
- * The concrete builder type for `@kubb/plugin-ts`.
201
- * Extends the base `Builder` with schema-building helpers used by the v5 type generator.
202
- */
203
- type BuilderTs = Builder & {
204
- buildParams(options: BuildParamsSchemaOptions): SchemaNode;
205
- buildData(options: BuildOperationSchemaOptions): SchemaNode;
206
- buildResponses(options: BuildOperationSchemaOptions): SchemaNode | null;
207
- buildResponseUnion(options: BuildOperationSchemaOptions): SchemaNode | null;
208
- };
209
- type Options = {
210
- /**
211
- * Specify the export location for the files and define the behavior of the output
212
- * @default { path: 'types', barrelType: 'named' }
213
- */
214
- output?: Output;
215
- /**
216
- * Define which contentType should be used.
217
- * By default, uses the first valid JSON media type.
218
- */
219
- contentType?: 'application/json' | (string & {});
220
- /**
221
- * Group the clients based on the provided name.
222
- */
223
- group?: Group;
224
- /**
225
- * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
226
- */
227
- exclude?: Array<Exclude>;
228
- /**
229
- * Array containing include parameters to include tags/operations/methods/paths.
230
- */
231
- include?: Array<Include>;
232
- /**
233
- * Array containing override parameters to override `options` based on tags/operations/methods/paths.
234
- */
235
- override?: Array<Override<ResolvedOptions>>;
236
- /**
237
- * Choose to use enum, asConst, asPascalConst, constEnum, literal, or inlineLiteral for enums.
238
- * - 'enum' generates TypeScript enum declarations.
239
- * - 'asConst' generates const objects with camelCase names and as const assertion.
240
- * - 'asPascalConst' generates const objects with PascalCase names and as const assertion.
241
- * - 'constEnum' generates TypeScript const enum declarations.
242
- * - 'literal' generates literal union types.
243
- * - 'inlineLiteral' inline enum values directly into the type (default in v5).
244
- * @default 'asConst'
245
- * @note In Kubb v5, 'inlineLiteral' becomes the default.
246
- */
247
- enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
248
- /**
249
- * Choose the casing for enum key names.
250
- * - 'screamingSnakeCase' generates keys in SCREAMING_SNAKE_CASE format.
251
- * - 'snakeCase' generates keys in snake_case format.
252
- * - 'pascalCase' generates keys in PascalCase format.
253
- * - 'camelCase' generates keys in camelCase format.
254
- * - 'none' uses the enum value as-is without transformation.
255
- * @default 'none'
256
- */
257
- enumKeyCasing?: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none';
258
- /**
259
- * Switch between type or interface for creating TypeScript types.
260
- * - 'type' generates type alias declarations.
261
- * - 'interface' generates interface declarations.
262
- * @default 'type'
263
- */
264
- syntaxType?: 'type' | 'interface';
265
- /**
266
- * Choose what to use as mode for an optional value.
267
- * - 'questionToken' marks the property as optional with ? (e.g., type?: string).
268
- * - 'undefined' adds undefined to the type union (e.g., type: string | undefined).
269
- * - 'questionTokenAndUndefined' combines both approaches (e.g., type?: string | undefined).
270
- * @default 'questionToken'
271
- */
272
- optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined';
273
- /**
274
- * Choose between Array<string> or string[] for array types.
275
- * - 'generic' generates Array<Type> syntax.
276
- * - 'array' generates Type[] syntax.
277
- * @default 'array'
278
- */
279
- arrayType?: 'generic' | 'array';
280
- /**
281
- * How to style your params, by default no casing is applied
282
- * - 'camelcase' uses camelCase for pathParams, queryParams and headerParams property names
283
- * @default undefined
284
- * @note response types (data/body) are NOT affected by this option
285
- */
286
- paramsCasing?: 'camelcase';
287
- /**
288
- * Define some generators next to the ts generators
289
- */
290
- generators?: Array<Generator<PluginTs>>;
291
- /**
292
- * Apply a compatibility naming preset.
293
- * Use `kubbV4` for strict v4 type-generation compatibility.
294
- * You can further customize naming with `resolvers`.
295
- * @default 'default'
296
- */
297
- compatibilityPreset?: CompatibilityPreset;
298
- /**
299
- * Array of named resolvers that control naming conventions.
300
- * Later entries override earlier ones (last wins).
301
- * Built-in: `resolverTs` (default), `resolverTsLegacy`.
302
- * @default [resolverTs]
303
- */
304
- resolvers?: Array<ResolverTs>;
305
- /**
306
- * Array of AST visitors applied to each SchemaNode/OperationNode before printing.
307
- * Uses `transform()` from `@kubb/ast` — visitors can modify, replace, or annotate nodes.
308
- *
309
- * @example Remove writeOnly properties from response types
310
- * ```ts
311
- * transformers: [{
312
- * property(node) {
313
- * if (node.schema.writeOnly) return undefined
314
- * }
315
- * }]
316
- * ```
317
- *
318
- * @example Force all dates to plain strings
319
- * ```ts
320
- * transformers: [{
321
- * schema(node) {
322
- * if (node.type === 'date') return { ...node, type: 'string' }
323
- * }
324
- * }]
325
- * ```
326
- */
327
- transformers?: Array<Visitor>;
328
- };
329
- type ResolvedOptions = {
330
- output: Output;
331
- group: Options['group'];
332
- enumType: NonNullable<Options['enumType']>;
333
- enumKeyCasing: NonNullable<Options['enumKeyCasing']>;
334
- optionalType: NonNullable<Options['optionalType']>;
335
- arrayType: NonNullable<Options['arrayType']>;
336
- syntaxType: NonNullable<Options['syntaxType']>;
337
- paramsCasing: Options['paramsCasing'];
338
- resolver: ResolverTs;
339
- transformers: Array<Visitor>;
340
- };
341
- type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions, ResolverTs, BuilderTs>;
342
- //#endregion
343
- export { ResolverTs as i, Options as n, PluginTs as r, BuilderTs as t };
344
- //# sourceMappingURL=types-BcyuFDn9.d.ts.map
@@ -1,92 +0,0 @@
1
- import { createProperty, createSchema } from '@kubb/ast'
2
- import { defineBuilder } from '@kubb/core'
3
- import type { PluginTs } from '../types.ts'
4
-
5
- export const builderTs = defineBuilder<PluginTs>(() => ({
6
- name: 'default',
7
- buildParams({ params, node, resolver }) {
8
- return createSchema({
9
- type: 'object',
10
- properties: params.map((param) =>
11
- createProperty({
12
- name: param.name,
13
- required: param.required,
14
- schema: createSchema({
15
- type: 'ref',
16
- name: resolver.resolveParamName(node, param),
17
- }),
18
- }),
19
- ),
20
- })
21
- },
22
- buildData({ node, resolver }) {
23
- const pathParams = node.parameters.filter((p) => p.in === 'path')
24
- const queryParams = node.parameters.filter((p) => p.in === 'query')
25
- const headerParams = node.parameters.filter((p) => p.in === 'header')
26
-
27
- return createSchema({
28
- type: 'object',
29
- deprecated: node.deprecated,
30
- properties: [
31
- createProperty({
32
- name: 'data',
33
- schema: node.requestBody?.schema
34
- ? createSchema({ type: 'ref', name: resolver.resolveDataTypedName(node), optional: true })
35
- : createSchema({ type: 'never', optional: true }),
36
- }),
37
- createProperty({
38
- name: 'pathParams',
39
- required: pathParams.length > 0,
40
- schema: pathParams.length > 0 ? this.buildParams({ params: pathParams, node, resolver }) : createSchema({ type: 'never' }),
41
- }),
42
- createProperty({
43
- name: 'queryParams',
44
- schema:
45
- queryParams.length > 0
46
- ? createSchema({ ...this.buildParams({ params: queryParams, node, resolver }), optional: true })
47
- : createSchema({ type: 'never', optional: true }),
48
- }),
49
- createProperty({
50
- name: 'headerParams',
51
- schema:
52
- headerParams.length > 0
53
- ? createSchema({ ...this.buildParams({ params: headerParams, node, resolver }), optional: true })
54
- : createSchema({ type: 'never', optional: true }),
55
- }),
56
- createProperty({
57
- name: 'url',
58
- required: true,
59
- schema: createSchema({ type: 'url', path: node.path }),
60
- }),
61
- ],
62
- })
63
- },
64
- buildResponses({ node, resolver }) {
65
- if (node.responses.length === 0) {
66
- return null
67
- }
68
-
69
- return createSchema({
70
- type: 'object',
71
- properties: node.responses.map((res) =>
72
- createProperty({
73
- name: String(res.statusCode),
74
- required: true,
75
- schema: createSchema({ type: 'ref', name: resolver.resolveResponseStatusTypedName(node, res.statusCode) }),
76
- }),
77
- ),
78
- })
79
- },
80
- buildResponseUnion({ node, resolver }) {
81
- const responsesWithSchema = node.responses.filter((res) => res.schema)
82
-
83
- if (responsesWithSchema.length === 0) {
84
- return null
85
- }
86
-
87
- return createSchema({
88
- type: 'union',
89
- members: responsesWithSchema.map((res) => createSchema({ type: 'ref', name: resolver.resolveResponseStatusTypedName(node, res.statusCode) })),
90
- })
91
- },
92
- }))
@@ -1 +0,0 @@
1
- export { builderTs } from './builderTs.ts'
@@ -1,2 +0,0 @@
1
- export { Enum } from './Enum.tsx'
2
- export { Type } from './Type.tsx'
@@ -1,2 +0,0 @@
1
- export { typeGenerator } from './typeGenerator.tsx'
2
- export { typeGeneratorLegacy } from './typeGeneratorLegacy.tsx'
@@ -1 +0,0 @@
1
- export { printerTs } from './printerTs.ts'
@@ -1,2 +0,0 @@
1
- export { resolverTs } from './resolverTs.ts'
2
- export { resolverTsLegacy } from './resolverTsLegacy.ts'