import { DurableObject } from "cloudflare:workers"; //#region src/db/do-class.d.ts /** Result shape returned by query() */ interface QueryResult { rows: Record[]; /** Number of rows written. Undefined for read-only queries. */ changes?: number; } /** A single statement for batch execution */ interface BatchStatement { sql: string; params?: unknown[]; } declare class EmDashPreviewDB extends DurableObject { /** * Execute a single SQL statement. * * Called via RPC from the Kysely driver connection. */ query(sql: string, params?: unknown[]): QueryResult; /** * Execute multiple statements in a single synchronous transaction. * * Used for snapshot import. */ batch(statements: BatchStatement[]): void; /** * Invalidate the cached snapshot so the next populateFromSnapshot call * re-fetches from the source site. */ invalidateSnapshot(): void; /** * Get snapshot metadata (generated-at timestamp). * Returns null if the DO has no snapshot loaded. */ getSnapshotMeta(): { generatedAt: string; } | null; /** * Populate from a snapshot (preview mode). * * Fetches content from a source EmDash site and loads it into * this DO's SQLite. Sets a TTL alarm for cleanup. */ populateFromSnapshot(sourceUrl: string, signature: string, options?: { drafts?: boolean; ttl?: number; }): Promise<{ generatedAt: string; }>; /** * Set a cleanup alarm after the given number of seconds. * * Used by the playground middleware to set TTL after initialization * is complete (initialization runs on the Worker side via RPC). */ setTtlAlarm(ttlSeconds: number): void; /** * Alarm handler — clean up expired preview/playground data. * * Drops all user tables to reclaim storage. */ alarm(): void; /** * Drop all user tables in the DO's SQLite database. * Preserves SQLite and Cloudflare internal tables. * * Disables foreign key enforcement before dropping to avoid cascade * errors when tables are dropped in an order that violates FK * dependencies (e.g. child dropped first, then parent's implicit * CASCADE delete references the already-dropped child table). */ private dropAllTables; private applySnapshot; } //#endregion export { EmDashPreviewDB as t };