/** * Schema Watcher (P6 — End-to-End Type Safety) * * Watches the Zveltio engine for DDL schema changes via WebSocket and * regenerates a TypeScript types file whenever a collection is created, * updated, or deleted. * * Usage (in `zveltio dev --watch`): * import { watchSchema } from '@zveltio/sdk/schema-watcher'; * await watchSchema('http://localhost:3000', './src/zveltio-types.d.ts'); */ export interface CollectionField { name: string; type: string; required?: boolean; } export interface CollectionSchema { name: string; display_name?: string; fields: CollectionField[]; } export interface WatchSchemaOptions { /** API token for the engine (admin key) */ apiKey?: string; /** Reconnect delay in ms (default: 3000) */ reconnectDelay?: number; /** Called after each successful type regeneration */ onUpdate?: (collections: CollectionSchema[]) => void; /** Called on connection errors */ onError?: (err: Error) => void; } /** * Start watching the engine's WebSocket for schema changes and regenerate * TypeScript types at `outputPath` whenever the schema changes. * * Returns a cleanup function that closes the WebSocket. */ export declare function watchSchema(engineUrl: string, outputPath: string, options?: WatchSchemaOptions): Promise<() => void>; /** One-shot type generation without watching. */ export declare function generateTypes(engineUrl: string, outputPath: string, apiKey?: string): Promise; //# sourceMappingURL=schema-watcher.d.ts.map