@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.mjs
CHANGED
|
@@ -9324,9 +9324,29 @@ function pageTitleFromText(text, fallback) {
|
|
|
9324
9324
|
const endorsement = normalized.match(/\bENDORSEMENT\s+(?:NO\.?|NUMBER|#)\s*[A-Z0-9][A-Z0-9.-]*\b/i)?.[0];
|
|
9325
9325
|
if (endorsement) return cleanText(endorsement, fallback);
|
|
9326
9326
|
const firstSentence = normalized.split(/(?<=\.)\s+/)[0];
|
|
9327
|
+
if (/^page\s+\d+\b/i.test(firstSentence)) return fallback;
|
|
9327
9328
|
if (firstSentence && firstSentence.length <= 120) return firstSentence.replace(/[.]$/, "");
|
|
9328
9329
|
return fallback;
|
|
9329
9330
|
}
|
|
9331
|
+
function pageHeadingTitleFromText(text, fallback) {
|
|
9332
|
+
const normalized = cleanText(text, "");
|
|
9333
|
+
const headingText = normalized.replace(/^page\s+\d+\s*(?:\|\s*page\s*\|\s*page\s+\d+\s*\|?)?/i, "").slice(0, 700);
|
|
9334
|
+
const patterns = [
|
|
9335
|
+
/\bIMPORTANT NOTICE\s+[—-]\s+HOW TO REPORT A CLAIM\b/i,
|
|
9336
|
+
/\bPRIVACY NOTICE TO POLICYHOLDERS\b/i,
|
|
9337
|
+
/\bOFAC ADVISORY NOTICE\b/i,
|
|
9338
|
+
/\bTERRORISM RISK INSURANCE ACT\s*\(TRIA\)\s*DISCLOSURE AND REJECTION\b/i,
|
|
9339
|
+
/\bDECLARATIONS PAGE\b/i,
|
|
9340
|
+
/\bTECHNOLOGY ERRORS?\s*&\s*OMISSIONS AND CYBER LIABILITY INSURANCE POLICY\b/i,
|
|
9341
|
+
/\bTRADE OR ECONOMIC SANCTIONS LIMITATION\b/i,
|
|
9342
|
+
/\bFORMS? AND ENDORSEMENTS\b/i
|
|
9343
|
+
];
|
|
9344
|
+
for (const pattern of patterns) {
|
|
9345
|
+
const match = headingText.match(pattern)?.[0];
|
|
9346
|
+
if (match) return cleanText(match, fallback);
|
|
9347
|
+
}
|
|
9348
|
+
return fallback;
|
|
9349
|
+
}
|
|
9330
9350
|
function pageFormTypeFromText(text) {
|
|
9331
9351
|
if (/\b(declarations?\s+page|declarations?\s+schedule)\b/i.test(text)) return "declarations";
|
|
9332
9352
|
if (/\b(endorsement\s+(?:no\.?|number|#)|this endorsement changes the policy|[A-Z]{2,}-END\s+\d{2,})\b/i.test(text)) return "endorsement";
|
|
@@ -9588,33 +9608,44 @@ function reparentNodes(sourceTree, childIds, parentId, organizerRepair) {
|
|
|
9588
9608
|
function applySemanticPageGrouping(sourceTree) {
|
|
9589
9609
|
const relabeled = sourceTree.map((node) => {
|
|
9590
9610
|
if (node.kind === "document" || node.kind === "page_group") return node;
|
|
9591
|
-
|
|
9592
|
-
if (
|
|
9611
|
+
let nextNode = node;
|
|
9612
|
+
if (node.kind === "page" && /^page\s+\d+$/i.test(node.title)) {
|
|
9613
|
+
const title = pageHeadingTitleFromText([node.textExcerpt, node.description].filter(Boolean).join(" "), node.title);
|
|
9614
|
+
if (title !== node.title) {
|
|
9615
|
+
nextNode = {
|
|
9616
|
+
...node,
|
|
9617
|
+
title: simplifyOrganizerTitle(title, title, node.kind),
|
|
9618
|
+
metadata: { ...node.metadata, organizerRepair: "semantic_page_title" }
|
|
9619
|
+
};
|
|
9620
|
+
}
|
|
9621
|
+
}
|
|
9622
|
+
const endorsement = endorsementStartTitle(nextNode);
|
|
9623
|
+
if (endorsement && nextNode.kind === "page") {
|
|
9593
9624
|
return {
|
|
9594
|
-
...
|
|
9625
|
+
...nextNode,
|
|
9595
9626
|
kind: "endorsement",
|
|
9596
9627
|
title: endorsement,
|
|
9597
|
-
description: endorsementDescription(endorsement,
|
|
9598
|
-
metadata: { ...
|
|
9628
|
+
description: endorsementDescription(endorsement, nextNode),
|
|
9629
|
+
metadata: { ...nextNode.metadata, organizerRepair: "semantic_page_grouping" }
|
|
9599
9630
|
};
|
|
9600
9631
|
}
|
|
9601
|
-
if (
|
|
9632
|
+
if (nextNode.kind === "page" && looksLikeDeclarationsStart(nextNode)) {
|
|
9602
9633
|
return {
|
|
9603
|
-
...
|
|
9634
|
+
...nextNode,
|
|
9604
9635
|
title: "Declarations",
|
|
9605
|
-
description: cleanText([
|
|
9606
|
-
metadata: { ...
|
|
9636
|
+
description: cleanText([nextNode.description, "Declarations"].join(" "), "Declarations"),
|
|
9637
|
+
metadata: { ...nextNode.metadata, organizerRepair: "semantic_page_grouping" }
|
|
9607
9638
|
};
|
|
9608
9639
|
}
|
|
9609
|
-
if (
|
|
9640
|
+
if (nextNode.kind === "page" && looksLikePolicyFormStart(nextNode)) {
|
|
9610
9641
|
return {
|
|
9611
|
-
...
|
|
9642
|
+
...nextNode,
|
|
9612
9643
|
title: "Policy Form",
|
|
9613
|
-
description: cleanText([
|
|
9614
|
-
metadata: { ...
|
|
9644
|
+
description: cleanText([nextNode.description, "Policy Form"].join(" "), "Policy Form"),
|
|
9645
|
+
metadata: { ...nextNode.metadata, organizerRepair: "semantic_page_grouping" }
|
|
9615
9646
|
};
|
|
9616
9647
|
}
|
|
9617
|
-
return
|
|
9648
|
+
return nextNode;
|
|
9618
9649
|
});
|
|
9619
9650
|
const rootId = sourceTreeRootId(relabeled);
|
|
9620
9651
|
const children = (nodesByParent(relabeled).get(rootId) ?? []).filter((node) => node.kind !== "document").sort((left, right) => left.order - right.order);
|