import type { Adapter } from "../index.js"; /** * A value the {@link MemoryAdapterOptions.initial} seed accepts for one key. * * The constructor is synchronous, so a seed body must be convertible to bytes * without awaiting — that rules out `Blob`/`File` (their `arrayBuffer()` is * async) and `ReadableStream`. Seed those by calling `upload()` after * construction instead. The object form lets a fixture pin a `contentType` / * `metadata` / `cacheControl` the way an `upload()` call would. */ export type MemorySeed = string | Uint8Array | ArrayBuffer | ArrayBufferView | { body: string | Uint8Array | ArrayBuffer | ArrayBufferView; contentType?: string; metadata?: Record; cacheControl?: string; }; export interface MemoryAdapterOptions { /** * Keys to pre-populate the store with, useful for tests that need fixtures * present up front. Each value is a body (string or bytes) or an object that * also pins `contentType` / `metadata` / `cacheControl`. Bodies are copied * in, so later mutation of a passed buffer does not change the stored bytes. */ initial?: Record; } /** One stored object: its bytes plus the metadata reads round-trip. */ export interface MemoryEntry { bytes: Uint8Array; contentType: string; metadata?: Record; cacheControl?: string; etag: string; lastModified: number; } /** * One change to the store, as the memory adapter reports it to * {@link MemoryAdapter.subscribe} listeners: its native bucket notification, * the way S3 or R2 emit theirs. `files-sdk/events` turns it into a * `FileEvent`, so event handlers can be tested with no provider setup. */ export interface MemoryNotification { type: "created" | "deleted"; key: string; size?: number; etag?: string; contentType?: string; /** ms since the epoch. */ time: number; /** Increases by one per notification from this adapter; unique within it. */ sequence: number; } /** * The `raw` escape hatch is the backing `Map`, so callers can inspect or reset * the store directly in tests — `adapter.raw.clear()`, `adapter.raw.size`, etc. * Changes made through `raw` bypass {@link MemoryAdapter.subscribe}. * * `move` is narrowed to required: the adapter always re-keys natively (no * copy+delete fallback), so callers can rely on it without an optional guard. */ export type MemoryAdapter = Adapter> & Required>, "move">> & { /** * Listen for every object this adapter creates (upload, copy, move * destination, resumable completion) or deletes (delete or move source of * a key that existed). Listeners run synchronously after the change, and a * throwing listener never fails the write. Returns an unsubscribe function. */ subscribe: (listener: (change: MemoryNotification) => void) => () => void; }; export declare const memory: (opts?: MemoryAdapterOptions) => MemoryAdapter; //# sourceMappingURL=index.d.ts.map