zod-to-x
Version:
Multi language types generation from Zod schemas.
21 lines (20 loc) • 1.41 kB
TypeScript
import { IZod2AstOpt } from "../../core";
import { ZodObject, ZodDiscriminatedUnion, ZodUnion } from "../../lib/zod_helpers";
import { IZod2ProtoV3Opt } from "./options";
/**
* Converts a Zod schema into a Protocol Buffers v3 definition.
*
* @param schema - The Zod object schema to be converted.
* @param opt - Optional configuration for the conversion process.
* @param opt.strict - Whether to enforce strict mode during AST generation.
* @param opt.packageName - The package name to use in the generated Protocol Buffers definition.
* @param opt.keepKeys - Whether to keep the original property names in the generated file instead
* of converting them to snake_case as per Protobuf conventions.
* @param opt.header - Custom header text to include in the generated file.
* @param opt.indent - The indentation style to use in the generated file.
* @param opt.includeComments - Whether to include comments in the generated Protocol Buffers
* definition.
* @returns The Protocol Buffers v3 definition as a string.
*/
export declare function zod2ProtoV3(schema: ZodObject<any> | ZodDiscriminatedUnion | ZodUnion<any>, // TODO: fix any to force only ZodObjects
opt?: Pick<IZod2AstOpt, "strict"> & Pick<IZod2ProtoV3Opt, "packageName" | "keepKeys" | "header" | "indent" | "includeComments" | "encodeDoubleAsInt" | "useExplicitOptional">): string;