import type { Adapter } from "../index.js"; type ConvexStorageId = string; interface ConvexStorageDoc { _id: ConvexStorageId; _creationTime: number; contentType?: string | null; sha256: string; size: number; } interface ConvexStorageLike { getUrl(storageId: ConvexStorageId): Promise; store?(blob: Blob, options?: { sha256?: string; }): Promise; get?(storageId: ConvexStorageId): Promise; getMetadata?(storageId: ConvexStorageId): Promise<{ contentType: string | null; sha256: string; size: number; } | null>; delete?(storageId: ConvexStorageId): Promise; generateUploadUrl?(): Promise; } interface ConvexPaginationResult { page: ConvexStorageDoc[]; isDone: boolean; continueCursor: string; } interface ConvexSystemQuery { paginate(opts: { numItems: number; cursor: string | null; }): Promise; } interface ConvexSystemReader { get(table: "_storage", storageId: ConvexStorageId): Promise; query(tableName: "_storage"): ConvexSystemQuery; } /** * The Convex function context the adapter wraps — the `ctx` passed to your * `action`, `mutation`, or `query` handler. Only `ctx.storage` (with `getUrl`) * and the optional `ctx.db.system` are used, so any real Convex context is * structurally assignable. */ export interface ConvexCtx { storage: ConvexStorageLike; db?: { system: ConvexSystemReader; }; } export interface ConvexAdapterOptions { /** * The Convex function context (`ctx`) for the current request. Construct the * adapter per-call inside a Convex function: `convex({ ctx })`. * * Which operations work depends on the context Convex gives you: * - **action / httpAction** — `upload`, `download`, `delete`, `url`, `head`, * `exists`, `signedUploadUrl`. `list` throws (no `ctx.db`). * - **mutation** — `delete`, `url`, `head`, `exists`, `list`, * `signedUploadUrl`. `upload` / `download` throw (no `ctx.storage.store` / * `get` outside actions). * - **query** — `url`, `head`, `exists`, `list` (all read-only). * * The adapter feature-detects the underlying primitive and throws a * descriptive error when it is unavailable in the current context. */ ctx: ConvexCtx; } export type ConvexAdapter = Adapter; export declare const convex: (opts: ConvexAdapterOptions) => ConvexAdapter; export {}; //# sourceMappingURL=index.d.ts.map