@claritylabs/cl-sdk 3.1.15 → 3.1.17
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 +89 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9355,6 +9355,9 @@ function normalizedTermText(term) {
|
|
|
9355
9355
|
function isLimitTerm(term) {
|
|
9356
9356
|
return ["each_claim_limit", "each_occurrence_limit", "each_loss_limit", "aggregate_limit", "sublimit"].includes(term.kind) || term.kind === "other" && /\b(limit|aggregate|claim|occurrence|loss|proceeding)\b/i.test(normalizedTermText(term));
|
|
9357
9357
|
}
|
|
9358
|
+
function isPrimaryLimitTerm(term) {
|
|
9359
|
+
return ["each_claim_limit", "each_occurrence_limit", "each_loss_limit", "aggregate_limit"].includes(term.kind);
|
|
9360
|
+
}
|
|
9358
9361
|
function isDeductibleTerm(term) {
|
|
9359
9362
|
return term.kind === "deductible" || term.kind === "retention" || /\b(deductible|retention|sir)\b/i.test(normalizedTermText(term));
|
|
9360
9363
|
}
|
|
@@ -9364,8 +9367,41 @@ function isPremiumTerm(term) {
|
|
|
9364
9367
|
function isRetroactiveDateTerm(term) {
|
|
9365
9368
|
return term.kind === "retroactive_date" || /\bretroactive\b/i.test(normalizedTermText(term));
|
|
9366
9369
|
}
|
|
9370
|
+
function fallbackLimitScope(kind) {
|
|
9371
|
+
switch (kind) {
|
|
9372
|
+
case "each_claim_limit":
|
|
9373
|
+
return "Each Claim";
|
|
9374
|
+
case "each_occurrence_limit":
|
|
9375
|
+
return "Each Occurrence";
|
|
9376
|
+
case "each_loss_limit":
|
|
9377
|
+
return "Each Loss";
|
|
9378
|
+
case "aggregate_limit":
|
|
9379
|
+
return "Aggregate";
|
|
9380
|
+
case "sublimit":
|
|
9381
|
+
return "Sub-Limit";
|
|
9382
|
+
default:
|
|
9383
|
+
return void 0;
|
|
9384
|
+
}
|
|
9385
|
+
}
|
|
9386
|
+
function displayLabelForLimitTerm(term) {
|
|
9387
|
+
const label = cleanProfileValue(term.label)?.replace(/\s+Limit$/i, "");
|
|
9388
|
+
if (label && !/^(?:limit|amount|value)$/i.test(label)) return label;
|
|
9389
|
+
return fallbackLimitScope(term.kind);
|
|
9390
|
+
}
|
|
9391
|
+
function displayValueForLimitTerm(term) {
|
|
9392
|
+
const value = cleanProfileValue(term.value);
|
|
9393
|
+
if (!value) return void 0;
|
|
9394
|
+
if (/\b(each|aggregate|occurrence|claim|loss|proceeding|policy|sublimit|sub-limit)\b/i.test(value)) {
|
|
9395
|
+
return value;
|
|
9396
|
+
}
|
|
9397
|
+
const label = displayLabelForLimitTerm(term);
|
|
9398
|
+
return label ? `${value} ${label}` : value;
|
|
9399
|
+
}
|
|
9367
9400
|
function primaryLimitFromTerms(terms) {
|
|
9368
|
-
|
|
9401
|
+
const primaryTerms = terms.filter(isPrimaryLimitTerm);
|
|
9402
|
+
const candidateTerms = primaryTerms.length > 0 ? primaryTerms : terms.filter(isLimitTerm);
|
|
9403
|
+
const values = uniqueStrings(candidateTerms.map((term) => displayValueForLimitTerm(term)).filter((value) => Boolean(value)));
|
|
9404
|
+
return values.length > 0 ? values.join(" / ") : void 0;
|
|
9369
9405
|
}
|
|
9370
9406
|
function deductibleFromTerms(terms) {
|
|
9371
9407
|
return terms.find(isDeductibleTerm)?.value;
|
|
@@ -9376,6 +9412,13 @@ function premiumFromTerms(terms) {
|
|
|
9376
9412
|
function retroactiveDateFromTerms(terms) {
|
|
9377
9413
|
return terms.find(isRetroactiveDateTerm)?.value;
|
|
9378
9414
|
}
|
|
9415
|
+
function shouldUseTermLimitDisplay(currentLimit, termLimit) {
|
|
9416
|
+
const current = cleanProfileValue(currentLimit);
|
|
9417
|
+
if (!current) return true;
|
|
9418
|
+
if (/\s+\/\s*$/.test(current)) return true;
|
|
9419
|
+
if (!/\b(each|aggregate|occurrence|claim|loss|proceeding|policy|sublimit|sub-limit)\b/i.test(current)) return true;
|
|
9420
|
+
return !current.includes("/") && termLimit.includes("/");
|
|
9421
|
+
}
|
|
9379
9422
|
function termDecisionTouches(coverage, decision, predicate) {
|
|
9380
9423
|
const existing = coverage.limits[decision.termIndex];
|
|
9381
9424
|
if (existing && predicate(existing)) return true;
|
|
@@ -9470,6 +9513,10 @@ function applyCoverageCleanupDecision(coverage, decision, validNodeIds, validSpa
|
|
|
9470
9513
|
else delete next.retroactiveDate;
|
|
9471
9514
|
}
|
|
9472
9515
|
}
|
|
9516
|
+
const termLimit = primaryLimitFromTerms(next.limits);
|
|
9517
|
+
if (termLimit && shouldUseTermLimitDisplay(next.limit, termLimit)) {
|
|
9518
|
+
next.limit = termLimit;
|
|
9519
|
+
}
|
|
9473
9520
|
next.sourceNodeIds = uniqueStrings([
|
|
9474
9521
|
...next.sourceNodeIds,
|
|
9475
9522
|
...next.limits.flatMap((term) => term.sourceNodeIds)
|
|
@@ -10855,6 +10902,46 @@ function tableRowTextFromCells(cells) {
|
|
|
10855
10902
|
}).filter(Boolean).join(" | ");
|
|
10856
10903
|
return text ? cleanText(text, text) : void 0;
|
|
10857
10904
|
}
|
|
10905
|
+
function normalizeTableBoundaryDelimiters(value) {
|
|
10906
|
+
const text = cleanText(value, "");
|
|
10907
|
+
if (!text) return void 0;
|
|
10908
|
+
const normalized = text.replace(/\s+\|\s+\|/g, " | ").replace(/\s+\/\s+\|/g, " |").replace(/\s+[|/]\s*$/g, "").replace(/\s{2,}/g, " ").trim();
|
|
10909
|
+
return normalized || void 0;
|
|
10910
|
+
}
|
|
10911
|
+
function normalizeSourceTreeTableDisplayText(sourceTree) {
|
|
10912
|
+
const byParent = nodesByParent(sourceTree);
|
|
10913
|
+
const updates = /* @__PURE__ */ new Map();
|
|
10914
|
+
const currentNode = (node) => updates.get(node.id) ?? node;
|
|
10915
|
+
for (const node of sourceTree) {
|
|
10916
|
+
if (node.kind !== "table_cell") continue;
|
|
10917
|
+
const textExcerpt = normalizeTableBoundaryDelimiters(node.textExcerpt);
|
|
10918
|
+
const textChanged = textExcerpt !== void 0 && textExcerpt !== node.textExcerpt;
|
|
10919
|
+
const description = textChanged && textExcerpt ? normalizeTableBoundaryDelimiters([node.title, textExcerpt].filter(Boolean).join(" | ")) : normalizeTableBoundaryDelimiters(node.description);
|
|
10920
|
+
if (textExcerpt === node.textExcerpt && description === node.description) continue;
|
|
10921
|
+
updates.set(node.id, {
|
|
10922
|
+
...node,
|
|
10923
|
+
...textExcerpt !== void 0 ? { textExcerpt } : {},
|
|
10924
|
+
...description !== void 0 ? { description } : {}
|
|
10925
|
+
});
|
|
10926
|
+
}
|
|
10927
|
+
for (const node of sourceTree) {
|
|
10928
|
+
if (node.kind !== "table_row") continue;
|
|
10929
|
+
const cells = (byParent.get(node.id) ?? []).filter((child) => child.kind === "table_cell").map(currentNode).sort(
|
|
10930
|
+
(left, right) => tableCellColumnIndex(left, 0) - tableCellColumnIndex(right, 0) || left.order - right.order || left.id.localeCompare(right.id)
|
|
10931
|
+
);
|
|
10932
|
+
const textExcerpt = cells.length ? tableRowTextFromCells(cells) : normalizeTableBoundaryDelimiters(node.textExcerpt);
|
|
10933
|
+
const textChanged = textExcerpt !== void 0 && textExcerpt !== node.textExcerpt;
|
|
10934
|
+
const description = textChanged && textExcerpt ? normalizeTableBoundaryDelimiters([node.title, textExcerpt].filter(Boolean).join(" | ")) : normalizeTableBoundaryDelimiters(node.description);
|
|
10935
|
+
if (textExcerpt === node.textExcerpt && description === node.description) continue;
|
|
10936
|
+
updates.set(node.id, {
|
|
10937
|
+
...node,
|
|
10938
|
+
...textExcerpt !== void 0 ? { textExcerpt } : {},
|
|
10939
|
+
...description !== void 0 ? { description } : {}
|
|
10940
|
+
});
|
|
10941
|
+
}
|
|
10942
|
+
if (updates.size === 0) return sourceTree;
|
|
10943
|
+
return sourceTree.map((node) => updates.get(node.id) ?? node);
|
|
10944
|
+
}
|
|
10858
10945
|
function tableRowTextForPrompt(row, cells) {
|
|
10859
10946
|
return cleanText(
|
|
10860
10947
|
cells.length ? cells.map(tableCellText).filter(Boolean).join(" | ") : row.textExcerpt ?? row.description ?? row.title,
|
|
@@ -11653,7 +11740,7 @@ async function runSourceTreeExtraction(params) {
|
|
|
11653
11740
|
trackUsage: localTrack,
|
|
11654
11741
|
log: params.log
|
|
11655
11742
|
});
|
|
11656
|
-
sourceTree = visualTableRepair.sourceTree;
|
|
11743
|
+
sourceTree = normalizeSourceTreeTableDisplayText(visualTableRepair.sourceTree);
|
|
11657
11744
|
warnings.push(...visualTableRepair.warnings);
|
|
11658
11745
|
const emptyProfile = emptyOperationalProfile();
|
|
11659
11746
|
let operationalProfile = emptyProfile;
|