document-cli 1.14.114 → 2.0.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/README.md +2 -2
- package/dist/cli.js +12 -3
- package/dist/index.cjs +11 -2
- package/dist/index.js +12 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -95,7 +95,7 @@ document-cli convert report.docx - --to pdf > report.pdf
|
|
|
95
95
|
|
|
96
96
|
**`formats`** — lists every `source -> target` pair the commands above support (`--json` for a machine-readable array), plus a pointer to the commands not on that list because they don't fit the source/target shape (`odm-to-pdf`, `odb-to-csv`, `odb-to-xlsx`, `odb-tables`, `odb-forms`, `odb-reports`, `pdf-inspect`, `from-package`, `fonts`, `docx-extras`, `metadata`, `set-metadata`).
|
|
97
97
|
|
|
98
|
-
**`from-package <input> [output]`** — reads back a `DocumentPackage` JSON file a previous conversion wrote via `--dump-package` (below) and exports it to a real target format, closing the round trip `--dump-package` otherwise has no return path for. Target resolution matches `convert`: an output path's own extension, or `--to <format>` when it doesn't have one. `pdf`
|
|
98
|
+
**`from-package <input> [output]`** — reads back a `DocumentPackage` JSON file a previous conversion wrote via `--dump-package` (below) and exports it to a real target format, closing the round trip `--dump-package` otherwise has no return path for. Target resolution matches `convert`: an output path's own extension, or `--to <format>` when it doesn't have one. `pdf` rebuilds the layout from the package's own recorded positions — each content node's `frames` plus the package's `pages` geometry (`layoutDocumentFromPackage` → `writePdf`; a package no longer carries a separate `layout` half at all); every other format builds a fresh package from the `content` half through the identical `buildXPackage` function the matching `pdf-to-X`/bridge conversion already uses — `xlsx` included, via `ooxml.js`'s own `buildXlsxPackage`. `odf` is the one target rejected outright, since a standalone formula document has no write path from `ContentDocument` at all. Only a file genuinely written by a current `--dump-package` round-trips here; anything else fails with its `$schema` mismatch named, and a dump from the documents.js 1.x `formatVersion` 1 shape (content plus a separate `layout` half) is rejected with an error naming the version change rather than silently accepted:
|
|
99
99
|
|
|
100
100
|
```sh
|
|
101
101
|
document-cli docx-to-pdf report.docx report.pdf --dump-package report.package.json
|
|
@@ -178,7 +178,7 @@ The explicit conversions, `convert`, `odm-to-pdf`, `odb-to-xlsx`, `odb-to-csv`,
|
|
|
178
178
|
| `-q, --quiet` | Suppress diagnostic and summary output (the JSON result-summary line still prints in `--json` mode, so a script consuming NDJSON always gets a terminating record). |
|
|
179
179
|
| `--verbose` | Include a full stack trace in the error line when the run fails. |
|
|
180
180
|
|
|
181
|
-
`--dump-package <file>` is one flag further, registered only on the explicit conversions and `convert` — it writes the intermediate `DocumentPackage` (content
|
|
181
|
+
`--dump-package <file>` is one flag further, registered only on the explicit conversions and `convert` — it writes the intermediate `DocumentPackage` (content carrying its own per-node rendered `frames`, plus the `pages` geometry those frames index into) that conversion built to a JSON file, tagged with its own `$schema` so `from-package` (above) can read it back in. Every conversion populates one, `odf-to-pdf` included — its dump carries a `formula`-kind content and the one A4 page it renders (the formula's glyphs travel through the PDF writer's own positioned-formula channel rather than as frame-stamped page content); the sixteen PDF-bypassing bridges (the ten same-variant pairs `odt-to-docx`/`docx-to-odt`, `odp-to-pptx`/`pptx-to-odp`, `ods-to-xlsx`/`xlsx-to-ods`, `markdown-to-docx`/`docx-to-markdown`, `markdown-to-odt`/`odt-to-markdown`, plus the six cross-variant pairs `docx-to-pptx`/`pptx-to-docx`, `odt-to-odp`/`odp-to-odt`, `xlsx-to-markdown`/`markdown-to-xlsx`) populate one too, just with `pages` always absent, since a bridge never runs a layout engine. `odm-to-pdf`/`odb-*`/`set-metadata` don't expose the flag at all, since none of them goes through `DocumentConverter.convert` in the first place. `odb-tables`, `odb-forms`, `odb-reports`, `fonts`, `docx-extras`, `metadata`, `formats`, and `pdf-inspect` each take only their own `--json` (plus `pdf-inspect`'s own `--full`); `odb-query` takes `--sql <text>`/`--query <savedName>` (mutually exclusive) alongside its own `--json`, with none of the shared flags above since it only reads and writes nothing; `from-package` and `set-metadata` each take `--to <format>` alongside the shared flags in this table; `odb-render-report` takes `--report <name>` and `--to <format>` alongside the shared flags and the font flags below; `tui` takes no flags at all, only an optional positional file.
|
|
182
182
|
|
|
183
183
|
### Real fonts
|
|
184
184
|
|
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import { a as odbFormSummary, c as formatDocxExtrasLines, d as writeOutput, f as
|
|
|
3
3
|
import { Command, CommanderError, InvalidArgumentError } from "commander";
|
|
4
4
|
import { writeFile } from "node:fs/promises";
|
|
5
5
|
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
6
|
-
import { HsqldbSqlEvaluationError, HsqldbSqlParseError, HsqldbSqlUnsupportedError, OdbNoEmbeddedDataSourceError, OdbReportNotSpecifiedError, OdbTableNotFoundError, OdbTableNotSpecifiedError, OdbUnsupportedFormatError, OdmUnresolvedSectionError, PdfEncryptedError, PdfParseError, UnrecognizedDocumentSchemaError, UnsupportedFontSourceFormatError, buildDocumentBytes, createLocalDocumentConverter, decodeOdbPackage, decodePackage, documentFromJson, documentPackageWithSchema, evaluateSelect, extractSourceFontsForFormat, hsqldbCellDisplayText, layoutDocumentWithSchema, odbReportToDocx, odbReportToOdt, odbReportToPdf, odbToCsv, odbToXlsx, odmToPdf, parseSelect, readDocumentMetadata, readDocxExtras, readOdbForms, readOdbInventory, readOdbReportContent, readOdbReports, readOdbTables, readPdf, setDocumentMetadata } from "documents.js";
|
|
6
|
+
import { HsqldbSqlEvaluationError, HsqldbSqlParseError, HsqldbSqlUnsupportedError, OdbNoEmbeddedDataSourceError, OdbReportNotSpecifiedError, OdbTableNotFoundError, OdbTableNotSpecifiedError, OdbUnsupportedFormatError, OdmUnresolvedSectionError, PdfEncryptedError, PdfParseError, UnrecognizedDocumentSchemaError, UnsupportedFontSourceFormatError, buildDocumentBytes, createLocalDocumentConverter, decodeOdbPackage, decodePackage, documentFromJson, documentPackageWithSchema, documentSchemaKindOf, evaluateSelect, extractSourceFontsForFormat, hsqldbCellDisplayText, layoutDocumentWithSchema, odbReportToDocx, odbReportToOdt, odbReportToPdf, odbToCsv, odbToXlsx, odmToPdf, parseSelect, readDocumentMetadata, readDocxExtras, readOdbForms, readOdbInventory, readOdbReportContent, readOdbReports, readOdbTables, readPdf, setDocumentMetadata } from "documents.js";
|
|
7
7
|
import { existsSync, readFileSync } from "node:fs";
|
|
8
8
|
//#region src/runtime/abort.ts
|
|
9
9
|
function combineSignals(a, b) {
|
|
@@ -217,7 +217,7 @@ function addVerboseOption(command) {
|
|
|
217
217
|
return command.option("--verbose", "include a full stack trace when the run fails", false);
|
|
218
218
|
}
|
|
219
219
|
function addDumpPackageOption(command) {
|
|
220
|
-
return command.option("--dump-package <file>", "write the intermediate DocumentPackage (content +
|
|
220
|
+
return command.option("--dump-package <file>", "write the intermediate DocumentPackage (content with its per-node layout frames + page sizes) this conversion built to a JSON file");
|
|
221
221
|
}
|
|
222
222
|
function collectFontFile(value, previous) {
|
|
223
223
|
return [...previous, value];
|
|
@@ -374,6 +374,11 @@ function registerFormatsCommand(program) {
|
|
|
374
374
|
}
|
|
375
375
|
//#endregion
|
|
376
376
|
//#region src/commands/from-package.ts
|
|
377
|
+
function isFormatVersionOneRecord(value) {
|
|
378
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
379
|
+
if (!("formatVersion" in value)) return false;
|
|
380
|
+
return value.formatVersion === 1;
|
|
381
|
+
}
|
|
377
382
|
async function runFromPackage(input, output, options) {
|
|
378
383
|
const command = "from-package";
|
|
379
384
|
if (output !== void 0 && options.out !== void 0 && output !== options.out) {
|
|
@@ -397,6 +402,10 @@ async function runFromPackage(input, output, options) {
|
|
|
397
402
|
process.stderr.write(`[${command}] '${input}' is not valid JSON: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
398
403
|
return 1;
|
|
399
404
|
}
|
|
405
|
+
if (documentSchemaKindOf(parsed) === "DocumentPackage" && isFormatVersionOneRecord(parsed)) {
|
|
406
|
+
process.stderr.write(`[${command}] '${input}' is a DocumentPackage dump at formatVersion 1 (the documents.js 1.x shape: content plus a separate layout half) -- documents.js 2.0.0 replaced it with formatVersion 2 (content carrying its own rendered frames, plus page sizes); re-run the source conversion with --dump-package to write a current dump\n`);
|
|
407
|
+
return 1;
|
|
408
|
+
}
|
|
400
409
|
const result = documentFromJson(parsed);
|
|
401
410
|
if (result.kind !== "DocumentPackage") {
|
|
402
411
|
process.stderr.write(`[${command}] '${input}' is a ${result.kind}, not a DocumentPackage -- only a file written by --dump-package can be read back by this command\n`);
|
|
@@ -1059,7 +1068,7 @@ function registerSetMetadataCommand(program) {
|
|
|
1059
1068
|
}
|
|
1060
1069
|
//#endregion
|
|
1061
1070
|
//#region package.json
|
|
1062
|
-
var version = "
|
|
1071
|
+
var version = "2.0.0";
|
|
1063
1072
|
//#endregion
|
|
1064
1073
|
//#region src/program.ts
|
|
1065
1074
|
function createProgram() {
|
package/dist/index.cjs
CHANGED
|
@@ -331,7 +331,7 @@ function addVerboseOption(command) {
|
|
|
331
331
|
return command.option("--verbose", "include a full stack trace when the run fails", false);
|
|
332
332
|
}
|
|
333
333
|
function addDumpPackageOption(command) {
|
|
334
|
-
return command.option("--dump-package <file>", "write the intermediate DocumentPackage (content +
|
|
334
|
+
return command.option("--dump-package <file>", "write the intermediate DocumentPackage (content with its per-node layout frames + page sizes) this conversion built to a JSON file");
|
|
335
335
|
}
|
|
336
336
|
function collectFontFile(value, previous) {
|
|
337
337
|
return [...previous, value];
|
|
@@ -546,6 +546,11 @@ function registerFormatsCommand(program) {
|
|
|
546
546
|
}
|
|
547
547
|
//#endregion
|
|
548
548
|
//#region src/commands/from-package.ts
|
|
549
|
+
function isFormatVersionOneRecord(value) {
|
|
550
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
551
|
+
if (!("formatVersion" in value)) return false;
|
|
552
|
+
return value.formatVersion === 1;
|
|
553
|
+
}
|
|
549
554
|
async function runFromPackage(input, output, options) {
|
|
550
555
|
const command = "from-package";
|
|
551
556
|
if (output !== void 0 && options.out !== void 0 && output !== options.out) {
|
|
@@ -569,6 +574,10 @@ async function runFromPackage(input, output, options) {
|
|
|
569
574
|
process.stderr.write(`[${command}] '${input}' is not valid JSON: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
570
575
|
return 1;
|
|
571
576
|
}
|
|
577
|
+
if ((0, documents_js.documentSchemaKindOf)(parsed) === "DocumentPackage" && isFormatVersionOneRecord(parsed)) {
|
|
578
|
+
process.stderr.write(`[${command}] '${input}' is a DocumentPackage dump at formatVersion 1 (the documents.js 1.x shape: content plus a separate layout half) -- documents.js 2.0.0 replaced it with formatVersion 2 (content carrying its own rendered frames, plus page sizes); re-run the source conversion with --dump-package to write a current dump\n`);
|
|
579
|
+
return 1;
|
|
580
|
+
}
|
|
572
581
|
const result = (0, documents_js.documentFromJson)(parsed);
|
|
573
582
|
if (result.kind !== "DocumentPackage") {
|
|
574
583
|
process.stderr.write(`[${command}] '${input}' is a ${result.kind}, not a DocumentPackage -- only a file written by --dump-package can be read back by this command\n`);
|
|
@@ -1387,7 +1396,7 @@ function registerSetMetadataCommand(program) {
|
|
|
1387
1396
|
}
|
|
1388
1397
|
//#endregion
|
|
1389
1398
|
//#region package.json
|
|
1390
|
-
var version = "
|
|
1399
|
+
var version = "2.0.0";
|
|
1391
1400
|
//#endregion
|
|
1392
1401
|
//#region src/program.ts
|
|
1393
1402
|
function createProgram() {
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile, writeFile } from "node:fs/promises";
|
|
2
2
|
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
3
|
-
import { HsqldbSqlEvaluationError, HsqldbSqlParseError, HsqldbSqlUnsupportedError, OdbNoEmbeddedDataSourceError, OdbReportNotSpecifiedError, OdbTableNotFoundError, OdbTableNotSpecifiedError, OdbUnsupportedFormatError, OdmUnresolvedSectionError, PdfEncryptedError, PdfParseError, UnrecognizedDocumentSchemaError, UnsupportedFontSourceFormatError, buildDocumentBytes, createLocalDocumentConverter, decodeOdbPackage, decodePackage, describeFontFace, documentFromJson, documentPackageWithSchema, evaluateSelect, extractSourceFontsForFormat, hsqldbCellDisplayText, layoutDocumentWithSchema, odbReportToDocx, odbReportToOdt, odbReportToPdf, odbToCsv, odbToXlsx, odmToPdf, parseSelect, readDocumentMetadata, readDocxExtras, readOdbForms, readOdbInventory, readOdbReportContent, readOdbReports, readOdbTables, readPdf, setDocumentMetadata } from "documents.js";
|
|
3
|
+
import { HsqldbSqlEvaluationError, HsqldbSqlParseError, HsqldbSqlUnsupportedError, OdbNoEmbeddedDataSourceError, OdbReportNotSpecifiedError, OdbTableNotFoundError, OdbTableNotSpecifiedError, OdbUnsupportedFormatError, OdmUnresolvedSectionError, PdfEncryptedError, PdfParseError, UnrecognizedDocumentSchemaError, UnsupportedFontSourceFormatError, buildDocumentBytes, createLocalDocumentConverter, decodeOdbPackage, decodePackage, describeFontFace, documentFromJson, documentPackageWithSchema, documentSchemaKindOf, evaluateSelect, extractSourceFontsForFormat, hsqldbCellDisplayText, layoutDocumentWithSchema, odbReportToDocx, odbReportToOdt, odbReportToPdf, odbToCsv, odbToXlsx, odmToPdf, parseSelect, readDocumentMetadata, readDocxExtras, readOdbForms, readOdbInventory, readOdbReportContent, readOdbReports, readOdbTables, readPdf, setDocumentMetadata } from "documents.js";
|
|
4
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
5
5
|
import { Command, InvalidArgumentError } from "commander";
|
|
6
6
|
//#region src/format.ts
|
|
@@ -330,7 +330,7 @@ function addVerboseOption(command) {
|
|
|
330
330
|
return command.option("--verbose", "include a full stack trace when the run fails", false);
|
|
331
331
|
}
|
|
332
332
|
function addDumpPackageOption(command) {
|
|
333
|
-
return command.option("--dump-package <file>", "write the intermediate DocumentPackage (content +
|
|
333
|
+
return command.option("--dump-package <file>", "write the intermediate DocumentPackage (content with its per-node layout frames + page sizes) this conversion built to a JSON file");
|
|
334
334
|
}
|
|
335
335
|
function collectFontFile(value, previous) {
|
|
336
336
|
return [...previous, value];
|
|
@@ -545,6 +545,11 @@ function registerFormatsCommand(program) {
|
|
|
545
545
|
}
|
|
546
546
|
//#endregion
|
|
547
547
|
//#region src/commands/from-package.ts
|
|
548
|
+
function isFormatVersionOneRecord(value) {
|
|
549
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
550
|
+
if (!("formatVersion" in value)) return false;
|
|
551
|
+
return value.formatVersion === 1;
|
|
552
|
+
}
|
|
548
553
|
async function runFromPackage(input, output, options) {
|
|
549
554
|
const command = "from-package";
|
|
550
555
|
if (output !== void 0 && options.out !== void 0 && output !== options.out) {
|
|
@@ -568,6 +573,10 @@ async function runFromPackage(input, output, options) {
|
|
|
568
573
|
process.stderr.write(`[${command}] '${input}' is not valid JSON: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
569
574
|
return 1;
|
|
570
575
|
}
|
|
576
|
+
if (documentSchemaKindOf(parsed) === "DocumentPackage" && isFormatVersionOneRecord(parsed)) {
|
|
577
|
+
process.stderr.write(`[${command}] '${input}' is a DocumentPackage dump at formatVersion 1 (the documents.js 1.x shape: content plus a separate layout half) -- documents.js 2.0.0 replaced it with formatVersion 2 (content carrying its own rendered frames, plus page sizes); re-run the source conversion with --dump-package to write a current dump\n`);
|
|
578
|
+
return 1;
|
|
579
|
+
}
|
|
571
580
|
const result = documentFromJson(parsed);
|
|
572
581
|
if (result.kind !== "DocumentPackage") {
|
|
573
582
|
process.stderr.write(`[${command}] '${input}' is a ${result.kind}, not a DocumentPackage -- only a file written by --dump-package can be read back by this command\n`);
|
|
@@ -1386,7 +1395,7 @@ function registerSetMetadataCommand(program) {
|
|
|
1386
1395
|
}
|
|
1387
1396
|
//#endregion
|
|
1388
1397
|
//#region package.json
|
|
1389
|
-
var version = "
|
|
1398
|
+
var version = "2.0.0";
|
|
1390
1399
|
//#endregion
|
|
1391
1400
|
//#region src/program.ts
|
|
1392
1401
|
function createProgram() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "document-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "CLI and interactive Ink TUI for documents.js: every docx/pptx/odt/odp/ods/odg/odf/pdf/odm/odb/xlsx/markdown conversion, bridge, and editor as a scriptable command or a terminal app.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"packageManager": "pnpm@11.6.0",
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"commander": "^15.0.0",
|
|
91
|
-
"documents.js": "^
|
|
91
|
+
"documents.js": "^2.0.0",
|
|
92
92
|
"ink": "^7.1.1",
|
|
93
93
|
"ink-text-input": "^6.0.0",
|
|
94
94
|
"react": "^19.2.8"
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"husky": "^9.1.7",
|
|
111
111
|
"ink-testing-library": "^4.0.0",
|
|
112
112
|
"lint-staged": "^17.3.0",
|
|
113
|
-
"odf.js": "^3.0.
|
|
113
|
+
"odf.js": "^3.0.1",
|
|
114
114
|
"pdf-codec": "^2.2.20",
|
|
115
115
|
"publint": "^0.3.22",
|
|
116
116
|
"semantic-release": "^25.0.8",
|