@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.js
CHANGED
|
@@ -9745,6 +9745,9 @@ function rejectsOrganizerGroup(group, children) {
|
|
|
9745
9745
|
function isEndorsementGroup(node) {
|
|
9746
9746
|
return node.kind === "page_group" && /^endorsements?\b/i.test(node.title);
|
|
9747
9747
|
}
|
|
9748
|
+
function isNoticesGroup(node) {
|
|
9749
|
+
return node.kind === "page_group" && /^notices?\s+and\s+jacket$/i.test(node.title);
|
|
9750
|
+
}
|
|
9748
9751
|
function endorsementGroupNodeId(documentId, parentId) {
|
|
9749
9752
|
return [
|
|
9750
9753
|
documentId.replace(/[^a-zA-Z0-9_.:-]/g, "_"),
|
|
@@ -9760,6 +9763,56 @@ function isPolicyFormNode(node) {
|
|
|
9760
9763
|
function isDeclarationsNode(node) {
|
|
9761
9764
|
return node.kind === "page_group" && node.title === "Declarations";
|
|
9762
9765
|
}
|
|
9766
|
+
function isAdministrativeNoticeNode(node) {
|
|
9767
|
+
const text = sourceNodeText(node);
|
|
9768
|
+
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);
|
|
9769
|
+
}
|
|
9770
|
+
function mergeAdministrativeNoticesIntoFrontMatter(sourceTree) {
|
|
9771
|
+
const rootId = sourceTreeRootId(sourceTree);
|
|
9772
|
+
if (!rootId) return sourceTree;
|
|
9773
|
+
const children = (nodesByParent(sourceTree).get(rootId) ?? []).filter((node) => node.kind !== "document");
|
|
9774
|
+
const noticesGroup = children.find(isNoticesGroup);
|
|
9775
|
+
if (!noticesGroup) return sourceTree;
|
|
9776
|
+
const noticesGroupChildren = new Set(
|
|
9777
|
+
(nodesByParent(sourceTree).get(noticesGroup.id) ?? []).map((node) => node.id)
|
|
9778
|
+
);
|
|
9779
|
+
const noticeIds = new Set(
|
|
9780
|
+
children.filter(
|
|
9781
|
+
(node) => node.id !== noticesGroup.id && !noticesGroupChildren.has(node.id) && node.kind === "page" && isAdministrativeNoticeNode(node)
|
|
9782
|
+
).map((node) => node.id)
|
|
9783
|
+
);
|
|
9784
|
+
if (noticeIds.size === 0) return sourceTree;
|
|
9785
|
+
return sourceTree.map(
|
|
9786
|
+
(node) => noticeIds.has(node.id) ? {
|
|
9787
|
+
...node,
|
|
9788
|
+
parentId: noticesGroup.id,
|
|
9789
|
+
metadata: {
|
|
9790
|
+
...node.metadata,
|
|
9791
|
+
organizerRepair: "merge_administrative_notice"
|
|
9792
|
+
}
|
|
9793
|
+
} : node
|
|
9794
|
+
);
|
|
9795
|
+
}
|
|
9796
|
+
function rootSemanticRank(node) {
|
|
9797
|
+
if (isNoticesGroup(node)) return 0;
|
|
9798
|
+
if (node.title === "Declarations") return 1;
|
|
9799
|
+
if (node.title === "Policy Form") return 2;
|
|
9800
|
+
if (isEndorsementGroup(node)) return 3;
|
|
9801
|
+
if (isAdministrativeNoticeNode(node)) return 0.5;
|
|
9802
|
+
return 2.5;
|
|
9803
|
+
}
|
|
9804
|
+
function normalizeRootSemanticOrder(sourceTree) {
|
|
9805
|
+
const rootId = sourceTreeRootId(sourceTree);
|
|
9806
|
+
if (!rootId) return sourceTree;
|
|
9807
|
+
const rootChildren2 = (nodesByParent(sourceTree).get(rootId) ?? []).filter((node) => node.kind !== "document").sort(
|
|
9808
|
+
(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)
|
|
9809
|
+
);
|
|
9810
|
+
const orderById = new Map(rootChildren2.map((node, index) => [node.id, index + 1]));
|
|
9811
|
+
return sourceTree.map((node) => {
|
|
9812
|
+
const order = orderById.get(node.id);
|
|
9813
|
+
return order === void 0 ? node : { ...node, order };
|
|
9814
|
+
});
|
|
9815
|
+
}
|
|
9763
9816
|
function normalizePolicyFormStructure(sourceTree) {
|
|
9764
9817
|
let nextTree = sourceTree;
|
|
9765
9818
|
const byParent = nodesByParent(nextTree);
|
|
@@ -9868,9 +9921,10 @@ function normalizeSemanticHierarchy(sourceTree) {
|
|
|
9868
9921
|
)
|
|
9869
9922
|
);
|
|
9870
9923
|
const nested = normalizeDocumentSourceTreePaths(nestEndorsementContinuationPages(normalized));
|
|
9871
|
-
const
|
|
9924
|
+
const mergedNotices = normalizeDocumentSourceTreePaths(mergeAdministrativeNoticesIntoFrontMatter(nested));
|
|
9925
|
+
const withEvidence = normalizeContainerEvidenceFromChildren(mergedNotices);
|
|
9872
9926
|
return normalizeDocumentSourceTreePaths(
|
|
9873
|
-
normalizeContainerEvidenceFromChildren(withEvidence)
|
|
9927
|
+
normalizeRootSemanticOrder(normalizeContainerEvidenceFromChildren(withEvidence))
|
|
9874
9928
|
);
|
|
9875
9929
|
}
|
|
9876
9930
|
function applyEndorsementGrouping(sourceTree) {
|