@particle-academy/holy-sheet 2.10.1 → 2.11.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/CHANGELOG.md +52 -0
- package/README.md +34 -0
- package/dist/chunk-OL6E7DE5.js +6828 -0
- package/dist/chunk-OL6E7DE5.js.map +1 -0
- package/dist/cli.cjs +6909 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +82 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +845 -267
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -5
- package/dist/index.d.ts +62 -5
- package/dist/index.js +9 -6255
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/index.d.cts
CHANGED
|
@@ -143,6 +143,8 @@ interface BuilderOptions {
|
|
|
143
143
|
enclosure?: string;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
type SourceKind = "document" | "template";
|
|
147
|
+
|
|
146
148
|
/**
|
|
147
149
|
* One op from `Agent.diff`, applied by `Agent.reduce`. Mirrors the PHP
|
|
148
150
|
* `HolySheet\Ops\SheetOpSchema` variants: same `type`, same field names.
|
|
@@ -264,7 +266,7 @@ interface SetMetaOp {
|
|
|
264
266
|
}
|
|
265
267
|
|
|
266
268
|
/** This package's own version, pinned to package.json by `version.test.ts`. */
|
|
267
|
-
declare const VERSION = "2.
|
|
269
|
+
declare const VERSION = "2.11.0";
|
|
268
270
|
type Any$6 = any;
|
|
269
271
|
/**
|
|
270
272
|
* Agent — the structured-tool surface for Holy Sheet. Mirrors PHP `Agent`.
|
|
@@ -286,6 +288,22 @@ declare const Agent: {
|
|
|
286
288
|
* schema. Throws `UnsupportedFormatException` for anything else.
|
|
287
289
|
*/
|
|
288
290
|
read(input: Uint8Array | ArrayBuffer): Record<string, unknown>;
|
|
291
|
+
/**
|
|
292
|
+
* Turn an Excel `.xltx` / LibreOffice `.ots` template into its `.xlsx` /
|
|
293
|
+
* `.ods` twin, or back. `to` is `"document"`, `"template"`, or null to flip.
|
|
294
|
+
* Universal and synchronous: bytes in, bytes out. Mirrors PHP
|
|
295
|
+
* `Agent::convertTemplate()`.
|
|
296
|
+
*
|
|
297
|
+
* Only the declaration moves: the workbook part's content type in
|
|
298
|
+
* `[Content_Types].xml`, or the ODF `mimetype` entry together with the
|
|
299
|
+
* manifest's root media-type (ODF 1.3 requires them to agree). Every other
|
|
300
|
+
* member is copied as its original zip record, byte for byte.
|
|
301
|
+
*
|
|
302
|
+
* Throws `OfficeTemplateRefused` (macro-enabled, mismatched, already that
|
|
303
|
+
* kind), `ArchiveRefused` (archive guard), or `UnsupportedFormatException`
|
|
304
|
+
* for a package that is not a spreadsheet.
|
|
305
|
+
*/
|
|
306
|
+
convertTemplate(input: Uint8Array | ArrayBuffer, to?: SourceKind | null): Uint8Array;
|
|
289
307
|
/** Round-trip an xlsx or ods file on disk back to a schema (Node only). */
|
|
290
308
|
describe(path: string): Promise<Record<string, unknown>>;
|
|
291
309
|
/** Validate + conservative repairs in one call. */
|
|
@@ -342,13 +360,15 @@ type Any$5 = any;
|
|
|
342
360
|
* over `Agent`. Provided for parity / DI ergonomics; most callers use `Agent`.
|
|
343
361
|
*/
|
|
344
362
|
declare class HolySheet {
|
|
345
|
-
static readonly VERSION = "2.
|
|
363
|
+
static readonly VERSION = "2.11.0";
|
|
346
364
|
validate(schema: Any$5): ValidationError[];
|
|
347
365
|
toBytes(schema: Any$5): Uint8Array;
|
|
348
366
|
write(schema: Any$5, path: string): Promise<WriteResult>;
|
|
349
367
|
toolDefinition(): Record<string, unknown>;
|
|
350
368
|
read(input: Uint8Array | ArrayBuffer): Record<string, unknown>;
|
|
351
369
|
describe(path: string): Promise<Record<string, unknown>>;
|
|
370
|
+
/** {@link Agent.convertTemplate}: .xltx/.ots to .xlsx/.ods and back. */
|
|
371
|
+
convertTemplate(input: Uint8Array | ArrayBuffer, to?: "document" | "template" | null): Uint8Array;
|
|
352
372
|
validateAndRepair(schema: Any$5): RepairResult;
|
|
353
373
|
fromArray(rows: Any$5[][], headers?: string[] | null, sheetName?: string, options?: BuilderOptions): HolySheetSchema;
|
|
354
374
|
fromCsv(csv: string, options?: BuilderOptions): HolySheetSchema;
|
|
@@ -357,6 +377,30 @@ declare class HolySheet {
|
|
|
357
377
|
static version(): string;
|
|
358
378
|
}
|
|
359
379
|
|
|
380
|
+
/** Bounded archive/security refusal; contains no document names or content. */
|
|
381
|
+
declare class ArchiveRefused extends Error {
|
|
382
|
+
readonly reason: string;
|
|
383
|
+
constructor(reason: string);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* An Office or LibreOffice template package refused, with a constant `reason`.
|
|
387
|
+
* Mirrors PHP `OfficeTemplateRefused`:
|
|
388
|
+
*
|
|
389
|
+
* - `macro_enabled` an .xltm (or a template carrying a VBA project). Never read
|
|
390
|
+
* and never converted.
|
|
391
|
+
* - `family_mismatch` it declares a template of another family, or its parts
|
|
392
|
+
* are not the family it declares.
|
|
393
|
+
* - `already_template` / `already_document` conversion asked for what it is.
|
|
394
|
+
* - `not_convertible` there is no single declaration that can be rewritten.
|
|
395
|
+
* - `odf_mimetype` an ODF package whose `mimetype` is not first and stored.
|
|
396
|
+
* - `bad_target` the conversion target is not `document` or `template`.
|
|
397
|
+
*
|
|
398
|
+
* Branch on `reason`; the message is for people.
|
|
399
|
+
*/
|
|
400
|
+
declare class OfficeTemplateRefused extends Error {
|
|
401
|
+
readonly reason: string;
|
|
402
|
+
constructor(reason: string);
|
|
403
|
+
}
|
|
360
404
|
/** Thrown when a Holy Sheet schema fails validation. Mirrors PHP `SchemaException`. */
|
|
361
405
|
declare class SchemaException extends Error {
|
|
362
406
|
readonly errors: ValidationError[];
|
|
@@ -382,6 +426,14 @@ declare class UnsupportedFormatException extends Error {
|
|
|
382
426
|
static unknownPackage(path: string | null, mimetype: string | null): UnsupportedFormatException;
|
|
383
427
|
}
|
|
384
428
|
|
|
429
|
+
interface ArchiveLimits {
|
|
430
|
+
maxArchiveBytes?: number;
|
|
431
|
+
maxEntries?: number;
|
|
432
|
+
maxPartBytes?: number;
|
|
433
|
+
maxExpandedBytes?: number;
|
|
434
|
+
maxCompressionRatio?: number;
|
|
435
|
+
}
|
|
436
|
+
|
|
385
437
|
type Any$4 = any;
|
|
386
438
|
/** Hand-rolled schema validator. Mirrors PHP `Schema\Validator`. */
|
|
387
439
|
declare class Validator {
|
|
@@ -564,7 +616,11 @@ declare class Sheet {
|
|
|
564
616
|
declare class Workbook {
|
|
565
617
|
readonly sheets: Sheet[];
|
|
566
618
|
readonly meta: Record<string, unknown>;
|
|
567
|
-
|
|
619
|
+
/** What a reader found: an .xltx / .ots reads exactly like its .xlsx / .ods twin and is marked `template`. */
|
|
620
|
+
readonly sourceKind: "document" | "template";
|
|
621
|
+
constructor(sheets: Sheet[], meta?: Record<string, unknown>,
|
|
622
|
+
/** What a reader found: an .xltx / .ots reads exactly like its .xlsx / .ods twin and is marked `template`. */
|
|
623
|
+
sourceKind?: "document" | "template");
|
|
568
624
|
}
|
|
569
625
|
|
|
570
626
|
type Any$2 = any;
|
|
@@ -909,6 +965,7 @@ interface ZipFile {
|
|
|
909
965
|
}
|
|
910
966
|
declare function zipSync(files: ZipFile[]): Uint8Array;
|
|
911
967
|
|
|
912
|
-
|
|
968
|
+
/** STORE/DEFLATE reader with metadata, CRC, duplicate and expansion checks. */
|
|
969
|
+
declare function unzipSync(data: Uint8Array, limits?: ArchiveLimits): Record<string, Uint8Array>;
|
|
913
970
|
|
|
914
|
-
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 };
|
|
971
|
+
export { type AddSheetOp, Agent, type AggOp, type ArchiveLimits, ArchiveRefused, 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, OfficeTemplateRefused, 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 SourceKind, type SpreadsheetFormat, Theme, type ThemeKey, UnsupportedFormatException, VERSION, type ValidationError, Validator, type WriteResult, XlsxReader, XlsxWriter, type ZipFile, unzipSync, zipSync };
|
package/dist/index.d.ts
CHANGED
|
@@ -143,6 +143,8 @@ interface BuilderOptions {
|
|
|
143
143
|
enclosure?: string;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
type SourceKind = "document" | "template";
|
|
147
|
+
|
|
146
148
|
/**
|
|
147
149
|
* One op from `Agent.diff`, applied by `Agent.reduce`. Mirrors the PHP
|
|
148
150
|
* `HolySheet\Ops\SheetOpSchema` variants: same `type`, same field names.
|
|
@@ -264,7 +266,7 @@ interface SetMetaOp {
|
|
|
264
266
|
}
|
|
265
267
|
|
|
266
268
|
/** This package's own version, pinned to package.json by `version.test.ts`. */
|
|
267
|
-
declare const VERSION = "2.
|
|
269
|
+
declare const VERSION = "2.11.0";
|
|
268
270
|
type Any$6 = any;
|
|
269
271
|
/**
|
|
270
272
|
* Agent — the structured-tool surface for Holy Sheet. Mirrors PHP `Agent`.
|
|
@@ -286,6 +288,22 @@ declare const Agent: {
|
|
|
286
288
|
* schema. Throws `UnsupportedFormatException` for anything else.
|
|
287
289
|
*/
|
|
288
290
|
read(input: Uint8Array | ArrayBuffer): Record<string, unknown>;
|
|
291
|
+
/**
|
|
292
|
+
* Turn an Excel `.xltx` / LibreOffice `.ots` template into its `.xlsx` /
|
|
293
|
+
* `.ods` twin, or back. `to` is `"document"`, `"template"`, or null to flip.
|
|
294
|
+
* Universal and synchronous: bytes in, bytes out. Mirrors PHP
|
|
295
|
+
* `Agent::convertTemplate()`.
|
|
296
|
+
*
|
|
297
|
+
* Only the declaration moves: the workbook part's content type in
|
|
298
|
+
* `[Content_Types].xml`, or the ODF `mimetype` entry together with the
|
|
299
|
+
* manifest's root media-type (ODF 1.3 requires them to agree). Every other
|
|
300
|
+
* member is copied as its original zip record, byte for byte.
|
|
301
|
+
*
|
|
302
|
+
* Throws `OfficeTemplateRefused` (macro-enabled, mismatched, already that
|
|
303
|
+
* kind), `ArchiveRefused` (archive guard), or `UnsupportedFormatException`
|
|
304
|
+
* for a package that is not a spreadsheet.
|
|
305
|
+
*/
|
|
306
|
+
convertTemplate(input: Uint8Array | ArrayBuffer, to?: SourceKind | null): Uint8Array;
|
|
289
307
|
/** Round-trip an xlsx or ods file on disk back to a schema (Node only). */
|
|
290
308
|
describe(path: string): Promise<Record<string, unknown>>;
|
|
291
309
|
/** Validate + conservative repairs in one call. */
|
|
@@ -342,13 +360,15 @@ type Any$5 = any;
|
|
|
342
360
|
* over `Agent`. Provided for parity / DI ergonomics; most callers use `Agent`.
|
|
343
361
|
*/
|
|
344
362
|
declare class HolySheet {
|
|
345
|
-
static readonly VERSION = "2.
|
|
363
|
+
static readonly VERSION = "2.11.0";
|
|
346
364
|
validate(schema: Any$5): ValidationError[];
|
|
347
365
|
toBytes(schema: Any$5): Uint8Array;
|
|
348
366
|
write(schema: Any$5, path: string): Promise<WriteResult>;
|
|
349
367
|
toolDefinition(): Record<string, unknown>;
|
|
350
368
|
read(input: Uint8Array | ArrayBuffer): Record<string, unknown>;
|
|
351
369
|
describe(path: string): Promise<Record<string, unknown>>;
|
|
370
|
+
/** {@link Agent.convertTemplate}: .xltx/.ots to .xlsx/.ods and back. */
|
|
371
|
+
convertTemplate(input: Uint8Array | ArrayBuffer, to?: "document" | "template" | null): Uint8Array;
|
|
352
372
|
validateAndRepair(schema: Any$5): RepairResult;
|
|
353
373
|
fromArray(rows: Any$5[][], headers?: string[] | null, sheetName?: string, options?: BuilderOptions): HolySheetSchema;
|
|
354
374
|
fromCsv(csv: string, options?: BuilderOptions): HolySheetSchema;
|
|
@@ -357,6 +377,30 @@ declare class HolySheet {
|
|
|
357
377
|
static version(): string;
|
|
358
378
|
}
|
|
359
379
|
|
|
380
|
+
/** Bounded archive/security refusal; contains no document names or content. */
|
|
381
|
+
declare class ArchiveRefused extends Error {
|
|
382
|
+
readonly reason: string;
|
|
383
|
+
constructor(reason: string);
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* An Office or LibreOffice template package refused, with a constant `reason`.
|
|
387
|
+
* Mirrors PHP `OfficeTemplateRefused`:
|
|
388
|
+
*
|
|
389
|
+
* - `macro_enabled` an .xltm (or a template carrying a VBA project). Never read
|
|
390
|
+
* and never converted.
|
|
391
|
+
* - `family_mismatch` it declares a template of another family, or its parts
|
|
392
|
+
* are not the family it declares.
|
|
393
|
+
* - `already_template` / `already_document` conversion asked for what it is.
|
|
394
|
+
* - `not_convertible` there is no single declaration that can be rewritten.
|
|
395
|
+
* - `odf_mimetype` an ODF package whose `mimetype` is not first and stored.
|
|
396
|
+
* - `bad_target` the conversion target is not `document` or `template`.
|
|
397
|
+
*
|
|
398
|
+
* Branch on `reason`; the message is for people.
|
|
399
|
+
*/
|
|
400
|
+
declare class OfficeTemplateRefused extends Error {
|
|
401
|
+
readonly reason: string;
|
|
402
|
+
constructor(reason: string);
|
|
403
|
+
}
|
|
360
404
|
/** Thrown when a Holy Sheet schema fails validation. Mirrors PHP `SchemaException`. */
|
|
361
405
|
declare class SchemaException extends Error {
|
|
362
406
|
readonly errors: ValidationError[];
|
|
@@ -382,6 +426,14 @@ declare class UnsupportedFormatException extends Error {
|
|
|
382
426
|
static unknownPackage(path: string | null, mimetype: string | null): UnsupportedFormatException;
|
|
383
427
|
}
|
|
384
428
|
|
|
429
|
+
interface ArchiveLimits {
|
|
430
|
+
maxArchiveBytes?: number;
|
|
431
|
+
maxEntries?: number;
|
|
432
|
+
maxPartBytes?: number;
|
|
433
|
+
maxExpandedBytes?: number;
|
|
434
|
+
maxCompressionRatio?: number;
|
|
435
|
+
}
|
|
436
|
+
|
|
385
437
|
type Any$4 = any;
|
|
386
438
|
/** Hand-rolled schema validator. Mirrors PHP `Schema\Validator`. */
|
|
387
439
|
declare class Validator {
|
|
@@ -564,7 +616,11 @@ declare class Sheet {
|
|
|
564
616
|
declare class Workbook {
|
|
565
617
|
readonly sheets: Sheet[];
|
|
566
618
|
readonly meta: Record<string, unknown>;
|
|
567
|
-
|
|
619
|
+
/** What a reader found: an .xltx / .ots reads exactly like its .xlsx / .ods twin and is marked `template`. */
|
|
620
|
+
readonly sourceKind: "document" | "template";
|
|
621
|
+
constructor(sheets: Sheet[], meta?: Record<string, unknown>,
|
|
622
|
+
/** What a reader found: an .xltx / .ots reads exactly like its .xlsx / .ods twin and is marked `template`. */
|
|
623
|
+
sourceKind?: "document" | "template");
|
|
568
624
|
}
|
|
569
625
|
|
|
570
626
|
type Any$2 = any;
|
|
@@ -909,6 +965,7 @@ interface ZipFile {
|
|
|
909
965
|
}
|
|
910
966
|
declare function zipSync(files: ZipFile[]): Uint8Array;
|
|
911
967
|
|
|
912
|
-
|
|
968
|
+
/** STORE/DEFLATE reader with metadata, CRC, duplicate and expansion checks. */
|
|
969
|
+
declare function unzipSync(data: Uint8Array, limits?: ArchiveLimits): Record<string, Uint8Array>;
|
|
913
970
|
|
|
914
|
-
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 };
|
|
971
|
+
export { type AddSheetOp, Agent, type AggOp, type ArchiveLimits, ArchiveRefused, 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, OfficeTemplateRefused, 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 SourceKind, type SpreadsheetFormat, Theme, type ThemeKey, UnsupportedFormatException, VERSION, type ValidationError, Validator, type WriteResult, XlsxReader, XlsxWriter, type ZipFile, unzipSync, zipSync };
|