import type { Pool } from 'pg';
type JsonObject = Record<string, unknown>;
export type StorageStatusCode = 400 | 401 | 403 | 404 | 409 | 413 | 415 | 416 | 500 | 503;
export declare class StorageError extends Error {
    readonly code: string;
    readonly statusCode: StorageStatusCode;
    constructor(message: string, code: string, statusCode: StorageStatusCode);
}
export type StorageResult<T> = {
    data: T;
    error: null;
} | {
    data: null;
    error: StorageError;
};
export interface StorageBucket {
    id: string;
    name: string;
    owner: string | null;
    owner_id: string | null;
    public: boolean;
    file_size_limit: number | null;
    allowed_mime_types: string[] | null;
    created_at: string;
    updated_at: string;
}
export interface BucketOptions {
    public?: boolean;
    fileSizeLimit?: number | null;
    allowedMimeTypes?: string[] | null;
}
export interface UploadOptions {
    cacheControl?: string;
    contentType?: string;
    upsert?: boolean;
    metadata?: JsonObject;
}
export interface SignedUrlOptions {
    download?: boolean | string;
}
export interface UploadedObject {
    path: string;
    fullPath: string;
}
export interface RemovedObject {
    id: string;
    bucket_id: string;
    name: string;
}
export interface StoredObject {
    id: string;
    bucketId: string;
    name: string;
    bytes: Buffer;
    size: number;
    contentType: string;
    etag: string | null;
    checksum: string | null;
    cacheControl: string | null;
    createdAt: string;
    updatedAt: string;
    isPublic: boolean;
}
export interface SignedAccess {
    download: boolean | string;
    expiresAt: number;
}
export interface LocalStorageOptions {
    root?: string;
    publicBaseUrl?: string;
    routePrefix?: string;
    signingSecret?: string;
}
export declare class LocalStorageService {
    private readonly pool;
    readonly storageRoot: string;
    readonly publicBaseUrl: string;
    readonly routePrefix: string;
    private readonly signingSecret;
    constructor(pool?: Pool, options?: LocalStorageOptions);
    from(bucketId: string): LocalStorageBucketClient;
    listBuckets(): Promise<StorageResult<StorageBucket[]>>;
    createBucket(bucketId: string, options?: BucketOptions): Promise<StorageResult<{
        name: string;
    }>>;
    updateBucket(bucketId: string, options: BucketOptions): Promise<StorageResult<{
        message: string;
    }>>;
    bucketIsPublic(bucketId: string): Promise<boolean>;
    publicUrl(bucketId: string, objectPath: string): string;
    signedUrl(bucketId: string, objectPath: string, expiresIn: number, options?: SignedUrlOptions): Promise<{
        signedUrl: string;
    }>;
    verifySignedAccess(token: string, bucketId: string, objectPath: string): SignedAccess;
    upload(bucketId: string, objectPath: string, body: unknown, options?: UploadOptions): Promise<StorageResult<UploadedObject>>;
    download(bucketId: string, objectPath: string): Promise<StorageResult<Blob>>;
    remove(bucketId: string, objectPaths: string[]): Promise<StorageResult<RemovedObject[]>>;
    readObject(bucketId: string, objectPath: string): Promise<StoredObject>;
    private uploadOrThrow;
    private removeOrThrow;
    private objectRow;
    private rowLocalPath;
    private resolveRelative;
    private ensureRoot;
    private ensureSafeParent;
    private assertSafeFileSystemPath;
    private regularFileExists;
}
export declare class LocalStorageBucketClient {
    private readonly service;
    private readonly bucketId;
    constructor(service: LocalStorageService, bucketId: string);
    upload(path: string, body: unknown, options?: UploadOptions): Promise<StorageResult<UploadedObject>>;
    download(path: string): Promise<StorageResult<Blob>>;
    remove(paths: string[]): Promise<StorageResult<RemovedObject[]>>;
    getPublicUrl(path: string): {
        data: {
            publicUrl: string;
        };
    };
    createSignedUrl(path: string, expiresIn: number, options?: SignedUrlOptions): Promise<StorageResult<{
        signedUrl: string;
    }>>;
}
export declare const storageService: LocalStorageService;
export {};
//# sourceMappingURL=service.d.ts.map