import { Client } from '@libsql/client/web'; import { ServerStorage, GetStorageHandleOptions, StorageHandle, ConnectorHealth, SyncState, SyncSchedulingState, MarkConnectorSyncSucceededOptions, RekeyConnectorResult } from '@rawdash/core'; import { Generated, ColumnType } from 'kysely'; declare class SchemaNotInitializedError extends Error { constructor(message: string, options?: { cause?: unknown; }); } declare function initLibsqlSchema(client: Client): Promise; interface LibsqlStorageOptions { client: Client; initSchema?: boolean; } declare class LibsqlStorage implements ServerStorage { private client; private db; private ready; private initError; constructor(options: LibsqlStorageOptions); private init; waitUntilReady(): Promise; getStorageHandle(connectorId: string, options?: GetStorageHandleOptions): StorageHandle; private buildHandle; getHealth(_connectorId: string): Promise; getSyncState(): Promise; getConnectorSyncState(connectorId: string): Promise; markSyncQueued(): Promise; markSyncRunning(): Promise; markSyncSucceeded(): Promise; markConnectorSyncSucceeded(connectorId: string, options?: MarkConnectorSyncSucceededOptions): Promise; markSyncFailed(error: string): Promise; rekeyConnectorId(fromConnectorId: string, toConnectorId: string): Promise; close(): Promise; } type JsonText = ColumnType; interface EventsTable { id: Generated; connector_id: string; name: string; start_ts: number; end_ts: number | null; attributes: JsonText; } interface EntitiesTable { connector_id: string; type: string; id: string; attributes: JsonText; updated_at: number; } interface MetricsTable { id: Generated; connector_id: string; name: string; ts: number; value: number; attributes: JsonText; } interface EdgesTable { connector_id: string; from_type: string; from_id: string; kind: string; to_type: string; to_id: string; attributes: JsonText; updated_at: number; } interface DistributionsTable { id: Generated; connector_id: string; name: string; ts: number; kind: string; data: JsonText; attributes: JsonText; } interface RollupsTable { connector_id: string; resource: string; field: string; granularity: string; dims_key: string; dims: JsonText; bucket_start: number; partials: JsonText; } interface RollupWatermarksTable { connector_id: string; resource: string; watermark: number; } interface SyncStateTable { id: number; status: string; queued_at: string | null; started_at: string | null; last_sync_at: string | null; last_error: string | null; } interface ConnectorSyncStateTable { connector_id: string; last_sync_at: string | null; last_backfill_at: string | null; } interface SchemaMigrationsTable { version: number; tag: string; applied_at: number; } interface Database { events: EventsTable; entities: EntitiesTable; metrics: MetricsTable; edges: EdgesTable; distributions: DistributionsTable; rollups: RollupsTable; rollup_watermarks: RollupWatermarksTable; sync_state: SyncStateTable; connector_sync_state: ConnectorSyncStateTable; schema_migrations: SchemaMigrationsTable; } type ConnectorKeyedTable = { [K in keyof Database]: Database[K] extends { connector_id: string; } ? K : never; }[keyof Database]; declare const CONNECTOR_KEYED_TABLES: readonly ["entities", "events", "metrics", "edges", "distributions", "rollups", "rollup_watermarks", "connector_sync_state"]; interface ApplyMigrationsOptions { assumeLegacyBaselineIfEventsExists?: boolean; } declare function migrateIfNeeded(client: Client, opts?: ApplyMigrationsOptions): Promise; declare function applyMigrations(client: Client, opts?: ApplyMigrationsOptions): Promise; interface BundledMigration { tag: string; statements: string[]; } declare const MIGRATIONS: readonly BundledMigration[]; export { type ApplyMigrationsOptions, type BundledMigration, CONNECTOR_KEYED_TABLES, type ConnectorKeyedTable, LibsqlStorage, type LibsqlStorageOptions, MIGRATIONS, SchemaNotInitializedError, applyMigrations, initLibsqlSchema, migrateIfNeeded };