@kubb/plugin-ts 5.0.10 → 5.0.12

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.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { n as __name } from "./rolldown-runtime-CthDji9g.js";
2
2
  import { KubbReactNode } from "kubb/jsx";
3
- import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ResolverPatch, ast } from "kubb/kit";
3
+ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
4
4
  import ts from "typescript";
5
- import "@kubb/adapter-oas";
6
5
  //#region src/printers/printerTs.d.ts
7
6
  /**
8
7
  * Partial map of node-type overrides for the TypeScript printer.
@@ -428,7 +427,7 @@ type ResolvedOptions = {
428
427
  syntaxType: NonNullable<Options['syntaxType']>;
429
428
  printer: Options['printer'];
430
429
  };
431
- type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, ResolverTs>;
430
+ type PluginTs = PluginType<'plugin-ts', Options, ResolvedOptions, ResolverTs>;
432
431
  declare global {
433
432
  namespace Kubb {
434
433
  interface PluginRegistry {
@@ -769,149 +768,6 @@ export declare function functionPrinter(options: FunctionPrinterOptions): {
769
768
  print(node: FunctionParametersNode): string;
770
769
  };
771
770
  //#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
771
  //#region src/resolvers/resolverTs.d.ts
916
772
  /**
917
773
  * Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths
@@ -935,6 +791,21 @@ export declare function createOperationParams(node: ast.OperationNode, options:
935
791
  export declare const resolverTs: ResolverTs;
936
792
  //#endregion
937
793
  //#region src/utils.d.ts
794
+ /**
795
+ * Resolves the type name an enum schema is referenced by. An enum emitted as a `const` object
796
+ * with a `typeSuffix` uses its suffixed key alias (e.g. `StatusKey`); every other schema uses its
797
+ * plain resolved name.
798
+ */
799
+ type EnumTypeNameProps = {
800
+ resolver: ResolverTs;
801
+ name: string;
802
+ enumOptions: {
803
+ type?: string;
804
+ typeSuffix?: string;
805
+ } | undefined;
806
+ isEnum: boolean;
807
+ };
808
+ export declare function enumTypeName({ resolver, name, enumOptions, isEnum }: EnumTypeNameProps): string;
938
809
  type BuildParamsSchemaOptions = {
939
810
  params: Array<ast.ParameterNode>;
940
811
  };
@@ -945,5 +816,5 @@ type BuildParamsSchemaOptions = {
945
816
  */
946
817
  export declare function buildParams({ params }: BuildParamsSchemaOptions): ast.SchemaNode;
947
818
  //#endregion
948
- export { type CreateOperationParamsOptions, 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
+ 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
820
  //# sourceMappingURL=index.d.ts.map