@claritylabs/cl-sdk 3.0.24 → 3.0.25
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 +37 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3359,8 +3359,12 @@ function inferDocumentType(nodes) {
|
|
|
3359
3359
|
return "policy";
|
|
3360
3360
|
}
|
|
3361
3361
|
function coverageNameFromRow(text) {
|
|
3362
|
-
const labelled = text.match(/\b(
|
|
3363
|
-
if (labelled)
|
|
3362
|
+
const labelled = text.match(/\b(coverage part|coverage|line)\s*:?\s*([^|;$]{3,80})/i);
|
|
3363
|
+
if (labelled) {
|
|
3364
|
+
const value = cleanCoverageLabel(labelled[2]);
|
|
3365
|
+
if (!value) return void 0;
|
|
3366
|
+
return /^coverage part$/i.test(labelled[1]) ? `Coverage Part ${value}` : value;
|
|
3367
|
+
}
|
|
3364
3368
|
const parts = text.split(/\s+\|\s+| {2,}|\t/).map(cleanCoverageLabel).filter(Boolean);
|
|
3365
3369
|
const first = parts.find(
|
|
3366
3370
|
(part) => !/^(limit|limits?|deductible|premium|amount|basis|rate|retroactive|aggregate|each occurrence)$/i.test(part) && !/^\$?[\d,]+/.test(part)
|
|
@@ -3568,6 +3572,22 @@ function legacyPremium(terms) {
|
|
|
3568
3572
|
function retroDate(terms) {
|
|
3569
3573
|
return terms.find((term) => term.kind === "retroactive_date")?.value;
|
|
3570
3574
|
}
|
|
3575
|
+
function hasCoverageLimitTerm(terms) {
|
|
3576
|
+
return terms.some(
|
|
3577
|
+
(term) => ["each_claim_limit", "each_occurrence_limit", "each_loss_limit", "aggregate_limit", "sublimit"].includes(term.kind) || term.kind === "other" && /\blimit\b/i.test(term.label) && moneyAmount(term.value) !== void 0
|
|
3578
|
+
);
|
|
3579
|
+
}
|
|
3580
|
+
function isOperationalCoverageRow(coverage) {
|
|
3581
|
+
const name = normalizeLabel(coverage.name);
|
|
3582
|
+
if (!hasCoverageLimitTerm(coverage.limits)) return false;
|
|
3583
|
+
if (/^(item\s+\d+|option:|annual policy premium|total premium|premium and payment)\b/i.test(coverage.name)) return false;
|
|
3584
|
+
if (/^(nwc|iso|cg|il|acord)[-\s]?[a-z0-9]/i.test(coverage.name)) return false;
|
|
3585
|
+
if (/\b(forms?|endorsements?|premium|payment|terrorism risk insurance act|tria|erp option|bilateral discovery)\b/i.test(name)) return false;
|
|
3586
|
+
if (coverage.name.split(/\s+/).length > 16 && !/\b(coverage|liability|sub[-\s]?limit|aggregate|each\s+(claim|loss|occurrence)|limit)\b/i.test(coverage.name)) {
|
|
3587
|
+
return false;
|
|
3588
|
+
}
|
|
3589
|
+
return /\b(coverage|coverage part|liability|sub[-\s]?limit|aggregate|each\s+(claim|loss|occurrence)|bricking|cyber|privacy|media|regulatory|defense|ai\/ml|errors?\s*&?\s*omissions|technology)\b/i.test(coverage.name);
|
|
3590
|
+
}
|
|
3571
3591
|
function uniqueTerms(terms) {
|
|
3572
3592
|
const seen = /* @__PURE__ */ new Set();
|
|
3573
3593
|
const result = [];
|
|
@@ -3653,6 +3673,7 @@ function buildCoverages(nodes) {
|
|
|
3653
3673
|
if (endorsementAncestor(row, byId)) continue;
|
|
3654
3674
|
const structured = row.kind === "table_row" ? coverageFromTableRow(row, children, byId) : void 0;
|
|
3655
3675
|
if (structured) {
|
|
3676
|
+
if (!isOperationalCoverageRow(structured)) continue;
|
|
3656
3677
|
const key2 = [
|
|
3657
3678
|
structured.name.toLowerCase(),
|
|
3658
3679
|
structured.limits.map((term) => `${term.kind}:${term.value}`).join(","),
|
|
@@ -3670,6 +3691,20 @@ function buildCoverages(nodes) {
|
|
|
3670
3691
|
const deductible = deductibleFromText(text);
|
|
3671
3692
|
const premium = premiumFromText(text);
|
|
3672
3693
|
if (!name || !limit && !deductible && !premium) continue;
|
|
3694
|
+
if (!isOperationalCoverageRow({
|
|
3695
|
+
name,
|
|
3696
|
+
limit,
|
|
3697
|
+
deductible,
|
|
3698
|
+
premium,
|
|
3699
|
+
coverageOrigin: "core",
|
|
3700
|
+
limits: [
|
|
3701
|
+
...limit ? [{ kind: "other", label: "Limit", value: limit, sourceNodeIds: [row.id], sourceSpanIds: row.sourceSpanIds }] : [],
|
|
3702
|
+
...deductible ? [{ kind: "deductible", label: "Deductible", value: deductible, sourceNodeIds: [row.id], sourceSpanIds: row.sourceSpanIds }] : [],
|
|
3703
|
+
...premium ? [{ kind: "premium", label: "Premium", value: premium, sourceNodeIds: [row.id], sourceSpanIds: row.sourceSpanIds }] : []
|
|
3704
|
+
],
|
|
3705
|
+
sourceNodeIds: [row.id],
|
|
3706
|
+
sourceSpanIds: row.sourceSpanIds
|
|
3707
|
+
})) continue;
|
|
3673
3708
|
const key = [name.toLowerCase(), limit, deductible, premium].join("|");
|
|
3674
3709
|
if (seen.has(key)) continue;
|
|
3675
3710
|
seen.add(key);
|