schedule#

Schedules a ProjectData snapshot once and returns the result. The call is stateless: it creates a temporary Project with default options, calls solve on it, and disposes it. Nothing is kept between calls. To keep the baseline for later previews or edits, use Project#solve.

Signature#

function schedule(data: ProjectData, options?: SolveOptions): ScheduleResult

Synchronous. Runs on the calling thread. The same data and options always produce the same dates.

Parameters#

Name Type Description
data ProjectData The full snapshot to schedule. Never mutated.
options SolveOptions Optional. What to schedule and what to report. Default {}: the whole project.

data is always validated in "strict" mode. For "repair" mode, create a Project with validation: "repair" and call solve on it.

Returns#

A ScheduleResult, a fresh object that shares nothing with data.

baselineId is set, but it names the baseline of the temporary project, so no later call can use it.

Note

schedule() always returns dates as "YYYY-MM-DD HH:MM" strings. To get local Date objects, create a Project with dates: "date" and call solve on it.

Errors#

Error When
InputError data or options fails parsing or strict validation; kind, message and path name the field. Also thrown for a non-finite number or an invalid Date in the input.
TypeError The input has a circular reference or a BigInt.

schedule never throws ProjectError: each call starts from a fresh project.

Example#

import { schedule } from "plen-js";

const result = schedule({
  tasks: [
    { id: "design", start_date: "2026-01-05 08:00", duration: 2 },
    { id: "build", start_date: "2026-01-05 08:00", duration: 3 },
  ],
  links: [{ id: "l1", source: "design", target: "build", type: "fs" }],
});

for (const update of result.updates) {
  if (update.start_date && update.end_date) {
    console.log(`${update.id}: ${update.start_date} - ${update.end_date}`);
  }
}