Hierarchy (View Summary)

Constructors

Properties

data: {
    error?: ErrorData;
    id: string;
    params: ProjectParams;
    queuePosition: number;
    startedAt: Date;
    status: ProjectStatus;
}
listeners: {
    completed?: (data: string[]) => void[];
    failed?: (data: ErrorData) => void[];
    jobCompleted?: (data: Job) => void[];
    jobFailed?: (data: Job) => void[];
    progress?: (data: number) => void[];
    updated?: (data: string[]) => void[];
} = {}

Accessors

  • get jobs(): Job[]
  • List of jobs in the project. Note that jobs will be added to this list as workers start processing them. So initially this list will be empty. Subscribe to project updated event to get notified about any update, including new jobs.

    Returns Job[]

    project.on('updated', (keys) => {
    if (keys.includes('jobs')) {
    // Project jobs have been updated
    }
    });
  • get progress(): number
  • Progress of the project in percentage (0-100).

    Returns number

  • get resultUrls(): string[]
  • List of result URLs for all completed jobs in the project.

    Returns string[]

Methods

  • Get full project data snapshot. Can be used to serialize the project and store it in a database.

    Returns {
        error?: ErrorData;
        id: string;
        jobs: {
            error?: ErrorData;
            id: string;
            isNSFW?: boolean;
            previewUrl?: string;
            resultUrl?: null | string;
            seed?: number;
            status: JobStatus;
            step: number;
            stepCount: number;
            userCanceled?: boolean;
        }[];
        params: ProjectParams;
        queuePosition: number;
        startedAt: Date;
        status: ProjectStatus;
    }

  • Wait for the project to complete, then return the result URLs, or throw an error if the project fails.

    Returns Promise<string[]>

    Promise<string[]> - Promise that resolves to the list of result URLs

    ErrorData