import PocketBaseClient from 'pocketbase'; import { Adapter, FilesError } from '../index.js'; interface PocketBaseAdapterOptions { /** * Collection name (or id) that holds the file records. Must already exist * with the configured `keyField` (unique-indexed text) and `fileField` * (single-value file). The adapter does not create or migrate the * collection — set it up via the PocketBase admin UI or migrations first. */ collection: string; /** * Existing PocketBase client. Highest precedence — when passed, all auth * options below are ignored. Useful when the host app already shares one * client across auth, realtime, and storage. */ client?: PocketBaseClient; /** * PocketBase backend URL (e.g. `https://pb.example.com`). Falls back to * `POCKETBASE_URL`. */ url?: string; /** * Superuser email. Combined with `adminPassword` to auth as a superuser * before each session. Falls back to `POCKETBASE_ADMIN_EMAIL`. */ adminEmail?: string; /** * Superuser password. Falls back to `POCKETBASE_ADMIN_PASSWORD`. */ adminPassword?: string; /** * Pre-issued auth token. Saved into the client's `authStore` directly — * use this when you already have a token from elsewhere (e.g. an OAuth2 * exchange or a custom user auth flow). Falls back to * `POCKETBASE_AUTH_TOKEN`. Mutually exclusive with the admin email/password * pair; if both are provided, the explicit token wins. */ authToken?: string; /** * Name of the text field on the collection holding the user-facing key. * Must be unique-indexed. Defaults to `"key"`. */ keyField?: string; /** * Name of the single-file field on the collection holding the body. * Defaults to `"file"`. */ fileField?: string; /** * Origin used to build URLs from `url()`. When set, `url(key)` returns * `${publicBaseUrl}/${key}` and skips PocketBase's file URL entirely — * appropriate when a CDN sits in front of the PB instance. When unset, * `url()` falls back to `pb.files.getURL(record, filename)`. */ publicBaseUrl?: string; } type PocketBaseAdapter = Adapter & { readonly collection: string; }; declare const mapPocketBaseError: (err: unknown) => FilesError; declare const pocketbase: (opts: PocketBaseAdapterOptions) => PocketBaseAdapter; export { type PocketBaseAdapter, type PocketBaseAdapterOptions, mapPocketBaseError, pocketbase };