This project is an utility to generate Zod schemas from Pocketbase instance.
npm install pocketbase-to-zodA lightweight CLI tool to automatically generate Zod schemas and TypeScript types directly from your PocketBase collections.
``bash`
npm install -g pocketbase-to-zodor use it via npx
npx pocketbase-to-zod [options]
`bash`
npx pocketbase-to-zod --url http://localhost:8090 --email admin@example.com --password yourpassword --output ./schemas.ts --split
: PocketBase instance URL (default: http://localhost:8090) [Required]
- --email : Admin email for authentication [Required]
- --password : Admin password for authentication [Required]
- --output : Output file path for generated schemas (default: ./pocketbase-schemas.ts) [Optional]
- --split: Generate a separate file for each collection [Optional]Example Output
`typescript
import { z } from "zod";export const UserSchema = z.object({
id: z.string(),
created: z.date(),
updated: z.date(),
email: z.string().email(),
verified: z.boolean(),
username: z.string().min(3).max(50),
profilePicture: z.url().optional().nullable(),
// ... other fields
});
export type User = z.infer;
``