Slot#

A plain object for one requirement instance on one task: the resources eligible for it and, when filled, the assignment that fills it. Project#slots builds slots from a worker pool and task requirements. You can also write them as object literals. Project#suggestAssignments takes them as input.

Fields#

Field Type Default Description
id Id required Unique among the slots of a call. An assignment created for the slot gets this id, so the slot finds it again on the next run. Must not equal the id of an existing assignment, active or inactive, other than the slot's own assignment.
task Id required The task the slot belongs to. Must be a scheduled leaf task: not unknown, unscheduled or a summary.
allowed Id[] required Eligible resources. The order is the preference between candidates of equal cost. Each entry must name a resource of the project.
value number 1 Rate of the assignment created when the slot is filled, in resource capacity units: 1 = 100 %. Must be finite and greater than 0. null reads as the default.
assignment Id absent The active assignment that fills the slot. Absent or null for an empty slot. Must name an active assignment on the slot's task, and no other slot may name the same assignment.

A slot's state comes from its assignment's resource: empty with no assignment, broken when the resource isn't in allowed, valid when it is. SuggestOptions.targets picks which states to act on.

An invalid value throws an InputError with kind: "validation" and a path under slots[i]: .id, .task, .allowed[j], .value or .assignment. An unknown key throws an InputError with kind: "parse".

Slots returned by Project#slots always carry value, and carry assignment only when they're filled.

Used by#

Example#

const slots = [
  // Empty slot: ann or bob, ann preferred on equal cost.
  { id: "be#1", task: "B", allowed: ["ann", "bob"] },
  // Filled slot at half rate, bound to assignment "be#2".
  { id: "be#2", task: "B", allowed: ["ann", "bob"], value: 0.5, assignment: "be#2" },
];