Skip to content

RestRequirementRule

A minimum of rest inside every window: “10 hours of rest in every 24, in at most two periods, one at least 6 hours long”.

import type { RestRequirementRule } from "@northguild/gmt";
MemberTypeDescription
labelstringThe caller’s name for the rule. The report is keyed by it; labels must be unique.
severity?"violation" | "advisory" (DutySeverity)Whether a failure is a violation or an advisory.
kind"restRequirement"Selects this rule kind.
restStatusesS[]The statuses that are rest.
perPeriodThe window the rest is counted in.
minimumstringThe least rest required in the window, a positive ISO 8601 duration of exact time.
composition?objectHow the rest may be divided: it is counted from the maxPeriods longest runs, the longest at least longestAtLeast and each other at least othersAtLeast.
composition.maxPeriodsnumberThe most runs the rest may come from, a positive integer.
composition.longestAtLeaststringThe floor on the longest run, a positive ISO 8601 duration of exact time.
composition.othersAtLeast?stringThe floor on every other run counted, a positive ISO 8601 duration of exact time.
composite?objectA consecutive run plus additional rest in blocks: rest is the longest run, at least consecutive, plus the other runs of at least blockMinimum, which must add up to additional.
composite.consecutivestringThe floor on the longest run, a positive ISO 8601 duration of exact time.
composite.additionalstringThe rest required beyond the longest run, a positive ISO 8601 duration of exact time.
composite.blockMinimumstringThe shortest block that counts, a positive ISO 8601 duration of exact time.
maxGap?stringThe most time allowed from the end of one run of rest, or from the log’s first entry, to the start of the next run of rest, a positive ISO 8601 duration of exact time.
type RestRequirementRule<S extends string = string> = {
/** The caller's name for the rule. The report is keyed by it; labels must be unique. */
label: string;
/**
* Whether a failure is a violation or an advisory.
*
* @defaultValue `"violation"`.
*/
severity?: DutySeverity;
/** Selects this rule kind. */
kind: "restRequirement";
/** The statuses that are rest. */
restStatuses: S[];
/** The window the rest is counted in. */
per: Period;
/** The least rest required in the window, a positive ISO 8601 duration of exact time. */
minimum: string;
/**
* How the rest may be divided: it is counted from the `maxPeriods` longest runs, the longest at
* least `longestAtLeast` and each other at least `othersAtLeast`.
*
* @defaultValue None. Every run of rest counts.
*/
composition?: {
/** The most runs the rest may come from, a positive integer. */
maxPeriods: number;
/** The floor on the longest run, a positive ISO 8601 duration of exact time. */
longestAtLeast: string;
/**
* The floor on every other run counted, a positive ISO 8601 duration of exact time.
*
* @defaultValue None. The other runs count at any length.
*/
othersAtLeast?: string;
};
/**
* A consecutive run plus additional rest in blocks: rest is the longest run, at least
* `consecutive`, plus the other runs of at least `blockMinimum`, which must add up to
* `additional`.
*
* @defaultValue None. Rest is counted without the split.
*/
composite?: {
/** The floor on the longest run, a positive ISO 8601 duration of exact time. */
consecutive: string;
/** The rest required beyond the longest run, a positive ISO 8601 duration of exact time. */
additional: string;
/** The shortest block that counts, a positive ISO 8601 duration of exact time. */
blockMinimum: string;
};
/**
* The most time allowed from the end of one run of rest, or from the log's first entry, to the
* start of the next run of rest, a positive ISO 8601 duration of exact time.
*
* @defaultValue None. The time between rests is not limited.
*/
maxGap?: string;
};

types/duty.ts