@particle-academy/holy-sheet 2.7.0 → 2.9.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
@@ -63,6 +63,8 @@ interface SheetSchema {
63
63
  print?: {
64
64
  orientation?: "portrait" | "landscape";
65
65
  fitToWidth?: boolean;
66
+ /** One page wide AND tall: a one-page summary with a chart prints whole. */
67
+ fitToPage?: boolean;
66
68
  /** `{page}` / `{pages}` print the page number and count. */
67
69
  footer?: {
68
70
  left?: string;
@@ -70,6 +72,33 @@ interface SheetSchema {
70
72
  right?: string;
71
73
  };
72
74
  };
75
+ /** Native charts drawn over cell ranges; they stay live when the cells change. */
76
+ charts?: ChartSchema[];
77
+ }
78
+ interface ChartSchema {
79
+ type: "column" | "bar" | "line" | "pie";
80
+ title?: string;
81
+ /** Axis labels, e.g. "A5:A7" or "'Other sheet'!A5:A7". */
82
+ categories?: string;
83
+ /** points colours single points (0-based within values) to make the finding stand out. */
84
+ series: {
85
+ name?: string;
86
+ values: string;
87
+ color?: string;
88
+ points?: {
89
+ index: number;
90
+ color: string;
91
+ }[];
92
+ }[];
93
+ /** Top-left and bottom-right cells; defaults to beside the data. */
94
+ position?: {
95
+ from: string;
96
+ to: string;
97
+ };
98
+ dataLabels?: boolean;
99
+ legend?: boolean;
100
+ /** Excel number format for the axis and labels, e.g. "$#,##0". */
101
+ format?: string;
73
102
  }
74
103
  interface HolySheetSchema {
75
104
  sheets: SheetSchema[];
@@ -235,7 +264,7 @@ interface SetMetaOp {
235
264
  }
236
265
 
237
266
  /** This package's own version, pinned to package.json by `version.test.ts`. */
238
- declare const VERSION = "2.7.0";
267
+ declare const VERSION = "2.9.0";
239
268
  type Any$6 = any;
240
269
  /**
241
270
  * Agent — the structured-tool surface for Holy Sheet. Mirrors PHP `Agent`.
@@ -307,7 +336,7 @@ type Any$5 = any;
307
336
  * over `Agent`. Provided for parity / DI ergonomics; most callers use `Agent`.
308
337
  */
309
338
  declare class HolySheet {
310
- static readonly VERSION = "2.7.0";
339
+ static readonly VERSION = "2.9.0";
311
340
  validate(schema: Any$5): ValidationError[];
312
341
  toBytes(schema: Any$5): Uint8Array;
313
342
  write(schema: Any$5, path: string): Promise<WriteResult>;
@@ -440,16 +469,66 @@ declare class MergedRegion {
440
469
  ref(): string;
441
470
  }
442
471
 
472
+ /**
473
+ * A cell range a chart reads from. Mirrors PHP `Workbook\ChartRange`:
474
+ * "B5:B7", "B5", "'Q3 Revenue'!B5:B7" or "Data!B5:B7", resolved against the
475
+ * chart's own sheet when no sheet is named.
476
+ */
477
+ declare class ChartRange {
478
+ readonly sheet: string;
479
+ /** 0-based first column. */
480
+ readonly c1: number;
481
+ /** 1-based first row. */
482
+ readonly r1: number;
483
+ readonly c2: number;
484
+ readonly r2: number;
485
+ constructor(sheet: string,
486
+ /** 0-based first column. */
487
+ c1: number,
488
+ /** 1-based first row. */
489
+ r1: number, c2: number, r2: number);
490
+ static parse(ref: unknown, defaultSheet: string): ChartRange | null;
491
+ /** 'Q3 Revenue'!$B$5:$B$7 */
492
+ formula(): string;
493
+ /** "B5:B7" on its own sheet, "'Data'!B5:B7" on another. */
494
+ toSchema(ownSheet: string): string;
495
+ /** A1 addresses, row by row. */
496
+ addresses(): string[];
497
+ }
498
+
443
499
  /** How a sheet prints. Mirrors the PHP `Sheet::$print` array. */
444
500
  interface PrintSetup {
445
501
  orientation: "portrait" | "landscape" | null;
446
502
  fitToWidth: boolean;
503
+ /** One page wide AND tall. */
504
+ fitToPage: boolean;
447
505
  footer: {
448
506
  left: string;
449
507
  center: string;
450
508
  right: string;
451
509
  } | null;
452
510
  }
511
+ /** A native chart, normalised. Mirrors the PHP `Sheet::$charts` entries. */
512
+ interface NormalizedChart {
513
+ type: "column" | "bar" | "line" | "pie";
514
+ title: string | null;
515
+ categories: ChartRange | null;
516
+ series: {
517
+ name: string | null;
518
+ values: ChartRange;
519
+ color: string | null;
520
+ points: {
521
+ index: number;
522
+ color: string;
523
+ }[];
524
+ }[];
525
+ /** [col, row], both 0-based. */
526
+ from: [number, number];
527
+ to: [number, number];
528
+ legend: boolean | null;
529
+ dataLabels: boolean;
530
+ format: string | null;
531
+ }
453
532
  /** A worksheet. Mirrors PHP `Workbook\Sheet`. Cells are an A1-keyed map. */
454
533
  declare class Sheet {
455
534
  readonly name: string;
@@ -461,9 +540,11 @@ declare class Sheet {
461
540
  /** 1-based row number → pixels. */
462
541
  readonly rowHeights: Map<number, number>;
463
542
  readonly print: PrintSetup | null;
543
+ readonly charts: NormalizedChart[];
464
544
  constructor(name: string, cells?: Map<string, Cell>, mergedRegions?: MergedRegion[], columnWidths?: Map<number, number>, frozenRows?: number, frozenCols?: number,
465
545
  /** 1-based row number → pixels. */
466
- rowHeights?: Map<number, number>, print?: PrintSetup | null);
546
+ rowHeights?: Map<number, number>, print?: PrintSetup | null, charts?: NormalizedChart[]);
547
+ withCharts(charts: NormalizedChart[]): Sheet;
467
548
  /** rowNumber → (colLetter → Cell), sorted by ascending row number. */
468
549
  rows(): Map<number, Map<string, Cell>>;
469
550
  hasComments(): boolean;
@@ -580,6 +661,7 @@ declare class XlsxWriter {
580
661
  private rootRelsXml;
581
662
  private workbookXml;
582
663
  private workbookRelsXml;
664
+ /** Comments keep rId1 (vml) and rId2 (comments); the chart drawing takes the next id. */
583
665
  private sheetRelsXml;
584
666
  private sheetXml;
585
667
  private cellXml;
@@ -823,4 +905,4 @@ declare function zipSync(files: ZipFile[]): Uint8Array;
823
905
 
824
906
  declare function unzipSync(data: Uint8Array): Record<string, Uint8Array>;
825
907
 
826
- 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 };
908
+ 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
@@ -63,6 +63,8 @@ interface SheetSchema {
63
63
  print?: {
64
64
  orientation?: "portrait" | "landscape";
65
65
  fitToWidth?: boolean;
66
+ /** One page wide AND tall: a one-page summary with a chart prints whole. */
67
+ fitToPage?: boolean;
66
68
  /** `{page}` / `{pages}` print the page number and count. */
67
69
  footer?: {
68
70
  left?: string;
@@ -70,6 +72,33 @@ interface SheetSchema {
70
72
  right?: string;
71
73
  };
72
74
  };
75
+ /** Native charts drawn over cell ranges; they stay live when the cells change. */
76
+ charts?: ChartSchema[];
77
+ }
78
+ interface ChartSchema {
79
+ type: "column" | "bar" | "line" | "pie";
80
+ title?: string;
81
+ /** Axis labels, e.g. "A5:A7" or "'Other sheet'!A5:A7". */
82
+ categories?: string;
83
+ /** points colours single points (0-based within values) to make the finding stand out. */
84
+ series: {
85
+ name?: string;
86
+ values: string;
87
+ color?: string;
88
+ points?: {
89
+ index: number;
90
+ color: string;
91
+ }[];
92
+ }[];
93
+ /** Top-left and bottom-right cells; defaults to beside the data. */
94
+ position?: {
95
+ from: string;
96
+ to: string;
97
+ };
98
+ dataLabels?: boolean;
99
+ legend?: boolean;
100
+ /** Excel number format for the axis and labels, e.g. "$#,##0". */
101
+ format?: string;
73
102
  }
74
103
  interface HolySheetSchema {
75
104
  sheets: SheetSchema[];
@@ -235,7 +264,7 @@ interface SetMetaOp {
235
264
  }
236
265
 
237
266
  /** This package's own version, pinned to package.json by `version.test.ts`. */
238
- declare const VERSION = "2.7.0";
267
+ declare const VERSION = "2.9.0";
239
268
  type Any$6 = any;
240
269
  /**
241
270
  * Agent — the structured-tool surface for Holy Sheet. Mirrors PHP `Agent`.
@@ -307,7 +336,7 @@ type Any$5 = any;
307
336
  * over `Agent`. Provided for parity / DI ergonomics; most callers use `Agent`.
308
337
  */
309
338
  declare class HolySheet {
310
- static readonly VERSION = "2.7.0";
339
+ static readonly VERSION = "2.9.0";
311
340
  validate(schema: Any$5): ValidationError[];
312
341
  toBytes(schema: Any$5): Uint8Array;
313
342
  write(schema: Any$5, path: string): Promise<WriteResult>;
@@ -440,16 +469,66 @@ declare class MergedRegion {
440
469
  ref(): string;
441
470
  }
442
471
 
472
+ /**
473
+ * A cell range a chart reads from. Mirrors PHP `Workbook\ChartRange`:
474
+ * "B5:B7", "B5", "'Q3 Revenue'!B5:B7" or "Data!B5:B7", resolved against the
475
+ * chart's own sheet when no sheet is named.
476
+ */
477
+ declare class ChartRange {
478
+ readonly sheet: string;
479
+ /** 0-based first column. */
480
+ readonly c1: number;
481
+ /** 1-based first row. */
482
+ readonly r1: number;
483
+ readonly c2: number;
484
+ readonly r2: number;
485
+ constructor(sheet: string,
486
+ /** 0-based first column. */
487
+ c1: number,
488
+ /** 1-based first row. */
489
+ r1: number, c2: number, r2: number);
490
+ static parse(ref: unknown, defaultSheet: string): ChartRange | null;
491
+ /** 'Q3 Revenue'!$B$5:$B$7 */
492
+ formula(): string;
493
+ /** "B5:B7" on its own sheet, "'Data'!B5:B7" on another. */
494
+ toSchema(ownSheet: string): string;
495
+ /** A1 addresses, row by row. */
496
+ addresses(): string[];
497
+ }
498
+
443
499
  /** How a sheet prints. Mirrors the PHP `Sheet::$print` array. */
444
500
  interface PrintSetup {
445
501
  orientation: "portrait" | "landscape" | null;
446
502
  fitToWidth: boolean;
503
+ /** One page wide AND tall. */
504
+ fitToPage: boolean;
447
505
  footer: {
448
506
  left: string;
449
507
  center: string;
450
508
  right: string;
451
509
  } | null;
452
510
  }
511
+ /** A native chart, normalised. Mirrors the PHP `Sheet::$charts` entries. */
512
+ interface NormalizedChart {
513
+ type: "column" | "bar" | "line" | "pie";
514
+ title: string | null;
515
+ categories: ChartRange | null;
516
+ series: {
517
+ name: string | null;
518
+ values: ChartRange;
519
+ color: string | null;
520
+ points: {
521
+ index: number;
522
+ color: string;
523
+ }[];
524
+ }[];
525
+ /** [col, row], both 0-based. */
526
+ from: [number, number];
527
+ to: [number, number];
528
+ legend: boolean | null;
529
+ dataLabels: boolean;
530
+ format: string | null;
531
+ }
453
532
  /** A worksheet. Mirrors PHP `Workbook\Sheet`. Cells are an A1-keyed map. */
454
533
  declare class Sheet {
455
534
  readonly name: string;
@@ -461,9 +540,11 @@ declare class Sheet {
461
540
  /** 1-based row number → pixels. */
462
541
  readonly rowHeights: Map<number, number>;
463
542
  readonly print: PrintSetup | null;
543
+ readonly charts: NormalizedChart[];
464
544
  constructor(name: string, cells?: Map<string, Cell>, mergedRegions?: MergedRegion[], columnWidths?: Map<number, number>, frozenRows?: number, frozenCols?: number,
465
545
  /** 1-based row number → pixels. */
466
- rowHeights?: Map<number, number>, print?: PrintSetup | null);
546
+ rowHeights?: Map<number, number>, print?: PrintSetup | null, charts?: NormalizedChart[]);
547
+ withCharts(charts: NormalizedChart[]): Sheet;
467
548
  /** rowNumber → (colLetter → Cell), sorted by ascending row number. */
468
549
  rows(): Map<number, Map<string, Cell>>;
469
550
  hasComments(): boolean;
@@ -580,6 +661,7 @@ declare class XlsxWriter {
580
661
  private rootRelsXml;
581
662
  private workbookXml;
582
663
  private workbookRelsXml;
664
+ /** Comments keep rId1 (vml) and rId2 (comments); the chart drawing takes the next id. */
583
665
  private sheetRelsXml;
584
666
  private sheetXml;
585
667
  private cellXml;
@@ -823,4 +905,4 @@ declare function zipSync(files: ZipFile[]): Uint8Array;
823
905
 
824
906
  declare function unzipSync(data: Uint8Array): Record<string, Uint8Array>;
825
907
 
826
- 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 };
908
+ 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 };