@kubb/plugin-ts 5.0.0-alpha.9 → 5.0.0-beta.100
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/LICENSE +17 -10
- package/README.md +38 -23
- package/dist/index.cjs +2376 -5
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +941 -40
- package/dist/index.js +2321 -2
- package/dist/index.js.map +1 -0
- package/dist/rolldown-runtime-CNktS9qV.js +17 -0
- package/package.json +38 -74
- package/dist/chunk--u3MIqq1.js +0 -8
- package/dist/components-CRu8IKY3.js +0 -729
- package/dist/components-CRu8IKY3.js.map +0 -1
- package/dist/components-DeNDKlzf.cjs +0 -982
- package/dist/components-DeNDKlzf.cjs.map +0 -1
- package/dist/components.cjs +0 -3
- package/dist/components.d.ts +0 -36
- package/dist/components.js +0 -2
- package/dist/generators.cjs +0 -4
- package/dist/generators.d.ts +0 -509
- package/dist/generators.js +0 -2
- package/dist/plugin-BZkBwnEA.js +0 -1269
- package/dist/plugin-BZkBwnEA.js.map +0 -1
- package/dist/plugin-Bunz1oGa.cjs +0 -1322
- package/dist/plugin-Bunz1oGa.cjs.map +0 -1
- package/dist/types-mSXmB8WU.d.ts +0 -298
- package/src/components/Type.tsx +0 -190
- package/src/components/index.ts +0 -1
- package/src/components/v2/Enum.tsx +0 -67
- package/src/components/v2/Type.tsx +0 -59
- package/src/constants.ts +0 -29
- package/src/factory.ts +0 -726
- package/src/generators/index.ts +0 -2
- package/src/generators/typeGenerator.tsx +0 -468
- package/src/generators/v2/typeGenerator.tsx +0 -167
- package/src/generators/v2/utils.ts +0 -140
- package/src/index.ts +0 -3
- package/src/parser.ts +0 -389
- package/src/plugin.ts +0 -232
- package/src/printer.ts +0 -368
- package/src/resolverTs.ts +0 -77
- package/src/types.ts +0 -296
package/src/types.ts
DELETED
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
import type { OperationNode, ParameterNode, SchemaNode, StatusCode } from '@kubb/ast/types'
|
|
2
|
-
import type { Group, Output, PluginFactoryOptions, ResolveNameParams, Resolver } from '@kubb/core'
|
|
3
|
-
import type { contentType, Oas } from '@kubb/oas'
|
|
4
|
-
import type { Exclude, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'
|
|
5
|
-
import type { Generator } from '@kubb/plugin-oas/generators'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The concrete resolver type for `@kubb/plugin-ts`.
|
|
9
|
-
* Extends the base `Resolver` (which provides `default` and `resolveOptions`) with
|
|
10
|
-
* plugin-specific naming helpers for operations, parameters, responses, and schemas.
|
|
11
|
-
*/
|
|
12
|
-
type ResolverTs = Resolver & {
|
|
13
|
-
/**
|
|
14
|
-
* Resolves the variable/function name for a given raw name (equivalent to `default(name, 'function')`).
|
|
15
|
-
* Use this shorthand when matching the `name` field produced by the v2 TypeGenerator,
|
|
16
|
-
* so call-sites don't need to repeat the `'function'` type literal.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* resolver.resolveName('list pets status 200') // → 'listPetsStatus200'
|
|
20
|
-
*/
|
|
21
|
-
resolveName(name: string): string
|
|
22
|
-
/**
|
|
23
|
-
* Resolves the TypeScript type name for a given raw name (equivalent to `default(name, 'type')`).
|
|
24
|
-
* Use this shorthand when matching the `typedName` field produced by the v2 TypeGenerator,
|
|
25
|
-
* so call-sites don't need to repeat the `'type'` type literal.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* resolver.resolveTypedName('list pets status 200') // → 'ListPetsStatus200'
|
|
29
|
-
*/
|
|
30
|
-
resolveTypedName(name: string): string
|
|
31
|
-
/**
|
|
32
|
-
* Resolves the file/path name for a given identifier using PascalCase.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* resolver.resolvePathName('list pets', 'file') // → 'ListPets'
|
|
36
|
-
*/
|
|
37
|
-
resolvePathName(name: string, type?: 'file' | 'function' | 'type' | 'const'): string
|
|
38
|
-
/**
|
|
39
|
-
* Resolves the variable/function name for an operation parameter.
|
|
40
|
-
* Encapsulates the `<operationId> <PascalCase(paramIn)> <paramName>` naming convention.
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* resolver.resolveParamName(node, param) // → 'ListPetsQueryLimit'
|
|
44
|
-
*/
|
|
45
|
-
resolveParamName(node: OperationNode, param: ParameterNode): string
|
|
46
|
-
/**
|
|
47
|
-
* Resolves the TypeScript type alias name for an operation parameter
|
|
48
|
-
* (equivalent to `resolveParamName` with `type: 'type'`).
|
|
49
|
-
* In the default implementation both return the same PascalCase string;
|
|
50
|
-
* the distinction is preserved so overrides can diverge the two forms.
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* resolver.resolveParamTypedName(node, param) // → 'ListPetsQueryLimit'
|
|
54
|
-
*/
|
|
55
|
-
resolveParamTypedName(node: OperationNode, param: ParameterNode): string
|
|
56
|
-
/**
|
|
57
|
-
* Resolves the variable/function name for an operation response by status code.
|
|
58
|
-
* Encapsulates the `<operationId> Status <statusCode>` template with PascalCase applied to the result.
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* resolver.resolveResponseStatusName(node, 200) // → 'ListPetsStatus200'
|
|
62
|
-
*/
|
|
63
|
-
resolveResponseStatusName(node: OperationNode, statusCode: StatusCode): string
|
|
64
|
-
/**
|
|
65
|
-
* Resolves the TypeScript type alias name for an operation response by status code.
|
|
66
|
-
* Encapsulates the `<operationId> Status <statusCode>` template with PascalCase applied to the result.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* resolver.resolveResponseStatusTypedName(node, 200) // → 'ListPetsStatus200'
|
|
70
|
-
*/
|
|
71
|
-
resolveResponseStatusTypedName(node: OperationNode, statusCode: StatusCode): string
|
|
72
|
-
/**
|
|
73
|
-
* Resolves the variable/function name for an operation's request body (`Data`).
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* resolver.resolveDataName(node) // → 'ListPetsData'
|
|
77
|
-
*/
|
|
78
|
-
resolveDataName(node: OperationNode): string
|
|
79
|
-
/**
|
|
80
|
-
* Resolves the TypeScript type alias name for an operation's request body (`Data`).
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* resolver.resolveDataTypedName(node) // → 'ListPetsData'
|
|
84
|
-
*/
|
|
85
|
-
resolveDataTypedName(node: OperationNode): string
|
|
86
|
-
/**
|
|
87
|
-
* Resolves the variable/function name for an operation's request config (`RequestConfig`).
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* resolver.resolveRequestConfigName(node) // → 'ListPetsRequestConfig'
|
|
91
|
-
*/
|
|
92
|
-
resolveRequestConfigName(node: OperationNode): string
|
|
93
|
-
/**
|
|
94
|
-
* Resolves the TypeScript type alias name for an operation's request config (`RequestConfig`).
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* resolver.resolveRequestConfigTypedName(node) // → 'ListPetsRequestConfig'
|
|
98
|
-
*/
|
|
99
|
-
resolveRequestConfigTypedName(node: OperationNode): string
|
|
100
|
-
/**
|
|
101
|
-
* Resolves the variable/function name for the collection of all operation responses (`Responses`).
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* resolver.resolveResponsesName(node) // → 'ListPetsResponses'
|
|
105
|
-
*/
|
|
106
|
-
resolveResponsesName(node: OperationNode): string
|
|
107
|
-
/**
|
|
108
|
-
* Resolves the TypeScript type alias name for the collection of all operation responses.
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* resolver.resolveResponsesTypedName(node) // → 'ListPetsResponses'
|
|
112
|
-
*/
|
|
113
|
-
resolveResponsesTypedName(node: OperationNode): string
|
|
114
|
-
/**
|
|
115
|
-
* Resolves the variable/function name for the union of all operation responses (`Response`).
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* resolver.resolveResponseName(node) // → 'ListPetsResponse'
|
|
119
|
-
*/
|
|
120
|
-
resolveResponseName(node: OperationNode): string
|
|
121
|
-
/**
|
|
122
|
-
* Resolves the TypeScript type alias name for the union of all operation responses.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* resolver.resolveResponseTypedName(node) // → 'ListPetsResponse'
|
|
126
|
-
*/
|
|
127
|
-
resolveResponseTypedName(node: OperationNode): string
|
|
128
|
-
/**
|
|
129
|
-
* Resolves the TypeScript type alias name for an enum schema's key variant.
|
|
130
|
-
* Appends the `Key` suffix after applying the default naming convention.
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* resolver.resolveEnumKeyTypedName(node) // → 'PetStatusKey'
|
|
134
|
-
*/
|
|
135
|
-
resolveEnumKeyTypedName(node: SchemaNode): string
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export type Options = {
|
|
139
|
-
/**
|
|
140
|
-
* Specify the export location for the files and define the behavior of the output
|
|
141
|
-
* @default { path: 'types', barrelType: 'named' }
|
|
142
|
-
*/
|
|
143
|
-
output?: Output<Oas>
|
|
144
|
-
/**
|
|
145
|
-
* Define which contentType should be used.
|
|
146
|
-
* By default, uses the first valid JSON media type.
|
|
147
|
-
*/
|
|
148
|
-
contentType?: contentType
|
|
149
|
-
/**
|
|
150
|
-
* Group the clients based on the provided name.
|
|
151
|
-
*/
|
|
152
|
-
group?: Group
|
|
153
|
-
/**
|
|
154
|
-
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
155
|
-
*/
|
|
156
|
-
exclude?: Array<Exclude>
|
|
157
|
-
/**
|
|
158
|
-
* Array containing include parameters to include tags/operations/methods/paths.
|
|
159
|
-
*/
|
|
160
|
-
include?: Array<Include>
|
|
161
|
-
/**
|
|
162
|
-
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
163
|
-
*/
|
|
164
|
-
override?: Array<Override<ResolvedOptions>>
|
|
165
|
-
/**
|
|
166
|
-
* Choose to use enum, asConst, asPascalConst, constEnum, literal, or inlineLiteral for enums.
|
|
167
|
-
* - 'enum' generates TypeScript enum declarations.
|
|
168
|
-
* - 'asConst' generates const objects with camelCase names and as const assertion.
|
|
169
|
-
* - 'asPascalConst' generates const objects with PascalCase names and as const assertion.
|
|
170
|
-
* - 'constEnum' generates TypeScript const enum declarations.
|
|
171
|
-
* - 'literal' generates literal union types.
|
|
172
|
-
* - 'inlineLiteral' inline enum values directly into the type (default in v5).
|
|
173
|
-
* @default 'asConst'
|
|
174
|
-
* @note In Kubb v5, 'inlineLiteral' becomes the default.
|
|
175
|
-
*/
|
|
176
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral'
|
|
177
|
-
/**
|
|
178
|
-
* Choose the casing for enum key names.
|
|
179
|
-
* - 'screamingSnakeCase' generates keys in SCREAMING_SNAKE_CASE format.
|
|
180
|
-
* - 'snakeCase' generates keys in snake_case format.
|
|
181
|
-
* - 'pascalCase' generates keys in PascalCase format.
|
|
182
|
-
* - 'camelCase' generates keys in camelCase format.
|
|
183
|
-
* - 'none' uses the enum value as-is without transformation.
|
|
184
|
-
* @default 'none'
|
|
185
|
-
*/
|
|
186
|
-
enumKeyCasing?: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none'
|
|
187
|
-
/**
|
|
188
|
-
* Switch between type or interface for creating TypeScript types.
|
|
189
|
-
* - 'type' generates type alias declarations.
|
|
190
|
-
* - 'interface' generates interface declarations.
|
|
191
|
-
* @default 'type'
|
|
192
|
-
*/
|
|
193
|
-
syntaxType?: 'type' | 'interface'
|
|
194
|
-
/**
|
|
195
|
-
* Set a suffix for the generated enums.
|
|
196
|
-
* @default 'enum'
|
|
197
|
-
* @deprecated Set `enumSuffix` on the adapter (`adapterOas({ enumSuffix })`) instead.
|
|
198
|
-
* In v5, the adapter owns this decision at parse time; the plugin option is ignored.
|
|
199
|
-
*/
|
|
200
|
-
enumSuffix?: string
|
|
201
|
-
/**
|
|
202
|
-
* Choose to use date or datetime as JavaScript Date instead of string.
|
|
203
|
-
* - 'string' represents dates as string values.
|
|
204
|
-
* - 'date' represents dates as JavaScript Date objects.
|
|
205
|
-
* @default 'string'
|
|
206
|
-
* @deprecated Set `dateType` on the adapter (`adapterOas({ dateType })`) instead.
|
|
207
|
-
* In v5, the adapter owns this decision at parse time; the plugin option is ignored.
|
|
208
|
-
*/
|
|
209
|
-
dateType?: 'string' | 'date'
|
|
210
|
-
/**
|
|
211
|
-
* Choose to use `number` or `bigint` for integer fields with `int64` format.
|
|
212
|
-
* - 'number' uses the TypeScript `number` type (matches JSON.parse() runtime behavior).
|
|
213
|
-
* - 'bigint' uses the TypeScript `bigint` type (accurate for values exceeding Number.MAX_SAFE_INTEGER).
|
|
214
|
-
* @note in v5 of Kubb 'bigint' will become the default to better align with OpenAPI's int64 specification.
|
|
215
|
-
* @default 'number'
|
|
216
|
-
* @deprecated Set `integerType` on the adapter (`adapterOas({ integerType })`) instead.
|
|
217
|
-
* In v5, the adapter owns this decision at parse time; the plugin option is ignored.
|
|
218
|
-
*/
|
|
219
|
-
integerType?: 'number' | 'bigint'
|
|
220
|
-
/**
|
|
221
|
-
* Which type to use when the Swagger/OpenAPI file is not providing more information.
|
|
222
|
-
* - 'any' allows any value.
|
|
223
|
-
* - 'unknown' requires type narrowing before use.
|
|
224
|
-
* - 'void' represents no value.
|
|
225
|
-
* @default 'any'
|
|
226
|
-
* @deprecated Set `unknownType` on the adapter (`adapterOas({ unknownType })`) instead.
|
|
227
|
-
* In v5, the adapter owns this decision at parse time; the plugin option is ignored.
|
|
228
|
-
*/
|
|
229
|
-
unknownType?: 'any' | 'unknown' | 'void'
|
|
230
|
-
/**
|
|
231
|
-
* Which type to use for empty schema values.
|
|
232
|
-
* - 'any' allows any value.
|
|
233
|
-
* - 'unknown' requires type narrowing before use.
|
|
234
|
-
* - 'void' represents no value.
|
|
235
|
-
* @default `unknownType`
|
|
236
|
-
* @deprecated Set `emptySchemaType` on the adapter (`adapterOas({ emptySchemaType })`) instead.
|
|
237
|
-
* In v5, the adapter owns this decision at parse time; the plugin option is ignored.
|
|
238
|
-
*/
|
|
239
|
-
emptySchemaType?: 'any' | 'unknown' | 'void'
|
|
240
|
-
/**
|
|
241
|
-
* Choose what to use as mode for an optional value.
|
|
242
|
-
* - 'questionToken' marks the property as optional with ? (e.g., type?: string).
|
|
243
|
-
* - 'undefined' adds undefined to the type union (e.g., type: string | undefined).
|
|
244
|
-
* - 'questionTokenAndUndefined' combines both approaches (e.g., type?: string | undefined).
|
|
245
|
-
* @default 'questionToken'
|
|
246
|
-
*/
|
|
247
|
-
optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined'
|
|
248
|
-
/**
|
|
249
|
-
* Choose between Array<string> or string[] for array types.
|
|
250
|
-
* - 'generic' generates Array<Type> syntax.
|
|
251
|
-
* - 'array' generates Type[] syntax.
|
|
252
|
-
* @default 'array'
|
|
253
|
-
*/
|
|
254
|
-
arrayType?: 'generic' | 'array'
|
|
255
|
-
transformers?: {
|
|
256
|
-
/**
|
|
257
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
258
|
-
*/
|
|
259
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* How to style your params, by default no casing is applied
|
|
263
|
-
* - 'camelcase' uses camelCase for pathParams, queryParams and headerParams property names
|
|
264
|
-
* @default undefined
|
|
265
|
-
* @note response types (data/body) are NOT affected by this option
|
|
266
|
-
*/
|
|
267
|
-
paramsCasing?: 'camelcase'
|
|
268
|
-
/**
|
|
269
|
-
* Define some generators next to the ts generators
|
|
270
|
-
*/
|
|
271
|
-
generators?: Array<Generator<PluginTs>>
|
|
272
|
-
/**
|
|
273
|
-
* Unstable naming for v5
|
|
274
|
-
*/
|
|
275
|
-
UNSTABLE_NAMING?: true
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
type ResolvedOptions = {
|
|
279
|
-
output: Output<Oas>
|
|
280
|
-
group: Options['group']
|
|
281
|
-
override: NonNullable<Options['override']>
|
|
282
|
-
enumType: NonNullable<Options['enumType']>
|
|
283
|
-
enumKeyCasing: NonNullable<Options['enumKeyCasing']>
|
|
284
|
-
enumSuffix: NonNullable<Options['enumSuffix']>
|
|
285
|
-
dateType: NonNullable<Options['dateType']>
|
|
286
|
-
integerType: NonNullable<Options['integerType']>
|
|
287
|
-
unknownType: NonNullable<Options['unknownType']>
|
|
288
|
-
emptySchemaType: NonNullable<Options['emptySchemaType']>
|
|
289
|
-
optionalType: NonNullable<Options['optionalType']>
|
|
290
|
-
arrayType: NonNullable<Options['arrayType']>
|
|
291
|
-
transformers: NonNullable<Options['transformers']>
|
|
292
|
-
syntaxType: NonNullable<Options['syntaxType']>
|
|
293
|
-
paramsCasing: Options['paramsCasing']
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions, ResolverTs>
|