import { ZodSchema } from "@lowcode-modou/zod"; import { JsonSchema7Type } from "./parseDef"; import { EffectStrategy } from "./References"; /** * * @param schema (ZodSchema) The Zod schema to be converted to a JSON schema. * @param name (string) The (optional) name of the schema. If provided, schema will be put in definitions/{name} */ declare function zodToJsonSchema(schema: ZodSchema, name?: Name): Name extends string ? { $schema: "http://json-schema.org/draft-07/schema#"; $ref: `#/definitions/${Name}`; definitions: Record; } : { $schema: "http://json-schema.org/draft-07/schema#"; } & JsonSchema7Type; /** * * @param schema (ZodSchema) The Zod schema to be converted to a JSON schema. * @param options (Object) The (optional) options object. * @param options.name (string) The (optional) name of the schema. If provided, schema will be put in definitions/{name} * @param options.$refStrategy ("root" | "relative" | "none") The (optional) reference builder strategy. Default: "root" * @param options.basePath (string[]) The (optional) basePath for the root reference builder strategy. Default: [#] * @param options.effectStrategy ("input" | "any") The (optional) effect resolver strategy. Default: "input" * @param options.definitionPath ("definitions" | "$defs") defaults to definitions. * @param options.target ("jsonSchema7" | "openApi3") defaults to "jsonSchema7" * */ declare function zodToJsonSchema(schema: ZodSchema, options?: { name?: Name; $refStrategy?: Strategy; basePath?: BasePath; effectStrategy?: EffectStrategy; definitionPath?: DefinitionPath; target?: Target; }): Target extends "openApi3" ? Name extends string ? BasePath extends string[] ? { $ref: string; } & Record> : Strategy extends "relative" ? { $ref: `0/${DefinitionPath}/${Name}`; } & Record> : { $ref: `#/${DefinitionPath}/${Name}`; } & Record> : object : Name extends string ? BasePath extends string[] ? { $schema: "http://json-schema.org/draft-07/schema#"; $ref: string; } & Record> : Strategy extends "relative" ? { $schema: "http://json-schema.org/draft-07/schema#"; $ref: `0/${DefinitionPath}/${Name}`; } & Record> : { $schema: "http://json-schema.org/draft-07/schema#"; $ref: `#/${DefinitionPath}/${Name}`; } & Record> : { $schema: "http://json-schema.org/draft-07/schema#"; } & JsonSchema7Type; export { zodToJsonSchema };