@particle-academy/holy-sheet 2.6.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -58,6 +58,40 @@ interface SheetSchema {
58
58
  columnWidths?: Record<number | string, number>;
59
59
  frozenRows?: number;
60
60
  frozenCols?: number;
61
+ /** 1-based row number → pixels. */
62
+ rowHeights?: Record<number | string, number>;
63
+ print?: {
64
+ orientation?: "portrait" | "landscape";
65
+ fitToWidth?: boolean;
66
+ /** `{page}` / `{pages}` print the page number and count. */
67
+ footer?: {
68
+ left?: string;
69
+ center?: string;
70
+ right?: string;
71
+ };
72
+ };
73
+ /** Native charts drawn over cell ranges; they stay live when the cells change. */
74
+ charts?: ChartSchema[];
75
+ }
76
+ interface ChartSchema {
77
+ type: "column" | "bar" | "line" | "pie";
78
+ title?: string;
79
+ /** Axis labels, e.g. "A5:A7" or "'Other sheet'!A5:A7". */
80
+ categories?: string;
81
+ series: {
82
+ name?: string;
83
+ values: string;
84
+ color?: string;
85
+ }[];
86
+ /** Top-left and bottom-right cells; defaults to beside the data. */
87
+ position?: {
88
+ from: string;
89
+ to: string;
90
+ };
91
+ dataLabels?: boolean;
92
+ legend?: boolean;
93
+ /** Excel number format for the axis and labels, e.g. "$#,##0". */
94
+ format?: string;
61
95
  }
