@json-to-office/core-docx 3.2.0 → 3.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/blueprints/index.d.ts +45 -0
- package/dist/blueprints/index.d.ts.map +1 -0
- package/dist/core/structure.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +786 -8
- package/dist/index.js.map +1 -1
- package/dist/plugin/example/index.js +55 -4
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/quality/facts.d.ts +28 -1
- package/dist/quality/facts.d.ts.map +1 -1
- package/dist/quality/preflight.d.ts.map +1 -1
- package/dist/quality/rules.d.ts +40 -0
- package/dist/quality/rules.d.ts.map +1 -1
- package/dist/templates/blueprints/client-report.docx.blueprint.json +473 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/serviceClient.d.ts +6 -0
- package/dist/utils/serviceClient.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -5307,6 +5307,10 @@ function resolveServiceUrl(propsUrl, servicesUrl, defaultUrl) {
|
|
|
5307
5307
|
const withScheme = /^https?:\/\//i.test(raw) ? raw : `http://${raw}`;
|
|
5308
5308
|
return withScheme.replace(/\/+$/, "");
|
|
5309
5309
|
}
|
|
5310
|
+
var SERVICE_UNAVAILABLE_CODE = "SERVICE_UNAVAILABLE";
|
|
5311
|
+
function serviceUnavailable(message) {
|
|
5312
|
+
return Object.assign(new Error(message), { code: SERVICE_UNAVAILABLE_CODE });
|
|
5313
|
+
}
|
|
5310
5314
|
async function postJsonToService(opts) {
|
|
5311
5315
|
const resolvedHeaders = typeof opts.headers === "function" ? await opts.headers(opts.body) : opts.headers;
|
|
5312
5316
|
const headers = {
|
|
@@ -5326,12 +5330,12 @@ async function postJsonToService(opts) {
|
|
|
5326
5330
|
});
|
|
5327
5331
|
} catch (error) {
|
|
5328
5332
|
if (error?.name === "AbortError") {
|
|
5329
|
-
throw
|
|
5333
|
+
throw serviceUnavailable(
|
|
5330
5334
|
`${opts.serviceLabel} timed out after ${timeoutMs}ms at ${opts.url}.`
|
|
5331
5335
|
);
|
|
5332
5336
|
}
|
|
5333
5337
|
const cause = error instanceof Error ? error.message : String(error);
|
|
5334
|
-
throw
|
|
5338
|
+
throw serviceUnavailable(opts.onUnreachable(opts.url, cause));
|
|
5335
5339
|
} finally {
|
|
5336
5340
|
clearTimeout(timer);
|
|
5337
5341
|
}
|
|
@@ -12026,6 +12030,7 @@ async function processResolvedDocument(document, resolved, themeName, generation
|
|
|
12026
12030
|
};
|
|
12027
12031
|
}
|
|
12028
12032
|
function createDocumentMetadata(props, generationDate = /* @__PURE__ */ new Date()) {
|
|
12033
|
+
const parsed = props.metadata?.date ? new Date(props.metadata.date) : void 0;
|
|
12029
12034
|
return {
|
|
12030
12035
|
title: props.metadata?.title,
|
|
12031
12036
|
subtitle: props.metadata?.subtitle,
|
|
@@ -12034,7 +12039,7 @@ function createDocumentMetadata(props, generationDate = /* @__PURE__ */ new Date
|
|
|
12034
12039
|
company: props.metadata?.company,
|
|
12035
12040
|
version: props.metadata?.version,
|
|
12036
12041
|
tags: props.metadata?.tags,
|
|
12037
|
-
date:
|
|
12042
|
+
date: parsed && !Number.isNaN(parsed.getTime()) ? parsed : generationDate
|
|
12038
12043
|
};
|
|
12039
12044
|
}
|
|
12040
12045
|
async function extractSections(components, context) {
|
|
@@ -12126,7 +12131,10 @@ import {
|
|
|
12126
12131
|
normalizeHighchartsChart
|
|
12127
12132
|
} from "@json-to-office/quality";
|
|
12128
12133
|
import { DEFAULT_DOCX_RENDERER_ID as DEFAULT_DOCX_RENDERER_ID2 } from "@json-to-office/shared-docx";
|
|
12129
|
-
import {
|
|
12134
|
+
import {
|
|
12135
|
+
designColors as designColors2,
|
|
12136
|
+
resolveDesignColor as resolveDesignColor2
|
|
12137
|
+
} from "@json-to-office/shared";
|
|
12130
12138
|
|
|
12131
12139
|
// src/json/normalizer.ts
|
|
12132
12140
|
function normalizeComponent(component) {
|
|
@@ -12942,6 +12950,38 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
12942
12950
|
...budget
|
|
12943
12951
|
});
|
|
12944
12952
|
}
|
|
12953
|
+
for (const role of blockSlotRoles2(themed.document, expanded.blocks)) {
|
|
12954
|
+
addFact({
|
|
12955
|
+
id: `docx:chrome-slot:${role.path}`,
|
|
12956
|
+
kind: "docx/chrome-slot",
|
|
12957
|
+
path: role.path,
|
|
12958
|
+
relatedPaths: [role.invocation],
|
|
12959
|
+
block: role.block,
|
|
12960
|
+
slot: role.slot,
|
|
12961
|
+
role: role.role,
|
|
12962
|
+
present: slotIsFilled(role.value),
|
|
12963
|
+
invocation: role.invocation
|
|
12964
|
+
});
|
|
12965
|
+
}
|
|
12966
|
+
const topLevel = Array.isArray(context.document.children) ? context.document.children : [];
|
|
12967
|
+
let inherited = {};
|
|
12968
|
+
topLevel.forEach((node, index) => {
|
|
12969
|
+
if (node?.name !== "section") return;
|
|
12970
|
+
const props = asRecord(node.props) ?? {};
|
|
12971
|
+
const part = (kind) => props[kind] === "linkToPrevious" ? inherited[kind] : props[kind];
|
|
12972
|
+
const header = part("header");
|
|
12973
|
+
const footer = part("footer");
|
|
12974
|
+
inherited = { header, footer };
|
|
12975
|
+
addFact({
|
|
12976
|
+
id: `docx:section-chrome:${index}`,
|
|
12977
|
+
kind: "docx/section-chrome",
|
|
12978
|
+
path: `/children/${index}`,
|
|
12979
|
+
index,
|
|
12980
|
+
header: partPresent(header),
|
|
12981
|
+
footer: partPresent(footer),
|
|
12982
|
+
pageNumber: hasPageField(header) || hasPageField(footer)
|
|
12983
|
+
});
|
|
12984
|
+
});
|
|
12945
12985
|
const paletteHexes = {};
|
|
12946
12986
|
const visualColors = designColors2(
|
|
12947
12987
|
resolved.theme.colors,
|
|
@@ -13136,6 +13176,17 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
13136
13176
|
}
|
|
13137
13177
|
};
|
|
13138
13178
|
}
|
|
13179
|
+
function slotIsFilled(value) {
|
|
13180
|
+
if (typeof value === "string") return value.trim() !== "";
|
|
13181
|
+
return value !== void 0 && value !== null && value !== false && (!Array.isArray(value) || value.length > 0);
|
|
13182
|
+
}
|
|
13183
|
+
function partPresent(part) {
|
|
13184
|
+
return Array.isArray(part) && part.length > 0;
|
|
13185
|
+
}
|
|
13186
|
+
var PAGE_FIELD = /\{(PAGE|PAGE_NUMBER|TOTAL_PAGES|NUMPAGES)\}/;
|
|
13187
|
+
function hasPageField(part) {
|
|
13188
|
+
return Array.isArray(part) && PAGE_FIELD.test(JSON.stringify(part));
|
|
13189
|
+
}
|
|
13139
13190
|
|
|
13140
13191
|
// src/core/generateFromIr.ts
|
|
13141
13192
|
var UncompiledComponentError = class extends Error {
|