@attentionform/astra 0.2.0 → 0.2.1
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/cli.js +12 -21
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -34084,19 +34084,6 @@ async function repairDocxBuffer(input, options = {}) {
|
|
|
34084
34084
|
}
|
|
34085
34085
|
return { buffer: normalized.length > 0 ? pack(current) : input, normalized, remaining, rolledBack };
|
|
34086
34086
|
}
|
|
34087
|
-
async function forecastNormalize(input) {
|
|
34088
|
-
try {
|
|
34089
|
-
const outcome = await repairDocxBuffer(input);
|
|
34090
|
-
if (outcome.normalized.length === 0) return void 0;
|
|
34091
|
-
return { changes: outcome.normalized.length, remaining: outcome.remaining };
|
|
34092
|
-
} catch {
|
|
34093
|
-
return void 0;
|
|
34094
|
-
}
|
|
34095
|
-
}
|
|
34096
|
-
function normalizeHintSentence(forecast, errorCount, how) {
|
|
34097
|
-
const left = forecast.remaining === 0 ? "and the document then validates" : forecast.remaining > 0 ? `and leaves ${forecast.remaining} of ${errorCount} errors, which need Word` : "and the rest need Word";
|
|
34098
|
-
return `${how} can repair some of these errors (${forecast.changes} change${forecast.changes === 1 ? "" : "s"}) ${left}.`;
|
|
34099
|
-
}
|
|
34100
34087
|
|
|
34101
34088
|
// ../engine/src/export/html.ts
|
|
34102
34089
|
function asFootnoteZipCapable(parser2) {
|
|
@@ -38633,7 +38620,7 @@ function summarizeStyleGuide(guide) {
|
|
|
38633
38620
|
// package.json
|
|
38634
38621
|
var package_default = {
|
|
38635
38622
|
name: "@attentionform/astra",
|
|
38636
|
-
version: "0.2.
|
|
38623
|
+
version: "0.2.1",
|
|
38637
38624
|
description: "Command-line tool for OOXML (.docx) document engineering",
|
|
38638
38625
|
main: "dist/cli.js",
|
|
38639
38626
|
types: "dist/packages/cli/src/cli.d.ts",
|
|
@@ -38676,8 +38663,8 @@ var package_default = {
|
|
|
38676
38663
|
"adm-zip-gate": "node ../../scripts/check-adm-zip-imports.mjs"
|
|
38677
38664
|
},
|
|
38678
38665
|
dependencies: {
|
|
38679
|
-
"@attentionform/astra-engine": "^0.2.
|
|
38680
|
-
"@attentionform/ooxml-validator": "^0.2.
|
|
38666
|
+
"@attentionform/astra-engine": "^0.2.1",
|
|
38667
|
+
"@attentionform/ooxml-validator": "^0.2.1",
|
|
38681
38668
|
"@xmldom/xmldom": "0.8.15",
|
|
38682
38669
|
"adm-zip": "0.6.1",
|
|
38683
38670
|
"isomorphic-git": "^1.25.0",
|
|
@@ -39179,6 +39166,7 @@ function commandHelpText(cmd) {
|
|
|
39179
39166
|
`Usage: ${CLI_NAME} validate <docx> [--max-errors <n>] [--max-ratio <n>] [--max-uncompressed-bytes <n>] [--allow-macros] [--strip-macros] [--style-guide <name|path>]`,
|
|
39180
39167
|
"",
|
|
39181
39168
|
"Fail-closed OOXML validation. Prints VALID <file> (exit 0) or INVALID + first errors (exit 1).",
|
|
39169
|
+
"Invalid documents receive advice to attempt normalize with --out to a new file, then validate again; no repair preview is run.",
|
|
39182
39170
|
" --max-errors <n> most errors listed by --json (integer 1 to 5000, default 500); the JSON carries truncated:true and maxErrors when the list was cut. The human output shows 10 and counts the rest.",
|
|
39183
39171
|
" --max-ratio <n> zip-bomb ratio ceiling override (default 100; env ASTRA_MAX_RATIO)",
|
|
39184
39172
|
" --max-uncompressed-bytes <n> zip-bomb total-bytes ceiling override in bytes (default 209715200; env ASTRA_MAX_UNCOMPRESSED_BYTES)",
|
|
@@ -41642,6 +41630,7 @@ async function cmdInspect(out, args) {
|
|
|
41642
41630
|
var DEFAULT_MAX_ERRORS = 500;
|
|
41643
41631
|
var MAX_ERRORS_LIMIT = 5e3;
|
|
41644
41632
|
var HUMAN_ERRORS_SHOWN = 10;
|
|
41633
|
+
var NORMALIZE_HINT = `Run \`${CLI_NAME} normalize\` with \`--out\` pointing to a new file to attempt supported repairs, then validate the result again.`;
|
|
41645
41634
|
async function cmdValidate(out, args) {
|
|
41646
41635
|
if (hasHelpFlag(args)) return printCommandHelp(out, "validate");
|
|
41647
41636
|
let file;
|
|
@@ -41719,6 +41708,7 @@ async function cmdValidate(out, args) {
|
|
|
41719
41708
|
}
|
|
41720
41709
|
const macroOpts = macroOptsFromFlags({ allowMacros, stripMacros });
|
|
41721
41710
|
let pendingNormalizations = [];
|
|
41711
|
+
let schemaValidationCompleted = false;
|
|
41722
41712
|
const result = await withZipCeilingEnv(ceilings, async () => {
|
|
41723
41713
|
let p;
|
|
41724
41714
|
try {
|
|
@@ -41747,7 +41737,9 @@ async function cmdValidate(out, args) {
|
|
|
41747
41737
|
} catch {
|
|
41748
41738
|
pendingNormalizations = [];
|
|
41749
41739
|
}
|
|
41750
|
-
|
|
41740
|
+
const validation = await p.validateOOXML({ maxErrors });
|
|
41741
|
+
schemaValidationCompleted = true;
|
|
41742
|
+
return validation;
|
|
41751
41743
|
});
|
|
41752
41744
|
const pending = pendingNormalizations.length > 0 ? { pendingNormalizations } : {};
|
|
41753
41745
|
if (result.ok) {
|
|
@@ -41801,8 +41793,7 @@ async function cmdValidate(out, args) {
|
|
|
41801
41793
|
if (errors.length > HUMAN_ERRORS_SHOWN) {
|
|
41802
41794
|
print(out, ` ... and ${errors.length - HUMAN_ERRORS_SHOWN} more${truncated ? " (the list is cut at the limit)" : ""}; --json lists them (up to ${maxErrors}, --max-errors <n> changes the limit)`);
|
|
41803
41795
|
}
|
|
41804
|
-
const
|
|
41805
|
-
const hint = forecast ? normalizeHintSentence(forecast, errors.length, `Run \`${CLI_NAME} normalize ${file}\`: it`) : void 0;
|
|
41796
|
+
const hint = schemaValidationCompleted ? NORMALIZE_HINT : void 0;
|
|
41806
41797
|
printJson(out, {
|
|
41807
41798
|
ok: false,
|
|
41808
41799
|
file,
|
|
@@ -41814,8 +41805,8 @@ async function cmdValidate(out, args) {
|
|
|
41814
41805
|
errors
|
|
41815
41806
|
});
|
|
41816
41807
|
if (!out.json) {
|
|
41817
|
-
const
|
|
41818
|
-
printStderr(`${CLI_NAME}: error: [E_VALIDATION] "${file}" failed OOXML validation. Remedy:
|
|
41808
|
+
const remedy = hint ? `${hint} Repair by hand what remains, for example in Word.` : "repair the document in Word and retry.";
|
|
41809
|
+
printStderr(`${CLI_NAME}: error: [E_VALIDATION] "${file}" failed OOXML validation. Remedy: ${remedy}`);
|
|
41819
41810
|
}
|
|
41820
41811
|
return EXIT_FAIL;
|
|
41821
41812
|
} catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@attentionform/astra",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Command-line tool for OOXML (.docx) document engineering",
|
|
5
5
|
"main": "dist/cli.js",
|
|
6
6
|
"types": "dist/packages/cli/src/cli.d.ts",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"adm-zip-gate": "node ../../scripts/check-adm-zip-imports.mjs"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@attentionform/astra-engine": "^0.2.
|
|
47
|
-
"@attentionform/ooxml-validator": "^0.2.
|
|
46
|
+
"@attentionform/astra-engine": "^0.2.1",
|
|
47
|
+
"@attentionform/ooxml-validator": "^0.2.1",
|
|
48
48
|
"@xmldom/xmldom": "0.8.15",
|
|
49
49
|
"adm-zip": "0.6.1",
|
|
50
50
|
"isomorphic-git": "^1.25.0",
|