API reference#

The plen-wasm package builds Planning Engine into a WebAssembly module. This reference covers its raw exports: every call takes JSON text and returns JSON text. For the Project class with typed errors, see JavaScript usage.

How the API is organized#

The module has two exports that do work:

  • schedule - a function that schedules one snapshot and keeps nothing.
  • JsonProject - a handle to a project held in wasm memory. It's created with new JsonProject(options_json), copied with clone() and released with free(). Each method has its own page, listed below.

init loads the module in the browser build. Payload types shared by several calls are under Types.

The package's exports map points only to the JS glue, so the raw bindings are loaded by path:

// Browser / ES module host
import init, { JsonProject, schedule } from "./pkg/plen_wasm.js";

await init();
// Node.js
const { JsonProject, schedule } = require("./pkg-node/plen_wasm.js");

Build targets and loading options are in Module and handles.

Only module loading is asynchronous: init() returns a promise. Every export is synchronous and runs on the calling thread. Each method returns an envelope string, {"ok": true, "result": ...} or {"ok": false, "error": ...}, and doesn't throw on bad input. The JsonProject constructor is the exception: it throws the error envelope as a string. Envelope rules are in Wire format, error kinds and codes in Error handling.

Calls by task#

To Call Request Response
Schedule a snapshot once schedule ProjectData, SolveOptions ScheduleResult
Load a live project or reschedule its edits JsonProject#solve ProjectData (optional), SolveOptions ScheduleResult
See what an edit would do JsonProject#preview SchedulingChanges, PreviewOptions ScheduleResult
Get critical path and slack without scheduling JsonProject#analyze ProjectData (optional), AnalyzeOptions ScheduleResult
Commit an edit JsonProject#apply SchedulingChanges ApplyReport
Resolve resource overallocation JsonProject#level LevelingOptions LevelingResult
Read resource load over a date range JsonProject#loadProfile LoadProfileOptions LoadProfile
Compare alternative edits JsonProject#evaluate Candidate[], EvaluateOptions EvaluateResult
Pick resources for open positions JsonProject#suggestAssignments Slot[], SuggestOptions SuggestResult
Build slots from skills and requirements JsonProject#slots Pool, Requirement[] Slot[]

preview, loadProfile, evaluate, suggestAssignments and slots need a solved project. apply leaves the project unsolved, so call solve again after it. Constructor, clone and free are on the JsonProject page.