@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 CHANGED
@@ -500,7 +500,10 @@ async function safeGenerateObject(generateObject, params, options) {
500
500
  () => generateObject(strictParams),
501
501
  options?.log
502
502
  );
503
- return result;
503
+ return {
504
+ ...result,
505
+ object: params.schema.parse(sanitizeNulls(result.object))
506
+ };
504
507
  } catch (error) {
505
508
  lastError = error;
506
509
  options?.onError?.(error, attempt);
@@ -3342,6 +3345,10 @@ function inferPolicyTypes(nodes) {
3342
3345
  const add = (pattern, type) => {
3343
3346
  if (pattern.test(text) && !types.includes(type)) types.push(type);
3344
3347
  };
3348
+ 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");
3349
+ add(/\b(critical illness|critical illness insurance|covered critical illness|partial benefit payout)\b/i, "critical_illness");
3350
+ add(/\b(disability benefit|total disability|catastrophic disability|disability waiver|waiver of premium disability)\b/i, "disability");
3351
+ add(/\b(long[-\s]?term care|long term care conversion)\b/i, "long_term_care");
3345
3352
  add(/\b(cyber|network security|privacy liability|data breach)\b/i, "cyber");
3346
3353
  add(/\b(professional liability|errors?\s*&?\s*omissions|e&o)\b/i, "professional_liability");
3347
3354
  add(/\b(commercial general liability|general liability|cgl)\b/i, "general_liability");
@@ -3786,8 +3793,8 @@ function buildDeterministicOperationalProfile(params) {
3786
3793
  documentType: inferDocumentType(nodes),
3787
3794
  policyTypes: inferPolicyTypes(nodes),
3788
3795
  policyNumber: firstMatch(nodes, [
3789
- /\bpolicy\s*(?:number|no\.?|#)\s*:?\s*([A-Z0-9][A-Z0-9-]{4,})/i,
3790
- /\bpolicy\s*[:#]\s*([A-Z0-9][A-Z0-9-]{4,})/i
3796
+ /\bpolicy\s*(?:number|no\.?|#)\s*:?\s*([A-Z0-9][A-Z0-9,.-]{4,}[A-Z0-9])/i,
3797
+ /\bpolicy\s*[:#]\s*([A-Z0-9][A-Z0-9,.-]{4,}[A-Z0-9])/i
3791
3798
  ]),
3792
3799
  namedInsured: firstMatch(nodes, [
3793
3800
  /\b(?:named insured|insured name|insured)\s*:?\s*(.+?)(?=\s+(?:coverage|policy number|insurer|carrier|premium|effective|expiration)\b|[|;\n]|$)/i,
@@ -3796,6 +3803,8 @@ function buildDeterministicOperationalProfile(params) {
3796
3803
  insurer: firstMatch(nodes, [
3797
3804
  /\b(?:insurer|carrier|company|security)\s*:?\s*([^|;\n]{3,120})/i,
3798
3805
  /\bunderwritten by\s+([^|;\n]{3,120})/i
3806
+ ]) ?? firstMatch(nodes, [
3807
+ /\b(Manulife)\b/i
3799
3808
  ]),
3800
3809
  broker: firstMatch(nodes, [
3801
3810
  /\b(?:broker|producer|agent)\s*:?\s*([^|;\n]{3,120})/i
@@ -3864,29 +3873,41 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
3864
3873
  };
3865
3874
  const coverages = base.coverages.length > 0 ? base.coverages : Array.isArray(candidate.coverages) ? candidate.coverages.map((coverage) => {
3866
3875
  const record = coverage;
3876
+ const name = typeof record.name === "string" ? cleanValue(record.name) : void 0;
3877
+ const sourceNodeIds = keepIds(record.sourceNodeIds, validNodeIds);
3878
+ const sourceSpanIds = keepIds(record.sourceSpanIds, validSpanIds);
3867
3879
  const limits = Array.isArray(record.limits) ? record.limits.filter(
3868
3880
  (term) => Boolean(term) && typeof term === "object" && !Array.isArray(term)
3869
3881
  ).flatMap((term) => {
3870
3882
  const label = typeof term.label === "string" ? cleanValue(term.label) : void 0;
3871
3883
  const value = typeof term.value === "string" ? cleanValue(term.value) : void 0;
3872
- const sourceNodeIds = keepIds(term.sourceNodeIds, validNodeIds);
3873
- const sourceSpanIds = keepIds(term.sourceSpanIds, validSpanIds);
3874
- if (!label || !value || sourceNodeIds.length === 0 && sourceSpanIds.length === 0) return [];
3884
+ const sourceNodeIds2 = keepIds(term.sourceNodeIds, validNodeIds);
3885
+ const sourceSpanIds2 = keepIds(term.sourceSpanIds, validSpanIds);
3886
+ if (!label || !value || sourceNodeIds2.length === 0 && sourceSpanIds2.length === 0) return [];
3875
3887
  return [{
3876
3888
  kind: normalizeTermKind(term.kind, label, value),
3877
3889
  label,
3878
3890
  value,
3879
3891
  amount: typeof term.amount === "number" && Number.isFinite(term.amount) ? term.amount : void 0,
3880
3892
  appliesTo: typeof term.appliesTo === "string" ? term.appliesTo : void 0,
3881
- sourceNodeIds,
3882
- sourceSpanIds
3893
+ sourceNodeIds: sourceNodeIds2,
3894
+ sourceSpanIds: sourceSpanIds2
3883
3895
  }];
3884
3896
  }) : [];
3885
3897
  return {
3886
- ...coverage,
3898
+ name,
3899
+ coverageCode: typeof record.coverageCode === "string" ? cleanValue(record.coverageCode) : void 0,
3900
+ limit: typeof record.limit === "string" ? cleanValue(record.limit) : void 0,
3901
+ deductible: typeof record.deductible === "string" ? cleanValue(record.deductible) : void 0,
3902
+ premium: typeof record.premium === "string" ? cleanValue(record.premium) : void 0,
3903
+ retroactiveDate: typeof record.retroactiveDate === "string" ? cleanValue(record.retroactiveDate) : void 0,
3904
+ formNumber: typeof record.formNumber === "string" ? cleanValue(record.formNumber) : void 0,
3905
+ sectionRef: typeof record.sectionRef === "string" ? cleanValue(record.sectionRef) : void 0,
3906
+ coverageOrigin: record.coverageOrigin === "core" || record.coverageOrigin === "endorsement" ? record.coverageOrigin : void 0,
3907
+ endorsementNumber: typeof record.endorsementNumber === "string" ? cleanValue(record.endorsementNumber) : void 0,
3887
3908
  limits,
3888
- sourceNodeIds: keepIds(record.sourceNodeIds, validNodeIds),
3889
- sourceSpanIds: keepIds(record.sourceSpanIds, validSpanIds)
3909
+ sourceNodeIds,
3910
+ sourceSpanIds
3890
3911
  };
3891
3912
  }).filter((coverage) => coverage.name && (coverage.sourceNodeIds.length > 0 || coverage.sourceSpanIds.length > 0)) : base.coverages;
3892
3913
  return PolicyOperationalProfileSchema.parse({