@claritylabs/cl-sdk 0.14.0 → 0.14.2

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
@@ -2156,6 +2156,9 @@ function synthesizeDeductibles(doc) {
2156
2156
  }
2157
2157
  var PREMIUM_PATTERNS = ["premium", "totalPremium", "annualPremium", "policyPremium", "basePremium"];
2158
2158
  var TOTAL_COST_PATTERNS = ["totalCost", "totalDue", "totalAmount", "totalPolicyPremium"];
2159
+ function absorbNegative(value) {
2160
+ return value.replace(/^-\s*/, "").replace(/^\(\s*(.*?)\s*\)$/, "$1");
2161
+ }
2159
2162
  function promotePremium(doc) {
2160
2163
  const raw = doc;
2161
2164
  const fields = getDeclarationFields(doc);
@@ -2167,6 +2170,8 @@ function promotePremium(doc) {
2167
2170
  const totalCost = findFieldValue(fields, TOTAL_COST_PATTERNS);
2168
2171
  if (totalCost) raw.totalCost = totalCost;
2169
2172
  }
2173
+ if (typeof raw.premium === "string") raw.premium = absorbNegative(raw.premium);
2174
+ if (typeof raw.totalCost === "string") raw.totalCost = absorbNegative(raw.totalCost);
2170
2175
  }
2171
2176
  function promoteExtractedFields(doc) {
2172
2177
  promoteCarrierFields(doc);
@@ -2460,6 +2465,15 @@ function formatAddress(addr) {
2460
2465
  return parts.join(", ");
2461
2466
  }
2462
2467
  function chunkDocument(doc) {
2468
+ const ensureArray = (v) => Array.isArray(v) ? v : [];
2469
+ doc = {
2470
+ ...doc,
2471
+ taxesAndFees: ensureArray(doc.taxesAndFees),
2472
+ ratingBasis: ensureArray(doc.ratingBasis),
2473
+ claimsContacts: ensureArray(doc.claimsContacts),
2474
+ regulatoryContacts: ensureArray(doc.regulatoryContacts),
2475
+ thirdPartyAdministrators: ensureArray(doc.thirdPartyAdministrators)
2476
+ };
2463
2477
  const chunks = [];
2464
2478
  const docId = doc.id;
2465
2479
  function stringMetadata(entries) {