@kubb/plugin-ts 5.0.11 → 5.0.14

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.
@@ -0,0 +1,819 @@
1
+ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
2
+ import { KubbReactNode } from "kubb/jsx";
3
+ import ts from "typescript";
4
+ //#region src/printers/printerTs.d.ts
5
+ /**
6
+ * Partial map of node-type overrides for the TypeScript printer.
7
+ *
8
+ * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`). The function
9
+ * replaces the built-in handler for that node type. Use `this.transform` to
10
+ * recurse into nested schema nodes, and `this.options` to read printer options.
11
+ *
12
+ * @example Override the `date` handler
13
+ * ```ts
14
+ * pluginTs({
15
+ * printer: {
16
+ * nodes: {
17
+ * date(node) {
18
+ * return ts.factory.createTypeReferenceNode('Date', [])
19
+ * },
20
+ * },
21
+ * },
22
+ * })
23
+ * ```
24
+ */
25
+ type PrinterTsNodes = ast.PrinterPartial<ts.TypeNode, PrinterTsOptions>;
26
+ type PrinterTsOptions = {
27
+ /**
28
+ * Mark parameters as optional with `?` or `| undefined`.
29
+ * - `'questionToken'` adds `?` to properties
30
+ * - `'undefined'` adds `| undefined` to types
31
+ *
32
+ * @default `'questionToken'`
33
+ */
34
+ optionalType: PluginTs['resolvedOptions']['optionalType'];
35
+ /**
36
+ * Array representation style.
37
+ * - `'array'` uses bracket notation (`T[]`)
38
+ * - `'generic'` uses generic syntax (`Array<T>`)
39
+ *
40
+ * @default `'array'`
41
+ */
42
+ arrayType: PluginTs['resolvedOptions']['arrayType'];
43
+ /**
44
+ * Grouped enum settings. The printer emits references to enums, not the enum declarations, so only
45
+ * `type` (the output format) and `typeSuffix` (the enum key reference suffix) matter here.
46
+ * `constCasing` and `keyCasing` are ignored.
47
+ */
48
+ enum: PluginTs['resolvedOptions']['enum'];
49
+ /**
50
+ * Syntax for generated declarations.
51
+ * - `'type'` generates type aliases
52
+ * - `'interface'` generates interface declarations
53
+ *
54
+ * @default `'type'`
55
+ */
56
+ syntaxType?: PluginTs['resolvedOptions']['syntaxType'];
57
+ /**
58
+ * Exported name for the type declaration.
59
+ * When omitted, returns only the raw type node.
60
+ */
61
+ name?: string;
62
+ /**
63
+ * JSDoc comment to attach to the generated type.
64
+ */
65
+ description?: string;
66
+ /**
67
+ * Properties to exclude using `Omit<Type, Keys>`.
68
+ * Forces type alias syntax regardless of `syntaxType` setting.
69
+ */
70
+ keysToOmit?: Array<string> | null;
71
+ /**
72
+ * Transforms raw schema names into valid TypeScript identifiers.
73
+ */
74
+ resolver: ResolverTs;
75
+ /**
76
+ * Schema names that represent enums for suffixed key references.
77
+ */
78
+ enumSchemaNames?: Set<string>;
79
+ /**
80
+ * Custom handler map for node type overrides.
81
+ */
82
+ nodes?: PrinterTsNodes;
83
+ };
84
+ /**
85
+ * TypeScript printer factory options: maps `SchemaNode` → `ts.TypeNode` (raw) or `ts.Node` (full declaration).
86
+ */
87
+ type PrinterTsFactory = ast.PrinterFactoryOptions<'typescript', PrinterTsOptions, ts.TypeNode, string>;
88
+ /**
89
+ * TypeScript type printer built with `definePrinter`.
90
+ *
91
+ * Converts a `SchemaNode` AST node into a TypeScript AST node:
92
+ * - **`printer.print(node)`** — when `options.typeName` is set, returns a full
93
+ * `type Name = …` or `interface Name { … }` declaration (`ts.Node`).
94
+ * Without `typeName`, returns the raw `ts.TypeNode` for the schema.
95
+ *
96
+ * Dispatches on `node.type` to the appropriate handler in `nodes`. Options are closed
97
+ * over per printer instance, so each call to `printerTs(options)` produces an independent printer.
98
+ *
99
+ * @example Raw type node (no `typeName`)
100
+ * ```ts
101
+ * const printer = printerTs({ optionalType: 'questionToken', arrayType: 'array', enum: { type: 'inlineLiteral' } })
102
+ * const typeNode = printer.print(schemaNode) // ts.TypeNode
103
+ * ```
104
+ *
105
+ * @example Full declaration (with `typeName`)
106
+ * ```ts
107
+ * const printer = printerTs({ optionalType: 'questionToken', arrayType: 'array', enum: { type: 'inlineLiteral' }, typeName: 'MyType' })
108
+ * const declaration = printer.print(schemaNode) // ts.TypeAliasDeclaration | ts.InterfaceDeclaration
109
+ * ```
110
+ */
111
+ export declare const printerTs: (options?: PrinterTsOptions | undefined) => ast.Printer<PrinterTsFactory>;
112
+ //#endregion
113
+ //#region src/types.d.ts
114
+ /**
115
+ * The concrete resolver type for `@kubb/plugin-ts`.
116
+ * Extends the base `Resolver` (which provides `default` naming and option helpers, the top-level
117
+ * `name` casing, and the `file` builder) with plugin-specific naming namespaces for operation
118
+ * parameters, responses, and enum schemas.
119
+ */
120
+ type ResolverTs = Resolver & {
121
+ /**
122
+ * Naming for an operation's parameters, grouped by location.
123
+ */
124
+ param: {
125
+ /**
126
+ * Resolves the type name for an individual parameter.
127
+ *
128
+ * @example Individual parameter name
129
+ * `resolver.param.name(node, param) // → 'DeletePetPathPetId'`
130
+ */
131
+ name(node: ast.OperationNode, param: ast.ParameterNode): string;
132
+ /**
133
+ * Resolves the name for an operation's grouped path parameters type.
134
+ *
135
+ * @example Path parameters names
136
+ * `resolver.param.path(node, param) // → 'GetPetByIdPath'`
137
+ */
138
+ path(node: ast.OperationNode, param: ast.ParameterNode): string;
139
+ /**
140
+ * Resolves the name for an operation's grouped query parameters type.
141
+ *
142
+ * @example Query parameters names
143
+ * `resolver.param.query(node, param) // → 'FindPetsByStatusQuery'`
144
+ */
145
+ query(node: ast.OperationNode, param: ast.ParameterNode): string;
146
+ /**
147
+ * Resolves the name for an operation's grouped header parameters type.
148
+ *
149
+ * @example Header parameters names
150
+ * `resolver.param.headers(node, param) // → 'DeletePetHeaders'`
151
+ */
152
+ headers(node: ast.OperationNode, param: ast.ParameterNode): string;
153
+ };
154
+ /**
155
+ * Naming for an operation's request and response types.
156
+ */
157
+ response: {
158
+ /**
159
+ * Resolves the name for an operation response by status code.
160
+ * Encapsulates the `<operationId> Status <statusCode>` template with PascalCase applied to the result.
161
+ *
162
+ * @example Response status names
163
+ * `resolver.response.status(node, 200) // → 'ListPetsStatus200'`
164
+ */
165
+ status(node: ast.OperationNode, statusCode: ast.StatusCode): string;
166
+ /**
167
+ * Resolves the name for an operation's grouped request options type (`Options`), the
168
+ * `{ body, path, query, headers }` bag passed to call an operation.
169
+ *
170
+ * @example Options type names
171
+ * `resolver.response.options(node) // → 'ListPetsOptions'`
172
+ */
173
+ options(node: ast.OperationNode): string;
174
+ /**
175
+ * Resolves the name for the collection of all operation responses (`Responses`).
176
+ *
177
+ * @example Responses collection names
178
+ * `resolver.response.responses(node) // → 'ListPetsResponses'`
179
+ */
180
+ responses(node: ast.OperationNode): string;
181
+ /**
182
+ * Resolves the name for the union of all operation responses (`Response`).
183
+ *
184
+ * @example Response union names
185
+ * `resolver.response.response(node) // → 'ListPetsResponse'`
186
+ */
187
+ response(node: ast.OperationNode): string;
188
+ /**
189
+ * Resolves the request body type name.
190
+ *
191
+ * @example Request body type name
192
+ * `resolver.response.body(node) // → 'CreatePetBody'`
193
+ */
194
+ body(node: ast.OperationNode): string;
195
+ };
196
+ /**
197
+ * Naming for enum schemas.
198
+ */
199
+ enum: {
200
+ /**
201
+ * Resolves the TypeScript type alias name for an enum schema's key variant.
202
+ * Appends `enumTypeSuffix` (default `'key'`) after applying the default naming convention.
203
+ *
204
+ * @example Enum key names with different suffixes
205
+ * ```ts
206
+ * resolver.enum.keyName(node, 'Key') // → 'PetStatusKey'
207
+ * resolver.enum.keyName(node, 'Value') // → 'PetStatusValue'
208
+ * resolver.enum.keyName(node, '') // → 'PetStatus'
209
+ * ```
210
+ */
211
+ keyName(node: {
212
+ name?: string | null;
213
+ }, enumTypeSuffix?: string): string;
214
+ };
215
+ };
216
+ type EnumKeyCasing = 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none';
217
+ type EnumConstCasing = 'camelCase' | 'pascalCase';
218
+ /**
219
+ * Grouped enum settings. Each `type` uses only some of the other fields.
220
+ *
221
+ * - `'asConst'` emits a `const` object plus a `typeof` type alias, so `constCasing`, `typeSuffix`, and `keyCasing` all apply.
222
+ * - `'enum'` and `'constEnum'` emit a TypeScript enum, so only `keyCasing` (the member names) applies.
223
+ * - `'literal'` and `'inlineLiteral'` emit union literals and drop the keys, so none of the other fields apply.
224
+ *
225
+ * @example Share one name between the const and the type
226
+ * ```ts
227
+ * enum: { type: 'asConst', constCasing: 'pascalCase', typeSuffix: '' }
228
+ * // export const VehicleType = { … } as const
229
+ * // export type VehicleType = (typeof VehicleType)[keyof typeof VehicleType]
230
+ * ```
231
+ */
232
+ type EnumOptions$1 = {
233
+ /**
234
+ * Emit a `const` object asserted with `as const`, paired with a `typeof` type alias.
235
+ * This is tree-shakeable and adds no enum runtime.
236
+ *
237
+ * @default 'asConst'
238
+ */
239
+ type?: 'asConst';
240
+ /**
241
+ * Casing of the generated const variable.
242
+ * - 'camelCase' names the const `vehicleType`.
243
+ * - 'pascalCase' names the const `VehicleType`, matching the schema name.
244
+ *
245
+ * @default 'camelCase'
246
+ */
247
+ constCasing?: EnumConstCasing;
248
+ /**
249
+ * Suffix appended to the generated type alias name. Only the type alias is renamed. The const
250
+ * object name stays the same. Set it to `''` together with `constCasing: 'pascalCase'` to merge
251
+ * the const and type under the schema's exact name.
252
+ *
253
+ * @default 'Key'
254
+ * @example A custom suffix
255
+ * `typeSuffix: 'Value'` renames the alias to `PetStatusValue`
256
+ */
257
+ typeSuffix?: string;
258
+ /**
259
+ * Choose the casing for enum key names.
260
+ * - 'screamingSnakeCase' generates keys in SCREAMING_SNAKE_CASE format.
261
+ * - 'snakeCase' generates keys in snake_case format.
262
+ * - 'pascalCase' generates keys in PascalCase format.
263
+ * - 'camelCase' generates keys in camelCase format.
264
+ * - 'none' uses the enum value as-is without transformation.
265
+ * @default 'none'
266
+ */
267
+ keyCasing?: EnumKeyCasing;
268
+ } | {
269
+ /**
270
+ * Emit a TypeScript `enum` (`'enum'`) or `const enum` (`'constEnum'`) declaration.
271
+ *
272
+ * @default 'asConst'
273
+ */
274
+ type?: 'enum' | 'constEnum';
275
+ /**
276
+ * `constCasing` has no effect for this `type`. Only `'asConst'` emits a const object.
277
+ */
278
+ constCasing?: never;
279
+ /**
280
+ * `typeSuffix` has no effect for this `type`. Only `'asConst'` emits a separate type alias.
281
+ */
282
+ typeSuffix?: never;
283
+ /**
284
+ * Choose the casing for enum member names.
285
+ * - 'screamingSnakeCase' generates keys in SCREAMING_SNAKE_CASE format.
286
+ * - 'snakeCase' generates keys in snake_case format.
287
+ * - 'pascalCase' generates keys in PascalCase format.
288
+ * - 'camelCase' generates keys in camelCase format.
289
+ * - 'none' uses the enum value as-is without transformation.
290
+ * @default 'none'
291
+ */
292
+ keyCasing?: EnumKeyCasing;
293
+ } | {
294
+ /**
295
+ * Emit a union of literals as a named alias (`'literal'`) or inline the union at every usage
296
+ * site (`'inlineLiteral'`).
297
+ *
298
+ * @default 'asConst'
299
+ */
300
+ type?: 'literal' | 'inlineLiteral';
301
+ /**
302
+ * `constCasing` has no effect for this `type`; literal modes emit no const object.
303
+ */
304
+ constCasing?: never;
305
+ /**
306
+ * `typeSuffix` has no effect for this `type`; literal modes emit no separate type alias.
307
+ */
308
+ typeSuffix?: never;
309
+ /**
310
+ * `keyCasing` has no effect for this `type`. Literal and inlineLiteral modes emit only values,
311
+ * so the keys are discarded.
312
+ */
313
+ keyCasing?: never;
314
+ };
315
+ /**
316
+ * Where the generated `.ts` files are written and how they are exported, plus the optional
317
+ * `group` strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
318
+ *
319
+ * @default { path: 'types', barrel: { type: 'named' } }
320
+ */
321
+ type Options = OutputOptions & {
322
+ /**
323
+ * Skip operations matching at least one entry in the list.
324
+ */
325
+ exclude?: Array<Exclude>;
326
+ /**
327
+ * Restrict generation to operations matching at least one entry in the list.
328
+ */
329
+ include?: Array<Include>;
330
+ /**
331
+ * Apply a different options object to operations matching a pattern.
332
+ */
333
+ override?: Array<Override<ResolvedOptions>>;
334
+ /**
335
+ * Whether object schemas are emitted as `type` aliases or `interface` declarations.
336
+ * - `'type'` emits closed type aliases. Safer default for generated code.
337
+ * - `'interface'` emits interfaces. Useful when consumers rely on declaration merging.
338
+ *
339
+ * @default 'type'
340
+ * @see https://www.totaltypescript.com/type-vs-interface-which-should-you-use
341
+ */
342
+ syntaxType?: 'type' | 'interface';
343
+ /**
344
+ * How optional properties are written in generated types.
345
+ * - `'questionToken'` — `type?: string`. The property may be missing.
346
+ * - `'undefined'` — `type: string | undefined`. Required to exist, may be `undefined`.
347
+ * - `'questionTokenAndUndefined'` — `type?: string | undefined`. Strictest.
348
+ *
349
+ * @default 'questionToken'
350
+ * @note Pick `'questionTokenAndUndefined'` when `exactOptionalPropertyTypes` is on in `tsconfig.json`.
351
+ */
352
+ optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined';
353
+ /**
354
+ * Syntax used for array types.
355
+ * - `'array'` — `Type[]`. Shorter.
356
+ * - `'generic'` — `Array<Type>`. More readable for complex element types.
357
+ *
358
+ * @default 'array'
359
+ */
360
+ arrayType?: 'generic' | 'array';
361
+ /**
362
+ * Override how names and file paths are built for generated symbols.
363
+ * Methods you omit fall back to the default `resolverTs`. `this` is bound to the
364
+ * full resolver, so `this.default.name(name)` delegates to the built-in implementation.
365
+ */
366
+ resolver?: ResolverPatch<ResolverTs>;
367
+ /**
368
+ * Macros applied to each schema or operation node before printing.
369
+ * Callbacks you omit fall back to the preset behavior.
370
+ *
371
+ * @example Drop writeOnly properties from response types
372
+ * ```ts
373
+ * macros: [
374
+ * {
375
+ * name: 'drop-write-only',
376
+ * property(node) {
377
+ * if (node.schema.writeOnly) return undefined
378
+ * },
379
+ * },
380
+ * ]
381
+ * ```
382
+ */
383
+ macros?: Array<ast.Macro>;
384
+ /**
385
+ * Replace the TypeScript handler for a specific schema type (`'integer'`, `'date'`, ...).
386
+ * Each handler returns a TypeScript AST node for that schema type. Use `this.transform`
387
+ * to recurse into nested schema nodes.
388
+ *
389
+ * @example Use the JavaScript `Date` object for date schemas
390
+ * ```ts
391
+ * import ts from 'typescript'
392
+ * pluginTs({
393
+ * printer: {
394
+ * nodes: {
395
+ * date() {
396
+ * return ts.factory.createTypeReferenceNode('Date', [])
397
+ * },
398
+ * },
399
+ * },
400
+ * })
401
+ * ```
402
+ */
403
+ printer?: {
404
+ nodes?: PrinterTsNodes;
405
+ };
406
+ /**
407
+ * How OpenAPI enums are represented in the generated TypeScript, and how their names are cased.
408
+ */
409
+ enum?: EnumOptions$1;
410
+ };
411
+ type ResolvedEnumOptions = {
412
+ type: NonNullable<EnumOptions$1['type']>;
413
+ constCasing: EnumConstCasing;
414
+ typeSuffix: string;
415
+ keyCasing: EnumKeyCasing;
416
+ };
417
+ type ResolvedOptions = {
418
+ output: Output;
419
+ exclude: Array<Exclude>;
420
+ include: Array<Include> | undefined;
421
+ override: Array<Override<ResolvedOptions>>;
422
+ group: Group | null;
423
+ enum: ResolvedEnumOptions;
424
+ optionalType: NonNullable<Options['optionalType']>;
425
+ arrayType: NonNullable<Options['arrayType']>;
426
+ syntaxType: NonNullable<Options['syntaxType']>;
427
+ printer: Options['printer'];
428
+ };
429
+ type PluginTs = PluginType<'plugin-ts', Options, ResolvedOptions, ResolverTs>;
430
+ declare global {
431
+ namespace Kubb {
432
+ interface PluginRegistry {
433
+ 'plugin-ts': PluginTs;
434
+ }
435
+ }
436
+ }
437
+ //#endregion
438
+ //#region src/components/Enum.d.ts
439
+ type EnumOptions = PluginTs['resolvedOptions']['enum'];
440
+ type Props$1 = {
441
+ node: ast.EnumSchemaNode;
442
+ enum: EnumOptions;
443
+ resolver: ResolverTs;
444
+ key?: string | number | null;
445
+ };
446
+ /**
447
+ * Renders the enum declaration(s) for a single named `EnumSchemaNode`.
448
+ *
449
+ * Depending on `enum.type` this may emit:
450
+ * - A runtime object (`asConst`) plus a `typeof` type alias
451
+ * - A `const enum` or plain `enum` declaration (`constEnum` / `enum`)
452
+ * - A union literal type alias (`literal`)
453
+ *
454
+ * The emitted `File.Source` nodes carry the resolved names so that the barrel
455
+ * index picks up the correct export identifiers.
456
+ */
457
+ export declare function Enum({ node, enum: enumOptions, resolver }: Props$1): KubbReactNode;
458
+ //#endregion
459
+ //#region src/components/Type.d.ts
460
+ type Props = {
461
+ name: string;
462
+ node: ast.SchemaNode;
463
+ /**
464
+ * Pre-configured printer instance created by the generator.
465
+ * Created with `printerTs({ ..., nodes: options.printer?.nodes })`.
466
+ */
467
+ printer: ast.Printer<PrinterTsFactory>;
468
+ enum: PluginTs['resolvedOptions']['enum'];
469
+ resolver: ResolverTs;
470
+ };
471
+ export declare function Type({ name, node, printer, enum: enumOptions, resolver }: Props): KubbReactNode;
472
+ //#endregion
473
+ //#region src/generators/typeGenerator.d.ts
474
+ /**
475
+ * Built-in generator for `@kubb/plugin-ts`. Emits one TypeScript file per
476
+ * schema in the spec plus per-operation request, response, and parameter
477
+ * types. Drop-replace with a custom `Generator<PluginTs>` to change how
478
+ * TypeScript output is produced.
479
+ */
480
+ export declare const typeGenerator: import("kubb/kit").Generator<PluginTs, unknown>;
481
+ //#endregion
482
+ //#region src/plugin.d.ts
483
+ /**
484
+ * Canonical plugin name for `@kubb/plugin-ts`. Used for driver lookups and
485
+ * cross-plugin dependency references.
486
+ */
487
+ export declare const pluginTsName = "plugin-ts";
488
+ /**
489
+ * Generates TypeScript `type` aliases and `interface` declarations from an
490
+ * OpenAPI spec. The foundation that every other Kubb plugin builds on:
491
+ * clients, query hooks, mocks, and validators all reference the names this
492
+ * plugin produces.
493
+ *
494
+ * @example
495
+ * ```ts
496
+ * import { defineConfig } from 'kubb/config'
497
+ * import { pluginTs } from '@kubb/plugin-ts'
498
+ *
499
+ * export default defineConfig({
500
+ * input: './petStore.yaml',
501
+ * output: { path: './src/gen' },
502
+ * plugins: [
503
+ * pluginTs({
504
+ * output: { path: './types' },
505
+ * enum: { type: 'asConst' },
506
+ * optionalType: 'questionTokenAndUndefined',
507
+ * }),
508
+ * ],
509
+ * })
510
+ * ```
511
+ */
512
+ export declare const pluginTs: import("kubb/kit").PluginFactory<PluginTs>;
513
+ //#endregion
514
+ //#region src/printers/functionParams.d.ts
515
+ /**
516
+ * A type expression used as a function parameter type annotation.
517
+ *
518
+ * - a plain `string` is a type reference rendered as-is, e.g. `'string'`, `'QueryParams'`, `'Partial<Config>'`
519
+ * - a {@link TypeLiteralNode} is an inline anonymous type, e.g. `{ petId: string; name?: string }`
520
+ * - an {@link IndexedAccessTypeNode} is a single field accessed from a named type, e.g. `PathParams['petId']`
521
+ */
522
+ type TypeExpression = string | TypeLiteralNode | IndexedAccessTypeNode;
523
+ /**
524
+ * An inline anonymous object type grouping named fields.
525
+ * Renders as `{ key: Type; other?: OtherType }`.
526
+ */
527
+ type TypeLiteralNode = {
528
+ kind: 'TypeLiteral';
529
+ /**
530
+ * Members of the object type, rendered in order.
531
+ */
532
+ members: Array<{
533
+ /**
534
+ * Member key.
535
+ */
536
+ name: string;
537
+ /**
538
+ * Member type expression.
539
+ */
540
+ type: TypeExpression;
541
+ /**
542
+ * Whether the member is optional, rendered with `?`.
543
+ */
544
+ optional?: boolean;
545
+ }>;
546
+ };
547
+ /**
548
+ * A single field accessed from a named group type. Renders as `target['key']`.
549
+ */
550
+ type IndexedAccessTypeNode = {
551
+ kind: 'IndexedAccessType';
552
+ /**
553
+ * Name of the type being indexed, e.g. `'GetPetPathParams'`.
554
+ */
555
+ target: string;
556
+ /**
557
+ * Field key to access, e.g. `'petId'`.
558
+ */
559
+ key: string;
560
+ };
561
+ /**
562
+ * An object destructuring binding, used as the name of a grouped function parameter.
563
+ * Renders as `{ id, name }` or `{ id: renamed }` when `propertyName` differs.
564
+ */
565
+ type ObjectBindingPatternNode = {
566
+ kind: 'ObjectBindingPattern';
567
+ /**
568
+ * Bound elements, rendered in order.
569
+ */
570
+ elements: Array<{
571
+ /**
572
+ * Local binding name.
573
+ */
574
+ name: string;
575
+ /**
576
+ * Source key when it differs from the binding name, rendered as `propertyName: name`.
577
+ */
578
+ propertyName?: string;
579
+ }>;
580
+ };
581
+ /**
582
+ * One function parameter.
583
+ *
584
+ * A simple parameter has a `string` name. A destructured group has an
585
+ * {@link ObjectBindingPatternNode} name paired with a {@link TypeLiteralNode} type.
586
+ *
587
+ * @example Required parameter
588
+ * `name: Type`
589
+ *
590
+ * @example Optional parameter
591
+ * `name?: Type`
592
+ *
593
+ * @example Parameter with default value
594
+ * `name: Type = defaultValue`
595
+ *
596
+ * @example Rest parameter
597
+ * `...name: Type[]`
598
+ *
599
+ * @example Destructured group
600
+ * `{ id, name? }: { id: string; name?: string } = {}`
601
+ */
602
+ type FunctionParameterNode = {
603
+ kind: 'FunctionParameter';
604
+ /**
605
+ * Parameter name, or an {@link ObjectBindingPatternNode} for a destructured group.
606
+ */
607
+ name: string | ObjectBindingPatternNode;
608
+ /**
609
+ * Type annotation as a {@link TypeExpression}. Omit for untyped output.
610
+ */
611
+ type?: TypeExpression;
612
+ /**
613
+ * Whether the parameter is optional, rendered with `?`.
614
+ */
615
+ optional?: boolean;
616
+ /**
617
+ * Default value, written verbatim after `=`. Commonly `'{}'` for a destructured group.
618
+ */
619
+ default?: string;
620
+ /**
621
+ * When `true` the parameter is emitted as a rest parameter, e.g. `...name: Type[]`.
622
+ */
623
+ rest?: boolean;
624
+ };
625
+ /**
626
+ * A complete function parameter list.
627
+ *
628
+ * Printers are responsible for sorting (`required` → `optional` → `defaulted`).
629
+ */
630
+ type FunctionParametersNode = {
631
+ kind: 'FunctionParameters';
632
+ /**
633
+ * Ordered parameter nodes.
634
+ */
635
+ params: ReadonlyArray<FunctionParameterNode>;
636
+ };
637
+ /**
638
+ * Creates a {@link TypeLiteralNode} representing an inline anonymous object type.
639
+ *
640
+ * @example
641
+ * ```ts
642
+ * createTypeLiteral({ members: [{ name: 'petId', type: 'string', optional: false }] })
643
+ * // { petId: string }
644
+ * ```
645
+ */
646
+ export declare function createTypeLiteral(props: Omit<TypeLiteralNode, 'kind'>): TypeLiteralNode;
647
+ /**
648
+ * Creates an {@link IndexedAccessTypeNode} representing a single field accessed from a named type.
649
+ *
650
+ * @example
651
+ * ```ts
652
+ * createIndexedAccessType({ target: 'DeletePetPathParams', key: 'petId' })
653
+ * // DeletePetPathParams['petId']
654
+ * ```
655
+ */
656
+ export declare function createIndexedAccessType(props: Omit<IndexedAccessTypeNode, 'kind'>): IndexedAccessTypeNode;
657
+ /**
658
+ * Creates an {@link ObjectBindingPatternNode} for a destructured parameter binding.
659
+ *
660
+ * @example
661
+ * ```ts
662
+ * createObjectBindingPattern({ elements: [{ name: 'id' }, { name: 'name' }] })
663
+ * // { id, name }
664
+ * ```
665
+ */
666
+ export declare function createObjectBindingPattern(props: Omit<ObjectBindingPatternNode, 'kind'>): ObjectBindingPatternNode;
667
+ /**
668
+ * Plain property descriptor for a destructured group built by {@link createFunctionParameter}.
669
+ */
670
+ type FunctionParameterProperty = {
671
+ name: string;
672
+ type: TypeExpression;
673
+ optional?: boolean;
674
+ };
675
+ type FunctionParameterInput = {
676
+ name: string | ObjectBindingPatternNode;
677
+ type?: TypeExpression;
678
+ optional?: boolean;
679
+ default?: string;
680
+ rest?: boolean;
681
+ } | {
682
+ properties: Array<FunctionParameterProperty>;
683
+ optional?: boolean;
684
+ default?: string;
685
+ };
686
+ /**
687
+ * Creates a {@link FunctionParameterNode}. `optional` defaults to `false`.
688
+ * Passing `properties` builds a destructured group: an {@link ObjectBindingPatternNode} name
689
+ * paired with a {@link TypeLiteralNode} type.
690
+ *
691
+ * @example Optional param
692
+ * ```ts
693
+ * createFunctionParameter({ name: 'params', type: 'QueryParams', optional: true })
694
+ * // → params?: QueryParams
695
+ * ```
696
+ *
697
+ * @example Destructured group
698
+ * ```ts
699
+ * createFunctionParameter({ properties: [{ name: 'id', type: 'string' }, { name: 'name', type: 'string', optional: true }], default: '{}' })
700
+ * // → { id, name }: { id: string; name?: string } = {}
701
+ * ```
702
+ */
703
+ export declare function createFunctionParameter(input: FunctionParameterInput): FunctionParameterNode;
704
+ /**
705
+ * Creates a {@link FunctionParametersNode} from an ordered list of parameters.
706
+ *
707
+ * @example
708
+ * ```ts
709
+ * const empty = createFunctionParameters()
710
+ * // { params: [] }
711
+ * ```
712
+ */
713
+ export declare function createFunctionParameters(props?: Partial<Omit<FunctionParametersNode, 'kind'>>): FunctionParametersNode;
714
+ //#endregion
715
+ //#region src/printers/functionPrinter.d.ts
716
+ /**
717
+ * Renders a {@link TypeExpression} to its TypeScript source.
718
+ *
719
+ * - a `string` is a type reference, returned as-is
720
+ * - an `IndexedAccessType` becomes `objectType['indexType']`
721
+ * - a `TypeLiteral` becomes `{ key: Type; key?: Type }`
722
+ *
723
+ * `transformType` is applied once to the fully rendered type, matching how the
724
+ * printer wrapped reference types before the `ts.factory` model.
725
+ */
726
+ export declare function renderType(type: TypeExpression, transformType?: (type: string) => string): string;
727
+ type FunctionPrinterOptions = {
728
+ /**
729
+ * Rendering modes supported by `functionPrinter`.
730
+ *
731
+ * | Mode | Output example | Use case |
732
+ * |---------------|-----------------------------------|--------------------------------|
733
+ * | `declaration` | `id: string, config: Config = {}` | Function parameter declaration |
734
+ * | `call` | `id, { method, url }` | Function call arguments |
735
+ */
736
+ mode: 'declaration' | 'call';
737
+ /**
738
+ * Optional transformation applied to every parameter name before printing.
739
+ */
740
+ transformName?: (name: string) => string;
741
+ /**
742
+ * Optional transformation applied to every type string before printing.
743
+ */
744
+ transformType?: (type: string) => string;
745
+ };
746
+ /**
747
+ * Default function-signature printer. Renders a parameter list in one of two modes:
748
+ * `declaration` for the function signature and `call` for the call arguments.
749
+ *
750
+ * @example
751
+ * ```ts
752
+ * const printer = functionPrinter({ mode: 'declaration' })
753
+ *
754
+ * const sig = createFunctionParameters({
755
+ * params: [
756
+ * createFunctionParameter({ name: 'petId', type: 'string', optional: false }),
757
+ * createFunctionParameter({ name: 'config', type: 'Config', optional: false, default: '{}' }),
758
+ * ],
759
+ * })
760
+ *
761
+ * printer.print(sig) // → "petId: string, config: Config = {}"
762
+ * ```
763
+ */
764
+ export declare function functionPrinter(options: FunctionPrinterOptions): {
765
+ name: "functionParameters";
766
+ options: FunctionPrinterOptions;
767
+ print(node: FunctionParametersNode): string;
768
+ };
769
+ //#endregion
770
+ //#region src/resolvers/resolverTs.d.ts
771
+ /**
772
+ * Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths
773
+ * for every generated TypeScript type. Import this in other plugins that need
774
+ * to reference the exact names `plugin-ts` produces without duplicating the
775
+ * casing/file-layout rules.
776
+ *
777
+ * The `default` helpers are supplied by `createResolver`. This plugin overrides the top-level `name`
778
+ * to use PascalCase for value and type names and `file` to write PascalCase file paths (dotted names
779
+ * become `/`-joined), and groups the operation-specific naming under the `param`, `response`, and
780
+ * `enum` namespaces.
781
+ *
782
+ * @example Resolve a type and file name
783
+ * ```ts
784
+ * import { resolverTs } from '@kubb/plugin-ts'
785
+ *
786
+ * resolverTs.name('list pets') // 'ListPets'
787
+ * resolverTs.response.status(node, 200) // 'ListPetsStatus200'
788
+ * ```
789
+ */
790
+ export declare const resolverTs: ResolverTs;
791
+ //#endregion
792
+ //#region src/utils.d.ts
793
+ /**
794
+ * Resolves the type name an enum schema is referenced by. An enum emitted as a `const` object
795
+ * with a `typeSuffix` uses its suffixed key alias (e.g. `StatusKey`); every other schema uses its
796
+ * plain resolved name.
797
+ */
798
+ type EnumTypeNameProps = {
799
+ resolver: ResolverTs;
800
+ name: string;
801
+ enumOptions: {
802
+ type?: string;
803
+ typeSuffix?: string;
804
+ } | undefined;
805
+ isEnum: boolean;
806
+ };
807
+ export declare function enumTypeName({ resolver, name, enumOptions, isEnum }: EnumTypeNameProps): string;
808
+ type BuildParamsSchemaOptions = {
809
+ params: Array<ast.ParameterNode>;
810
+ };
811
+ /**
812
+ * Builds the object schema for a group of parameters sharing one `in` location (path, query, or
813
+ * header), embedding each param's own schema (and JSDoc) directly rather than referencing a
814
+ * separate per-param type — the group itself is the only type these params get exported as.
815
+ */
816
+ export declare function buildParams({ params }: BuildParamsSchemaOptions): ast.SchemaNode;
817
+ //#endregion
818
+ export { type FunctionParameterNode, type FunctionParametersNode, type IndexedAccessTypeNode, type ObjectBindingPatternNode, type PluginTs, type PrinterTsFactory, type PrinterTsNodes, type PrinterTsOptions, type ResolverTs, type TypeExpression, type TypeLiteralNode, pluginTs as default };
819
+ //# sourceMappingURL=index.d.cts.map