Skip to content

RestBeforeDutyRule

A rest required before each duty: “10 hours off in the 24 before a duty”, “rest before duty at least as long as the duty before it, and never under 12 hours”.

import type { RestBeforeDutyRule } 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"restBeforeDuty"Selects this rule kind.
restStatusesS[]The statuses that are rest.
minimumstringThe least rest required, a positive ISO 8601 duration of exact time.
withinstringHow far before a duty the rest is looked for, a positive ISO 8601 duration of exact time. With orFactor the rest is the one right before the duty, which within does not cut.
orFactor?objectA requirement that grows with the previous duty: the larger of k × its length and floor.
orFactor.knumberThe multiple of the previous duty’s length, a positive finite number. It is read as the shortest decimal String(k) prints, exactly: 1.1 is eleven tenths, and 0.1 + 0.2 is 0.30000000000000004. The product is rounded up to the nanosecond.
orFactor.floorstringThe least the requirement can be, a positive ISO 8601 duration of exact time.
type RestBeforeDutyRule<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: "restBeforeDuty";
/** The statuses that are rest. */
restStatuses: S[];
/** The least rest required, a positive ISO 8601 duration of exact time. */
minimum: string;
/**
* How far before a duty the rest is looked for, a positive ISO 8601 duration of exact time.
* With `orFactor` the rest is the one right before the duty, which `within` does not cut.
*/
within: string;
/**
* A requirement that grows with the previous duty: the larger of `k` × its length and `floor`.
*
* @defaultValue None. The requirement is `minimum`.
*/
orFactor?: {
/**
* The multiple of the previous duty's length, a positive finite number. It is read as the
* shortest decimal `String(k)` prints, exactly: `1.1` is eleven tenths, and `0.1 + 0.2` is
* 0.30000000000000004. The product is rounded up to the nanosecond.
*/
k: number;
/** The least the requirement can be, a positive ISO 8601 duration of exact time. */
floor: string;
};
};

types/duty.ts