util.d.ts•1.63 kB
export declare enum APIVersion {
    V1 = "v1"
}
export type OutputFormat = 'jpeg' | 'png' | 'webp';
export declare const DEFAULT_OUTPUT_FORMAT: OutputFormat;
export type EverArtContentResponse = {
    filepath: string;
    filename: string;
    contentType: 'image' | 'video';
    outputFormat: OutputFormat | 'mp4';
    contentFiltered: boolean;
    errored: boolean;
    seed: number;
};
export type EverArtStatusResult = {
    id: string;
    status: 'in-progress';
};
export declare function makeUrl(verison: APIVersion, endpoint: string): string;
/**
 * Download an image from a URL and return the local file path
 *
 * @param url
 * @returns filepath string
 */
export declare function downloadImage(url: string): Promise<string>;
export type EverArtErrorName = 'EverArtInvalidRequestError' | 'EverArtUnauthorizedError' | 'EverArtForbiddenError' | 'EverArtContentModerationError' | 'EverArtRecordNotFoundError' | 'EverArtUnknownError';
export declare class EverArtError extends Error {
    constructor(status: number, message: string, data?: any);
}
export declare function sleep(ms: number): Promise<unknown>;
/**
 * Uploads a file to a pre-signed URL obtained from the images.uploads endpoint
 * @param filePath Local path to the file to upload
 * @param uploadUrl Pre-signed URL to upload to
 * @param contentType MIME type of the file
 */
export declare function uploadFile(filePath: string, uploadUrl: string, contentType: ContentType): Promise<void>;
export type ContentType = 'image/jpeg' | 'image/png' | 'image/webp' | 'image/heic' | 'image/heif';
export declare function getContentType(filename: string): ContentType;