Metakit / @doeixd/metakit/temporal

requirements

function · packages/metakit/src/temporalObligations.ts:26

function requirements<
  State = never,
  Transitions extends Readonly<Record<string, unknown>> = {},
  Aggregates extends Readonly<Record<string, Tagged>> = {},
>(declared: {
  readonly machine?: Machine<State, Transitions>
  readonly aggregates?: Aggregates
}): ReadonlyArray<
  Requirement<(keyof Transitions & string) | (keyof Aggregates & string)>
>

The capability each declared rule needs, by the rule's key.

  • An aggregate (Rows.sum, Rows.count, …) reads every row under one parent, so two writers that each read a value admitting them can together break a rule over it: it needs parent-serialized.
  • A transition that reads the state it writes, or writes a state whose Schema carries rules, needs row-atomic: its proof assumes the state the guard read is the state the writes land on. A transition that writes nothing needs nothing.

Throws for a key declared as both a transition and an aggregate.