@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.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,22 @@ 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 (/^(nwc|iso|cg|il|acord)[-\s]?[a-z0-9]/i.test(coverage.name)) return false;
3229
+ if (/\b(forms?|endorsements?|premium|payment|terrorism risk insurance act|tria|erp option|bilateral discovery)\b/i.test(name)) return false;
3230
+ 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)) {
3231
+ return false;
3232
+ }
3233
+ 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);
3234
+ }
3215
3235
  function uniqueTerms(terms) {
3216
3236
  const seen = /* @__PURE__ */ new Set();
3217
3237
  const result = [];
@@ -3297,6 +3317,7 @@ function buildCoverages(nodes) {
3297
3317
  if (endorsementAncestor(row, byId)) continue;
3298
3318
  const structured = row.kind === "table_row" ? coverageFromTableRow(row, children, byId) : void 0;
3299
3319
  if (structured) {
3320
+ if (!isOperationalCoverageRow(structured)) continue;
3300
3321
  const key2 = [
3301
3322
  structured.name.toLowerCase(),
3302
3323
  structured.limits.map((term) => `${term.kind}:${term.value}`).join(","),
@@ -3314,6 +3335,20 @@ function buildCoverages(nodes) {
3314
3335
  const deductible = deductibleFromText(text);
3315
3336
  const premium = premiumFromText(text);
3316
3337
  if (!name || !limit && !deductible && !premium) continue;
3338
+ if (!isOperationalCoverageRow({
3339
+ name,
3340
+ limit,
3341
+ deductible,
3342
+ premium,
3343
+ coverageOrigin: "core",
3344
+ limits: [
3345
+ ...limit ? [{ kind: "other", label: "Limit", value: limit, sourceNodeIds: [row.id], sourceSpanIds: row.sourceSpanIds }] : [],
3346
+ ...deductible ? [{ kind: "deductible", label: "Deductible", value: deductible, sourceNodeIds: [row.id], sourceSpanIds: row.sourceSpanIds }] : [],
3347
+ ...premium ? [{ kind: "premium", label: "Premium", value: premium, sourceNodeIds: [row.id], sourceSpanIds: row.sourceSpanIds }] : []
3348
+ ],
3349
+ sourceNodeIds: [row.id],
3350
+ sourceSpanIds: row.sourceSpanIds
3351
+ })) continue;
3317
3352
  const key = [name.toLowerCase(), limit, deductible, premium].join("|");
3318
3353
  if (seen.has(key)) continue;
3319
3354
  seen.add(key);