Skip to content

ElapsedWindowRule

A window that opens when work starts after a reset and closes length later, whatever rest falls inside it: “no driving more than 14 hours after work began”.

import type { ElapsedWindowRule } 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"elapsedWindow"Selects this rule kind.
startStatusesS[]The statuses whose first entry after the reset opens the window.
lengthstringHow long the window stays open, a positive ISO 8601 duration of exact time.
restrictedStatusesS[]The statuses not allowed once the window has closed.
sinceReset<S> (Reset)The rest that closes one window, so that the next work opens a new one.
exclude?PairSpecA paired rest that does not count against the window.
extension?objectA caller-declared extension: the window open at from closes by later.
extension.bystringHow much later the window closes, a positive ISO 8601 duration of exact time.
extension.fromstringThe instant the extension is declared at, an ISO 8601 instant string.
type ElapsedWindowRule<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: "elapsedWindow";
/** The statuses whose first entry after the reset opens the window. */
startStatuses: S[];
/** How long the window stays open, a positive ISO 8601 duration of exact time. */
length: string;
/** The statuses not allowed once the window has closed. */
restrictedStatuses: S[];
/** The rest that closes one window, so that the next work opens a new one. */
since: Reset<S>;
/**
* A paired rest that does not count against the window.
*
* @defaultValue None. Rest inside the window never moves it.
*/
exclude?: PairSpec;
/**
* A caller-declared extension: the window open at `from` closes `by` later.
*
* @defaultValue None. No window is extended.
*/
extension?: {
/** How much later the window closes, a positive ISO 8601 duration of exact time. */
by: string;
/** The instant the extension is declared at, an ISO 8601 instant string. */
from: string;
};
};

types/duty.ts