@particle-academy/holy-sheet 2.2.0 → 2.3.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
@@ -102,8 +102,8 @@ interface BuilderOptions {
102
102
  enclosure?: string;
103
103
  }
104
104
 
105
- /** Feature-parity baseline with PHP holy-sheet; bumped independently on npm. */
106
- declare const VERSION = "1.0.0";
105
+ /** This package's own version, pinned to package.json by `version.test.ts`. */
106
+ declare const VERSION = "2.3.0";
107
107
  type Any$5 = any;
108
108
  /**
109
109
  * Agent — the structured-tool surface for Holy Sheet. Mirrors PHP `Agent`.
@@ -119,9 +119,13 @@ declare const Agent: {
119
119
  write(schema: Any$5, path: string): Promise<WriteResult>;
120
120
  /** JSON Schema for LLM tool-use. */
121
121
  toolDefinition(): Record<string, unknown>;
122
- /** Round-trip xlsx bytes back to a schema. Universal. */
122
+ /**
123
+ * Round-trip xlsx or ods bytes back to a schema. Universal. The format is
124
+ * told apart by content, never by name, and both describe to the same
125
+ * schema. Throws `UnsupportedFormatException` for anything else.
126
+ */
123
127
  read(input: Uint8Array | ArrayBuffer): Record<string, unknown>;
124
- /** Round-trip an xlsx file on disk back to a schema (Node only). */
128
+ /** Round-trip an xlsx or ods file on disk back to a schema (Node only). */
125
129
  describe(path: string): Promise<Record<string, unknown>>;
126
130
  /** Validate + conservative repairs in one call. */
127
131
  validateAndRepair(schema: Any$5): RepairResult;
@@ -140,7 +144,7 @@ type Any$4 = any;
140
144
  * over `Agent`. Provided for parity / DI ergonomics; most callers use `Agent`.
141
145
  */
