import type { LODCacheRecord } from "./lod"; import type { SimulationCacheManifestIR } from "./simulation-cache"; import type { ErrorCode } from "./error"; export interface StorageSmokeResult { backend: "indexeddb"; opfsAvailable: boolean; rowCount: number; persisted: boolean; schemaVersion: number; stores: string[]; } export interface StorageInfoResult { backend: "indexeddb"; opfsAvailable: boolean; schemaVersion: number; stores: string[]; } export interface StorageProjectResult { projectId: string; scenePath: string; directories: string[]; } export interface StorageSaveResult { projectId: string; bytes: number; revision: number; persisted: boolean; backend: "opfs" | "indexeddb"; scenePath: string; sha256: string; } export interface StorageRecoveryResult { projectId: string; status: "clean" | "recovered" | "missing"; recovered: boolean; backend: "opfs" | "indexeddb"; revision?: number; bytes?: number; sha256?: string; } export interface StorageProjectReadResult { projectId: string; revision: number; bytes: number; sha256: string; backend: "opfs" | "indexeddb"; recovered: boolean; buffer: ArrayBuffer; } export interface StorageOperationResult { id: string; projectId: string; revision: number; persisted: boolean; } export interface StorageOperationRecord { id: string; projectId: string; revision: number; payload: unknown; inversePayload?: unknown; createdAt: string; } export interface StorageOperationListResult { projectId: string; afterRevision: number; operations: StorageOperationRecord[]; quarantined: number; } export interface StorageOperationPruneResult { projectId: string; throughRevision: number; removed: number; } export interface StorageSnapshotRecord { projectId: string; revision: number; bytes: number; sha256: string; createdAt: string; } export interface StorageSnapshotResult extends StorageSnapshotRecord { persisted: boolean; } export interface StorageSnapshotListResult { projectId: string; snapshots: StorageSnapshotRecord[]; } export interface StorageSnapshotReadResult extends StorageSnapshotRecord { buffer: ArrayBuffer; } export interface StorageAssetRecord { assetId: string; projectId: string; sha256: string; bytes: number; mimeType: string; sourcePath?: string; path: string; createdAt: string; lastAccessAt: string; } export interface StorageAssetPutResult extends StorageAssetRecord { persisted: boolean; deduplicated: boolean; } export interface StorageAssetReadResult { asset: StorageAssetRecord; data: ArrayBuffer; } export interface StorageAssetListResult { projectId: string; assets: StorageAssetRecord[]; } export interface StorageLODResult { projectId: string; cacheKey: string; bytes: number; persisted: boolean; path: string; } export interface StorageLODManifestResult { projectId: string; cacheKey: string; persisted: boolean; manifest?: LODCacheRecord; } export interface StorageLODManifestListResult { projectId: string; manifests: LODCacheRecord[]; } export interface StorageLODReadResult { projectId: string; cacheKey: string; data: ArrayBuffer; bytes: number; } export interface StorageLODPruneResult { projectId: string; maxBytes: number; removed: number; bytes: number; cacheKeys: string[]; } export interface StorageSimulationCacheResult { projectId: string; cacheKey: string; persisted: boolean; manifest: SimulationCacheManifestIR; path: string; } export interface StorageSimulationCacheReadResult extends StorageSimulationCacheResult { data: ArrayBuffer; } export interface StorageSimulationCacheFrameReadResult extends StorageSimulationCacheResult { frame: number; byteOffset: number; byteLength: number; data: ArrayBuffer; } export interface StorageSimulationCacheListResult { projectId: string; caches: Array<{ cacheKey: string; manifest: SimulationCacheManifestIR; path: string; createdAt: string; }>; } export interface StorageRequest { requestId: string; command: | { type: "smoke" } | { type: "info" } | { type: "ensureProject"; projectId: string } | { type: "saveProject"; projectId: string; revision: number; buffer: ArrayBuffer; faultAt?: "after-stage" | "after-scene-commit" | "quota" } | { type: "recoverProject"; projectId: string } | { type: "readProject"; projectId: string } | { type: "appendOperation"; id: string; projectId: string; revision: number; payload: unknown; inversePayload?: unknown } | { type: "listOperations"; projectId: string; afterRevision: number } | { type: "pruneOperations"; projectId: string; throughRevision: number } | { type: "saveSnapshot"; projectId: string; revision: number; buffer: ArrayBuffer; maxCount?: number; maxBytes?: number } | { type: "listSnapshots"; projectId: string } | { type: "readSnapshot"; projectId: string; revision: number } | { type: "putAsset"; projectId: string; data: ArrayBuffer; mimeType: string; sourcePath?: string } | { type: "readAsset"; projectId: string; sha256: string } | { type: "listAssets"; projectId: string } | { type: "saveLOD"; projectId: string; cacheKey: string; data: ArrayBuffer } | { type: "putLODManifest"; projectId: string; manifest: LODCacheRecord } | { type: "getLODManifest"; projectId: string; cacheKey: string } | { type: "listLODManifests"; projectId: string } | { type: "readLOD"; projectId: string; cacheKey: string } | { type: "deleteLOD"; projectId: string; cacheKey: string } | { type: "pruneLOD"; projectId: string; maxBytes: number } | { type: "putSimulationCache"; projectId: string; manifest: SimulationCacheManifestIR; data: ArrayBuffer } | { type: "readSimulationCache"; projectId: string; cacheKey: string } | { type: "readSimulationCacheFrame"; projectId: string; cacheKey: string; frame: number } | { type: "listSimulationCaches"; projectId: string }; } export interface StorageResponse { requestId: string; ok: boolean; result?: StorageSmokeResult | StorageInfoResult | StorageProjectResult | StorageSaveResult | StorageRecoveryResult | StorageProjectReadResult | StorageOperationResult | StorageOperationListResult | StorageOperationPruneResult | StorageSnapshotResult | StorageSnapshotListResult | StorageSnapshotReadResult | StorageAssetPutResult | StorageAssetReadResult | StorageAssetListResult | StorageLODResult | StorageLODManifestResult | StorageLODManifestListResult | StorageLODReadResult | StorageLODPruneResult | StorageSimulationCacheResult | StorageSimulationCacheReadResult | StorageSimulationCacheFrameReadResult | StorageSimulationCacheListResult; error?: string; errorCode?: ErrorCode; }