@claritylabs/cl-sdk 3.0.20 → 3.0.22
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 +45 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9671,9 +9671,29 @@ function pageTitleFromText(text, fallback) {
|
|
|
9671
9671
|
const endorsement = normalized.match(/\bENDORSEMENT\s+(?:NO\.?|NUMBER|#)\s*[A-Z0-9][A-Z0-9.-]*\b/i)?.[0];
|
|
9672
9672
|
if (endorsement) return cleanText(endorsement, fallback);
|
|
9673
9673
|
const firstSentence = normalized.split(/(?<=\.)\s+/)[0];
|
|
9674
|
+
if (/^page\s+\d+\b/i.test(firstSentence)) return fallback;
|
|
9674
9675
|
if (firstSentence && firstSentence.length <= 120) return firstSentence.replace(/[.]$/, "");
|
|
9675
9676
|
return fallback;
|
|
9676
9677
|
}
|
|
9678
|
+
function pageHeadingTitleFromText(text, fallback) {
|
|
9679
|
+
const normalized = cleanText(text, "");
|
|
9680
|
+
const headingText = normalized.replace(/^page\s+\d+\s*(?:\|\s*page\s*\|\s*page\s+\d+\s*\|?)?/i, "").slice(0, 700);
|
|
9681
|
+
const patterns = [
|
|
9682
|
+
/\bIMPORTANT NOTICE\s+[—-]\s+HOW TO REPORT A CLAIM\b/i,
|
|
9683
|
+
/\bPRIVACY NOTICE TO POLICYHOLDERS\b/i,
|
|
9684
|
+
/\bOFAC ADVISORY NOTICE\b/i,
|
|
9685
|
+
/\bTERRORISM RISK INSURANCE ACT\s*\(TRIA\)\s*DISCLOSURE AND REJECTION\b/i,
|
|
9686
|
+
/\bDECLARATIONS PAGE\b/i,
|
|
9687
|
+
/\bTECHNOLOGY ERRORS?\s*&\s*OMISSIONS AND CYBER LIABILITY INSURANCE POLICY\b/i,
|
|
9688
|
+
/\bTRADE OR ECONOMIC SANCTIONS LIMITATION\b/i,
|
|
9689
|
+
/\bFORMS? AND ENDORSEMENTS\b/i
|
|
9690
|
+
];
|
|
9691
|
+
for (const pattern of patterns) {
|
|
9692
|
+
const match = headingText.match(pattern)?.[0];
|
|
9693
|
+
if (match) return cleanText(match, fallback);
|
|
9694
|
+
}
|
|
9695
|
+
return fallback;
|
|
9696
|
+
}
|
|
9677
9697
|
function pageFormTypeFromText(text) {
|
|
9678
9698
|
if (/\b(declarations?\s+page|declarations?\s+schedule)\b/i.test(text)) return "declarations";
|
|
9679
9699
|
if (/\b(endorsement\s+(?:no\.?|number|#)|this endorsement changes the policy|[A-Z]{2,}-END\s+\d{2,})\b/i.test(text)) return "endorsement";
|
|
@@ -9935,33 +9955,44 @@ function reparentNodes(sourceTree, childIds, parentId, organizerRepair) {
|
|
|
9935
9955
|
function applySemanticPageGrouping(sourceTree) {
|
|
9936
9956
|
const relabeled = sourceTree.map((node) => {
|
|
9937
9957
|
if (node.kind === "document" || node.kind === "page_group") return node;
|
|
9938
|
-
|
|
9939
|
-
if (
|
|
9958
|
+
let nextNode = node;
|
|
9959
|
+
if (node.kind === "page" && /^page\s+\d+$/i.test(node.title)) {
|
|
9960
|
+
const title = pageHeadingTitleFromText([node.textExcerpt, node.description].filter(Boolean).join(" "), node.title);
|
|
9961
|
+
if (title !== node.title) {
|
|
9962
|
+
nextNode = {
|
|
9963
|
+
...node,
|
|
9964
|
+
title: simplifyOrganizerTitle(title, title, node.kind),
|
|
9965
|
+
metadata: { ...node.metadata, organizerRepair: "semantic_page_title" }
|
|
9966
|
+
};
|
|
9967
|
+
}
|
|
9968
|
+
}
|
|
9969
|
+
const endorsement = endorsementStartTitle(nextNode);
|
|
9970
|
+
if (endorsement && nextNode.kind === "page") {
|
|
9940
9971
|
return {
|
|
9941
|
-
...
|
|
9972
|
+
...nextNode,
|
|
9942
9973
|
kind: "endorsement",
|
|
9943
9974
|
title: endorsement,
|
|
9944
|
-
description: endorsementDescription(endorsement,
|
|
9945
|
-
metadata: { ...
|
|
9975
|
+
description: endorsementDescription(endorsement, nextNode),
|
|
9976
|
+
metadata: { ...nextNode.metadata, organizerRepair: "semantic_page_grouping" }
|
|
9946
9977
|
};
|
|
9947
9978
|
}
|
|
9948
|
-
if (
|
|
9979
|
+
if (nextNode.kind === "page" && looksLikeDeclarationsStart(nextNode)) {
|
|
9949
9980
|
return {
|
|
9950
|
-
...
|
|
9981
|
+
...nextNode,
|
|
9951
9982
|
title: "Declarations",
|
|
9952
|
-
description: cleanText([
|
|
9953
|
-
metadata: { ...
|
|
9983
|
+
description: cleanText([nextNode.description, "Declarations"].join(" "), "Declarations"),
|
|
9984
|
+
metadata: { ...nextNode.metadata, organizerRepair: "semantic_page_grouping" }
|
|
9954
9985
|
};
|
|
9955
9986
|
}
|
|
9956
|
-
if (
|
|
9987
|
+
if (nextNode.kind === "page" && looksLikePolicyFormStart(nextNode)) {
|
|
9957
9988
|
return {
|
|
9958
|
-
...
|
|
9989
|
+
...nextNode,
|
|
9959
9990
|
title: "Policy Form",
|
|
9960
|
-
description: cleanText([
|
|
9961
|
-
metadata: { ...
|
|
9991
|
+
description: cleanText([nextNode.description, "Policy Form"].join(" "), "Policy Form"),
|
|
9992
|
+
metadata: { ...nextNode.metadata, organizerRepair: "semantic_page_grouping" }
|
|
9962
9993
|
};
|
|
9963
9994
|
}
|
|
9964
|
-
return
|
|
9995
|
+
return nextNode;
|
|
9965
9996
|
});
|
|
9966
9997
|
const rootId = sourceTreeRootId(relabeled);
|
|
9967
9998
|
const children = (nodesByParent(relabeled).get(rootId) ?? []).filter((node) => node.kind !== "document").sort((left, right) => left.order - right.order);
|