@kubb/plugin-ts 5.0.0-beta.56 → 5.0.0-beta.73
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/README.md +2 -2
- package/dist/index.cjs +624 -156
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +377 -36
- package/dist/index.js +611 -159
- package/dist/index.js.map +1 -1
- package/dist/rolldown-runtime-CNktS9qV.js +17 -0
- package/package.json +8 -10
- package/dist/chunk-C0LytTxp.js +0 -8
- package/src/components/Enum.tsx +0 -87
- package/src/components/Type.tsx +0 -55
- package/src/constants.ts +0 -39
- package/src/factory.ts +0 -970
- package/src/generators/typeGenerator.tsx +0 -274
- package/src/index.ts +0 -9
- package/src/plugin.ts +0 -95
- package/src/printers/functionPrinter.ts +0 -197
- package/src/printers/printerTs.ts +0 -315
- package/src/resolvers/resolverTs.ts +0 -69
- package/src/types.ts +0 -335
- package/src/utils.ts +0 -140
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Exclude, Generator, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
|
|
1
|
+
import { n as __name } from "./rolldown-runtime-CNktS9qV.js";
|
|
3
2
|
import ts from "typescript";
|
|
3
|
+
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
|
|
4
4
|
import { KubbReactNode } from "@kubb/renderer-jsx/types";
|
|
5
|
+
import { OperationNode } from "@kubb/ast";
|
|
5
6
|
|
|
7
|
+
//#region ../../internals/shared/src/operation.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Resolver interface for building operation parameters.
|
|
10
|
+
*
|
|
11
|
+
* `ResolverTs` from `@kubb/plugin-ts` satisfies this interface and can be passed directly.
|
|
12
|
+
*/
|
|
13
|
+
type OperationParamsResolver = {
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the type name for an individual parameter.
|
|
16
|
+
*
|
|
17
|
+
* @example Individual path parameter name
|
|
18
|
+
* `resolver.resolveParamName(node, param) // → 'DeletePetPathPetId'`
|
|
19
|
+
*/
|
|
20
|
+
resolveParamName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
21
|
+
/**
|
|
22
|
+
* Resolves the request body type name.
|
|
23
|
+
*
|
|
24
|
+
* @example Request body type name
|
|
25
|
+
* `resolver.resolveDataName(node) // → 'CreatePetData'`
|
|
26
|
+
*/
|
|
27
|
+
resolveDataName(node: ast.OperationNode): string;
|
|
28
|
+
/**
|
|
29
|
+
* Resolves the grouped path parameters type name.
|
|
30
|
+
* When the return value equals `resolveParamName`, no indexed access is emitted.
|
|
31
|
+
*
|
|
32
|
+
* @example Grouped path params type name
|
|
33
|
+
* `resolver.resolvePathParamsName(node, param) // → 'DeletePetPathParams'`
|
|
34
|
+
*/
|
|
35
|
+
resolvePathParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
36
|
+
/**
|
|
37
|
+
* Resolves the grouped query parameters type name.
|
|
38
|
+
* When the return value equals `resolveParamName`, an inline struct type is emitted instead.
|
|
39
|
+
*
|
|
40
|
+
* @example Grouped query params type name
|
|
41
|
+
* `resolver.resolveQueryParamsName(node, param) // → 'FindPetsByStatusQueryParams'`
|
|
42
|
+
*/
|
|
43
|
+
resolveQueryParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
44
|
+
/**
|
|
45
|
+
* Resolves the grouped header parameters type name.
|
|
46
|
+
* When the return value equals `resolveParamName`, an inline struct type is emitted instead.
|
|
47
|
+
*
|
|
48
|
+
* @example Grouped header params type name
|
|
49
|
+
* `resolver.resolveHeaderParamsName(node, param) // → 'DeletePetHeaderParams'`
|
|
50
|
+
*/
|
|
51
|
+
resolveHeaderParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
6
54
|
//#region src/printers/printerTs.d.ts
|
|
7
55
|
/**
|
|
8
56
|
* Partial map of node-type overrides for the TypeScript printer.
|
|
@@ -118,7 +166,7 @@ declare const printerTs: (options?: PrinterTsOptions | undefined) => ast.Printer
|
|
|
118
166
|
* Extends the base `Resolver` (which provides `default` and `resolveOptions`) with
|
|
119
167
|
* plugin-specific naming helpers for operations, parameters, responses, and schemas.
|
|
120
168
|
*/
|
|
121
|
-
type ResolverTs = Resolver &
|
|
169
|
+
type ResolverTs = Resolver & OperationParamsResolver & {
|
|
122
170
|
/**
|
|
123
171
|
* Resolves the name for a given raw name (equivalent to `default(name, 'function')`).
|
|
124
172
|
* Since TypeScript only emits types, this is the canonical naming method.
|
|
@@ -149,6 +197,9 @@ type ResolverTs = Resolver & ast.OperationParamsResolver & {
|
|
|
149
197
|
/**
|
|
150
198
|
* Resolves the name for an operation's request config (`RequestConfig`).
|
|
151
199
|
*
|
|
200
|
+
* The `RequestConfig` suffix is kept through the v5 beta to avoid churn, but it overlaps with the
|
|
201
|
+
* runtime client's `RequestConfig`. Renaming to `Request` is on the table before stable.
|
|
202
|
+
*
|
|
152
203
|
* @example Request config names
|
|
153
204
|
* `resolver.resolveRequestConfigName(node) // → 'ListPetsRequestConfig'`
|
|
154
205
|
*/
|
|
@@ -349,17 +400,6 @@ type Options = OutputOptions & {
|
|
|
349
400
|
* @default 'array'
|
|
350
401
|
*/
|
|
351
402
|
arrayType?: 'generic' | 'array';
|
|
352
|
-
/**
|
|
353
|
-
* Rename properties inside `PathParams`, `QueryParams`, and `HeaderParams` types.
|
|
354
|
-
* Response and request body types are not affected.
|
|
355
|
-
*
|
|
356
|
-
* @note Every plugin that touches operation parameters must use the same value.
|
|
357
|
-
*/
|
|
358
|
-
paramsCasing?: 'camelcase';
|
|
359
|
-
/**
|
|
360
|
-
* Custom generators that run alongside the built-in TypeScript generators.
|
|
361
|
-
*/
|
|
362
|
-
generators?: Array<Generator<PluginTs>>;
|
|
363
403
|
/**
|
|
364
404
|
* Override how names and file paths are built for generated symbols.
|
|
365
405
|
* Methods you omit fall back to the default `resolverTs`. `this` is bound to the
|
|
@@ -368,19 +408,22 @@ type Options = OutputOptions & {
|
|
|
368
408
|
*/
|
|
369
409
|
resolver?: Partial<ResolverTs> & ThisType<ResolverTs>;
|
|
370
410
|
/**
|
|
371
|
-
*
|
|
372
|
-
*
|
|
411
|
+
* Macros applied to each schema or operation node before printing.
|
|
412
|
+
* Callbacks you omit fall back to the preset behavior.
|
|
373
413
|
*
|
|
374
414
|
* @example Drop writeOnly properties from response types
|
|
375
415
|
* ```ts
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
*
|
|
416
|
+
* macros: [
|
|
417
|
+
* {
|
|
418
|
+
* name: 'drop-write-only',
|
|
419
|
+
* property(node) {
|
|
420
|
+
* if (node.schema.writeOnly) return undefined
|
|
421
|
+
* },
|
|
422
|
+
* },
|
|
423
|
+
* ]
|
|
381
424
|
* ```
|
|
382
425
|
*/
|
|
383
|
-
|
|
426
|
+
macros?: Array<ast.Macro>;
|
|
384
427
|
/**
|
|
385
428
|
* Replace the TypeScript handler for a specific schema type (`'integer'`, `'date'`, ...).
|
|
386
429
|
* Each handler returns a TypeScript AST node for that schema type. Use `this.transform`
|
|
@@ -424,7 +467,6 @@ type ResolvedOptions = {
|
|
|
424
467
|
optionalType: NonNullable<Options['optionalType']>;
|
|
425
468
|
arrayType: NonNullable<Options['arrayType']>;
|
|
426
469
|
syntaxType: NonNullable<Options['syntaxType']>;
|
|
427
|
-
paramsCasing: Options['paramsCasing'];
|
|
428
470
|
printer: Options['printer'];
|
|
429
471
|
};
|
|
430
472
|
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, ResolverTs>;
|
|
@@ -532,19 +574,229 @@ declare const pluginTsName = "plugin-ts";
|
|
|
532
574
|
*/
|
|
533
575
|
declare const pluginTs: (options?: Options | undefined) => import("@kubb/core").Plugin<PluginTs>;
|
|
534
576
|
//#endregion
|
|
577
|
+
//#region src/printers/functionParams.d.ts
|
|
578
|
+
/**
|
|
579
|
+
* A type expression used as a function parameter type annotation.
|
|
580
|
+
*
|
|
581
|
+
* - a plain `string` is a type reference rendered as-is, e.g. `'string'`, `'QueryParams'`, `'Partial<Config>'`
|
|
582
|
+
* - a {@link TypeLiteralNode} is an inline anonymous type, e.g. `{ petId: string; name?: string }`
|
|
583
|
+
* - an {@link IndexedAccessTypeNode} is a single field accessed from a named type, e.g. `PathParams['petId']`
|
|
584
|
+
*/
|
|
585
|
+
type TypeExpression = string | TypeLiteralNode | IndexedAccessTypeNode;
|
|
586
|
+
/**
|
|
587
|
+
* An inline anonymous object type grouping named fields.
|
|
588
|
+
* Renders as `{ key: Type; other?: OtherType }`.
|
|
589
|
+
*/
|
|
590
|
+
type TypeLiteralNode = {
|
|
591
|
+
kind: 'TypeLiteral';
|
|
592
|
+
/**
|
|
593
|
+
* Members of the object type, rendered in order.
|
|
594
|
+
*/
|
|
595
|
+
members: Array<{
|
|
596
|
+
/**
|
|
597
|
+
* Member key.
|
|
598
|
+
*/
|
|
599
|
+
name: string;
|
|
600
|
+
/**
|
|
601
|
+
* Member type expression.
|
|
602
|
+
*/
|
|
603
|
+
type: TypeExpression;
|
|
604
|
+
/**
|
|
605
|
+
* Whether the member is optional, rendered with `?`.
|
|
606
|
+
*/
|
|
607
|
+
optional?: boolean;
|
|
608
|
+
}>;
|
|
609
|
+
};
|
|
610
|
+
/**
|
|
611
|
+
* A single field accessed from a named group type. Renders as `target['key']`.
|
|
612
|
+
*/
|
|
613
|
+
type IndexedAccessTypeNode = {
|
|
614
|
+
kind: 'IndexedAccessType';
|
|
615
|
+
/**
|
|
616
|
+
* Name of the type being indexed, e.g. `'GetPetPathParams'`.
|
|
617
|
+
*/
|
|
618
|
+
target: string;
|
|
619
|
+
/**
|
|
620
|
+
* Field key to access, e.g. `'petId'`.
|
|
621
|
+
*/
|
|
622
|
+
key: string;
|
|
623
|
+
};
|
|
624
|
+
/**
|
|
625
|
+
* An object destructuring binding, used as the name of a grouped function parameter.
|
|
626
|
+
* Renders as `{ id, name }` or `{ id: renamed }` when `propertyName` differs.
|
|
627
|
+
*/
|
|
628
|
+
type ObjectBindingPatternNode = {
|
|
629
|
+
kind: 'ObjectBindingPattern';
|
|
630
|
+
/**
|
|
631
|
+
* Bound elements, rendered in order.
|
|
632
|
+
*/
|
|
633
|
+
elements: Array<{
|
|
634
|
+
/**
|
|
635
|
+
* Local binding name.
|
|
636
|
+
*/
|
|
637
|
+
name: string;
|
|
638
|
+
/**
|
|
639
|
+
* Source key when it differs from the binding name, rendered as `propertyName: name`.
|
|
640
|
+
*/
|
|
641
|
+
propertyName?: string;
|
|
642
|
+
}>;
|
|
643
|
+
};
|
|
644
|
+
/**
|
|
645
|
+
* One function parameter.
|
|
646
|
+
*
|
|
647
|
+
* A simple parameter has a `string` name. A destructured group has an
|
|
648
|
+
* {@link ObjectBindingPatternNode} name paired with a {@link TypeLiteralNode} type.
|
|
649
|
+
*
|
|
650
|
+
* @example Required parameter
|
|
651
|
+
* `name: Type`
|
|
652
|
+
*
|
|
653
|
+
* @example Optional parameter
|
|
654
|
+
* `name?: Type`
|
|
655
|
+
*
|
|
656
|
+
* @example Parameter with default value
|
|
657
|
+
* `name: Type = defaultValue`
|
|
658
|
+
*
|
|
659
|
+
* @example Rest parameter
|
|
660
|
+
* `...name: Type[]`
|
|
661
|
+
*
|
|
662
|
+
* @example Destructured group
|
|
663
|
+
* `{ id, name? }: { id: string; name?: string } = {}`
|
|
664
|
+
*/
|
|
665
|
+
type FunctionParameterNode = {
|
|
666
|
+
kind: 'FunctionParameter';
|
|
667
|
+
/**
|
|
668
|
+
* Parameter name, or an {@link ObjectBindingPatternNode} for a destructured group.
|
|
669
|
+
*/
|
|
670
|
+
name: string | ObjectBindingPatternNode;
|
|
671
|
+
/**
|
|
672
|
+
* Type annotation as a {@link TypeExpression}. Omit for untyped output.
|
|
673
|
+
*/
|
|
674
|
+
type?: TypeExpression;
|
|
675
|
+
/**
|
|
676
|
+
* Whether the parameter is optional, rendered with `?`.
|
|
677
|
+
*/
|
|
678
|
+
optional?: boolean;
|
|
679
|
+
/**
|
|
680
|
+
* Default value, written verbatim after `=`. Commonly `'{}'` for a destructured group.
|
|
681
|
+
*/
|
|
682
|
+
default?: string;
|
|
683
|
+
/**
|
|
684
|
+
* When `true` the parameter is emitted as a rest parameter, e.g. `...name: Type[]`.
|
|
685
|
+
*/
|
|
686
|
+
rest?: boolean;
|
|
687
|
+
};
|
|
688
|
+
/**
|
|
689
|
+
* A complete function parameter list.
|
|
690
|
+
*
|
|
691
|
+
* Printers are responsible for sorting (`required` → `optional` → `defaulted`).
|
|
692
|
+
*/
|
|
693
|
+
type FunctionParametersNode = {
|
|
694
|
+
kind: 'FunctionParameters';
|
|
695
|
+
/**
|
|
696
|
+
* Ordered parameter nodes.
|
|
697
|
+
*/
|
|
698
|
+
params: ReadonlyArray<FunctionParameterNode>;
|
|
699
|
+
};
|
|
700
|
+
/**
|
|
701
|
+
* Creates a {@link TypeLiteralNode} representing an inline anonymous object type.
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* ```ts
|
|
705
|
+
* createTypeLiteral({ members: [{ name: 'petId', type: 'string', optional: false }] })
|
|
706
|
+
* // { petId: string }
|
|
707
|
+
* ```
|
|
708
|
+
*/
|
|
709
|
+
declare function createTypeLiteral(props: Omit<TypeLiteralNode, 'kind'>): TypeLiteralNode;
|
|
710
|
+
/**
|
|
711
|
+
* Creates an {@link IndexedAccessTypeNode} representing a single field accessed from a named type.
|
|
712
|
+
*
|
|
713
|
+
* @example
|
|
714
|
+
* ```ts
|
|
715
|
+
* createIndexedAccessType({ target: 'DeletePetPathParams', key: 'petId' })
|
|
716
|
+
* // DeletePetPathParams['petId']
|
|
717
|
+
* ```
|
|
718
|
+
*/
|
|
719
|
+
declare function createIndexedAccessType(props: Omit<IndexedAccessTypeNode, 'kind'>): IndexedAccessTypeNode;
|
|
720
|
+
/**
|
|
721
|
+
* Creates an {@link ObjectBindingPatternNode} for a destructured parameter binding.
|
|
722
|
+
*
|
|
723
|
+
* @example
|
|
724
|
+
* ```ts
|
|
725
|
+
* createObjectBindingPattern({ elements: [{ name: 'id' }, { name: 'name' }] })
|
|
726
|
+
* // { id, name }
|
|
727
|
+
* ```
|
|
728
|
+
*/
|
|
729
|
+
declare function createObjectBindingPattern(props: Omit<ObjectBindingPatternNode, 'kind'>): ObjectBindingPatternNode;
|
|
730
|
+
/**
|
|
731
|
+
* Plain property descriptor for a destructured group built by {@link createFunctionParameter}.
|
|
732
|
+
*/
|
|
733
|
+
type FunctionParameterProperty = {
|
|
734
|
+
name: string;
|
|
735
|
+
type: TypeExpression;
|
|
736
|
+
optional?: boolean;
|
|
737
|
+
};
|
|
738
|
+
type FunctionParameterInput = {
|
|
739
|
+
name: string | ObjectBindingPatternNode;
|
|
740
|
+
type?: TypeExpression;
|
|
741
|
+
optional?: boolean;
|
|
742
|
+
default?: string;
|
|
743
|
+
rest?: boolean;
|
|
744
|
+
} | {
|
|
745
|
+
properties: Array<FunctionParameterProperty>;
|
|
746
|
+
optional?: boolean;
|
|
747
|
+
default?: string;
|
|
748
|
+
};
|
|
749
|
+
/**
|
|
750
|
+
* Creates a {@link FunctionParameterNode}. `optional` defaults to `false`.
|
|
751
|
+
* Passing `properties` builds a destructured group: an {@link ObjectBindingPatternNode} name
|
|
752
|
+
* paired with a {@link TypeLiteralNode} type.
|
|
753
|
+
*
|
|
754
|
+
* @example Optional param
|
|
755
|
+
* ```ts
|
|
756
|
+
* createFunctionParameter({ name: 'params', type: 'QueryParams', optional: true })
|
|
757
|
+
* // → params?: QueryParams
|
|
758
|
+
* ```
|
|
759
|
+
*
|
|
760
|
+
* @example Destructured group
|
|
761
|
+
* ```ts
|
|
762
|
+
* createFunctionParameter({ properties: [{ name: 'id', type: 'string' }, { name: 'name', type: 'string', optional: true }], default: '{}' })
|
|
763
|
+
* // → { id, name }: { id: string; name?: string } = {}
|
|
764
|
+
* ```
|
|
765
|
+
*/
|
|
766
|
+
declare function createFunctionParameter(input: FunctionParameterInput): FunctionParameterNode;
|
|
767
|
+
/**
|
|
768
|
+
* Creates a {@link FunctionParametersNode} from an ordered list of parameters.
|
|
769
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
* ```ts
|
|
772
|
+
* const empty = createFunctionParameters()
|
|
773
|
+
* // { params: [] }
|
|
774
|
+
* ```
|
|
775
|
+
*/
|
|
776
|
+
declare function createFunctionParameters(props?: Partial<Omit<FunctionParametersNode, 'kind'>>): FunctionParametersNode;
|
|
777
|
+
//#endregion
|
|
535
778
|
//#region src/printers/functionPrinter.d.ts
|
|
779
|
+
/**
|
|
780
|
+
* Renders a {@link TypeExpression} to its TypeScript source.
|
|
781
|
+
*
|
|
782
|
+
* - a `string` is a type reference, returned as-is
|
|
783
|
+
* - an `IndexedAccessType` becomes `objectType['indexType']`
|
|
784
|
+
* - a `TypeLiteral` becomes `{ key: Type; key?: Type }`
|
|
785
|
+
*
|
|
786
|
+
* `transformType` is applied once to the fully rendered type, matching how the
|
|
787
|
+
* printer wrapped reference types before the `ts.factory` model.
|
|
788
|
+
*/
|
|
789
|
+
declare function renderType(type: TypeExpression, transformType?: (type: string) => string): string;
|
|
536
790
|
type FunctionPrinterOptions = {
|
|
537
791
|
/**
|
|
538
792
|
* Rendering modes supported by `functionPrinter`.
|
|
539
793
|
*
|
|
540
|
-
* | Mode | Output example
|
|
541
|
-
*
|
|
542
|
-
* | `declaration` | `id: string, config: Config = {}`
|
|
543
|
-
* | `call` | `id, { method, url }`
|
|
544
|
-
* | `keys` | `{ id, config }` | Key names only (destructuring) |
|
|
545
|
-
* | `values` | `{ id: id, config: config }` | Key/value object entries |
|
|
794
|
+
* | Mode | Output example | Use case |
|
|
795
|
+
* |---------------|-----------------------------------|--------------------------------|
|
|
796
|
+
* | `declaration` | `id: string, config: Config = {}` | Function parameter declaration |
|
|
797
|
+
* | `call` | `id, { method, url }` | Function call arguments |
|
|
546
798
|
*/
|
|
547
|
-
mode: 'declaration' | 'call'
|
|
799
|
+
mode: 'declaration' | 'call';
|
|
548
800
|
/**
|
|
549
801
|
* Optional transformation applied to every parameter name before printing.
|
|
550
802
|
*/
|
|
@@ -555,8 +807,8 @@ type FunctionPrinterOptions = {
|
|
|
555
807
|
transformType?: (type: string) => string;
|
|
556
808
|
};
|
|
557
809
|
/**
|
|
558
|
-
* Default function-signature printer.
|
|
559
|
-
*
|
|
810
|
+
* Default function-signature printer. Renders a parameter list in one of two modes:
|
|
811
|
+
* `declaration` for the function signature and `call` for the call arguments.
|
|
560
812
|
*
|
|
561
813
|
* @example
|
|
562
814
|
* ```ts
|
|
@@ -572,13 +824,102 @@ type FunctionPrinterOptions = {
|
|
|
572
824
|
* printer.print(sig) // → "petId: string, config: Config = {}"
|
|
573
825
|
* ```
|
|
574
826
|
*/
|
|
575
|
-
declare
|
|
827
|
+
declare function functionPrinter(options: FunctionPrinterOptions): {
|
|
576
828
|
name: "functionParameters";
|
|
577
829
|
options: FunctionPrinterOptions;
|
|
578
|
-
|
|
579
|
-
print: (node: ast.FunctionParamNode) => string | null;
|
|
830
|
+
print(node: FunctionParametersNode): string;
|
|
580
831
|
};
|
|
581
832
|
//#endregion
|
|
833
|
+
//#region src/printers/operationParams.d.ts
|
|
834
|
+
/**
|
|
835
|
+
* Options for {@link createOperationParams}.
|
|
836
|
+
*/
|
|
837
|
+
type CreateOperationParamsOptions = {
|
|
838
|
+
/**
|
|
839
|
+
* How all operation parameters are grouped in the function signature.
|
|
840
|
+
* - `'object'` wraps all params into a single destructured object `{ petId, data, params }`
|
|
841
|
+
* - `'inline'` emits each param category as a separate top-level parameter
|
|
842
|
+
*/
|
|
843
|
+
paramsType: 'object' | 'inline';
|
|
844
|
+
/**
|
|
845
|
+
* How path parameters are emitted when `paramsType` is `'inline'`.
|
|
846
|
+
* - `'object'` groups them as `{ petId, storeId }: PathParams`
|
|
847
|
+
* - `'inline'` spreads them as individual parameters `petId: string, storeId: string`
|
|
848
|
+
* - `'inlineSpread'` emits a single rest parameter `...pathParams: PathParams`
|
|
849
|
+
*/
|
|
850
|
+
pathParamsType: 'object' | 'inline' | 'inlineSpread';
|
|
851
|
+
/**
|
|
852
|
+
* Converts parameter names to camelCase before output.
|
|
853
|
+
*/
|
|
854
|
+
paramsCasing?: 'camelcase';
|
|
855
|
+
/**
|
|
856
|
+
* Resolver for parameter and request body type names.
|
|
857
|
+
* Pass `ResolverTs` from `@kubb/plugin-ts` directly.
|
|
858
|
+
* When omitted, falls back to the schema primitive or `'unknown'`.
|
|
859
|
+
*/
|
|
860
|
+
resolver?: OperationParamsResolver;
|
|
861
|
+
/**
|
|
862
|
+
* Default value for the path parameters binding when `pathParamsType` is `'object'`.
|
|
863
|
+
* Falls back to `'{}'` when all path params are optional.
|
|
864
|
+
*/
|
|
865
|
+
pathParamsDefault?: string;
|
|
866
|
+
/**
|
|
867
|
+
* Extra parameters appended after the standard operation parameters.
|
|
868
|
+
*
|
|
869
|
+
* @example Plugin-specific trailing parameter
|
|
870
|
+
* ```ts
|
|
871
|
+
* extraParams: [createFunctionParameter({ name: 'options', type: 'Partial<RequestOptions>', default: '{}' })]
|
|
872
|
+
* ```
|
|
873
|
+
*/
|
|
874
|
+
extraParams?: Array<FunctionParameterNode>;
|
|
875
|
+
/**
|
|
876
|
+
* Override the default parameter names used for body, query, header, and rest-path groups.
|
|
877
|
+
*
|
|
878
|
+
* Useful when targeting languages or frameworks with different naming conventions.
|
|
879
|
+
*
|
|
880
|
+
* @default { data: 'data', params: 'params', headers: 'headers', path: 'pathParams' }
|
|
881
|
+
*/
|
|
882
|
+
paramNames?: {
|
|
883
|
+
/**
|
|
884
|
+
* Name for the request body parameter.
|
|
885
|
+
* @default 'data'
|
|
886
|
+
*/
|
|
887
|
+
data?: string;
|
|
888
|
+
/**
|
|
889
|
+
* Name for the query parameters group parameter.
|
|
890
|
+
* @default 'params'
|
|
891
|
+
*/
|
|
892
|
+
params?: string;
|
|
893
|
+
/**
|
|
894
|
+
* Name for the header parameters group parameter.
|
|
895
|
+
* @default 'headers'
|
|
896
|
+
*/
|
|
897
|
+
headers?: string;
|
|
898
|
+
/**
|
|
899
|
+
* Name for the rest path-parameters parameter when `pathParamsType` is `'inlineSpread'`.
|
|
900
|
+
* @default 'pathParams'
|
|
901
|
+
*/
|
|
902
|
+
path?: string;
|
|
903
|
+
};
|
|
904
|
+
/**
|
|
905
|
+
* Transforms every resolved type name before it lands in a parameter node, for framework-level
|
|
906
|
+
* type wrappers.
|
|
907
|
+
*
|
|
908
|
+
* @example Vue Query, wrap every parameter type with `MaybeRefOrGetter`
|
|
909
|
+
* `typeWrapper: (t) => \`MaybeRefOrGetter<${t}>\``
|
|
910
|
+
*/
|
|
911
|
+
typeWrapper?: (type: string) => string;
|
|
912
|
+
};
|
|
913
|
+
/**
|
|
914
|
+
* Converts an `OperationNode` into function parameters for code generation.
|
|
915
|
+
*
|
|
916
|
+
* Centralizes parameter grouping logic for all plugins. `paramsType` chooses between one
|
|
917
|
+
* destructured object parameter (`object`) and separate top-level parameters (`inline`), while
|
|
918
|
+
* `pathParamsType` controls how path params render in inline mode. Provide a `resolver` for type
|
|
919
|
+
* name resolution and `extraParams` for plugin-specific trailing parameters such as an `options` object.
|
|
920
|
+
*/
|
|
921
|
+
declare function createOperationParams(node: OperationNode, options: CreateOperationParamsOptions): FunctionParametersNode;
|
|
922
|
+
//#endregion
|
|
582
923
|
//#region src/resolvers/resolverTs.d.ts
|
|
583
924
|
/**
|
|
584
925
|
* Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths
|
|
@@ -600,5 +941,5 @@ declare const functionPrinter: (options?: FunctionPrinterOptions | undefined) =>
|
|
|
600
941
|
*/
|
|
601
942
|
declare const resolverTs: ResolverTs;
|
|
602
943
|
//#endregion
|
|
603
|
-
export { Enum, type PluginTs, type PrinterTsFactory, type PrinterTsNodes, type PrinterTsOptions, type ResolverTs, Type, pluginTs as default, pluginTs, functionPrinter, pluginTsName, printerTs, resolverTs, typeGenerator };
|
|
944
|
+
export { type CreateOperationParamsOptions, Enum, type FunctionParameterNode, type FunctionParametersNode, type IndexedAccessTypeNode, type ObjectBindingPatternNode, type PluginTs, type PrinterTsFactory, type PrinterTsNodes, type PrinterTsOptions, type ResolverTs, Type, type TypeExpression, type TypeLiteralNode, createFunctionParameter, createFunctionParameters, createIndexedAccessType, createObjectBindingPattern, createOperationParams, createTypeLiteral, pluginTs as default, pluginTs, functionPrinter, pluginTsName, printerTs, renderType, resolverTs, typeGenerator };
|
|
604
945
|
//# sourceMappingURL=index.d.ts.map
|