142
146
  declare class HolySheet {
143
- static readonly VERSION = "1.0.0";
147
+ static readonly VERSION = "2.3.0";
144
148
  validate(schema: Any$4): ValidationError[];
145
149
  toBytes(schema: Any$4): Uint8Array;
146
150
  write(schema: Any$4, path: string): Promise<WriteResult>;
@@ -162,6 +166,23 @@ declare class SchemaException extends Error {
162
166
  static fromErrors(errors: ValidationError[]): SchemaException;
163
167
  getErrors(): ValidationError[];
164
168
  }
169
+ /**
170
+ * Thrown by `Agent.read()` / `Agent.describe()` for a file that is neither an
171
+ * xlsx workbook nor an OpenDocument spreadsheet. Mirrors PHP
172
+ * `UnsupportedFormatException`.
173
+ *
174
+ * It extends Error, which is what an unreadable file threw before it existed,
175
+ * so an existing catch still catches it. `mimetype` carries what the package
176
+ * declared about itself when it declared anything (an OpenDocument TEXT file,
177
+ * say), so a caller can say "that is a document, not a spreadsheet".
178
+ */
179
+ declare class UnsupportedFormatException extends Error {
180
+ readonly path: string | null;
181
+ readonly mimetype: string | null;
182
+ constructor(message: string, path?: string | null, mimetype?: string | null);
183
+ static notAZip(path?: string | null): UnsupportedFormatException;
184
+ static unknownPackage(path: string | null, mimetype: string | null): UnsupportedFormatException;
185
+ }
165
186
 
166
187
  type Any$3 = any;
167
188
  /** Hand-rolled schema validator. Mirrors PHP `Schema\Validator`. */
@@ -372,12 +393,42 @@ declare class XlsxWriter {
372
393
  declare class XlsxReader {
373
394
  describe(bytes: Uint8Array): Record<string, unknown>;
374
395
  readWorkbook(bytes: Uint8Array): Workbook;
396
+ /** Read an already-unzipped package (name -> bytes), so a caller that sniffed it does not unzip twice. */
397
+ readFiles(files: Record<string, Uint8Array>): Workbook;
375
398
  private parseDocProps;
376
- private workbookToSchema;
377
- private sheetToSchema;
378
- private cellToSchema;
379
399
  }
380
400
 
401
+ /**
402
+ * OpenDocument Spreadsheet (.ods) reader — bytes → Holy Sheet schema, the same
403
+ * schema the xlsx reader returns. Mirrors PHP `Reader\OdsReader`, where what is
404
+ * and is not mapped is documented.
405
+ */
406
+ declare class OdsReader {
407
+ describe(bytes: Uint8Array): Record<string, unknown>;
408
+ readWorkbook(bytes: Uint8Array): Workbook;
409
+ /** Read an already-unzipped package (name -> bytes). */
410
+ readFiles(files: Record<string, Uint8Array>): Workbook;
411
+ private readSheet;
412
+ private walkRows;
413
+ private readRow;
414
+ }
415
+
416
+ type SpreadsheetFormat = "xlsx" | "ods";
417
+ /**
418
+ * Which reader a file needs, decided from its contents, never its extension.
419
+ * Mirrors PHP `Reader\FormatSniffer`.
420
+ *
421
+ * An OpenDocument package names itself in its `mimetype` entry; an xlsx has no
422
+ * such entry and is recognised by `xl/workbook.xml`. Anything else is refused
423
+ * by name. The unzipped entries are returned so the reader does not unzip again.
424
+ */
425
+ declare const FormatSniffer: {
426
+ sniff(bytes: Uint8Array, path?: string | null): {
427
+ format: SpreadsheetFormat;
428
+ files: Record<string, Uint8Array>;
429
+ };
430
+ };
431
+
381
432
  type Any = any;
382
433
  /**
383
434
  * Flat rows (+ optional headers) → Holy Sheet schema with inferred column types.
@@ -417,4 +468,4 @@ declare function zipSync(files: ZipFile[]): Uint8Array;
417
468
 
418
469
  declare function unzipSync(data: Uint8Array): Record<string, Uint8Array>;
419
470
 
420
- export { Agent, type AggOp, ArrayBuilder, type BuilderOptions, CellAddress, type CellData, type CellFormatInput, type CellPrimitive, type ColumnSchema, type ColumnType, type CommentInput, CsvBuilder, type DisplayFormat, FormulaLinter, type FormulaProblem, HolySheet, type HolySheetSchema, Inference, Normalizer, type RepairResult, Repairer, type RowCell, SchemaException, type SheetSchema, Theme, type ThemeKey, VERSION, type ValidationError, Validator, type WriteResult, XlsxReader, XlsxWriter, type ZipFile, unzipSync, zipSync };
471
+ export { Agent, type AggOp, ArrayBuilder, type BuilderOptions, CellAddress, type CellData, type CellFormatInput, type CellPrimitive, type ColumnSchema, type ColumnType, type CommentInput, CsvBuilder, type DisplayFormat, FormatSniffer, FormulaLinter, type FormulaProblem, HolySheet, type HolySheetSchema, Inference, Normalizer, OdsReader, type RepairResult, Repairer, type RowCell, SchemaException, 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
@@ -102,8 +102,8 @@ interface BuilderOptions {
102
102
  enclosure?: string;
103
103
  }
104
104
 
105
- /** Feature-parity baseline with PHP holy-sheet; bumped independently on npm. */
106
- declare const VERSION = "1.0.0";
105
+ /** This package's own version, pinned to package.json by `version.test.ts`. */
106
+ declare const VERSION = "2.3.0";
107
107
  type Any$5 = any;
108
108
  /**
109
109
  * Agent — the structured-tool surface for Holy Sheet. Mirrors PHP `Agent`.
@@ -119,9 +119,13 @@ declare const Agent: {
119
119
  write(schema: Any$5, path: string): Promise<WriteResult>;
120
120
  /** JSON Schema for LLM tool-use. */
121
121
  toolDefinition(): Record<string, unknown>;
122
- /** Round-trip xlsx bytes back to a schema. Universal. */
122
+ /**
123
+ * Round-trip xlsx or ods bytes back to a schema. Universal. The format is
124
+ * told apart by content, never by name, and both describe to the same
125
+ * schema. Throws `UnsupportedFormatException` for anything else.
126
+ */
123
127
  read(input: Uint8Array | ArrayBuffer): Record<string, unknown>;
124
- /** Round-trip an xlsx file on disk back to a schema (Node only). */
128
+ /** Round-trip an xlsx or ods file on disk back to a schema (Node only). */
125
129
  describe(path: string): Promise<Record<string, unknown>>;
126
130
  /** Validate + conservative repairs in one call. */
127
131
  validateAndRepair(schema: Any$5): RepairResult;
@@ -140,7 +144,7 @@ type Any$4 = any;
140
144
  * over `Agent`. Provided for parity / DI ergonomics; most callers use `Agent`.
141
145
  */
142
146
  declare class HolySheet {
143
- static readonly VERSION = "1.0.0";
147
+ static readonly VERSION = "2.3.0";
144
148
  validate(schema: Any$4): ValidationError[];
145
149
  toBytes(schema: Any$4): Uint8Array;
146
150
  write(schema: Any$4, path: string): Promise<WriteResult>;
@@ -162,6 +166,23 @@ declare class SchemaException extends Error {
162
166
  static fromErrors(errors: ValidationError[]): SchemaException;
163
167
  getErrors(): ValidationError[];
164
168
  }
169
+ /**
170
+ * Thrown by `Agent.read()` / `Agent.describe()` for a file that is neither an
171
+ * xlsx workbook nor an OpenDocument spreadsheet. Mirrors PHP
172
+ * `UnsupportedFormatException`.
173
+ *
174
+ * It extends Error, which is what an unreadable file threw before it existed,
175
+ * so an existing catch still catches it. `mimetype` carries what the package
176
+ * declared about itself when it declared anything (an OpenDocument TEXT file,
177
+ * say), so a caller can say "that is a document, not a spreadsheet".
178
+ */
179
+ declare class UnsupportedFormatException extends Error {
180
+ readonly path: string | null;
181
+ readonly mimetype: string | null;
182
+ constructor(message: string, path?: string | null, mimetype?: string | null);
183
+ static notAZip(path?: string | null): UnsupportedFormatException;
184
+ static unknownPackage(path: string | null, mimetype: string | null): UnsupportedFormatException;
185
+ }
165
186
 
166
187
  type Any$3 = any;
167
188
  /** Hand-rolled schema validator. Mirrors PHP `Schema\Validator`. */
@@ -372,12 +393,42 @@ declare class XlsxWriter {
372
393
  declare class XlsxReader {
373
394
  describe(bytes: Uint8Array): Record<string, unknown>;
374
395
  readWorkbook(bytes: Uint8Array): Workbook;
396
+ /** Read an already-unzipped package (name -> bytes), so a caller that sniffed it does not unzip twice. */
397
+ readFiles(files: Record<string, Uint8Array>): Workbook;
375
398
  private parseDocProps;
376
- private workbookToSchema;
377
- private sheetToSchema;
378
- private cellToSchema;
379
399
  }
380
400
 
401
+ /**
402
+ * OpenDocument Spreadsheet (.ods) reader — bytes → Holy Sheet schema, the same
403
+ * schema the xlsx reader returns. Mirrors PHP `Reader\OdsReader`, where what is
404
+ * and is not mapped is documented.
405
+ */
406
+ declare class OdsReader {
407
+ describe(bytes: Uint8Array): Record<string, unknown>;
408
+ readWorkbook(bytes: Uint8Array): Workbook;
409
+ /** Read an already-unzipped package (name -> bytes). */
410
+ readFiles(files: Record<string, Uint8Array>): Workbook;
411
+ private readSheet;
412
+ private walkRows;
413
+ private readRow;
414
+ }
415
+
416
+ type SpreadsheetFormat = "xlsx" | "ods";
417
+ /**
418
+ * Which reader a file needs, decided from its contents, never its extension.
419
+ * Mirrors PHP `Reader\FormatSniffer`.
420
+ *
421
+ * An OpenDocument package names itself in its `mimetype` entry; an xlsx has no
422
+ * such entry and is recognised by `xl/workbook.xml`. Anything else is refused
423
+ * by name. The unzipped entries are returned so the reader does not unzip again.
424
+ */
425
+ declare const FormatSniffer: {
426
+ sniff(bytes: Uint8Array, path?: string | null): {
427
+ format: SpreadsheetFormat;
428
+ files: Record<string, Uint8Array>;
429
+ };
430
+ };
431
+
381
432
  type Any = any;
382
433
  /**
383
434
  * Flat rows (+ optional headers) → Holy Sheet schema with inferred column types.
@@ -417,4 +468,4 @@ declare function zipSync(files: ZipFile[]): Uint8Array;
417
468
 
418
469
  declare function unzipSync(data: Uint8Array): Record<string, Uint8Array>;
419
470
 
420
- export { Agent, type AggOp, ArrayBuilder, type BuilderOptions, CellAddress, type CellData, type CellFormatInput, type CellPrimitive, type ColumnSchema, type ColumnType, type CommentInput, CsvBuilder, type DisplayFormat, FormulaLinter, type FormulaProblem, HolySheet, type HolySheetSchema, Inference, Normalizer, type RepairResult, Repairer, type RowCell, SchemaException, type SheetSchema, Theme, type ThemeKey, VERSION, type ValidationError, Validator, type WriteResult, XlsxReader, XlsxWriter, type ZipFile, unzipSync, zipSync };
471
+ export { Agent, type AggOp, ArrayBuilder, type BuilderOptions, CellAddress, type CellData, type CellFormatInput, type CellPrimitive, type ColumnSchema, type ColumnType, type CommentInput, CsvBuilder, type DisplayFormat, FormatSniffer, FormulaLinter, type FormulaProblem, HolySheet, type HolySheetSchema, Inference, Normalizer, OdsReader, type RepairResult, Repairer, type RowCell, SchemaException, type SheetSchema, type SpreadsheetFormat, Theme, type ThemeKey, UnsupportedFormatException, VERSION, type ValidationError, Validator, type WriteResult, XlsxReader, XlsxWriter, type ZipFile, unzipSync, zipSync };