@claritylabs/cl-sdk 3.1.16 → 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 +48 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -1
- 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)
|