From b3394a5c1a3c1374b635ad9f369cc805fa583241 Mon Sep 17 00:00:00 2001 From: "Russ T. Fugal" Date: Tue, 10 Mar 2026 09:00:00 -0600 Subject: [PATCH] feat(api): root and advanced subpath barrels The public API surface: a root barrel with the common readers and writers, and an `advanced` subpath exposing the lower-level building blocks. Reader and writer option types (e.g. MspdiWriterOptions) are exported alongside their functions so callers can name them. --- src/advanced.ts | 13 ++++++++++ src/index.ts | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 src/advanced.ts create mode 100644 src/index.ts diff --git a/src/advanced.ts b/src/advanced.ts new file mode 100644 index 0000000..056f799 --- /dev/null +++ b/src/advanced.ts @@ -0,0 +1,13 @@ +export { MppReader, parseMppBuffer } from "./mpp/MppReader.ts"; +export { MspdiReader } from "./mspdi/MspdiReader.ts"; +export { MspdiWriter } from "./mspdi/MspdiWriter.ts"; +export { JsonReader } from "./json/JsonReader.ts"; +export { JsonWriter } from "./json/JsonWriter.ts"; +export { CsvWriter } from "./csv/CsvWriter.ts"; +export { XlsxWriter } from "./xlsx/XlsxWriter.ts"; +export { detectMppVariant } from "./mpp/MppVariant.ts"; +export type { JsonWriterOptions } from "./json/JsonWriter.ts"; +export type { CsvWriterOptions } from "./csv/CsvWriter.ts"; +export type { XlsxWriterOptions } from "./xlsx/XlsxWriter.ts"; +export type { MppContainer, MppInspection } from "./mpp/Mpp14Reader.ts"; +export type { MppVariant } from "./mpp/MppVariant.ts"; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..5ea0268 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,67 @@ +import { MppReader } from "./mpp/MppReader.ts"; +import { MspdiReader } from "./mspdi/MspdiReader.ts"; +import { MspdiWriter } from "./mspdi/MspdiWriter.ts"; +import { JsonReader } from "./json/JsonReader.ts"; +import { JsonWriter } from "./json/JsonWriter.ts"; +import { CsvWriter } from "./csv/CsvWriter.ts"; +import type { CsvWriterOptions } from "./csv/CsvWriter.ts"; +import { XlsxWriter } from "./xlsx/XlsxWriter.ts"; +import type { XlsxWriterOptions } from "./xlsx/XlsxWriter.ts"; +import type { ProjectFile } from "./model/Project.ts"; + +export function readMpp(data: Uint8Array | ArrayBuffer): ProjectFile { + return new MppReader().read(data); +} + +export function readMspdi(xml: string): ProjectFile { + return new MspdiReader().read(xml); +} + +export function writeMspdi(project: ProjectFile, options?: { saveVersion?: number }): string { + return new MspdiWriter().write(project, options); +} + +export function readJson(json: string): ProjectFile { + return new JsonReader().read(json); +} + +export function writeJson(project: ProjectFile, options?: { pretty?: boolean }): string { + return new JsonWriter().write(project, options); +} + +export function writeCsv(project: ProjectFile, options?: CsvWriterOptions): string { + return new CsvWriter().write(project, options); +} + +export async function writeXlsx( + project: ProjectFile, + options?: XlsxWriterOptions, +): Promise { + return new XlsxWriter().write(project, options); +} + +// Types +export type { ProjectFile } from "./model/Project.ts"; +export type { ProjectProperties } from "./model/types.ts"; +export type { Task } from "./model/Task.ts"; +export type { Resource } from "./model/Resource.ts"; +export type { Assignment } from "./model/Assignment.ts"; +export type { Calendar } from "./model/Calendar.ts"; +export type { Relation } from "./model/Relation.ts"; + +// Classes +export { Duration } from "./model/Duration.ts"; +export { JsonReader } from "./json/JsonReader.ts"; +export { JsonWriter } from "./json/JsonWriter.ts"; +export type { JsonWriterOptions } from "./json/JsonWriter.ts"; +export { CsvWriter } from "./csv/CsvWriter.ts"; +export type { CsvWriterOptions } from "./csv/CsvWriter.ts"; +export { XlsxWriter } from "./xlsx/XlsxWriter.ts"; +export type { XlsxWriterOptions } from "./xlsx/XlsxWriter.ts"; +export type { MspdiWriterOptions } from "./mspdi/MspdiWriter.ts"; + +// Enums +export { TimeUnit, RelationType, ResourceType, ConstraintType, Priority } from "./model/types.ts"; + +// Date utilities +export { parseProjectDate, formatProjectDate } from "./dateTime.ts"; -- 2.54.0