import storageService from "./StorageService.js";
import type { FileData, FileMetadata, InternalUploadedFile } from '../types/index.js';
/** True if the foldered physical storage layout is enabled (default off). */
export declare function storageFolderStructureEnabled(): boolean;
/**
 * Build the storage FOLDER prefix for a file from its owner context. Returns null
 * when the foldered layout is off (file stays flat). Layout:
 *   tenants/{tenantId}/users/{userId}   — tenant + user file
 *   tenants/{tenantId}/system           — tenant + no user (system-generated)
 *   users/{userId}                       — no tenant + user file
 *   system                               — no tenant + no user (system-generated)
 * This value is stored in baasix_File.storage_folder; the full physical key is
 * `storage_folder + "/" + filename`.
 */
export declare function buildStorageFolder(ctx: {
    tenant_Id?: any;
    userCreated_Id?: any;
}): string | null;
/**
 * The SINGLE source of truth for a file's full physical storage key. Every read /
 * serve / delete / processed-cache path must resolve the key through this, so the
 * storage_folder + filename split is invisible to the rest of the system.
 *   - storage_folder set  → `${storage_folder}/${filename}`  (new foldered layout)
 *   - storage_folder null → `filename`                       (legacy flat layout)
 * Accepts either a file record or a {storage_folder, filename} pair.
 */
export declare function getStorageKey(file: {
    storage_folder?: string | null;
    filename: string;
}): string;
declare class FilesService {
    protected accountability?: any;
    protected storageService: typeof storageService;
    private itemService;
    private tempDir;
    constructor(params?: {
        accountability?: any;
    });
    /**
     * Coerce metadata values to correct types
     * Form data sends booleans as strings, need to convert them
     */
    private coerceMetadataTypes;
    createOne(fileData: FileData, metadata?: FileMetadata): Promise<string | number>;
    uploadToTemp(file: any): Promise<string>;
    handleFileUpload(tempPath: string, originalFilename: string, storage: string, uniqueid: string | number, ownerContext?: {
        tenant_Id?: any;
        userCreated_Id?: any;
    }): Promise<InternalUploadedFile>;
    getFileDetails(file: InternalUploadedFile, tempPath: string, { storage, folder, filename, title, description, type, originalFilename }: FileMetadata): Promise<any>;
    getFileType(filePath: string): Promise<string>;
    readByQuery(query: any): Promise<any>;
    readOne(id: string | number, query?: any, bypassPermissions?: boolean): Promise<any>;
    updateOne(id: string | number, fileData: FileData, metadata?: FileMetadata): Promise<string | number>;
    deleteOne(id: string | number): Promise<string | number>;
    deleteFile(file: any): Promise<void>;
    /**
     * Delete processed/resized versions of an image file.
     * Override in AssetsService for the actual implementation.
     */
    protected deleteProcessedVersions(_file: any): Promise<void>;
    uploadFromUrl(fileUrl: string, metadata?: FileMetadata): Promise<string | number>;
    downloadFile(url: string, outputLocationPath: string): Promise<void>;
    /** Read a provider object fully into a Buffer (handles both Buffer and stream). */
    private readProviderObject;
    /**
     * Migrate existing files into the foldered storage layout (tenant/user/system).
     *
     * Per file, the move is crash-safe: copy → verify → update DB pointer → delete old.
     * The file stays readable at every step (the DB only points at the new key once the
     * copy is verified). Idempotent: files already in the new layout are skipped, so the
     * migration is safely resumable / re-runnable. Per-file errors are recorded and
     * skipped, never fatal.
     *
     * @param options.dryRun  When true, only report the planned moves; touch nothing.
     * @param options.limit   Max files to process this call (for batching large sets).
     * @returns A summary { scanned, moved, skipped, failed, planned[] }.
     */
    migrateStorageStructure(options?: {
        dryRun?: boolean;
        limit?: number;
    }): Promise<{
        dryRun: boolean;
        scanned: number;
        moved: number;
        skipped: number;
        failed: number;
        planned: Array<{
            id: any;
            from: string;
            to: string;
            status: string;
            error?: string;
        }>;
    }>;
}
export default FilesService;
//# sourceMappingURL=FilesService.d.ts.map