Skip to content

UsageLookbackRule

An allowance used at most once inside a window, restored by a rest: “not used within the previous 7 days unless 34 hours off came between”.

import type { UsageLookbackRule } 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"usageLookback"Selects this rule kind.
usesstring[]The instants the allowance was used, as ISO 8601 instant strings.
notWithinPeriodThe window no second use may fall in.
resetReset<S> (Reset)The rest that restores the allowance.
type UsageLookbackRule<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: "usageLookback";
/** The instants the allowance was used, as ISO 8601 instant strings. */
uses: string[];
/** The window no second use may fall in. */
notWithin: Period;
/** The rest that restores the allowance. */
reset: Reset<S>;
};

types/duty.ts