namespace Chronos.Protocol;
/// A job of the queue. : the schedule that queued it (owner review 2, R10), absent otherwise.
public sealed record JobDto(
Guid Id,
string Kind,
IReadOnlyList TargetIds,
string? TargetLabel,
string State,
string Priority,
long ProgressDone,
long ProgressTotal,
double? ItemsPerSecond,
double? EtaSeconds,
string? LogTail,
string? NodeId,
int Attempts,
string? Error,
DateTimeOffset Created,
DateTimeOffset? Started,
DateTimeOffset? Finished,
Guid? ScheduleId = null);
/// POST /api/v1/jobs: kind = render, deep-analyse, proxies, thumbs, verify, scan, rebuild, maintenance…
public sealed record CreateJobRequest(string Kind, IReadOnlyList Target, string? ParametersJson);
///
/// POST /api/v1/nodes/register: a client offers its GPU encoders (BRIEF §14.7). ×
/// is the largest output of any of them, for encoders that announce no limit of their own.
///
public sealed record RegisterNodeRequest(string ClientName, IReadOnlyList Encoders, int MaxWidth, int MaxHeight);
///
/// One encoder of a render node. × is its largest output (0 = not announced:
/// the node's own limit applies), so jobs go only to a node with an encoder of their codec that takes their size.
///
public sealed record NodeEncoder(string Codec, string Name, bool Hardware, bool TenBit, int MaxWidth = 0, int MaxHeight = 0);
public sealed record RenderNodeDto(Guid Id, string ClientName, string Username, IReadOnlyList Encoders, DateTimeOffset LastHeartbeat, string State);
/// POST /api/v1/nodes/{id}/claim: the job and everything needed to run it, or 204 when none matches.
/// Every frame of the sequence; a node renders none flagged missing, corrupt or excluded.
/// How to make the proxies the server asks for (); null when it makes none.
public sealed record ClaimedJob(JobDto Job, Guid SequenceId, string SettingsJson, string PresetJson, bool UseProxies, IReadOnlyList Frames,
ProxySpec? Proxies = null);
/// POST /api/v1/nodes/{id}/jobs/{jobId}/progress.
public sealed record NodeProgress(long Done, long Total, double? ItemsPerSecond, string? LogLine);
/// POST /api/v1/jobs/{id}/priority: background, normal or user.
public sealed record JobPriorityRequest(string Priority);
///
/// parametersJson of a render job: what to encode. Render nodes claim the job when they have an encoder for
/// at × (BRIEF §14.7).
///
/// The settings to render; null renders the sequence's own (or, with ,
/// that version's). Settings in the portable form of a project version (positions parked by photo) are placed on the sequence's
/// frames before the render.
/// The project whose version is rendered (owner review 2, R8); recorded with the render.
/// The project version rendered; recorded with the render.
public sealed record RenderJobParameters(string PresetName, string PresetJson, string Codec, int Width, int Height, bool UseProxies, string? SettingsJson,
Guid? ProjectId = null, Guid? ProjectVersionId = null);
///
/// POST /api/v1/nodes/{id}/jobs/{jobId}/result: the finished output a node is about to upload in chunks. A
/// result/complete that cannot file it for now answers 503 sequence_busy, archive_offline or
/// folder_moved (another index moved the sequence's folder; the server's next scan finds it); the upload and the
/// job stay the node's, to be completed again.
///
public sealed record RenderResultRequest(
string FileName,
long Size,
string Sha256,
string PresetName,
string? Codec,
int Width,
int Height,
double Fps,
double DurationSeconds);
/// POST /api/v1/nodes/{id}/jobs/{jobId}/failed: the node could not render the job.
public sealed record NodeJobFailure(string Error);