@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.
- package/dist/index.cjs +114 -496
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +819 -0
- package/dist/index.d.ts +17 -147
- package/dist/index.js +130 -497
- package/dist/index.js.map +1 -1
- package/kubb-extension.json +1 -1
- package/package.json +13 -8
- package/dist/rolldown-runtime-CthDji9g.js +0 -18
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { n as __name } from "./rolldown-runtime-CthDji9g.js";
|
|
2
|
-
import { KubbReactNode } from "kubb/jsx";
|
|
3
1
|
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
|
|
2
|
+
import { KubbReactNode } from "kubb/jsx";
|
|
4
3
|
import ts from "typescript";
|
|
5
|
-
import "@kubb/adapter-oas";
|
|
6
4
|
//#region src/printers/printerTs.d.ts
|
|
7
5
|
/**
|
|
8
6
|
* Partial map of node-type overrides for the TypeScript printer.
|
|
@@ -769,149 +767,6 @@ export declare function functionPrinter(options: FunctionPrinterOptions): {
|
|
|
769
767
|
print(node: FunctionParametersNode): string;
|
|
770
768
|
};
|
|
771
769
|
//#endregion
|
|
772
|
-
//#region ../../internals/shared/src/operation.d.ts
|
|
773
|
-
/**
|
|
774
|
-
* Resolver interface for building operation parameters.
|
|
775
|
-
*
|
|
776
|
-
* `ResolverTs` from `@kubb/plugin-ts` satisfies this interface and can be passed directly.
|
|
777
|
-
*/
|
|
778
|
-
type OperationParamsResolver = {
|
|
779
|
-
/**
|
|
780
|
-
* Naming for an operation's parameters, grouped by location.
|
|
781
|
-
*/
|
|
782
|
-
param: {
|
|
783
|
-
/**
|
|
784
|
-
* Resolves the type name for an individual parameter.
|
|
785
|
-
*
|
|
786
|
-
* @example Individual path parameter name
|
|
787
|
-
* `resolver.param.name(node, param) // → 'DeletePetPathPetId'`
|
|
788
|
-
*/
|
|
789
|
-
name(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
790
|
-
/**
|
|
791
|
-
* Resolves the grouped path parameters type name.
|
|
792
|
-
* When the return value equals `resolver.param.name`, no indexed access is emitted.
|
|
793
|
-
*
|
|
794
|
-
* @example Grouped path params type name
|
|
795
|
-
* `resolver.param.path(node, param) // → 'DeletePetPath'`
|
|
796
|
-
*/
|
|
797
|
-
path(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
798
|
-
/**
|
|
799
|
-
* Resolves the grouped query parameters type name.
|
|
800
|
-
* When the return value equals `resolver.param.name`, an inline struct type is emitted instead.
|
|
801
|
-
*
|
|
802
|
-
* @example Grouped query params type name
|
|
803
|
-
* `resolver.param.query(node, param) // → 'FindPetsByStatusQuery'`
|
|
804
|
-
*/
|
|
805
|
-
query(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
806
|
-
/**
|
|
807
|
-
* Resolves the grouped header parameters type name.
|
|
808
|
-
* When the return value equals `resolver.param.name`, an inline struct type is emitted instead.
|
|
809
|
-
*
|
|
810
|
-
* @example Grouped header params type name
|
|
811
|
-
* `resolver.param.headers(node, param) // → 'DeletePetHeaders'`
|
|
812
|
-
*/
|
|
813
|
-
headers(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
814
|
-
};
|
|
815
|
-
/**
|
|
816
|
-
* Naming for an operation's request and response types.
|
|
817
|
-
*/
|
|
818
|
-
response: {
|
|
819
|
-
/**
|
|
820
|
-
* Resolves the request body type name.
|
|
821
|
-
*
|
|
822
|
-
* @example Request body type name
|
|
823
|
-
* `resolver.response.body(node) // → 'CreatePetBody'`
|
|
824
|
-
*/
|
|
825
|
-
body(node: ast.OperationNode): string;
|
|
826
|
-
};
|
|
827
|
-
};
|
|
828
|
-
//#endregion
|
|
829
|
-
//#region src/printers/operationParams.d.ts
|
|
830
|
-
/**
|
|
831
|
-
* Options for {@link createOperationParams}.
|
|
832
|
-
*/
|
|
833
|
-
type CreateOperationParamsOptions = {
|
|
834
|
-
/**
|
|
835
|
-
* How all operation parameters are grouped in the function signature.
|
|
836
|
-
* - `'object'` wraps all params into a single destructured object `{ petId, data, params }`
|
|
837
|
-
* - `'inline'` emits each param category as a separate top-level parameter
|
|
838
|
-
*/
|
|
839
|
-
paramsType: 'object' | 'inline';
|
|
840
|
-
/**
|
|
841
|
-
* How path parameters are emitted when `paramsType` is `'inline'`.
|
|
842
|
-
* - `'object'` groups them as `{ petId, storeId }: PathParams`
|
|
843
|
-
* - `'inline'` spreads them as individual parameters `petId: string, storeId: string`
|
|
844
|
-
* - `'inlineSpread'` emits a single rest parameter `...pathParams: PathParams`
|
|
845
|
-
*/
|
|
846
|
-
pathParamsType: 'object' | 'inline' | 'inlineSpread';
|
|
847
|
-
/**
|
|
848
|
-
* Resolver for parameter and request body type names.
|
|
849
|
-
* Pass `ResolverTs` from `@kubb/plugin-ts` directly.
|
|
850
|
-
* When omitted, falls back to the schema primitive or `'unknown'`.
|
|
851
|
-
*/
|
|
852
|
-
resolver?: OperationParamsResolver;
|
|
853
|
-
/**
|
|
854
|
-
* Default value for the path parameters binding when `pathParamsType` is `'object'`.
|
|
855
|
-
* Falls back to `'{}'` when all path params are optional.
|
|
856
|
-
*/
|
|
857
|
-
pathParamsDefault?: string;
|
|
858
|
-
/**
|
|
859
|
-
* Extra parameters appended after the standard operation parameters.
|
|
860
|
-
*
|
|
861
|
-
* @example Plugin-specific trailing parameter
|
|
862
|
-
* ```ts
|
|
863
|
-
* extraParams: [createFunctionParameter({ name: 'options', type: 'Partial<RequestOptions>', default: '{}' })]
|
|
864
|
-
* ```
|
|
865
|
-
*/
|
|
866
|
-
extraParams?: Array<FunctionParameterNode>;
|
|
867
|
-
/**
|
|
868
|
-
* Override the default parameter names used for body, query, header, and rest-path groups.
|
|
869
|
-
*
|
|
870
|
-
* Useful when targeting languages or frameworks with different naming conventions.
|
|
871
|
-
*
|
|
872
|
-
* @default { data: 'data', params: 'params', headers: 'headers', path: 'pathParams' }
|
|
873
|
-
*/
|
|
874
|
-
paramNames?: {
|
|
875
|
-
/**
|
|
876
|
-
* Name for the request body parameter.
|
|
877
|
-
* @default 'data'
|
|
878
|
-
*/
|
|
879
|
-
data?: string;
|
|
880
|
-
/**
|
|
881
|
-
* Name for the query parameters group parameter.
|
|
882
|
-
* @default 'params'
|
|
883
|
-
*/
|
|
884
|
-
params?: string;
|
|
885
|
-
/**
|
|
886
|
-
* Name for the header parameters group parameter.
|
|
887
|
-
* @default 'headers'
|
|
888
|
-
*/
|
|
889
|
-
headers?: string;
|
|
890
|
-
/**
|
|
891
|
-
* Name for the rest path-parameters parameter when `pathParamsType` is `'inlineSpread'`.
|
|
892
|
-
* @default 'pathParams'
|
|
893
|
-
*/
|
|
894
|
-
path?: string;
|
|
895
|
-
};
|
|
896
|
-
/**
|
|
897
|
-
* Transforms every resolved type name before it lands in a parameter node, for framework-level
|
|
898
|
-
* type wrappers.
|
|
899
|
-
*
|
|
900
|
-
* @example Vue Query, wrap every parameter type with `MaybeRefOrGetter`
|
|
901
|
-
* `typeWrapper: (t) => \`MaybeRefOrGetter<${t}>\``
|
|
902
|
-
*/
|
|
903
|
-
typeWrapper?: (type: string) => string;
|
|
904
|
-
};
|
|
905
|
-
/**
|
|
906
|
-
* Converts an `OperationNode` into function parameters for code generation.
|
|
907
|
-
*
|
|
908
|
-
* Centralizes parameter grouping logic for all plugins. `paramsType` chooses between one
|
|
909
|
-
* destructured object parameter (`object`) and separate top-level parameters (`inline`), while
|
|
910
|
-
* `pathParamsType` controls how path params render in inline mode. Provide a `resolver` for type
|
|
911
|
-
* name resolution and `extraParams` for plugin-specific trailing parameters such as an `options` object.
|
|
912
|
-
*/
|
|
913
|
-
export declare function createOperationParams(node: ast.OperationNode, options: CreateOperationParamsOptions): FunctionParametersNode;
|
|
914
|
-
//#endregion
|
|
915
770
|
//#region src/resolvers/resolverTs.d.ts
|
|
916
771
|
/**
|
|
917
772
|
* Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths
|
|
@@ -935,6 +790,21 @@ export declare function createOperationParams(node: ast.OperationNode, options:
|
|
|
935
790
|
export declare const resolverTs: ResolverTs;
|
|
936
791
|
//#endregion
|
|
937
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;
|
|
938
808
|
type BuildParamsSchemaOptions = {
|
|
939
809
|
params: Array<ast.ParameterNode>;
|
|
940
810
|
};
|
|
@@ -945,5 +815,5 @@ type BuildParamsSchemaOptions = {
|
|
|
945
815
|
*/
|
|
946
816
|
export declare function buildParams({ params }: BuildParamsSchemaOptions): ast.SchemaNode;
|
|
947
817
|
//#endregion
|
|
948
|
-
export { type
|
|
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 };
|
|
949
819
|
//# sourceMappingURL=index.d.ts.map
|