@claritylabs/cl-sdk 3.0.24 → 3.0.26

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 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(?:coverage|coverage part|line)\s*:?\s*([^|;$]{3,80})/i)?.[1];
3363
- if (labelled) return cleanCoverageLabel(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,24 @@ 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 (/^coverage part\s+s\b/i.test(coverage.name)) return false;
3585
+ if (/^(nwc|iso|cg|il|acord)[-\s]?[a-z0-9]/i.test(coverage.name)) return false;
3586
+ if (/\b(forms?|endorsements?|premium|payment|terrorism risk insurance act|tria|erp option|bilateral discovery)\b/i.test(name)) return false;
3587
+ if (/\b(incurred in excess|shall erode|subject to|combined defense expenses)\b/i.test(name)) return false;
3588
+ 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)) {
3589
+ return false;
3590
+ }
3591
+ 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);
3592
+ }
3571
3593
  function uniqueTerms(terms) {
3572
3594
  const seen = /* @__PURE__ */ new Set();
3573
3595
  const result = [];
@@ -3653,6 +3675,7 @@ function buildCoverages(nodes) {
3653
3675
  if (endorsementAncestor(row, byId)) continue;
3654
3676
  const structured = row.kind === "table_row" ? coverageFromTableRow(row, children, byId) : void 0;
3655
3677
  if (structured) {
3678
+ if (!isOperationalCoverageRow(structured)) continue;
3656
3679
  const key2 = [
3657
3680
  structured.name.toLowerCase(),
3658
3681
  structured.limits.map((term) => `${term.kind}:${term.value}`).join(","),
@@ -3670,6 +3693,20 @@ function buildCoverages(nodes) {
3670
3693
  const deductible = deductibleFromText(text);
3671
3694
  const premium = premiumFromText(text);
3672
3695
  if (!name || !limit && !deductible && !premium) continue;
3696
+ if (!isOperationalCoverageRow({
3697
+ name,
3698
+ limit,
3699
+ deductible,
3700
+ premium,
3701
+ coverageOrigin: "core",
3702
+ limits: [
3703
+ ...limit ? [{ kind: "other", label: "Limit", value: limit, sourceNodeIds: [row.id], sourceSpanIds: row.sourceSpanIds }] : [],
3704
+ ...deductible ? [{ kind: "deductible", label: "Deductible", value: deductible, sourceNodeIds: [row.id], sourceSpanIds: row.sourceSpanIds }] : [],
3705
+ ...premium ? [{ kind: "premium", label: "Premium", value: premium, sourceNodeIds: [row.id], sourceSpanIds: row.sourceSpanIds }] : []
3706
+ ],
3707
+ sourceNodeIds: [row.id],
3708
+ sourceSpanIds: row.sourceSpanIds
3709
+ })) continue;
3673
3710
  const key = [name.toLowerCase(), limit, deductible, premium].join("|");
3674
3711
  if (seen.has(key)) continue;
3675
3712
  seen.add(key);