Project#

A stateful project. It holds the imported data, the accepted baseline and the last result, so later calls can preview, edit, level and assign against that baseline. Create one with new Project(options) and keep it for as long as the plan is open. For a one-off run without state, use schedule.

Declaration#

class Project {
  constructor(options?: ProjectOptions);
}

Every member is synchronous and runs on the calling thread. Memory is freed by garbage collection; dispose is optional.

Creating#

new Project(options?: ProjectOptions)

Creates an empty project. Call solve with a ProjectData object to load data into it.

Name Type Description
options ProjectOptions Optional. Date representation of results and validation mode. Default {}.

ProjectOptions#

Settings fixed for the project's lifetime.

Field Type Default Description
dates "string" | "date" "string" Representation of dates in results. "string": "YYYY-MM-DD HH:MM" strings. "date": local Date objects. Input accepts both forms either way.
validation "strict" | "repair" "strict" How input data is checked. "strict" rejects ambiguous input. "repair" coerces the input (deduplicates ids, derives missing dates and durations, fixes inconsistent date triples) and reports each one as a repaired note in the result.
Note

Set dates: "date" to get result dates as local Date objects instead of "YYYY-MM-DD HH:MM" strings; schedule() always returns strings.

For how dates convert in both directions, see Plain objects and dates. For what "repair" changes, see Accept messy input.

Errors#

Error When
InputError "validation", path "dates" dates is neither "string" nor "date"; message "Unknown dates representation".
InputError options has an unknown key, or validation has an unknown value.
Note

new Project(options) throws an InputError if an option is unknown or has an invalid value.

Example#

import { Project } from "plen-js";

const project = new Project({ dates: "date", validation: "repair" });
const result = project.solve(
  { tasks: [{ id: 1, start_date: "2026-08-10 08:00", duration: 2 }] },
  { includeUnchanged: true },
);

console.log(result.updates[0].start_date instanceof Date); // true

Operations#

Operation Description
solve Load data or reschedule edits, and accept the dates as the baseline.
preview Schedule hypothetical changes against the baseline without changing the project.
analyze Critical path and slack over given or current dates, without scheduling.
apply Commit an ordered set of edits to the accepted state.
level Resolve resource overallocation and accept the leveled dates.
loadProfile Per-bucket load and capacity of resources on the baseline.
evaluate Score alternative change sets against the baseline.
slots Build requirement slots from a worker pool and task requirements.
suggestAssignments Propose assignments that fill, repair or rebalance slots.

Members#

clone#

clone(): Project

Returns an independent copy of the project: its accepted state, cached result and options, including dates. Calls on the copy don't affect the original, and the other way around. Use it to try leveling or edits without touching the original.

Throws Error("Project has been disposed") if the project was disposed.

Note

clone() copies the whole project at once, so its cost grows with the project's size.

const trial = project.clone();
trial.level();
// `project` keeps its baseline; `trial` holds the leveled dates.

dispose#

dispose(): void

Marks the project as unusable. It's idempotent, and it doesn't affect clones made earlier. After it, every call on the project throws Error("Project has been disposed").

Note

dispose() is optional; after it, every call on that project throws Error("Project has been disposed").