API reference#

The JavaScript API of Planning Engine ships as one package, plen-js. It schedules, edits, levels and scores projects, and builds slots from skills for auto-assignment. Inputs and results are plain JS objects.

How the API is organized#

Almost every operation is a method of the Project class. The package also exports schedule for a one-shot solve, the InputError and ProjectError classes, a default init export, and every data, option and result type. Nothing else is public.

  • Project - creating a project, clone, dispose, and the list of operations.
  • One page per operation (api/project-*.md) - parameters, behavior, result and errors of one call. Option and result shapes used by a single operation are documented on that operation's page.
  • Types - data, change, option and result shapes shared by several operations, plus errors and common types.
npm install plen-js
import { Project, schedule, InputError, ProjectError } from "plen-js";

The package has ESM and CommonJS builds with bundled .d.ts files, and runs in Node 18 or later and in browsers. In CommonJS, the named exports are direct (require("plen-js").Project) and init is .default.

Every Project method and schedule is synchronous. Only init returns a Promise. Invalid input throws InputError, and a call that doesn't fit the project's state throws ProjectError. Cycles, conflicts and rejected edits come back as data in the result. See Error handling for which failures throw and which don't.

Note

init() isn't needed before new Project(); it loads nothing and resolves immediately.

Calls by task#

To Call Options Returns
Schedule a snapshot once schedule SolveOptions ScheduleResult
Keep code written for the WASM package working init - Promise<unknown>
Load a live project or reschedule its edits Project#solve SolveOptions ScheduleResult
See what an edit would do Project#preview PreviewOptions ScheduleResult
Get critical path and slack without scheduling Project#analyze AnalyzeOptions ScheduleResult
Commit an edit Project#apply SchedulingChanges ApplyReport
Resolve resource overallocation Project#level LevelingOptions LevelingResult
Read resource load per hour or day Project#loadProfile LoadProfileOptions LoadProfile
Compare alternative edits Project#evaluate EvaluateOptions EvaluateResult
Pick resources for open positions Project#suggestAssignments SuggestOptions SuggestResult
Build slots from skills and requirements Project#slots Pool, Requirement Slot[]

preview, loadProfile, evaluate, suggestAssignments and slots need a solved project. Creating a project, clone and dispose are on the Project page.