//#region src/shared/datasources/preview-db.d.ts type DatasourceItemFromApi = { id: string; data: Record; createdAt?: string | null; updatedAt?: string | null; }; type FetchItems = (datasourceId: string) => Promise; type SeedOptions = { fetchItems?: FetchItems; persistTo?: string; }; /** * Apply pending D1 migrations declared in the workspace's `.migrations/` folder * into the local SQLite file (same `--persist-to` as the seed so wrangler-CLI and * the preview-runtime miniflare share state). Idempotent: wrangler tracks applied * migrations in the `d1_migrations` table. * * Migration files are the SOLE authority for the schema (local and remote): the * local DB is never created out-of-band, which is why re-applying them never hits * the "DROP TABLE on a populated, FK-referenced table" failure. * * No-ops if `.migrations/` doesn't exist yet (fresh skeleton) or D1 isn't * configured. Throws on wrangler exit != 0 so the caller can decide what to do. */ declare function applyWranglerMigrations(WORKSPACE: string, options?: { persistTo?: string; }): Promise; /** * Seed the local D1 with datasource DATA only — no schema. The schema is owned by * `applyWranglerMigrations`; callers must run that first (the tables must exist). * * For each datasource it clears the table (`DELETE FROM`, so a re-seed is * idempotent) and re-inserts either real items from the API (`fetchItems`) or the * static example fixtures. Everything runs in one `defer_foreign_keys` batch so * cross-datasource FK fixtures (e.g. `projects.categoryId → categories`) stay valid. * * No-ops silently if wrangler.json has no D1 binding or there are no datasources. */ declare function seedWranglerDb(WORKSPACE: string, WORKSPACE_TMP: string, options?: SeedOptions): Promise; /** * Bring the local preview D1 fully up to date: apply pending migrations (schema) * then seed data. This is the single entry point used at editor-open and by the * pre-commit hook; the schema always comes from the `.migrations/` files. */ declare function syncPreviewDb(WORKSPACE: string, WORKSPACE_TMP: string, options?: SeedOptions): Promise; //#endregion export { DatasourceItemFromApi, applyWranglerMigrations, seedWranglerDb, syncPreviewDb }; //# sourceMappingURL=preview-db.d.ts.map