Socket
Book a DemoInstallSign in
Socket

supabase-to-zod

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

supabase-to-zod

Generate Zod schemas (v3) from Typescript types generated by the Supabase CLI.

latest
Source
npmnpm
Version
1.0.7
Version published
Weekly downloads
982
-11.29%
Maintainers
0
Weekly downloads
 
Created
Source

supabase-to-zod

Generate Zod schemas (v3) from Typescript types generated by the Supabase CLI.

Version License

Usage

$ pnpm add --D supabase-to-zod
$ supabase gen types typescript --local > types.ts
$ pnpm supabase-to-zod --input types.ts --output schemas.ts

That's it, go to schemas.ts file, you should have a schema for all tables, views, enums and functions.

Authors Note

This project was created in a few hours during the Launchweek VI hackathon and the approach is very hacky: It transforms the nested Database type generated by the Supabase CLI into flat types, and passes them through ts-to-zod to generate zod schemas. A proper solution would be using the pg-meta API to generate zod schemas directly from the source of truth, similar to how the Typescript types are generated.

FAQs

Package last updated on 26 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts