# DueByRule

Industry: Workforce

A rest that must start within a number of periods of the last one: "a weekly rest by the end of six operator days after the previous one".

```ts
import type { DueByRule } from "@northguild/gmt";
```

## Members

| Member | Type | Description |
| --- | --- | --- |
| `label` | `string` | The caller's name for the rule. The report is keyed by it; labels must be unique. |
| `severity?` | `"violation"` \| `"advisory"` ([`DutySeverity`](/gmt/reference/types/DutySeverity/)) | Whether a failure is a violation or an advisory. |
| `kind` | `"dueBy"` | Selects this rule kind. |
| `event` | `object` | The rest that is due. |
| `event.statuses` | `S[]` | The statuses the rest is made of. |
| `event.minimum` | `string` | How long the rest must be, a positive ISO 8601 duration of exact time. |
| `within` | `object` ([`Period`](/gmt/reference/types/Period/)) | How soon the rest is due. |
| `within.periods` | `number` | How many periods, an integer from 1 to 10,000. Times a count `period`, it is 10,000 at most. |
| `within.period` | [`Period`](/gmt/reference/types/Period/) | The period counted: an `elapsed` length, or one local period (`{ operatorDays: 1 }`). |
| `reset?` | `Reset<S>` ([`Reset`](/gmt/reference/types/Reset/)) | Another rest that also starts the clock. |

## Definition

```ts
type DueByRule<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: "dueBy";
  /** The rest that is due. */
  event: {
    /** The statuses the rest is made of. */
    statuses: S[];
    /** How long the rest must be, a positive ISO 8601 duration of exact time. */
    minimum: string;
  };
  /** How soon the rest is due. */
  within: {
    /**
     * How many periods, an integer from 1 to 10,000. Times a count `period`, it is 10,000 at
     * most.
     */
    periods: number;
    /** The period counted: an `elapsed` length, or one local period (`{ operatorDays: 1 }`). */
    period: Period;
  };
  /**
   * Another rest that also starts the clock.
   *
   * @defaultValue None. Only the event starts the clock.
   */
  reset?: Reset<S>;
};
```

## Used by

- [`dutyViolations`](/gmt/reference/workforce/calculate/dutyViolations/)
- [`evaluateDutyLog`](/gmt/reference/workforce/calculate/evaluateDutyLog/)

## Source

[types/duty.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/types/duty.ts)
