import { type Type } from 'arktype'; import { type TargetModelParams, type OnCallCreateModelResult, type FirestoreModelKey } from '../../common'; import { type ModelFirebaseCrudFunction, type FirebaseFunctionTypeConfigMap, type ModelFirebaseCrudFunctionConfigMap, type ModelFirebaseFunctionMap, type ModelFirebaseCreateFunction } from '../../client'; import { type StorageFileSignedDownloadUrl, type StorageFileTypes } from './storagefile'; import { type StorageFileKey, type StorageFileId } from './storagefile.id'; import { type StorageBucketId, type StoragePath, type StorageSlashPath } from '../../common/storage'; import { type ContentDispositionString, type ContentTypeMimeType, type Maybe, type Milliseconds, type UnixDateTimeSecondsNumber } from '@dereekb/util'; import { type SendNotificationResult } from '../notification/notification.api'; export declare const DOWNLOAD_MULTIPLE_STORAGE_FILES_MIN_FILES = 1; export declare const DOWNLOAD_MULTIPLE_STORAGE_FILES_MAX_FILES = 50; /** * Parameters for directly creating a new StorageFile document (no upload initialization). * * Typically used server-side or for testing. Validated with {@link createStorageFileParamsType}. */ export interface CreateStorageFileParams { } export declare const createStorageFileParamsType: Type; /** * Parameters for batch-initializing all files found in the uploads folder. * * Scans the uploads folder (or a custom path) and runs the upload determination/initialization * pipeline for each file found. Validated with {@link initializeAllStorageFilesFromUploadsParamsType}. */ export interface InitializeAllStorageFilesFromUploadsParams { readonly maxFilesToInitialize?: Maybe; readonly folderPath?: Maybe; readonly overrideUploadsFolderPath?: Maybe; } export declare const initializeAllStorageFilesFromUploadsParamsType: Type; /** * Result of batch upload initialization, reporting visit and success/failure counts. */ export interface InitializeAllStorageFilesFromUploadsResult extends OnCallCreateModelResult { readonly filesVisited: number; readonly initializationsSuccessCount: number; readonly initializationsFailureCount: number; } /** * Parameters for initializing a single StorageFile from an uploaded file at a specific storage path. * * The file is run through the upload type determination pipeline and, if matched, * creates a corresponding StorageFile document. Validated with {@link initializeStorageFileFromUploadParamsType}. */ export interface InitializeStorageFileFromUploadParams extends Pick { readonly bucketId?: Maybe; readonly pathString: StorageSlashPath; readonly expediteProcessing?: Maybe; } export declare const initializeStorageFileFromUploadParamsType: Type; /** * Parameters for triggering processing of a specific StorageFile. * * Supports various modes: immediate processing, retry checking, force restart, * and reprocessing already-successful files. Validated with {@link processStorageFileParamsType}. */ export interface ProcessStorageFileParams extends TargetModelParams { readonly runImmediately?: Maybe; readonly checkRetryProcessing?: Maybe; readonly forceRestartProcessing?: Maybe; readonly processAgainIfSuccessful?: Maybe; } export declare const processStorageFileParamsType: Type; export interface ProcessStorageFileResult { readonly runImmediately: boolean; readonly expediteResult: Maybe; } /** * Processes all StorageFiles that are queued for processing. */ export interface ProcessAllQueuedStorageFilesParams { } export declare const processAllQueuedStorageFilesParamsType: Type; export interface ProcessAllQueuedStorageFilesResult { readonly storageFilesVisited: number; readonly storageFilesProcessStarted: number; readonly storageFilesFailedStarting: number; } export interface UpdateStorageFileParams extends TargetModelParams { readonly sdat?: Maybe; } export declare const updateStorageFileParamsType: Type; export interface DeleteStorageFileParams extends TargetModelParams { readonly force?: Maybe; } export declare const deleteStorageFileParamsType: Type; /** * Processes all StorageFiles that are queued for processing. */ export interface DeleteAllQueuedStorageFilesParams { } export declare const deleteAllQueuedStorageFilesParamsType: Type; export interface DeleteAllQueuedStorageFilesResult { readonly storageFilesVisited: number; readonly storageFilesDeleted: number; readonly storageFilesFailedDeleting: number; } /** * Shared download options for StorageFile downloads. * * Supports custom expiration, content disposition, and content type overrides. * Admin downloads (`asAdmin`) allow longer expiration times. */ export interface DownloadStorageFileOptions { readonly expiresAt?: Maybe; readonly expiresIn?: Maybe; readonly responseDisposition?: Maybe; readonly responseContentType?: Maybe; readonly asAdmin?: Maybe; } /** * Parameters for generating a signed download URL for a single StorageFile. * * Extends {@link DownloadStorageFileOptions} with target model key. * Validated with {@link downloadStorageFileParamsType}. */ export interface DownloadStorageFileParams extends TargetModelParams, DownloadStorageFileOptions { } export declare const downloadStorageFileParamsType: Type; /** * Result of downloading a StorageFile. */ export interface DownloadStorageFileResult { readonly url: StorageFileSignedDownloadUrl; readonly fileName?: Maybe; readonly mimeType?: Maybe; readonly expiresAt?: Maybe; } /** * Per-file download options, excluding `asAdmin` which is controlled at the batch level. * * Each per-file option overrides the corresponding default from the parent {@link DownloadMultipleStorageFilesParams}. */ export interface DownloadMultipleStorageFilesFileParams extends TargetModelParams, Omit { } export declare const downloadMultipleStorageFilesFileParamsType: Type; /** * Success item in a batch download result. * * Extends the single-file {@link DownloadStorageFileResult} with the document key for correlation. */ export interface DownloadMultipleStorageFileSuccessItem extends DownloadStorageFileResult { readonly key: StorageFileKey; } /** * Error item in a batch download result. * * Includes the document key and a human-readable error message. */ export interface DownloadMultipleStorageFileErrorItem { readonly key: StorageFileKey; readonly error: string; } /** * Parameters for batch-downloading multiple StorageFiles. * * Top-level {@link DownloadStorageFileOptions} serve as defaults for all files. * Each item in `files` can override per-file options (except `asAdmin`, which is root-level only). * Validated with {@link downloadMultipleStorageFilesParamsType}. * * @example * ```ts * const params: DownloadMultipleStorageFilesParams = { * expiresIn: 1800000, * files: [ * { key: 'storageFile/abc' }, * { key: 'storageFile/def', expiresIn: 60000 } * ] * }; * ``` */ export interface DownloadMultipleStorageFilesParams extends DownloadStorageFileOptions { readonly files: DownloadMultipleStorageFilesFileParams[]; /** * When true, throws on the first download failure instead of collecting it in the errors array. */ readonly throwOnFirstError?: Maybe; } export declare const downloadMultipleStorageFilesParamsType: Type; /** * Result of a batch StorageFile download. * * Contains separate arrays for successful downloads and failures. * Individual download errors do not fail the entire batch. */ export interface DownloadMultipleStorageFilesResult { readonly success: DownloadMultipleStorageFileSuccessItem[]; readonly errors: DownloadMultipleStorageFileErrorItem[]; } /** * Used for creating or initializing a new StorageFileGroup for a StorageFile. * * Mainly used for testing. Not exposed to the API. * * The preferred way is to create a StorageFileGroup through a StorageFile. */ export interface CreateStorageFileGroupParams { readonly model?: Maybe; readonly storageFileId?: Maybe; } export declare const createStorageFileGroupParamsType: Type; export interface SyncStorageFileWithGroupsParams extends TargetModelParams { readonly force?: Maybe; } export declare const syncStorageFileWithGroupsParamsType: Type; export interface SyncStorageFileWithGroupsResult { readonly storageFilesGroupsCreated: number; readonly storageFilesGroupsUpdated: number; } export interface SyncAllFlaggedStorageFilesWithGroupsParams { } export declare const syncAllFlaggedStorageFilesWithGroupsParamsType: Type; export interface SyncAllFlaggedStorageFilesWithGroupsResult { readonly storageFilesSynced: number; readonly storageFilesGroupsCreated: number; readonly storageFilesGroupsUpdated: number; } export interface UpdateStorageFileGroupEntryParams { readonly s: StorageFileId; readonly n?: Maybe; } export declare const updateStorageFileGroupEntryParamsType: Type; export interface UpdateStorageFileGroupParams extends TargetModelParams { readonly entries?: Maybe; } export declare const updateStorageFileGroupParamsType: Type; export interface RegenerateStorageFileGroupContentParams extends TargetModelParams { readonly force?: Maybe; } export declare const regenerateStorageFileGroupContentParamsType: Type; export interface RegenerateStorageFileGroupContentResult { readonly contentStorageFilesFlaggedForProcessing: number; } export interface RegenerateAllFlaggedStorageFileGroupsContentParams { } export declare const regenerateAllFlaggedStorageFileGroupsContentParamsType: Type; export interface RegenerateAllFlaggedStorageFileGroupsContentResult { readonly storageFileGroupsUpdated: number; readonly contentStorageFilesFlaggedForProcessing: number; } /** * Used for initializing an uninitialized model like NotificationBox or NotificationSummary. */ export interface InitializeStorageFileModelParams extends TargetModelParams { readonly throwErrorIfAlreadyInitialized?: Maybe; } export declare const initializeStorageFileModelParamsType: Type; export interface InitializeAllApplicableStorageFileGroupsParams { } export declare const initializeAllApplicableStorageFileGroupsParamsType: Type; export interface InitializeAllApplicableStorageFileGroupsResult { readonly storageFileGroupsVisited: number; readonly storageFileGroupsSucceeded: number; readonly storageFileGroupsFailed: number; readonly storageFileGroupsAlreadyInitialized: number; } /** * Custom (non-CRUD) function type map for StorageFile. Currently empty — all operations use CRUD functions. */ export type StorageFileFunctionTypeMap = {}; export declare const storageFileFunctionTypeConfigMap: FirebaseFunctionTypeConfigMap; /** * CRUD function configuration map for the StorageFile model family. * * Defines all callable cloud function endpoints for StorageFile and StorageFileGroup, * including creation (direct, from upload, batch), processing, sync, download, and deletion. * * Used by {@link StorageFileFunctions} and {@link storageFileFunctionMap} to generate * typed callable function references. */ export type StorageFileModelCrudFunctionsConfig = { readonly storageFile: { create: { _: CreateStorageFileParams; fromUpload: InitializeStorageFileFromUploadParams; allFromUpload: [InitializeAllStorageFilesFromUploadsParams, InitializeAllStorageFilesFromUploadsResult]; }; update: { _: UpdateStorageFileParams; process: [ProcessStorageFileParams, ProcessStorageFileResult]; syncWithGroups: [SyncStorageFileWithGroupsParams, SyncStorageFileWithGroupsResult]; }; read: { download: [DownloadStorageFileParams, DownloadStorageFileResult]; downloadMultiple: [DownloadMultipleStorageFilesParams, DownloadMultipleStorageFilesResult]; }; delete: { _: DeleteStorageFileParams; }; }; readonly storageFileGroup: { update: { _: UpdateStorageFileGroupParams; regenerateContent: [RegenerateStorageFileGroupContentParams, RegenerateStorageFileGroupContentResult]; }; }; }; export declare const storageFileModelCrudFunctionsConfig: ModelFirebaseCrudFunctionConfigMap; /** * Abstract class defining all callable StorageFile cloud functions. * * Implement this in your app module to wire up the function endpoints. * Use {@link storageFileFunctionMap} to create a client-side callable map. */ export declare abstract class StorageFileFunctions implements ModelFirebaseFunctionMap { abstract storageFile: { createStorageFile: { create: ModelFirebaseCreateFunction; fromUpload: ModelFirebaseCreateFunction; allFromUpload: ModelFirebaseCrudFunction; }; updateStorageFile: { update: ModelFirebaseCrudFunction; process: ModelFirebaseCrudFunction; syncWithGroups: ModelFirebaseCrudFunction; }; readStorageFile: { download: ModelFirebaseCrudFunction; downloadMultiple: ModelFirebaseCrudFunction; }; deleteStorageFile: { delete: ModelFirebaseCrudFunction; }; }; abstract storageFileGroup: { updateStorageFileGroup: { update: ModelFirebaseCrudFunction; regenerateContent: ModelFirebaseCrudFunction; }; }; } /** * Client-side callable function map factory for all StorageFile and StorageFileGroup CRUD operations. * * @example * ```ts * const functions = storageFileFunctionMap(callableFactory); * const result = await functions.storageFile.createStorageFile.fromUpload({ pathString: 'uploads/u/123/avatar.png' }); * ``` */ export declare const storageFileFunctionMap: import("../..").ModelFirebaseFunctionMapFactory;