UNPKG

solobase-js

Version:

A 100% drop-in replacement for the Supabase JavaScript client. Self-hosted Supabase alternative with complete API compatibility.

216 lines 5.68 kB
import { SolobaseFetch } from './lib/fetch.js'; import { StorageError, FileObject, FileOptions, SearchOptions, Bucket } from './types/index.js'; export interface StorageFileApi { upload(path: string, file: File | Blob | ArrayBuffer, options?: FileOptions): Promise<{ data: { path: string; } | null; error: StorageError | null; }>; download(path: string): Promise<{ data: Blob | null; error: StorageError | null; }>; list(path?: string, options?: SearchOptions): Promise<{ data: FileObject[] | null; error: StorageError | null; }>; update(path: string, file: File | Blob | ArrayBuffer, options?: FileOptions): Promise<{ data: { path: string; } | null; error: StorageError | null; }>; move(fromPath: string, toPath: string): Promise<{ data: { message: string; } | null; error: StorageError | null; }>; copy(fromPath: string, toPath: string): Promise<{ data: { path: string; } | null; error: StorageError | null; }>; remove(paths: string[]): Promise<{ data: FileObject[] | null; error: StorageError | null; }>; createSignedUrl(path: string, expiresIn?: number): Promise<{ data: { signedUrl: string; } | null; error: StorageError | null; }>; createSignedUrls(paths: string[], expiresIn?: number): Promise<{ data: { signedUrls: { path: string; signedUrl: string; }[]; } | null; error: StorageError | null; }>; getPublicUrl(path: string): { data: { publicUrl: string; }; }; } export declare class SolobaseStorageFileApi implements StorageFileApi { private fetch; private bucketId; constructor(fetch: SolobaseFetch, bucketId: string); /** * Upload a file to the bucket */ upload(path: string, file: File | Blob | ArrayBuffer, options?: FileOptions): Promise<{ data: { path: string; } | null; error: StorageError | null; }>; /** * Download a file from the bucket */ download(path: string): Promise<{ data: Blob | null; error: StorageError | null; }>; /** * List files in the bucket */ list(path?: string, options?: SearchOptions): Promise<{ data: FileObject[] | null; error: StorageError | null; }>; /** * Update/replace a file in the bucket */ update(path: string, file: File | Blob | ArrayBuffer, options?: FileOptions): Promise<{ data: { path: string; } | null; error: StorageError | null; }>; /** * Move a file within the bucket */ move(fromPath: string, toPath: string): Promise<{ data: { message: string; } | null; error: StorageError | null; }>; /** * Copy a file within the bucket */ copy(fromPath: string, toPath: string): Promise<{ data: { path: string; } | null; error: StorageError | null; }>; /** * Remove files from the bucket */ remove(paths: string[]): Promise<{ data: FileObject[] | null; error: StorageError | null; }>; /** * Create a signed URL for a file */ createSignedUrl(path: string, expiresIn?: number): Promise<{ data: { signedUrl: string; } | null; error: StorageError | null; }>; /** * Create signed URLs for multiple files */ createSignedUrls(paths: string[], expiresIn?: number): Promise<{ data: { signedUrls: { path: string; signedUrl: string; }[]; } | null; error: StorageError | null; }>; /** * Get the public URL for a file (if bucket is public) */ getPublicUrl(path: string): { data: { publicUrl: string; }; }; } export declare class SolobaseStorageClient { private fetch; constructor(fetch: SolobaseFetch); /** * Get a reference to a storage bucket */ from(bucketId: string): StorageFileApi; /** * List all buckets */ listBuckets(): Promise<{ data: Bucket[] | null; error: StorageError | null; }>; /** * Get bucket details */ getBucket(bucketId: string): Promise<{ data: Bucket | null; error: StorageError | null; }>; /** * Create a new bucket */ createBucket(bucketId: string, options?: { public?: boolean; fileSizeLimit?: number; allowedMimeTypes?: string[]; }): Promise<{ data: Bucket | null; error: StorageError | null; }>; /** * Update bucket configuration */ updateBucket(bucketId: string, options: { public?: boolean; fileSizeLimit?: number; allowedMimeTypes?: string[]; }): Promise<{ data: { message: string; } | null; error: StorageError | null; }>; /** * Delete a bucket */ deleteBucket(bucketId: string): Promise<{ data: { message: string; } | null; error: StorageError | null; }>; /** * Empty a bucket (delete all files) */ emptyBucket(bucketId: string): Promise<{ data: { message: string; } | null; error: StorageError | null; }>; } //# sourceMappingURL=SolobaseStorageClient.d.ts.map