import { type BrowserDownload as BrowserDownloadValue, type BrowserDownloadSaveRequest as BrowserDownloadSaveRequestValue, type BrowserDownloadSaveResponse as BrowserDownloadSaveResponseValue } from "@opengeni/contracts"; import { type Database } from "./database.js"; import * as schema from "./schema.js"; type OperationRow = typeof schema.interactionResourceOperations.$inferSelect; type SaveMetadata = { browserSessionId: string; controllerGeneration: string; sourceSessionId: string; destinationPath: string; overwrite: boolean; fileId: string; uploadId: string; objectKey: string; safeFilename: string; contentType: string; download: BrowserDownloadValue; }; export type BrowserDownloadSavePreparation = SaveMetadata & { operationId: string; state: OperationRow["state"]; errorCode: string | null; replayed: boolean; dispatchedNow: boolean; response: BrowserDownloadSaveResponseValue | null; }; type SaveIdentity = { accountId: string; workspaceId: string; actorSubjectId: string; browserSessionId: string; downloadId: string; request: BrowserDownloadSaveRequestValue; }; export declare function findBrowserDownloadSave(db: Database, inputValue: SaveIdentity): Promise; export declare function prepareBrowserDownloadSave(db: Database, inputValue: SaveIdentity & { sourceSessionId: string; download: BrowserDownloadValue; fileId: string; safeFilename: string; contentType: string; bucket: string; objectKey: string; uploadExpiresAt: Date; /** The download was retained as this workspace file before its browser's * controller went away: the save reuses it instead of a new upload, and * does not need the browser to be running. */ retained?: { fileId: string; uploadId: string; }; }): Promise; /** A completed download kept as a workspace file after its browser's * working directory went away (suspension removes it). */ export type RetainedBrowserDownload = { download: BrowserDownloadValue; fileId: string; uploadId: string; objectKey: string; safeFilename: string; contentType: string; }; type RetainedScope = { accountId: string; workspaceId: string; browserSessionId: string; }; /** The browser's chat lost its creation binding, or its private chat has no owner. */ export declare class BrowserDownloadOwnerUnavailableError extends Error { } /** * Whose private files a browser's kept downloads are: the owner of the chat * that created the browser when that chat is private, else null (workspace * files). Read with system authority, because the request saving the browser * (a capacity save) may not see another person's private chat; the read is * bound to the browser's own creating chat and only decides file ownership. */ export declare function getBrowserDownloadPrivateOwner(db: Database, input: RetainedScope & { sourceSessionId: string; }): Promise; /** Record that a completed download is retained as a ready workspace file. * Idempotent per download: the first retained file wins. */ export declare function recordRetainedBrowserDownload(db: Database, input: RetainedScope & { download: BrowserDownloadValue; fileId: string; uploadId: string; }): Promise; /** Every download of a browser kept as a ready workspace file, oldest first. */ export declare function listRetainedBrowserDownloads(db: Database, input: RetainedScope): Promise; export declare function getRetainedBrowserDownload(db: Database, input: RetainedScope & { downloadId: string; }): Promise; export declare function dispatchBrowserDownloadSave(db: Database, inputValue: SaveIdentity): Promise; export declare function completeBrowserDownloadSave(db: Database, inputValue: SaveIdentity): Promise; export declare function settleBrowserDownloadSaveFailure(db: Database, inputValue: SaveIdentity & { state: "failed" | "outcome_unknown"; errorCode: string; }): Promise; export {};