import { F as File, L as LocalMetaStorageOptions, i as BaseStorageOptions, M as MetaStorage, d as FileInit, O as OperationOptions, e as FilePart, f as FileQuery, g as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-C9EdfTf1.js"; import { L as LocalMetaStorage } from "../../packem_shared/local-meta-storage.d-CYWYyCUo.js"; import 'node:stream'; import 'node:timers'; import 'node:crypto'; import 'node:http'; import 'lru-cache'; declare class PocketBaseFile extends File { bucket?: string; path?: string; publicUrl?: string; } declare class PocketBaseMetaStorage extends LocalMetaStorage { constructor(config?: LocalMetaStorageOptions); } /** * Minimal structural type for the PocketBase client used by the adapter. * Declared locally so the package does not require `pocketbase` to be * installed for type-checking (it is an optional peer dependency). */ interface PocketBaseClientLike { authStore: { isValid: boolean; save: (token: string, model: unknown) => void; }; collection: (name: string) => { authWithPassword: (email: string, password: string) => Promise; create: (body: unknown) => Promise; delete: (id: string) => Promise; getFirstListItem: (filter: string) => Promise; getList: (page: number, perPage: number) => Promise<{ items: PocketBaseRecord[]; }>; update: (id: string, body: unknown) => Promise; }; files: { getToken: () => Promise; getURL?: (record: PocketBaseRecord, filename: string, options?: { token?: string; }) => string; getUrl?: (record: PocketBaseRecord, filename: string, options?: { token?: string; }) => string; }; filter: (raw: string, parameters?: Record) => string; } /** * Minimal structural type for a PocketBase record. The file field holds the * stored filename string; the key field holds the logical object key. */ interface PocketBaseRecord { [field: string]: unknown; id: string; } interface PocketBaseStorageOptions extends BaseStorageOptions { /** * Superuser email used for lazy authentication. Ignored when `client` or * `authToken` is supplied. Falls back to `POCKETBASE_ADMIN_EMAIL`. */ adminEmail?: string; /** * Superuser password used for lazy authentication. Ignored when `client` * or `authToken` is supplied. Falls back to `POCKETBASE_ADMIN_PASSWORD`. */ adminPassword?: string; /** * Pre-saved auth token stored on the client's `authStore`. Ignored when * `client` is supplied. Falls back to `POCKETBASE_AUTH_TOKEN`. */ authToken?: string; /** * Pre-built `PocketBase` instance. Mutually exclusive with `url`. When * supplied it is used as-is and no authentication is performed. */ client?: PocketBaseClientLike; /** * Collection name backing the object store. Each record holds exactly one * file. Required — the adapter does not create the collection. */ collection: string; /** * Default expiry, in seconds, for `getReadUrl`. PocketBase file tokens are * short-lived; a fresh token is requested per call. Defaults to 3600. */ defaultUrlExpiresIn?: number; /** * File field on the collection holding the stored file. Defaults to `file`. */ fileField?: string; /** * Text field on the collection holding the logical object key. Defaults * to `key`. */ keyField?: string; /** * Configure metafiles storage. Used for TUS-style resumable upload * bookkeeping. Defaults to {@link LocalMetaStorage} under the OS tmp * directory. */ metaStorageConfig?: LocalMetaStorageOptions; /** * Public base URL for served files. When set, `getReadUrl` returns * `${publicBaseUrl}/${key}` without requesting a file token. */ publicBaseUrl?: string; /** * PocketBase instance URL (e.g. `https://pb.example.com`). Ignored when * `client` is supplied. Falls back to `POCKETBASE_URL`. */ url?: string; } /** * PocketBase storage backend. * * PocketBase is record-based: a collection where each record holds exactly * one file. This adapter maps the object store onto such a collection, * keying records by a text field (`keyField`) and storing bytes in a file * field (`fileField`). Uploads are single-shot — the part stream is buffered * and sent as one multipart request. * @example * ```ts * import { PocketBaseStorage } from "@visulima/storage/provider/pocketbase"; * * const storage = new PocketBaseStorage({ * url: process.env.POCKETBASE_URL, * adminEmail: process.env.POCKETBASE_ADMIN_EMAIL, * adminPassword: process.env.POCKETBASE_ADMIN_PASSWORD, * collection: "uploads", * }); * ``` * @remarks * - ⚠️ Per-operation `signal`/`timeout` are best-effort: the underlying SDK does not support request cancellation, so an in-flight call may complete server-side even after abort. `retries` is honored. */ declare class PocketBaseStorage extends BaseStorage { static override readonly name: string; override checksumTypes: string[]; protected meta: MetaStorage; private readonly client; private readonly collectionName; private readonly defaultUrlExpiresIn; private readonly fileField; private readonly keyField; private readonly publicBaseUrl?; private ensureAuth; constructor(config: PocketBaseStorageOptions); override get raw(): PocketBaseClientLike; create(config: FileInit, _options?: OperationOptions): Promise; write(part: FilePart | FileQuery | PocketBaseFile, options?: OperationOptions): Promise; delete({ id }: FileQuery, options?: OperationOptions): Promise; override exists({ id }: FileQuery, options?: OperationOptions): Promise; get({ id }: FileQuery, options?: OperationOptions): Promise; copy(name: string, destination: string, options?: OperationOptions & { storageClass?: string; }): Promise; move(name: string, destination: string, options?: OperationOptions): Promise; override list(limit?: number, options?: OperationOptions): Promise; override getReadUrl(key: string, options?: { expiresIn?: number; responseContentDisposition?: string; responseContentType?: string; }): Promise; private findRecord; private putRecord; private getMetaSafe; private internalOnComplete; } export { PocketBaseFile, PocketBaseMetaStorage, PocketBaseStorage, type PocketBaseStorageOptions };