CLI
The CLI generates Zod schemas for your PocketBase instance.
Usage
To generate your schemas, run the following from your project directory:
npx zod-pocketbase
pnpm zod-pocketbase
yarn zod-pocketbase

Config File
You can provide a zod-pocketbase.config.ts
or zod-pocketbase.config.js
config file.
import type { Config } from "zod-pocketbase";
export default { // default values adminEmail: undefined, adminPassword: undefined, ignore: [], nameEnum: (name: string) => snakeCase(name).toUpperCase(), nameEnumField: (collectionName: string, fieldName: string) => `${collectionName}${pascalCase(fieldName)}`, nameEnumSchema: (name: string) => pascalCase(name), nameEnumType: (name: string) => pascalCase(name), nameEnumValues: (name: string) => `${name}Values`, nameRecordSchema: (name: string) => `${pascalCase(name)}Record`, nameRecordType: (name: string) => `${pascalCase(name)}Record`, output: "./zod-pocketbase.ts", url: undefined,} satisfies Config;
Environment variables
You can provide your admin credentials and your PocketBase instance url as environment variables:
ZOD_POCKETBASE_ADMIN_EMAIL="admin@mydomain.com"ZOD_POCKETBASE_ADMIN_PASSWORD="mypassword"ZOD_POCKETBASE_URL="https://myproject.pockethost.io"