export type PayloadTypes = 'string' | 'file' | 'blob' | 'buffer' | 'arraybuffer' | 'formdata' | 'x-www-form-urlencoded';
export type DeserializedPayload = string | Blob | File | FormData | Buffer | ArrayBuffer | undefined;
export declare const SupportedPayloadTypes: PayloadTypes[];
export interface IMultipartBody {
    /**
     * Whether the parameter is enabled. Default to true.
     */
    enabled?: boolean;
    /**
     * The name of the filed
     */
    name: string;
    /**
     * Converted value.
     * When the part value was a string this is a string.
     * When the previous value was a Blob or a Buffer, this will be a serialized payload.
     */
    value: string | ISafePayload;
    /**
     * Aside from the `value` which is used to process the Payload, the purpose of this field to to keep
     * the entered by the user string value for the "blob" item. This is primarily handled by the UI
     * and ignored by the HTTP Engine.
     */
    blobText?: string;
    /**
     * When `true` this entry represent a file part
     * @deprecated This is only used for the compatibility with ARC. This information is encoded in the `value`.
     */
    isFile?: boolean;
    /**
     * A content type entered by the user to the text part of the text part input.
     * This can only be set when `isFile` is false.
     * @deprecated This is only used for the compatibility with ARC. This information is encoded in the `value`.
     */
    type?: string;
    /**
     * The original file name used with the part
     * @deprecated This is only used for the compatibility with ARC. This information is encoded in the `value`.
     */
    fileName?: string;
}
export interface IBlobMeta {
    /**
     * The blob's mime type.
     */
    mime: string;
}
export interface IFileMeta extends IBlobMeta {
    /**
     * The file name.
     */
    name: string;
}
/**
 * Represents a payload that is safe to store in a data store.
 * The `string` goes without any transformations.
 * The `file` and the `blob` are data URLs encoded as string.
 * The `buffer` and `arraybuffer` are UInt8Arrays.
 */
export interface ISafePayload {
    /**
     * The type od the originating payload object.
     */
    type: PayloadTypes;
    /**
     * The payload contents. The data type depends on the `type`.
     */
    data: string | number[] | IMultipartBody[];
    /**
     * Optionally the original mime type of the payload.
     * This is used with files.
     */
    meta?: IBlobMeta | IFileMeta;
}
/**
 * The request payload. When not a string then it has to go through a
 * transformation from a store safe object to the original data object.
 * For example, a file is stored as type 'file' and data with the file's data URL.
 * A Buffer / ArrayBuffer is stored as type 'buffer' / 'arraybuffer' respectively
 * with the `data` being an UInt8Array of the content.
 */
export type Payload = string | ISafePayload;
export declare class PayloadSerializer {
    /**
     * Checked whether the passed payload can be safely stored in the data store.
     * @param payload The value to test.
     */
    static isSafePayload(payload: unknown): boolean;
    /**
     * Tests whether the given input should be processed by the `serialize()`.
     */
    static needsSerialization(input: unknown): boolean;
    /**
     * Transforms the payload into a data store safe object.
     */
    static serialize(payload: DeserializedPayload): Promise<ISafePayload | string | undefined>;
    /**
     * Stringifies a file object.
     */
    static stringifyFile(file: File): Promise<ISafePayload>;
    /**
     * Stringifies a blob object.
     *
     * @param blob Blob object to be translated to string
     */
    static stringifyBlob(blob: Blob): Promise<ISafePayload>;
    /**
     * When the passed argument is a NodeJS buffer it creates an object describing the buffer
     * in a safe to store object.
     *
     * @returns The buffer metadata or undefined if the passed argument is not a Buffer.
     */
    static stringifyBuffer(payload: Buffer): ISafePayload | undefined;
    /**
     * When the passed argument is an ArrayBuffer it creates an object describing the object in a safe to store object.
     *
     * @param payload
     * @returns The buffer metadata or undefined if the passed argument is not an ArrayBuffer.
     */
    static stringifyArrayBuffer(payload: ArrayBuffer): ISafePayload | undefined;
    /**
     * Transforms the FormData object to a serialized object describing the data.
     *
     * @param payload A `FormData` object
     * @return A promise resolved to a datastore safe entries.
     */
    static stringifyFormData(payload: FormData): Promise<ISafePayload>;
    /**
     * Transforms a FormData entry into a safe-to-store text entry
     *
     * @param name The part name
     * @param file The part value
     * @returns Transformed FormData part to a datastore safe entry.
     */
    static serializeFormDataEntry(name: string, file: string | File | Blob): Promise<IMultipartBody>;
    /**
     * Restores the payload into its original format.
     */
    static deserialize(payload: ISafePayload | string | undefined, as: 'buffer'): Promise<Buffer | undefined>;
    /**
     * Restores the payload into its original format.
     */
    static deserialize(payload: ISafePayload | string | undefined, as?: string): Promise<DeserializedPayload>;
    /**
     * Deserializes previously serialized file object.
     *
     * @param payload The serialized payload with a file.
     */
    static deserializeFile(payload: ISafePayload): File;
    /**
     * Deserializes previously serialized blob object.
     *
     * In previous versions of ARC the data was a string as data URL. In API client this is a buffer.
     *
     * @param payload The serialized payload.
     * @return Restored blob value
     */
    static deserializeBlob(payload: ISafePayload): Blob | undefined;
    /**
     * The old implementation of the blob deserializer.
     *
     * @deprecated
     * @param dataUrl Data url from blob value.
     * @return Restored blob value
     */
    static deserializeBlobLegacy(dataUrl: string): Blob | undefined;
    /**
     * Converts previously serialized File to a Buffer.
     *
     * @param payload The serialized payload.
     * @return Restored File value as Buffer
     */
    static deserializeFileBuffer(payload: ISafePayload): Buffer;
    /**
     * Converts data-url string to buffer
     *
     * @param payload The serialized payload.
     * @return Restored blob value
     */
    static deserializeBlobBuffer(payload: ISafePayload): Buffer;
    /**
     * Converts data-url string to buffer
     *
     * @deprecated
     * @param dataUrl Data url from blob value.
     * @return Restored blob value
     */
    static deserializeBlobBufferLegacy(dataUrl: string): Buffer;
    /**
     * Converts UInt8Array to a Buffer.
     *
     * @param data Previously serialized buffer.
     * @return Restored blob value
     */
    static deserializeBuffer(data: number[]): Buffer;
    /**
     * Converts UInt8Array to an ArrayBuffer.
     *
     * @param data Previously serialized buffer.
     */
    static deserializeArrayBuffer(data: number[]): ArrayBuffer;
    /**
     * Converts UInt8Array to a Buffer.
     *
     * @param data Previously serialized buffer.
     */
    static deserializeArrayBufferBuffer(data: number[]): Buffer;
    /**
     * Deserializes FormData from API Client data model.
     *
     * @param parts API Client model for multipart.
     * @return {FormData} Restored form data
     */
    static deserializeFormData(parts: IMultipartBody[]): FormData;
    private static deserializeFormDataPart;
    /**
     * @deprecated This is only for compatibility with ARC.
     */
    private static deserializeFormDataLegacy;
}
//# sourceMappingURL=PayloadSerializer.d.ts.map