@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.mjs CHANGED
@@ -3003,8 +3003,12 @@ function inferDocumentType(nodes) {
3003
3003
  return "policy";
3004
3004
  }
3005
3005
  function coverageNameFromRow(text) {
3006
- const labelled = text.match(/\b(?:coverage|coverage part|line)\s*:?\s*([^|;$]{3,80})/i)?.[1];
3007
- if (labelled) return cleanCoverageLabel(labelled);
3006
+ const labelled = text.match(/\b(coverage part|coverage|line)\s*:?\s*([^|;$]{3,80})/i);
3007
+ if (labelled) {
3008
+ const value = cleanCoverageLabel(labelled[2]);
3009
+ if (!value) return void 0;
3010
+ return /^coverage part$/i.test(labelled[1]) ? `Coverage Part ${value}` : value;
3011
+ }
3008
3012
  const parts = text.split(/\s+\|\s+| {2,}|\t/).map(cleanCoverageLabel).filter(Boolean);
3009
3013
  const first = parts.find(
3010
3014
  (part) => !/^(limit|limits?|deductible|premium|amount|basis|rate|retroactive|aggregate|each occurrence)$/i.test(part) && !/^\$?[\d,]+/.test(part)
@@ -3212,6 +3216,24 @@ function legacyPremium(terms) {
3212
3216
  function retroDate(terms) {
3213
3217
  return terms.find((term) => term.kind === "retroactive_date")?.value;
3214
3218
  }
3219
+ function hasCoverageLimitTerm(terms) {
3220
+ return terms.some(
3221
+ (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
3222
+ );
3223
+ }
3224
+ function isOperationalCoverageRow(coverage) {
3225
+ const name = normalizeLabel(coverage.name);
3226
+ if (!hasCoverageLimitTerm(coverage.limits)) return false;
3227
+ if (/^(item\s+\d+|option:|annual policy premium|total premium|premium and payment)\b/i.test(coverage.name)) return false;
3228
+ if (/^coverage part\s+s\b/i.test(coverage.name)) return false;
3229
+ if (/^(nwc|iso|cg|il|acord)[-\s]?[a-z0-9]/i.test(coverage.name)) return false;
3230
+ if (/\b(forms?|endorsements?|premium|payment|terrorism risk insurance act|tria|erp option|bilateral discovery)\b/i.test(name)) return false;
3231
+ if (/\b(incurred in excess|shall erode|subject to|combined defense expenses)\b/i.test(name)) return false;
3232
+ 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)) {
3233
+ return false;
3234
+ }
3235
+ 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);
3236
+ }
3215
3237
  function uniqueTerms(terms) {
3216
3238
  const seen = /* @__PURE__ */ new Set();
3217
3239
  const result = [];
@@ -3297,6 +3319,7 @@ function buildCoverages(nodes) {
3297
3319
  if (endorsementAncestor(row, byId)) continue;
3298
3320
  const structured = row.kind === "table_row" ? coverageFromTableRow(row, children, byId) : void 0;
3299
3321
  if (structured) {
3322
+ if (!isOperationalCoverageRow(structured)) continue;
3300
3323
  const key2 = [
3301
3324
  structured.name.toLowerCase(),
3302
3325
  structured.limits.map((term) => `${term.kind}:${term.value}`).join(","),
@@ -3314,6 +3337,20 @@ function buildCoverages(nodes) {
3314
3337
  const deductible = deductibleFromText(text);
3315
3338
  const premium = premiumFromText(text);
3316
3339
  if (!name || !limit && !deductible && !premium) continue;
3340
+ if (!isOperationalCoverageRow({
3341
+ name,
3342
+ limit,
3343
+ deductible,
3344
+ premium,
3345
+ coverageOrigin: "core",
3346
+ limits: [
3347
+ ...limit ? [{ kind: "other", label: "Limit", value: limit, sourceNodeIds: [row.id], sourceSpanIds: row.sourceSpanIds }] : [],
3348
+ ...deductible ? [{ kind: "deductible", label: "Deductible", value: deductible, sourceNodeIds: [row.id], sourceSpanIds: row.sourceSpanIds }] : [],
3349
+ ...premium ? [{ kind: "premium", label: "Premium", value: premium, sourceNodeIds: [row.id], sourceSpanIds: row.sourceSpanIds }] : []
3350
+ ],
3351
+ sourceNodeIds: [row.id],
3352
+ sourceSpanIds: row.sourceSpanIds
3353
+ })) continue;
3317
3354
  const key = [name.toLowerCase(), limit, deductible, premium].join("|");
3318
3355
  if (seen.has(key)) continue;
3319
3356
  seen.add(key);