import { type DeclaredMimeType, type DetectedMimeType, type FileChecksumSha256, type NonEmptyArray, type PositiveByteCount, type Result, type StorageBucketName, type StoragePath, type UtcIsoDateTimeString } from '@riverbankcms/core';
import { type AccessPolicy, type FileAssetId, type FileKind, type FileUse, type StorageClass, type UploadPolicyPostProcessTag } from './fileDomain';
import type { FileUploadSessionRecord } from './filePersistence';
export type FinalizableUploadSessionState = Extract<FileUploadSessionRecord['state'], {
    readonly tag: 'pending' | 'uploaded' | 'finalizing';
}>;
export type FinalizedUploadSessionState = Extract<FileUploadSessionRecord['state'], {
    readonly tag: 'finalized';
}>;
export type FinalizableFileUploadSessionRecord = Omit<FileUploadSessionRecord, 'state'> & {
    readonly state: FinalizableUploadSessionState;
};
export type FinalizedFileUploadSessionRecord = Omit<FileUploadSessionRecord, 'state'> & {
    readonly state: FinalizedUploadSessionState;
};
export type FileUploadFinalizationError = 'checksum-mismatch' | 'checksum-missing' | 'declared-detected-mime-mismatch' | 'file-too-large' | 'kind-not-allowed' | 'policy-intent-mismatch' | 'storage-bucket-mismatch' | 'storage-path-mismatch' | 'upload-session-expired' | 'upload-session-not-finalizable' | 'unsupported-declared-mime-type' | 'unsupported-detected-mime-type';
export type FileUploadFinalizationInput = {
    readonly uploadSession: FileUploadSessionRecord;
    readonly requestedStorageBucket: StorageBucketName;
    readonly requestedStoragePath: StoragePath;
    readonly detectedMimeType: DetectedMimeType;
    readonly declaredMimeType?: DeclaredMimeType;
    readonly byteCount: PositiveByteCount;
    readonly checksumSha256?: FileChecksumSha256;
    readonly now: UtcIsoDateTimeString;
};
export type FileUploadFinalizationPlan = {
    readonly tag: 'return-existing-asset';
    readonly assetId: FileAssetId;
    readonly uploadSession: FinalizedFileUploadSessionRecord;
} | {
    readonly tag: 'finalize-upload';
    readonly uploadSession: FinalizableFileUploadSessionRecord;
    readonly detectedMimeType: DetectedMimeType;
    readonly detectedKind: FileKind;
    readonly fileUses: NonEmptyArray<FileUse>;
    readonly accessPolicy: AccessPolicy;
    readonly storageClass: StorageClass;
    readonly targetStorageBucket: StorageBucketName;
    readonly postProcess: {
        readonly tag: UploadPolicyPostProcessTag;
    };
    readonly byteCount: PositiveByteCount;
    readonly checksumSha256?: FileChecksumSha256;
};
export declare function planFileUploadFinalization(input: FileUploadFinalizationInput): Result<FileUploadFinalizationPlan, FileUploadFinalizationError>;
