@claritylabs/cl-sdk 3.0.13 → 3.0.14
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.js +56 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9398,6 +9398,9 @@ function rejectsOrganizerGroup(group, children) {
|
|
|
9398
9398
|
function isEndorsementGroup(node) {
|
|
9399
9399
|
return node.kind === "page_group" && /^endorsements?\b/i.test(node.title);
|
|
9400
9400
|
}
|
|
9401
|
+
function isNoticesGroup(node) {
|
|
9402
|
+
return node.kind === "page_group" && /^notices?\s+and\s+jacket$/i.test(node.title);
|
|
9403
|
+
}
|
|
9401
9404
|
function endorsementGroupNodeId(documentId, parentId) {
|
|
9402
9405
|
return [
|
|
9403
9406
|
documentId.replace(/[^a-zA-Z0-9_.:-]/g, "_"),
|
|
@@ -9413,6 +9416,56 @@ function isPolicyFormNode(node) {
|
|
|
9413
9416
|
function isDeclarationsNode(node) {
|
|
9414
9417
|
return node.kind === "page_group" && node.title === "Declarations";
|
|
9415
9418
|
}
|
|
9419
|
+
function isAdministrativeNoticeNode(node) {
|
|
9420
|
+
const text = sourceNodeText(node);
|
|
9421
|
+
return /\b(specimen policy|policy jacket|important notice|privacy notice|ofac advisory|terrorism risk insurance act|tria|trade or economic sanctions|economic sanctions limitation|signature|countersignature|how to report a claim)\b/i.test(text);
|
|
9422
|
+
}
|
|
9423
|
+
function mergeAdministrativeNoticesIntoFrontMatter(sourceTree) {
|
|
9424
|
+
const rootId = sourceTreeRootId(sourceTree);
|
|
9425
|
+
if (!rootId) return sourceTree;
|
|
9426
|
+
const children = (nodesByParent(sourceTree).get(rootId) ?? []).filter((node) => node.kind !== "document");
|
|
9427
|
+
const noticesGroup = children.find(isNoticesGroup);
|
|
9428
|
+
if (!noticesGroup) return sourceTree;
|
|
9429
|
+
const noticesGroupChildren = new Set(
|
|
9430
|
+
(nodesByParent(sourceTree).get(noticesGroup.id) ?? []).map((node) => node.id)
|
|
9431
|
+
);
|
|
9432
|
+
const noticeIds = new Set(
|
|
9433
|
+
children.filter(
|
|
9434
|
+
(node) => node.id !== noticesGroup.id && !noticesGroupChildren.has(node.id) && node.kind === "page" && isAdministrativeNoticeNode(node)
|
|
9435
|
+
).map((node) => node.id)
|
|
9436
|
+
);
|
|
9437
|
+
if (noticeIds.size === 0) return sourceTree;
|
|
9438
|
+
return sourceTree.map(
|
|
9439
|
+
(node) => noticeIds.has(node.id) ? {
|
|
9440
|
+
...node,
|
|
9441
|
+
parentId: noticesGroup.id,
|
|
9442
|
+
metadata: {
|
|
9443
|
+
...node.metadata,
|
|
9444
|
+
organizerRepair: "merge_administrative_notice"
|
|
9445
|
+
}
|
|
9446
|
+
} : node
|
|
9447
|
+
);
|
|
9448
|
+
}
|
|
9449
|
+
function rootSemanticRank(node) {
|
|
9450
|
+
if (isNoticesGroup(node)) return 0;
|
|
9451
|
+
if (node.title === "Declarations") return 1;
|
|
9452
|
+
if (node.title === "Policy Form") return 2;
|
|
9453
|
+
if (isEndorsementGroup(node)) return 3;
|
|
9454
|
+
if (isAdministrativeNoticeNode(node)) return 0.5;
|
|
9455
|
+
return 2.5;
|
|
9456
|
+
}
|
|
9457
|
+
function normalizeRootSemanticOrder(sourceTree) {
|
|
9458
|
+
const rootId = sourceTreeRootId(sourceTree);
|
|
9459
|
+
if (!rootId) return sourceTree;
|
|
9460
|
+
const rootChildren2 = (nodesByParent(sourceTree).get(rootId) ?? []).filter((node) => node.kind !== "document").sort(
|
|
9461
|
+
(left, right) => rootSemanticRank(left) - rootSemanticRank(right) || (left.pageStart ?? Number.MAX_SAFE_INTEGER) - (right.pageStart ?? Number.MAX_SAFE_INTEGER) || left.order - right.order || left.id.localeCompare(right.id)
|
|
9462
|
+
);
|
|
9463
|
+
const orderById = new Map(rootChildren2.map((node, index) => [node.id, index + 1]));
|
|
9464
|
+
return sourceTree.map((node) => {
|
|
9465
|
+
const order = orderById.get(node.id);
|
|
9466
|
+
return order === void 0 ? node : { ...node, order };
|
|
9467
|
+
});
|
|
9468
|
+
}
|
|
9416
9469
|
function normalizePolicyFormStructure(sourceTree) {
|
|
9417
9470
|
let nextTree = sourceTree;
|
|
9418
9471
|
const byParent = nodesByParent(nextTree);
|
|
@@ -9521,9 +9574,10 @@ function normalizeSemanticHierarchy(sourceTree) {
|
|
|
9521
9574
|
)
|
|
9522
9575
|
);
|
|
9523
9576
|
const nested = normalizeDocumentSourceTreePaths(nestEndorsementContinuationPages(normalized));
|
|
9524
|
-
const
|
|
9577
|
+
const mergedNotices = normalizeDocumentSourceTreePaths(mergeAdministrativeNoticesIntoFrontMatter(nested));
|
|
9578
|
+
const withEvidence = normalizeContainerEvidenceFromChildren(mergedNotices);
|
|
9525
9579
|
return normalizeDocumentSourceTreePaths(
|
|
9526
|
-
normalizeContainerEvidenceFromChildren(withEvidence)
|
|
9580
|
+
normalizeRootSemanticOrder(normalizeContainerEvidenceFromChildren(withEvidence))
|
|
9527
9581
|
);
|
|
9528
9582
|
}
|
|
9529
9583
|
function applyEndorsementGrouping(sourceTree) {
|