import type { LODCacheRecord } from "./lod"; import type { SimulationCacheManifestIR } from "./simulation-cache"; import type { RecentProjectIssue, RecentProjectRecord } from "./recent-projects"; import type { StorageBudgetBreakdown } from "./storage-budget"; import type { ErrorCode } from "./error"; import type { TexturePaintTileBindingRequestIR, TexturePaintTileBindingResultIR, TexturePaintTileCommitIR, TexturePaintTileCommitResultIR } from "./texture-paint-asset"; 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 StorageBudgetResult extends StorageBudgetBreakdown {} export interface StorageRecentProjectsResult { projects: RecentProjectRecord[]; quarantined: number; issues: RecentProjectIssue[]; } export interface StorageProjectResult { projectId: string; scenePath: string; directories: string[]; } export interface StorageProjectCleanupResult { projectId: string; removed: number; bytes: number; paths: 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 StorageSimulationCachePlaybackReadyResult extends StorageSimulationCacheResult { verifiedAt: string; } export interface StorageSimulationCachePlaybackReleaseResult { projectId: string; cacheKey: string; released: true; } export interface StorageSimulationCachePruneResult { projectId: string; maxBytes: number; beforeBytes: number; remainingBytes: number; removedBytes: number; removed: number; cacheKeys: string[]; protectedCacheKeys: string[]; budgetSatisfied: boolean; } export interface StorageSimulationCacheQuarantineIssue { cacheKey: string; code: ErrorCode; reason: string; quarantinedAt: string; } export interface StorageSimulationCacheListResult { projectId: string; caches: Array<{ cacheKey: string; manifest: SimulationCacheManifestIR; path: string; createdAt: string; lastAccessAt: string; }>; quarantined: number; issues: StorageSimulationCacheQuarantineIssue[]; } export interface StorageRequest { requestId: string; command: | { type: "smoke" } | { type: "crashForTest" } | { type: "info" } | { type: "getBudget"; projectId: string } | { type: "cleanupProject"; projectId: string } | { type: "listRecentProjects" } | { type: "touchRecentProject"; project: RecentProjectRecord } | { type: "removeRecentProject"; projectId: string } | { type: "ensureProject"; projectId: string } | { type: "saveProject"; projectId: string; revision: number; buffer: ArrayBuffer; faultAt?: "after-stage" | "after-scene-commit" | "before-metadata-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: "commitTexturePaintTile"; commit: TexturePaintTileCommitIR } | { type: "readTexturePaintTileBinding"; request: TexturePaintTileBindingRequestIR } | { 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: "prepareSimulationCachePlayback"; projectId: string; cacheKey: string } | { type: "releaseSimulationCachePlayback"; projectId: string; cacheKey: string } | { type: "readSimulationCache"; projectId: string; cacheKey: string } | { type: "readSimulationCacheFrame"; projectId: string; cacheKey: string; frame: number } | { type: "listSimulationCaches"; projectId: string } | { type: "pruneSimulationCaches"; projectId: string; maxBytes: number; protectedCacheKeys?: string[] } | { type: "cancelRequest"; targetRequestId: string }; } export interface StorageResponse { requestId: string; ok: boolean; result?: StorageSmokeResult | StorageInfoResult | StorageBudgetResult | StorageRecentProjectsResult | StorageProjectResult | StorageProjectCleanupResult | StorageSaveResult | StorageRecoveryResult | StorageProjectReadResult | StorageOperationResult | StorageOperationListResult | StorageOperationPruneResult | StorageSnapshotResult | StorageSnapshotListResult | StorageSnapshotReadResult | StorageAssetPutResult | StorageAssetReadResult | StorageAssetListResult | TexturePaintTileCommitResultIR | TexturePaintTileBindingResultIR | StorageLODResult | StorageLODManifestResult | StorageLODManifestListResult | StorageLODReadResult | StorageLODPruneResult | StorageSimulationCacheResult | StorageSimulationCacheReadResult | StorageSimulationCacheFrameReadResult | StorageSimulationCachePlaybackReadyResult | StorageSimulationCachePlaybackReleaseResult | StorageSimulationCachePruneResult | StorageSimulationCacheListResult; error?: string; errorCode?: ErrorCode; }