import { StorageClient } from '@supabase/storage-js'; import { Adapter, FilesError } from '../index.js'; interface SupabaseAdapterOptions { /** * Supabase storage bucket. Must already exist (this SDK does not create * buckets). Surfaced as `bucket` on the returned adapter for cross-adapter * API consistency (S3/R2/GCS/MinIO/Azure all expose `bucket`). */ bucket: string; /** * Existing client instance. Highest precedence. Pass either: * - a `StorageClient` (from `@supabase/storage-js`), or * - a `SupabaseClient` (from `@supabase/supabase-js`) — the adapter will * pick `client.storage` automatically. * * Useful when the consumer already constructs a Supabase client for auth * or postgrest and wants to share it with the storage adapter. */ client?: StorageClient | { storage: StorageClient; }; /** * Supabase project URL (e.g. `https://xxxx.supabase.co`). Required if * `client` is not provided. The adapter appends `/storage/v1` automatically * when constructing a `StorageClient`. Falls back to `SUPABASE_URL`, then * `NEXT_PUBLIC_SUPABASE_URL`. */ url?: string; /** * Supabase API key. The service role key is required for write operations * on RLS-protected buckets; the anon key works for public buckets. Falls * back to `SUPABASE_SERVICE_ROLE_KEY`, then `SUPABASE_KEY`, then * `NEXT_PUBLIC_SUPABASE_ANON_KEY`. */ key?: string; /** * Set to `true` if the bucket is configured as a public bucket. `url()` * will then return `getPublicUrl()` results — a permanent, unsigned URL — * instead of minting a signed read URL. * * Supabase exposes no API to detect bucket visibility from the client; if * `public: true` is set on a private bucket, the returned URL will 4xx * when fetched. */ public?: boolean; /** * Origin used to build URLs from `url()`. When set, `url(key)` returns * `${publicBaseUrl}/${key}` and skips both signing and `getPublicUrl()` — * appropriate when a CDN sits in front of the Supabase project. Implies * `public: true`. */ publicBaseUrl?: string; /** * Default expiry, in seconds, for the signed read URLs returned by * `url()` when neither `public` nor `publicBaseUrl` is set. Defaults to * 3600 (1 hour). Per-call `url(key, { expiresIn })` overrides. */ defaultUrlExpiresIn?: number; } type SupabaseAdapter = Adapter & { readonly bucket: string; }; declare const mapSupabaseError: (err?: unknown) => FilesError; declare const supabase: (opts: SupabaseAdapterOptions) => SupabaseAdapter; export { type SupabaseAdapter, type SupabaseAdapterOptions, mapSupabaseError, supabase };