62
96
  interface HolySheetSchema {
63
97
  sheets: SheetSchema[];
@@ -223,7 +257,7 @@ interface SetMetaOp {
223
257
  }
224
258
 
225
259
  /** This package's own version, pinned to package.json by `version.test.ts`. */
226
- declare const VERSION = "2.6.0";
260
+ declare const VERSION = "2.8.0";
227
261
  type Any$6 = any;
228
262
  /**
229
263
  * Agent — the structured-tool surface for Holy Sheet. Mirrors PHP `Agent`.
@@ -295,7 +329,7 @@ type Any$5 = any;
295
329
  * over `Agent`. Provided for parity / DI ergonomics; most callers use `Agent`.
296
330
  */
297
331
  declare class HolySheet {
298
- static readonly VERSION = "2.6.0";
332
+ static readonly VERSION = "2.8.0";
299
333
  validate(schema: Any$5): ValidationError[];
300
334
  toBytes(schema: Any$5): Uint8Array;
301
335
  write(schema: Any$5, path: string): Promise<WriteResult>;
@@ -428,6 +462,60 @@ declare class MergedRegion {
428
462
  ref(): string;
429
463
  }
430
464
 
465
+ /**
466
+ * A cell range a chart reads from. Mirrors PHP `Workbook\ChartRange`:
467
+ * "B5:B7", "B5", "'Q3 Revenue'!B5:B7" or "Data!B5:B7", resolved against the
468
+ * chart's own sheet when no sheet is named.
469
+ */
470
+ declare class ChartRange {
471
+ readonly sheet: string;
472
+ /** 0-based first column. */
473
+ readonly c1: number;
474
+ /** 1-based first row. */
475
+ readonly r1: number;
476
+ readonly c2: number;
477
+ readonly r2: number;
478
+ constructor(sheet: string,
479
+ /** 0-based first column. */
480
+ c1: number,
481
+ /** 1-based first row. */
482
+ r1: number, c2: number, r2: number);
483
+ static parse(ref: unknown, defaultSheet: string): ChartRange | null;
484
+ /** 'Q3 Revenue'!$B$5:$B$7 */
485
+ formula(): string;
486
+ /** "B5:B7" on its own sheet, "'Data'!B5:B7" on another. */
487
+ toSchema(ownSheet: string): string;
488
+ /** A1 addresses, row by row. */
489
+ addresses(): string[];
490
+ }
491
+
492
+ /** How a sheet prints. Mirrors the PHP `Sheet::$print` array. */
493
+ interface PrintSetup {
494
+ orientation: "portrait" | "landscape" | null;
495
+ fitToWidth: boolean;
496
+ footer: {
497
+ left: string;
498
+ center: string;
499
+ right: string;
500
+ } | null;
501
+ }
502
+ /** A native chart, normalised. Mirrors the PHP `Sheet::$charts` entries. */
503
+ interface NormalizedChart {
504
+ type: "column" | "bar" | "line" | "pie";
505
+ title: string | null;
506
+ categories: ChartRange | null;
507
+ series: {
508
+ name: string | null;
509
+ values: ChartRange;
510
+ color: string | null;
511
+ }[];
512
+ /** [col, row], both 0-based. */
513
+ from: [number, number];
514
+ to: [number, number];
515
+ legend: boolean | null;
516
+ dataLabels: boolean;
517
+ format: string | null;
518
+ }
431
519
  /** A worksheet. Mirrors PHP `Workbook\Sheet`. Cells are an A1-keyed map. */
432
520
  declare class Sheet {
433
521
  readonly name: string;
@@ -436,7 +524,14 @@ declare class Sheet {
436
524
  readonly columnWidths: Map<number, number>;
437
525
  readonly frozenRows: number;
438
526
  readonly frozenCols: number;
439
- constructor(name: string, cells?: Map<string, Cell>, mergedRegions?: MergedRegion[], columnWidths?: Map<number, number>, frozenRows?: number, frozenCols?: number);
527
+ /** 1-based row number → pixels. */
528
+ readonly rowHeights: Map<number, number>;
529
+ readonly print: PrintSetup | null;
530
+ readonly charts: NormalizedChart[];
531
+ constructor(name: string, cells?: Map<string, Cell>, mergedRegions?: MergedRegion[], columnWidths?: Map<number, number>, frozenRows?: number, frozenCols?: number,
532
+ /** 1-based row number → pixels. */
533
+ rowHeights?: Map<number, number>, print?: PrintSetup | null, charts?: NormalizedChart[]);
534
+ withCharts(charts: NormalizedChart[]): Sheet;
440
535
  /** rowNumber → (colLetter → Cell), sorted by ascending row number. */
441
536
  rows(): Map<number, Map<string, Cell>>;
442
537
  hasComments(): boolean;
@@ -547,16 +642,13 @@ declare class Theme {
547
642
  totalsFormat(): CellFormat | null;
548
643
  }
549
644
 
550
- /**
551
- * XLSX writer — emits a complete OOXML SpreadsheetML package as bytes.
552
- * Mirrors PHP `Writer\XlsxWriter` (file I/O moved to the Agent for isomorphism).
553
- */
554
645
  declare class XlsxWriter {
555
646
  toBytes(workbook: Workbook): Uint8Array;
556
647
  private contentTypesXml;
557
648
  private rootRelsXml;
558
649
  private workbookXml;
559
650
  private workbookRelsXml;
651
+ /** Comments keep rId1 (vml) and rId2 (comments); the chart drawing takes the next id. */
560
652
  private sheetRelsXml;
561
653
  private sheetXml;
562
654
  private cellXml;
@@ -800,4 +892,4 @@ declare function zipSync(files: ZipFile[]): Uint8Array;
800
892
 
801
893
  declare function unzipSync(data: Uint8Array): Record<string, Uint8Array>;
802
894
 
803
- export { type AddSheetOp, Agent, type AggOp, ArrayBuilder, type BuilderOptions, CellAddress, type CellData, type CellFormatInput, type CellPrimitive, type ClearCellOp, type ColumnSchema, type ColumnType, type CommentInput, CsvBuilder, type DeleteColumnsOp, type DeleteRowsOp, type DisplayFormat, FormatSniffer, FormulaLinter, type FormulaProblem, HolySheet, type HolySheetSchema, Inference, type InsertColumnsOp, type InsertRowsOp, type MoveSheetOp, Normalizer, OdsReader, type RemoveSheetOp, type RenameSheetOp, type RepairResult, Repairer, type ReplaceSheetOp, type RowCell, SchemaException, type SetCellOp, type SetColumnWidthsOp, type SetFrozenOp, type SetMergedRegionsOp, type SetMetaOp, type SetRangeOp, type SetWorkbookOp, SheetDiff, type SheetOp, SheetOpSchema, type SheetOpType, SheetReducer, type SheetSchema, type SpreadsheetFormat, Theme, type ThemeKey, UnsupportedFormatException, VERSION, type ValidationError, Validator, type WriteResult, XlsxReader, XlsxWriter, type ZipFile, unzipSync, zipSync };
895
+ export { type AddSheetOp, Agent, type AggOp, ArrayBuilder, type BuilderOptions, CellAddress, type CellData, type CellFormatInput, type CellPrimitive, type ChartSchema, type ClearCellOp, type ColumnSchema, type ColumnType, type CommentInput, CsvBuilder, type DeleteColumnsOp, type DeleteRowsOp, type DisplayFormat, FormatSniffer, FormulaLinter, type FormulaProblem, HolySheet, type HolySheetSchema, Inference, type InsertColumnsOp, type InsertRowsOp, type MoveSheetOp, Normalizer, OdsReader, type RemoveSheetOp, type RenameSheetOp, type RepairResult, Repairer, type ReplaceSheetOp, type RowCell, SchemaException, type SetCellOp, type SetColumnWidthsOp, type SetFrozenOp, type SetMergedRegionsOp, type SetMetaOp, type SetRangeOp, type SetWorkbookOp, SheetDiff, type SheetOp, SheetOpSchema, type SheetOpType, SheetReducer, type SheetSchema, type SpreadsheetFormat, Theme, type ThemeKey, UnsupportedFormatException, VERSION, type ValidationError, Validator, type WriteResult, XlsxReader, XlsxWriter, type ZipFile, unzipSync, zipSync };
package/dist/index.d.ts CHANGED
@@ -58,6 +58,40 @@ interface SheetSchema {
58
58
  columnWidths?: Record<number | string, number>;
59
59
  frozenRows?: number;
60
60
  frozenCols?: number;
61
+ /** 1-based row number → pixels. */
62
+ rowHeights?: Record<number | string, number>;
63
+ print?: {
64
+ orientation?: "portrait" | "landscape";
65
+ fitToWidth?: boolean;
66
+ /** `{page}` / `{pages}` print the page number and count. */
67
+ footer?: {
68
+ left?: string;
69
+ center?: string;
70
+ right?: string;
71
+ };
72
+ };
73
+ /** Native charts drawn over cell ranges; they stay live when the cells change. */
74
+ charts?: ChartSchema[];
75
+ }
76
+ interface ChartSchema {
77
+ type: "column" | "bar" | "line" | "pie";
78
+ title?: string;
79
+ /** Axis labels, e.g. "A5:A7" or "'Other sheet'!A5:A7". */
80
+ categories?: string;
81
+ series: {
82
+ name?: string;
83
+ values: string;
84
+ color?: string;
85
+ }[];
86
+ /** Top-left and bottom-right cells; defaults to beside the data. */
87
+ position?: {
88
+ from: string;
89
+ to: string;
90
+ };
91
+ dataLabels?: boolean;
92
+ legend?: boolean;
93
+ /** Excel number format for the axis and labels, e.g. "$#,##0". */
94
+ format?: string;
61
95
  }
62
96
  interface HolySheetSchema {
63
97
  sheets: SheetSchema[];
@@ -223,7 +257,7 @@ interface SetMetaOp {
223
257
  }
224
258
 
225
259
  /** This package's own version, pinned to package.json by `version.test.ts`. */
226
- declare const VERSION = "2.6.0";
260
+ declare const VERSION = "2.8.0";
227
261
  type Any$6 = any;
228
262
  /**
229
263
  * Agent — the structured-tool surface for Holy Sheet. Mirrors PHP `Agent`.
@@ -295,7 +329,7 @@ type Any$5 = any;
295
329
  * over `Agent`. Provided for parity / DI ergonomics; most callers use `Agent`.
296
330
  */
297
331
  declare class HolySheet {
298
- static readonly VERSION = "2.6.0";
332
+ static readonly VERSION = "2.8.0";
299
333
  validate(schema: Any$5): ValidationError[];
300
334
  toBytes(schema: Any$5): Uint8Array;
301
335
  write(schema: Any$5, path: string): Promise<WriteResult>;
@@ -428,6 +462,60 @@ declare class MergedRegion {
428
462
  ref(): string;
429
463
  }
430
464
 
465
+ /**
466
+ * A cell range a chart reads from. Mirrors PHP `Workbook\ChartRange`:
467
+ * "B5:B7", "B5", "'Q3 Revenue'!B5:B7" or "Data!B5:B7", resolved against the
468
+ * chart's own sheet when no sheet is named.
469
+ */
470
+ declare class ChartRange {
471
+ readonly sheet: string;
472
+ /** 0-based first column. */
473
+ readonly c1: number;
474
+ /** 1-based first row. */
475
+ readonly r1: number;
476
+ readonly c2: number;
477
+ readonly r2: number;
478
+ constructor(sheet: string,
479
+ /** 0-based first column. */
480
+ c1: number,
481
+ /** 1-based first row. */
482
+ r1: number, c2: number, r2: number);
483
+ static parse(ref: unknown, defaultSheet: string): ChartRange | null;
484
+ /** 'Q3 Revenue'!$B$5:$B$7 */
485
+ formula(): string;
486
+ /** "B5:B7" on its own sheet, "'Data'!B5:B7" on another. */
487
+ toSchema(ownSheet: string): string;
488
+ /** A1 addresses, row by row. */
489
+ addresses(): string[];
490
+ }
491
+
492
+ /** How a sheet prints. Mirrors the PHP `Sheet::$print` array. */
493
+ interface PrintSetup {
494
+ orientation: "portrait" | "landscape" | null;
495
+ fitToWidth: boolean;
496
+ footer: {
497
+ left: string;
498
+ center: string;
499
+ right: string;
500
+ } | null;
501
+ }
502
+ /** A native chart, normalised. Mirrors the PHP `Sheet::$charts` entries. */
503
+ interface NormalizedChart {
504
+ type: "column" | "bar" | "line" | "pie";
505
+ title: string | null;
506
+ categories: ChartRange | null;
507
+ series: {
508
+ name: string | null;
509
+ values: ChartRange;
510
+ color: string | null;
511
+ }[];
512
+ /** [col, row], both 0-based. */
513
+ from: [number, number];
514
+ to: [number, number];
515
+ legend: boolean | null;
516
+ dataLabels: boolean;
517
+ format: string | null;
518
+ }
431
519
  /** A worksheet. Mirrors PHP `Workbook\Sheet`. Cells are an A1-keyed map. */
432
520
  declare class Sheet {
433
521
  readonly name: string;
@@ -436,7 +524,14 @@ declare class Sheet {
436
524
  readonly columnWidths: Map<number, number>;
437
525
  readonly frozenRows: number;
438
526
  readonly frozenCols: number;
439
- constructor(name: string, cells?: Map<string, Cell>, mergedRegions?: MergedRegion[], columnWidths?: Map<number, number>, frozenRows?: number, frozenCols?: number);
527
+ /** 1-based row number → pixels. */
528
+ readonly rowHeights: Map<number, number>;
529
+ readonly print: PrintSetup | null;
530
+ readonly charts: NormalizedChart[];
531
+ constructor(name: string, cells?: Map<string, Cell>, mergedRegions?: MergedRegion[], columnWidths?: Map<number, number>, frozenRows?: number, frozenCols?: number,
532
+ /** 1-based row number → pixels. */
533
+ rowHeights?: Map<number, number>, print?: PrintSetup | null, charts?: NormalizedChart[]);
534
+ withCharts(charts: NormalizedChart[]): Sheet;
440
535
  /** rowNumber → (colLetter → Cell), sorted by ascending row number. */
441
536
  rows(): Map<number, Map<string, Cell>>;
442
537
  hasComments(): boolean;
@@ -547,16 +642,13 @@ declare class Theme {
547
642
  totalsFormat(): CellFormat | null;
548
643
  }
549
644
 
550
- /**
551
- * XLSX writer — emits a complete OOXML SpreadsheetML package as bytes.
552
- * Mirrors PHP `Writer\XlsxWriter` (file I/O moved to the Agent for isomorphism).
553
- */
554
645
  declare class XlsxWriter {
555
646
  toBytes(workbook: Workbook): Uint8Array;
556
647
  private contentTypesXml;
557
648
  private rootRelsXml;
558
649
  private workbookXml;
559
650
  private workbookRelsXml;
651
+ /** Comments keep rId1 (vml) and rId2 (comments); the chart drawing takes the next id. */
560
652
  private sheetRelsXml;
561
653
  private sheetXml;
562
654
  private cellXml;
@@ -800,4 +892,4 @@ declare function zipSync(files: ZipFile[]): Uint8Array;
800
892
 
801
893
  declare function unzipSync(data: Uint8Array): Record<string, Uint8Array>;
802
894
 
803
- export { type AddSheetOp, Agent, type AggOp, ArrayBuilder, type BuilderOptions, CellAddress, type CellData, type CellFormatInput, type CellPrimitive, type ClearCellOp, type ColumnSchema, type ColumnType, type CommentInput, CsvBuilder, type DeleteColumnsOp, type DeleteRowsOp, type DisplayFormat, FormatSniffer, FormulaLinter, type FormulaProblem, HolySheet, type HolySheetSchema, Inference, type InsertColumnsOp, type InsertRowsOp, type MoveSheetOp, Normalizer, OdsReader, type RemoveSheetOp, type RenameSheetOp, type RepairResult, Repairer, type ReplaceSheetOp, type RowCell, SchemaException, type SetCellOp, type SetColumnWidthsOp, type SetFrozenOp, type SetMergedRegionsOp, type SetMetaOp, type SetRangeOp, type SetWorkbookOp, SheetDiff, type SheetOp, SheetOpSchema, type SheetOpType, SheetReducer, type SheetSchema, type SpreadsheetFormat, Theme, type ThemeKey, UnsupportedFormatException, VERSION, type ValidationError, Validator, type WriteResult, XlsxReader, XlsxWriter, type ZipFile, unzipSync, zipSync };
895
+ export { type AddSheetOp, Agent, type AggOp, ArrayBuilder, type BuilderOptions, CellAddress, type CellData, type CellFormatInput, type CellPrimitive, type ChartSchema, type ClearCellOp, type ColumnSchema, type ColumnType, type CommentInput, CsvBuilder, type DeleteColumnsOp, type DeleteRowsOp, type DisplayFormat, FormatSniffer, FormulaLinter, type FormulaProblem, HolySheet, type HolySheetSchema, Inference, type InsertColumnsOp, type InsertRowsOp, type MoveSheetOp, Normalizer, OdsReader, type RemoveSheetOp, type RenameSheetOp, type RepairResult, Repairer, type ReplaceSheetOp, type RowCell, SchemaException, type SetCellOp, type SetColumnWidthsOp, type SetFrozenOp, type SetMergedRegionsOp, type SetMetaOp, type SetRangeOp, type SetWorkbookOp, SheetDiff, type SheetOp, SheetOpSchema, type SheetOpType, SheetReducer, type SheetSchema, type SpreadsheetFormat, Theme, type ThemeKey, UnsupportedFormatException, VERSION, type ValidationError, Validator, type WriteResult, XlsxReader, XlsxWriter, type ZipFile, unzipSync, zipSync };