@claritylabs/cl-sdk 3.0.27 → 3.0.29
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 +32 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -144,7 +144,10 @@ async function safeGenerateObject(generateObject, params, options) {
|
|
|
144
144
|
() => generateObject(strictParams),
|
|
145
145
|
options?.log
|
|
146
146
|
);
|
|
147
|
-
return
|
|
147
|
+
return {
|
|
148
|
+
...result,
|
|
149
|
+
object: params.schema.parse(sanitizeNulls(result.object))
|
|
150
|
+
};
|
|
148
151
|
} catch (error) {
|
|
149
152
|
lastError = error;
|
|
150
153
|
options?.onError?.(error, attempt);
|
|
@@ -2986,6 +2989,10 @@ function inferPolicyTypes(nodes) {
|
|
|
2986
2989
|
const add = (pattern, type) => {
|
|
2987
2990
|
if (pattern.test(text) && !types.includes(type)) types.push(type);
|
|
2988
2991
|
};
|
|
2992
|
+
add(/\b(life insurance|permanent life|term life|whole life|universal life|sun permanent life|sun par protector|manulife par|vitality\s*plus|death benefit)\b/i, "life");
|
|
2993
|
+
add(/\b(critical illness|critical illness insurance|covered critical illness|partial benefit payout)\b/i, "critical_illness");
|
|
2994
|
+
add(/\b(disability benefit|total disability|catastrophic disability|disability waiver|waiver of premium disability)\b/i, "disability");
|
|
2995
|
+
add(/\b(long[-\s]?term care|long term care conversion)\b/i, "long_term_care");
|
|
2989
2996
|
add(/\b(cyber|network security|privacy liability|data breach)\b/i, "cyber");
|
|
2990
2997
|
add(/\b(professional liability|errors?\s*&?\s*omissions|e&o)\b/i, "professional_liability");
|
|
2991
2998
|
add(/\b(commercial general liability|general liability|cgl)\b/i, "general_liability");
|
|
@@ -3430,8 +3437,8 @@ function buildDeterministicOperationalProfile(params) {
|
|
|
3430
3437
|
documentType: inferDocumentType(nodes),
|
|
3431
3438
|
policyTypes: inferPolicyTypes(nodes),
|
|
3432
3439
|
policyNumber: firstMatch(nodes, [
|
|
3433
|
-
/\bpolicy\s*(?:number|no\.?|#)\s*:?\s*([A-Z0-9][A-Z0-9
|
|
3434
|
-
/\bpolicy\s*[:#]\s*([A-Z0-9][A-Z0-9
|
|
3440
|
+
/\bpolicy\s*(?:number|no\.?|#)\s*:?\s*([A-Z0-9][A-Z0-9,.-]{4,}[A-Z0-9])/i,
|
|
3441
|
+
/\bpolicy\s*[:#]\s*([A-Z0-9][A-Z0-9,.-]{4,}[A-Z0-9])/i
|
|
3435
3442
|
]),
|
|
3436
3443
|
namedInsured: firstMatch(nodes, [
|
|
3437
3444
|
/\b(?:named insured|insured name|insured)\s*:?\s*(.+?)(?=\s+(?:coverage|policy number|insurer|carrier|premium|effective|expiration)\b|[|;\n]|$)/i,
|
|
@@ -3440,6 +3447,8 @@ function buildDeterministicOperationalProfile(params) {
|
|
|
3440
3447
|
insurer: firstMatch(nodes, [
|
|
3441
3448
|
/\b(?:insurer|carrier|company|security)\s*:?\s*([^|;\n]{3,120})/i,
|
|
3442
3449
|
/\bunderwritten by\s+([^|;\n]{3,120})/i
|
|
3450
|
+
]) ?? firstMatch(nodes, [
|
|
3451
|
+
/\b(Manulife)\b/i
|
|
3443
3452
|
]),
|
|
3444
3453
|
broker: firstMatch(nodes, [
|
|
3445
3454
|
/\b(?:broker|producer|agent)\s*:?\s*([^|;\n]{3,120})/i
|
|
@@ -3508,29 +3517,41 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
3508
3517
|
};
|
|
3509
3518
|
const coverages = base.coverages.length > 0 ? base.coverages : Array.isArray(candidate.coverages) ? candidate.coverages.map((coverage) => {
|
|
3510
3519
|
const record = coverage;
|
|
3520
|
+
const name = typeof record.name === "string" ? cleanValue(record.name) : void 0;
|
|
3521
|
+
const sourceNodeIds = keepIds(record.sourceNodeIds, validNodeIds);
|
|
3522
|
+
const sourceSpanIds = keepIds(record.sourceSpanIds, validSpanIds);
|
|
3511
3523
|
const limits = Array.isArray(record.limits) ? record.limits.filter(
|
|
3512
3524
|
(term) => Boolean(term) && typeof term === "object" && !Array.isArray(term)
|
|
3513
3525
|
).flatMap((term) => {
|
|
3514
3526
|
const label = typeof term.label === "string" ? cleanValue(term.label) : void 0;
|
|
3515
3527
|
const value = typeof term.value === "string" ? cleanValue(term.value) : void 0;
|
|
3516
|
-
const
|
|
3517
|
-
const
|
|
3518
|
-
if (!label || !value ||
|
|
3528
|
+
const sourceNodeIds2 = keepIds(term.sourceNodeIds, validNodeIds);
|
|
3529
|
+
const sourceSpanIds2 = keepIds(term.sourceSpanIds, validSpanIds);
|
|
3530
|
+
if (!label || !value || sourceNodeIds2.length === 0 && sourceSpanIds2.length === 0) return [];
|
|
3519
3531
|
return [{
|
|
3520
3532
|
kind: normalizeTermKind(term.kind, label, value),
|
|
3521
3533
|
label,
|
|
3522
3534
|
value,
|
|
3523
3535
|
amount: typeof term.amount === "number" && Number.isFinite(term.amount) ? term.amount : void 0,
|
|
3524
3536
|
appliesTo: typeof term.appliesTo === "string" ? term.appliesTo : void 0,
|
|
3525
|
-
sourceNodeIds,
|
|
3526
|
-
sourceSpanIds
|
|
3537
|
+
sourceNodeIds: sourceNodeIds2,
|
|
3538
|
+
sourceSpanIds: sourceSpanIds2
|
|
3527
3539
|
}];
|
|
3528
3540
|
}) : [];
|
|
3529
3541
|
return {
|
|
3530
|
-
|
|
3542
|
+
name,
|
|
3543
|
+
coverageCode: typeof record.coverageCode === "string" ? cleanValue(record.coverageCode) : void 0,
|
|
3544
|
+
limit: typeof record.limit === "string" ? cleanValue(record.limit) : void 0,
|
|
3545
|
+
deductible: typeof record.deductible === "string" ? cleanValue(record.deductible) : void 0,
|
|
3546
|
+
premium: typeof record.premium === "string" ? cleanValue(record.premium) : void 0,
|
|
3547
|
+
retroactiveDate: typeof record.retroactiveDate === "string" ? cleanValue(record.retroactiveDate) : void 0,
|
|
3548
|
+
formNumber: typeof record.formNumber === "string" ? cleanValue(record.formNumber) : void 0,
|
|
3549
|
+
sectionRef: typeof record.sectionRef === "string" ? cleanValue(record.sectionRef) : void 0,
|
|
3550
|
+
coverageOrigin: record.coverageOrigin === "core" || record.coverageOrigin === "endorsement" ? record.coverageOrigin : void 0,
|
|
3551
|
+
endorsementNumber: typeof record.endorsementNumber === "string" ? cleanValue(record.endorsementNumber) : void 0,
|
|
3531
3552
|
limits,
|
|
3532
|
-
sourceNodeIds
|
|
3533
|
-
sourceSpanIds
|
|
3553
|
+
sourceNodeIds,
|
|
3554
|
+
sourceSpanIds
|
|
3534
3555
|
};
|
|
3535
3556
|
}).filter((coverage) => coverage.name && (coverage.sourceNodeIds.length > 0 || coverage.sourceSpanIds.length > 0)) : base.coverages;
|
|
3536
3557
|
return PolicyOperationalProfileSchema.parse({
|