// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT

/**
 * Caps describes which controls a job supports.  The frontend renders
 * buttons from these rather than switching on Kind, so a job that gains
 * pause support later needs no frontend change.
 */
export interface Caps {
    "pausable": boolean;
    "cancellable": boolean;
}

/**
 * Job is the frontend-facing snapshot of a single background job.
 */
export interface Job {
    "id": string;
    "kind": Kind;
    "title": string;
    "subtitle"?: string;
    "state": State;
    "phase"?: string;

    /**
     * Current/Total drive the progress bar.  Total == 0 means the job
     * is indeterminate and the frontend should render a spinner.
     */
    "current": number;
    "total": number;
    "caps": Caps;
    "stages": Stage[] | null;
    "stats": Stat[] | null;
    "error"?: string;

    /**
     * unix milliseconds
     */
    "startedAt": number;
    "updatedAt": number;
    "endedAt"?: number;
    "logCount": number;
    "warnCount": number;
    "errorCount": number;
}

/**
 * Kind identifies the subsystem that owns a job.  The frontend uses it
 * to pick an icon and to route "view details" to the right panel.
 */
export enum Kind {
    /**
     * The Go zero value for the underlying type of the enum.
     */
    $zero = "",

    /**
     * Job kinds.
     */
    KindLibraryScan = "library-scan",
    KindIndexBuild = "index-build",
    KindDownload = "download",
    KindAutotagApply = "autotag-apply",

    /**
     * KindCatalogEnrich is background catalog work for content the user
     * already owns — the discography backfills.  It is distinct from
     * KindIndexBuild because the two differ in what cancelling costs:
     * an index build discards hours of downloading and the frontend
     * confirms before stopping one, where a backfill is resumable per
     * artist and stopping it is free.
     */
    KindCatalogEnrich = "catalog-enrich",
};

/**
 * Level is the severity of a job log entry.
 */
export enum Level {
    /**
     * The Go zero value for the underlying type of the enum.
     */
    $zero = "",

    /**
     * Log levels.
     */
    LevelInfo = "info",
    LevelWarn = "warn",
    LevelError = "error",
};

/**
 * LogEntry is one line of a job's output log.
 */
export interface LogEntry {
    /**
     * unix milliseconds
     */
    "time": number;
    "level": Level;
    "message": string;
    "detail"?: string;
}

/**
 * Stage is one named sub-step of a multi-stage job, such as an index
 * build tier.  Jobs with a single linear phase leave Stages empty.
 */
export interface Stage {
    "name": string;

    /**
     * pending, running, complete, error, skipped
     */
    "state": string;
    "current": number;
    "total": number;
    "error"?: string;
}

/**
 * Stat is a display-only key/value pair shown in the job detail panel
 * (e.g. "Added" / "1,204").
 */
export interface Stat {
    "label": string;
    "value": string;
}

/**
 * State is the lifecycle position of a job.
 */
export enum State {
    /**
     * The Go zero value for the underlying type of the enum.
     */
    $zero = "",

    /**
     * Job states.  Queued, Running, Paused and Pausing are live; Complete,
     * Cancelled and Error are terminal.
     */
    StateQueued = "queued",
    StateRunning = "running",
    StatePausing = "pausing",
    StatePaused = "paused",
    StateCancelling = "cancelling",
    StateComplete = "complete",
    StateCancelled = "cancelled",
    StateError = "error",
};
