Skip to main content
Home

latest
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
23%
Published
2 months ago (0.0.2)
Package root>src>convert.ts
// import { zodToTs } from 'zod-to-ts' import { compile } from 'npm:json-schema-to-typescript@^9.1.0' import { generate } from "npm:ts-to-zod@^1.0.0"; import type { JsonSchema } from "./model.ts" // export function zodToTsDefinitions(zod: z.ZodTypeAny, name: string): string { return zodToTs(zod, name, { resolveNativeEnums: true }).node.getFullText() } export function jsonSchemaToTsDefinitions(jsonSchema: JsonSchema, name: string) { return compile(jsonSchema as any, name) } export function tsDefinitionsToZod(tsCode: string) {return generate({ sourceText: tsCode, keepComments: true, skipParseJSDoc: true}).transformedSourceText;} // export function zodToSchemaObj(zod: z.ZodTypeAny) { return zodToTs(zod, 'Schema', { resolveNativeEnums: true }) } // export function objectToSchemaObj() { } // export function jsonSchemaToSchemaObj(jsonSchema: JsonSchema, name: string) { } // function schemaObj(to: "interface" | "zod" | "jsonSchema") { // }