import DataEntity, { EntityEvents } from '../lib/DataEntity'; import ErrorData from '../types/ErrorData'; import { RawJob, RawProject } from './types/RawProject'; import ProjectsApi from './index'; import { Logger } from '../lib/DefaultLogger'; export type JobStatus = 'pending' | 'initiating' | 'processing' | 'completed' | 'failed' | 'canceled'; /** * @inline */ export interface JobData { id: string; projectId: string; status: JobStatus; step: number; stepCount: number; workerName?: string; seed?: number; isNSFW?: boolean; userCanceled?: boolean; previewUrl?: string; resultUrl?: string | null; error?: ErrorData; } export interface JobEventMap extends EntityEvents { progress: number; completed: string; failed: ErrorData; } export interface JobOptions { api: ProjectsApi; logger: Logger; } declare class Job extends DataEntity { static fromRaw(rawProject: RawProject, rawJob: RawJob, options: JobOptions): Job; private readonly _api; private readonly _logger; constructor(data: JobData, options: JobOptions); get id(): string; get projectId(): string; /** * Current status of the job. */ get status(): JobStatus; get finished(): boolean; /** * Progress of the job in percentage (0-100). */ get progress(): number; /** * Current step of the job. */ get step(): number; /** * Total number of steps that worker will perform. */ get stepCount(): number; /** * Seed used to generate the image. This property is only available when the job is completed. */ get seed(): number | undefined; /** * Last preview image URL generated by the worker. */ get previewUrl(): string | undefined; /** * URL to the result image, could be null if the job was canceled or triggered NSFW filter while * it was not disabled explicitly. */ get resultUrl(): string | null | undefined; get imageUrl(): string | undefined; get error(): ErrorData | undefined; /** * Whether the image is NSFW or not. Only makes sense if job is completed. * If NSFW filter is disabled, this property will always be false. * If NSFW filter is enabled and the image is NSFW, image will not be available for download. */ get isNSFW(): boolean; /** * Name of the worker that is processing this job. */ get workerName(): string | undefined; /** * Syncs the job data with the data received from the REST API. * @internal * @param data */ _syncWithRestData(data: RawJob): Promise; private handleUpdated; } export default Job;