[Canonical page](<https://docs.dhtmlx.com/planning-engine/js/api/project/>)
[Full documentation index](<https://docs.dhtmlx.com/planning-engine/llms.txt>)


# 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`](<https://docs.dhtmlx.com/planning-engine/js/api/schedule.md>).

## Declaration

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

Every member is synchronous and runs on the calling thread. Memory is freed by garbage collection; [`dispose`](<https://docs.dhtmlx.com/planning-engine/js/api/project.md#dispose>) is optional.

## Creating

```ts
new Project(options?: ProjectOptions)
```

Creates an empty project. Call [`solve`](<https://docs.dhtmlx.com/planning-engine/js/api/project-solve.md>) with a [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/js/api/types/project-data.md>) object to load data into it.

| Name | Type | Description |
|---|---|---|
| `options` | [`ProjectOptions`](<https://docs.dhtmlx.com/planning-engine/js/api/project.md#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](<https://docs.dhtmlx.com/planning-engine/js/plain-objects-and-dates.md>). For what `"repair"` changes, see [Accept messy input](<https://docs.dhtmlx.com/planning-engine/js/how-to/accept-messy-input.md>).

### Errors

| Error | When |
|---|---|
| [`InputError`](<https://docs.dhtmlx.com/planning-engine/js/api/types/errors.md>) `"validation"`, path `"dates"` | `dates` is neither `"string"` nor `"date"`; message `"Unknown dates representation"`. |
| [`InputError`](<https://docs.dhtmlx.com/planning-engine/js/api/types/errors.md>) | `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

```js
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`](<https://docs.dhtmlx.com/planning-engine/js/api/project-solve.md>) | Load data or reschedule edits, and accept the dates as the baseline. |
| [`preview`](<https://docs.dhtmlx.com/planning-engine/js/api/project-preview.md>) | Schedule hypothetical changes against the baseline without changing the project. |
| [`analyze`](<https://docs.dhtmlx.com/planning-engine/js/api/project-analyze.md>) | Critical path and slack over given or current dates, without scheduling. |
| [`apply`](<https://docs.dhtmlx.com/planning-engine/js/api/project-apply.md>) | Commit an ordered set of edits to the accepted state. |
| [`level`](<https://docs.dhtmlx.com/planning-engine/js/api/project-level.md>) | Resolve resource overallocation and accept the leveled dates. |
| [`loadProfile`](<https://docs.dhtmlx.com/planning-engine/js/api/project-load-profile.md>) | Per-bucket load and capacity of resources on the baseline. |
| [`evaluate`](<https://docs.dhtmlx.com/planning-engine/js/api/project-evaluate.md>) | Score alternative change sets against the baseline. |
| [`slots`](<https://docs.dhtmlx.com/planning-engine/js/api/project-slots.md>) | Build requirement slots from a worker pool and task requirements. |
| [`suggestAssignments`](<https://docs.dhtmlx.com/planning-engine/js/api/project-suggest-assignments.md>) | Propose assignments that fill, repair or rebalance slots. |

## Members

### clone

```ts
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.
:::

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

### dispose

```ts
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")`.
:::

## Related

- [`schedule`](<https://docs.dhtmlx.com/planning-engine/js/api/schedule.md>) - one-shot scheduling without a project
- [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/js/api/types/project-data.md>) - the data `solve` loads
- [Errors](<https://docs.dhtmlx.com/planning-engine/js/api/types/errors.md>) - `InputError` from the constructor and the disposed-project error
- [Plain objects and dates](<https://docs.dhtmlx.com/planning-engine/js/plain-objects-and-dates.md>) - how the `dates` option converts results
- [Editing a project](<https://docs.dhtmlx.com/planning-engine/js/live-projects/editing-a-project.md>) - keeping a project live across edits
