import { RobotsApiVersion, RobotsJobRow, RobotsNodeState } from '../../../types/robots'; /** What any source says about one job or run. `undefined` means "this source doesn't know". */ export type IncomingRow = Partial> & { mux_id: string; is_directive_run: boolean; }; /** A job as Mux describes it: a webhook, a single read, a create or cancel answer, or a list summary. */ export interface MuxJobLike { id: string; workflow?: string; status?: string; created_at?: number; updated_at?: number; parameters?: object; outputs?: object; errors?: unknown; units_consumed?: number; directive?: { id?: string; run_id?: string; }; /** List summaries only: the route of the version that created the job. */ _links?: { self?: { href?: string; }; }; } /** * A directive run as a webhook or the REST API describes it: v1 says `id` and `subject_id` everywhere; * v0 says `run_id` over REST, and `id` and `asset_id` in webhooks. */ export interface MuxRunLike { id?: string; run_id?: string; directive_id?: string; asset_id?: string; subject_id?: string; status?: string; node_states?: RobotsNodeState[]; started_at?: number; completed_at?: number | null; } /** Mux timestamps are Unix seconds. */ export declare const isoFromSeconds: (seconds: unknown) => string; export declare const secondsFromDate: (value: unknown) => number; /** * `apiVersion` is the version the job was read or created through. Without it, a list summary's link * says which; anything else leaves the stored version as it is. */ export declare function rowFromJob(job: MuxJobLike, { workflow, assetId, detail, apiVersion, }: { workflow: string; assetId?: string | null; detail: boolean; apiVersion?: RobotsApiVersion; }): IncomingRow; export declare function rowFromRun(run: MuxRunLike, { directiveId, assetId, status, apiVersion, }: { directiveId?: string; assetId?: string | null; status?: string; apiVersion: RobotsApiVersion; }): IncomingRow | undefined; /** * What to change on `row` given `incoming`, or `null` when nothing would change. A row never moves * backwards, whatever order copies arrive in: * * - A terminal row never changes status again, but a later copy may fill its empty fields: a list * summary has no outputs, the webhook that follows does. * - Otherwise a status ranked at least the stored one applies, with the rest of what it says. * - Anything older only fills empty fields, so duplicates and late deliveries are no-ops. */ export declare function mergeIntoRow(row: RobotsJobRow, incoming: IncomingRow): Partial | null; export declare const robotJobs: () => import("@strapi/database/dist/entity-manager").Repository; export declare function findRowById(id: number): Promise; export declare function findRowByMuxId(muxId: string): Promise; export interface ClaimCriteria { assetId: string | null | undefined; /** Jobs claim job placeholders of their workflow, runs the placeholders of their directive. */ workflow?: string | null; directiveId?: string | null; /** Unix seconds: the job's `created_at`, or the run's `started_at`. */ at: number | undefined; } /** * Writes what a source says about a job or run: onto its row when the Mux id is known, else onto the * placeholder it resolves, else as a new row. Returns the row as stored. */ export declare function upsertRobotsRow(incoming: IncomingRow, claim?: ClaimCriteria): Promise;