diff --git a/services/hometitle/coverage/base.css b/services/hometitle/coverage/base.css new file mode 100644 index 0000000..f418035 --- /dev/null +++ b/services/hometitle/coverage/base.css @@ -0,0 +1,224 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/services/hometitle/coverage/block-navigation.js b/services/hometitle/coverage/block-navigation.js new file mode 100644 index 0000000..530d1ed --- /dev/null +++ b/services/hometitle/coverage/block-navigation.js @@ -0,0 +1,87 @@ +/* eslint-disable */ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selector that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); + } + + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } + + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } + + makeCurrent(nextIndex); + } + + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); + } + + return function jump(event) { + if ( + document.getElementById('fileSearch') === document.activeElement && + document.activeElement != null + ) { + // if we're currently focused on the search input, we don't want to navigate + return; + } + + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); +window.addEventListener('keydown', jumpToCode); diff --git a/services/hometitle/coverage/change-detector.ts.html b/services/hometitle/coverage/change-detector.ts.html new file mode 100644 index 0000000..9fee0c4 --- /dev/null +++ b/services/hometitle/coverage/change-detector.ts.html @@ -0,0 +1,691 @@ + + + + + + Code coverage report for change-detector.ts + + + + + + + + + +
+
+

All files change-detector.ts

+
+ +
+ 98.83% + Statements + 85/86 +
+ + +
+ 91.07% + Branches + 51/56 +
+ + +
+ 100% + Functions + 11/11 +
+ + +
+ 98.73% + Lines + 78/79 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +11x +  +5x +  +  +  +  +  +5x +  +2x +2x +  +2x +2x +  +1x +1x +  +1x +1x +  +  +  +  +11x +  +  +  +5x +  +  +  +  +  +  +  +5x +5x +  +  +  +15x +  +15x +  +  +  +  +  +  +  +15x +  +15x +14x +14x +14x +  +  +10x +9x +9x +  +  +5x +  +  +  +15x +  +13x +13x +16x +  +6x +6x +  +3x +3x +  +3x +3x +3x +3x +3x +  +  +2x +2x +  +2x +  +  +  +13x +  +  +  +  +  +  +  +11x +11x +  +11x +  +  +  +  +  +  +  +  +11x +66x +66x +  +66x +11x +  +  +  +11x +11x +  +11x +11x +  +11x +11x +4x +7x +2x +5x +1x +4x +1x +  +  +11x +  +  +  +  +  +  +  +  +  +  +  +  +11x +  +11x +  +11x +77x +77x +77x +1x +  +  +  +  +  +  +  +  +11x +  +  +  +5x +5x +5x +5x +  +  +  + 
import {
+  PropertySnapshot,
+  ChangeDetectionResult,
+  ChangeType,
+  Severity,
+  PropertyChange,
+  DetectionConfig,
+  Address,
+} from './types';
+import { matchRecords } from './matcher.service';
+ 
+const DEFAULT_DETECTION_CONFIG: DetectionConfig = {
+  ownershipNameThreshold: 0.7,
+  deedDateSensitivity: 0.9,
+  taxAmountChangePercent: 15,
+};
+ 
+function classifyFieldChange(field: string, oldValue: unknown, newValue: unknown, config: DetectionConfig): PropertyChange {
+  let changeType: ChangeType;
+ 
+  switch (field) {
+    case 'ownerName':
+      changeType =
+        typeof oldValue === 'string' && typeof newValue === 'string'
+          ? isSignificantNameChange(oldValue, newValue, config)
+            ? 'ownership_transfer'
+            : 'metadata_change'
+          : 'ownership_transfer';
+      break;
+    case 'deedDate':
+      changeType = 'deed_change';
+      break;
+    case 'taxAmount':
+      changeType = 'tax_change';
+      break;
+    case 'lienCount':
+      changeType = (newValue as number) > (oldValue as number) ? 'lien_filing' : 'metadata_change';
+      break;
+    case 'taxId':
+      changeType = 'deed_change';
+      break;
+    default:
+      changeType = 'metadata_change';
+  }
+ 
+  return { field, oldValue, newValue, changeType };
+}
+ 
+function isSignificantNameChange(oldName: string, newName: string, config: DetectionConfig): boolean {
+  const dummyAddress: Address = {
+    streetNumber: '0',
+    streetName: 'dummy',
+    city: 'dummy',
+    state: 'XX',
+    zip: '00000',
+  };
+ 
+  const result = matchRecords(oldName, dummyAddress, newName, dummyAddress);
+  return result.nameScore < config.ownershipNameThreshold;
+}
+ 
+function determineSeverity(changes: PropertyChange[], config: DetectionConfig): Severity {
+  const severityOverrides = config.severityOverrides || {};
+ 
+  const typeToSeverity: Record<ChangeType, Severity> = {
+    ownership_transfer: severityOverrides['ownership_transfer'] || 'major',
+    deed_change: severityOverrides['deed_change'] || 'moderate',
+    lien_filing: severityOverrides['lien_filing'] || 'moderate',
+    tax_change: severityOverrides['tax_change'] || 'minor',
+    metadata_change: severityOverrides['metadata_change'] || 'minor',
+  };
+ 
+  const severityOrder: Severity[] = ['major', 'moderate', 'minor'];
+ 
+  for (const change of changes) {
+    const sev = typeToSeverity[change.changeType];
+    const idx = severityOrder.indexOf(sev);
+    if (idx === 0) return 'major';
+  }
+ 
+  for (const change of changes) {
+    const sev = typeToSeverity[change.changeType];
+    if (sev === 'moderate') return 'moderate';
+  }
+ 
+  return 'minor';
+}
+ 
+function computeChangeConfidence(changes: PropertyChange[], config: DetectionConfig): number {
+  if (changes.length === 0) return 0;
+ 
+  let totalConfidence = 0;
+  for (const change of changes) {
+    switch (change.changeType) {
+      case 'ownership_transfer':
+        totalConfidence += 0.95;
+        break;
+      case 'deed_change':
+        totalConfidence += config.deedDateSensitivity;
+        break;
+      case 'tax_change': {
+        const oldVal = change.oldValue as number;
+        const newVal = change.newValue as number;
+        const pctChange = oldVal ? Math.abs(newVal - oldVal) / oldVal * 100 : 100;
+        totalConfidence += pctChange >= config.taxAmountChangePercent ? 0.85 : 0.5;
+        break;
+      }
+      case 'lien_filing':
+        totalConfidence += 0.9;
+        break;
+      default:
+        totalConfidence += 0.4;
+    }
+  }
+ 
+  return Math.round((totalConfidence / changes.length) * 1000) / 1000;
+}
+ 
+export function detectChanges(
+  previous: PropertySnapshot,
+  current: PropertySnapshot,
+  config?: Partial<DetectionConfig>,
+): ChangeDetectionResult {
+  const effectiveConfig = { ...DEFAULT_DETECTION_CONFIG, ...config };
+  const changes: PropertyChange[] = [];
+ 
+  const fieldsToCompare: (keyof Omit<PropertySnapshot, 'id' | 'capturedAt' | 'propertyId'>)[] = [
+    'ownerName',
+    'deedDate',
+    'taxId',
+    'taxAmount',
+    'lienCount',
+    'propertyType',
+  ];
+ 
+  for (const field of fieldsToCompare) {
+    const oldValue = previous[field];
+    const newValue = current[field];
+ 
+    if (oldValue !== newValue) {
+      changes.push(classifyFieldChange(field, oldValue, newValue, effectiveConfig));
+    }
+  }
+ 
+  const addressChanges = detectAddressChanges(previous.address, current.address);
+  changes.push(...addressChanges);
+ 
+  const severity = determineSeverity(changes, effectiveConfig);
+  const confidence = computeChangeConfidence(changes, effectiveConfig);
+ 
+  let changeType: ChangeType = 'metadata_change';
+  if (changes.some(c => c.changeType === 'ownership_transfer')) {
+    changeType = 'ownership_transfer';
+  } else if (changes.some(c => c.changeType === 'deed_change')) {
+    changeType = 'deed_change';
+  } else if (changes.some(c => c.changeType === 'lien_filing')) {
+    changeType = 'lien_filing';
+  } else if (changes.some(c => c.changeType === 'tax_change')) {
+    changeType = 'tax_change';
+  }
+ 
+  return {
+    propertyId: previous.propertyId,
+    changeType,
+    severity,
+    confidence,
+    changes,
+    previousSnapshot: previous,
+    currentSnapshot: current,
+    detectedAt: new Date().toISOString(),
+  };
+}
+ 
+function detectAddressChanges(oldAddr: Address, newAddr: Address): PropertyChange[] {
+  const changes: PropertyChange[] = [];
+ 
+  const addressFields: (keyof Address)[] = ['streetNumber', 'streetName', 'streetType', 'unit', 'city', 'state', 'zip'];
+ 
+  for (const field of addressFields) {
+    const oldVal = oldAddr[field];
+    const newVal = newAddr[field];
+    if (oldVal !== newVal) {
+      changes.push({
+        field: `address.${field}`,
+        oldValue: oldVal,
+        newValue: newVal,
+        changeType: 'metadata_change',
+      });
+    }
+  }
+ 
+  return changes;
+}
+ 
+export function shouldTriggerAlert(result: ChangeDetectionResult, minSeverity: Severity = 'moderate'): boolean {
+  const severityOrder: Severity[] = ['minor', 'moderate', 'major'];
+  const resultIdx = severityOrder.indexOf(result.severity);
+  const minIdx = severityOrder.indexOf(minSeverity);
+  return resultIdx >= minIdx && result.confidence >= 0.7;
+}
+ 
+export { classifyFieldChange, determineSeverity, computeChangeConfidence };
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/services/hometitle/coverage/coverage-final.json b/services/hometitle/coverage/coverage-final.json new file mode 100644 index 0000000..de6d546 --- /dev/null +++ b/services/hometitle/coverage/coverage-final.json @@ -0,0 +1,5 @@ +{"/home/mike/code/ShieldAI/services/hometitle/src/change-detector.ts": {"path":"/home/mike/code/ShieldAI/services/hometitle/src/change-detector.ts","statementMap":{"0":{"start":{"line":12,"column":50},"end":{"line":16,"column":null}},"1":{"start":{"line":21,"column":2},"end":{"line":43,"column":null}},"2":{"start":{"line":23,"column":6},"end":{"line":28,"column":null}},"3":{"start":{"line":29,"column":6},"end":{"line":29,"column":null}},"4":{"start":{"line":31,"column":6},"end":{"line":31,"column":null}},"5":{"start":{"line":32,"column":6},"end":{"line":32,"column":null}},"6":{"start":{"line":34,"column":6},"end":{"line":34,"column":null}},"7":{"start":{"line":35,"column":6},"end":{"line":35,"column":null}},"8":{"start":{"line":37,"column":6},"end":{"line":37,"column":null}},"9":{"start":{"line":38,"column":6},"end":{"line":38,"column":null}},"10":{"start":{"line":40,"column":6},"end":{"line":40,"column":null}},"11":{"start":{"line":41,"column":6},"end":{"line":41,"column":null}},"12":{"start":{"line":43,"column":6},"end":{"line":43,"column":null}},"13":{"start":{"line":46,"column":2},"end":{"line":46,"column":null}},"14":{"start":{"line":50,"column":32},"end":{"line":56,"column":null}},"15":{"start":{"line":58,"column":8},"end":{"line":58,"column":75}},"16":{"start":{"line":59,"column":2},"end":{"line":59,"column":null}},"17":{"start":{"line":63,"column":28},"end":{"line":63,"column":58}},"18":{"start":{"line":65,"column":55},"end":{"line":71,"column":null}},"19":{"start":{"line":73,"column":36},"end":{"line":73,"column":null}},"20":{"start":{"line":75,"column":2},"end":{"line":78,"column":null}},"21":{"start":{"line":76,"column":16},"end":{"line":76,"column":null}},"22":{"start":{"line":77,"column":16},"end":{"line":77,"column":42}},"23":{"start":{"line":78,"column":4},"end":{"line":78,"column":null}},"24":{"start":{"line":78,"column":19},"end":{"line":78,"column":null}},"25":{"start":{"line":81,"column":2},"end":{"line":83,"column":null}},"26":{"start":{"line":82,"column":16},"end":{"line":82,"column":null}},"27":{"start":{"line":83,"column":4},"end":{"line":83,"column":null}},"28":{"start":{"line":83,"column":28},"end":{"line":83,"column":null}},"29":{"start":{"line":86,"column":2},"end":{"line":86,"column":null}},"30":{"start":{"line":90,"column":2},"end":{"line":90,"column":null}},"31":{"start":{"line":90,"column":28},"end":{"line":90,"column":null}},"32":{"start":{"line":92,"column":24},"end":{"line":92,"column":null}},"33":{"start":{"line":93,"column":2},"end":{"line":112,"column":null}},"34":{"start":{"line":94,"column":4},"end":{"line":112,"column":null}},"35":{"start":{"line":96,"column":8},"end":{"line":96,"column":null}},"36":{"start":{"line":97,"column":8},"end":{"line":97,"column":null}},"37":{"start":{"line":99,"column":8},"end":{"line":99,"column":null}},"38":{"start":{"line":100,"column":8},"end":{"line":100,"column":null}},"39":{"start":{"line":102,"column":23},"end":{"line":102,"column":null}},"40":{"start":{"line":103,"column":23},"end":{"line":103,"column":null}},"41":{"start":{"line":104,"column":26},"end":{"line":104,"column":null}},"42":{"start":{"line":105,"column":8},"end":{"line":105,"column":null}},"43":{"start":{"line":106,"column":8},"end":{"line":106,"column":null}},"44":{"start":{"line":109,"column":8},"end":{"line":109,"column":null}},"45":{"start":{"line":110,"column":8},"end":{"line":110,"column":null}},"46":{"start":{"line":112,"column":8},"end":{"line":112,"column":null}},"47":{"start":{"line":116,"column":2},"end":{"line":116,"column":null}},"48":{"start":{"line":124,"column":26},"end":{"line":124,"column":null}},"49":{"start":{"line":125,"column":36},"end":{"line":125,"column":38}},"50":{"start":{"line":127,"column":96},"end":{"line":134,"column":null}},"51":{"start":{"line":136,"column":2},"end":{"line":141,"column":null}},"52":{"start":{"line":137,"column":21},"end":{"line":137,"column":null}},"53":{"start":{"line":138,"column":21},"end":{"line":138,"column":null}},"54":{"start":{"line":140,"column":4},"end":{"line":141,"column":null}},"55":{"start":{"line":141,"column":6},"end":{"line":141,"column":null}},"56":{"start":{"line":145,"column":25},"end":{"line":145,"column":80}},"57":{"start":{"line":146,"column":2},"end":{"line":146,"column":null}},"58":{"start":{"line":148,"column":19},"end":{"line":148,"column":62}},"59":{"start":{"line":149,"column":21},"end":{"line":149,"column":70}},"60":{"start":{"line":151,"column":31},"end":{"line":151,"column":null}},"61":{"start":{"line":152,"column":2},"end":{"line":159,"column":null}},"62":{"start":{"line":152,"column":24},"end":{"line":152,"column":62}},"63":{"start":{"line":153,"column":4},"end":{"line":153,"column":null}},"64":{"start":{"line":154,"column":13},"end":{"line":159,"column":null}},"65":{"start":{"line":154,"column":31},"end":{"line":154,"column":62}},"66":{"start":{"line":155,"column":4},"end":{"line":155,"column":null}},"67":{"start":{"line":156,"column":13},"end":{"line":159,"column":null}},"68":{"start":{"line":156,"column":31},"end":{"line":156,"column":62}},"69":{"start":{"line":157,"column":4},"end":{"line":157,"column":null}},"70":{"start":{"line":158,"column":13},"end":{"line":159,"column":null}},"71":{"start":{"line":158,"column":31},"end":{"line":158,"column":61}},"72":{"start":{"line":159,"column":4},"end":{"line":159,"column":null}},"73":{"start":{"line":162,"column":2},"end":{"line":171,"column":null}},"74":{"start":{"line":175,"column":36},"end":{"line":175,"column":38}},"75":{"start":{"line":177,"column":43},"end":{"line":177,"column":null}},"76":{"start":{"line":179,"column":2},"end":{"line":188,"column":null}},"77":{"start":{"line":180,"column":19},"end":{"line":180,"column":null}},"78":{"start":{"line":181,"column":19},"end":{"line":181,"column":null}},"79":{"start":{"line":182,"column":4},"end":{"line":188,"column":null}},"80":{"start":{"line":183,"column":6},"end":{"line":188,"column":null}},"81":{"start":{"line":192,"column":2},"end":{"line":192,"column":null}},"82":{"start":{"line":196,"column":36},"end":{"line":196,"column":null}},"83":{"start":{"line":197,"column":20},"end":{"line":197,"column":58}},"84":{"start":{"line":198,"column":17},"end":{"line":198,"column":51}},"85":{"start":{"line":199,"column":2},"end":{"line":199,"column":null}}},"fnMap":{"0":{"name":"classifyFieldChange","decl":{"start":{"line":18,"column":9},"end":{"line":18,"column":29}},"loc":{"start":{"line":18,"column":123},"end":{"line":46,"column":null}},"line":18},"1":{"name":"isSignificantNameChange","decl":{"start":{"line":49,"column":9},"end":{"line":49,"column":33}},"loc":{"start":{"line":49,"column":101},"end":{"line":59,"column":null}},"line":49},"2":{"name":"determineSeverity","decl":{"start":{"line":62,"column":9},"end":{"line":62,"column":27}},"loc":{"start":{"line":62,"column":89},"end":{"line":86,"column":null}},"line":62},"3":{"name":"computeChangeConfidence","decl":{"start":{"line":89,"column":9},"end":{"line":89,"column":33}},"loc":{"start":{"line":89,"column":93},"end":{"line":116,"column":null}},"line":89},"4":{"name":"detectChanges","decl":{"start":{"line":119,"column":16},"end":{"line":119,"column":null}},"loc":{"start":{"line":123,"column":25},"end":{"line":171,"column":null}},"line":123},"5":{"name":"(anonymous_5)","decl":{"start":{"line":152,"column":14},"end":{"line":152,"column":19}},"loc":{"start":{"line":152,"column":24},"end":{"line":152,"column":62}},"line":152},"6":{"name":"(anonymous_6)","decl":{"start":{"line":154,"column":21},"end":{"line":154,"column":26}},"loc":{"start":{"line":154,"column":31},"end":{"line":154,"column":62}},"line":154},"7":{"name":"(anonymous_7)","decl":{"start":{"line":156,"column":21},"end":{"line":156,"column":26}},"loc":{"start":{"line":156,"column":31},"end":{"line":156,"column":62}},"line":156},"8":{"name":"(anonymous_8)","decl":{"start":{"line":158,"column":21},"end":{"line":158,"column":26}},"loc":{"start":{"line":158,"column":31},"end":{"line":158,"column":61}},"line":158},"9":{"name":"detectAddressChanges","decl":{"start":{"line":174,"column":9},"end":{"line":174,"column":30}},"loc":{"start":{"line":174,"column":84},"end":{"line":192,"column":null}},"line":174},"10":{"name":"shouldTriggerAlert","decl":{"start":{"line":195,"column":16},"end":{"line":195,"column":35}},"loc":{"start":{"line":195,"column":111},"end":{"line":199,"column":null}},"line":195}},"branchMap":{"0":{"loc":{"start":{"line":21,"column":2},"end":{"line":43,"column":null}},"type":"switch","locations":[{"start":{"line":22,"column":4},"end":{"line":29,"column":null}},{"start":{"line":30,"column":4},"end":{"line":32,"column":null}},{"start":{"line":33,"column":4},"end":{"line":35,"column":null}},{"start":{"line":36,"column":4},"end":{"line":38,"column":null}},{"start":{"line":39,"column":4},"end":{"line":41,"column":null}},{"start":{"line":42,"column":4},"end":{"line":43,"column":null}}],"line":21},"1":{"loc":{"start":{"line":24,"column":8},"end":{"line":28,"column":null}},"type":"cond-expr","locations":[{"start":{"line":25,"column":12},"end":{"line":27,"column":null}},{"start":{"line":28,"column":12},"end":{"line":28,"column":null}}],"line":24},"2":{"loc":{"start":{"line":24,"column":8},"end":{"line":24,"column":null}},"type":"binary-expr","locations":[{"start":{"line":24,"column":8},"end":{"line":24,"column":40}},{"start":{"line":24,"column":40},"end":{"line":24,"column":null}}],"line":24},"3":{"loc":{"start":{"line":25,"column":12},"end":{"line":27,"column":null}},"type":"cond-expr","locations":[{"start":{"line":26,"column":14},"end":{"line":26,"column":null}},{"start":{"line":27,"column":14},"end":{"line":27,"column":null}}],"line":25},"4":{"loc":{"start":{"line":37,"column":20},"end":{"line":37,"column":null}},"type":"cond-expr","locations":[{"start":{"line":37,"column":65},"end":{"line":37,"column":81}},{"start":{"line":37,"column":81},"end":{"line":37,"column":null}}],"line":37},"5":{"loc":{"start":{"line":63,"column":28},"end":{"line":63,"column":58}},"type":"binary-expr","locations":[{"start":{"line":63,"column":28},"end":{"line":63,"column":56}},{"start":{"line":63,"column":56},"end":{"line":63,"column":58}}],"line":63},"6":{"loc":{"start":{"line":66,"column":24},"end":{"line":66,"column":null}},"type":"binary-expr","locations":[{"start":{"line":66,"column":24},"end":{"line":66,"column":67}},{"start":{"line":66,"column":67},"end":{"line":66,"column":null}}],"line":66},"7":{"loc":{"start":{"line":67,"column":17},"end":{"line":67,"column":null}},"type":"binary-expr","locations":[{"start":{"line":67,"column":17},"end":{"line":67,"column":53}},{"start":{"line":67,"column":53},"end":{"line":67,"column":null}}],"line":67},"8":{"loc":{"start":{"line":68,"column":17},"end":{"line":68,"column":null}},"type":"binary-expr","locations":[{"start":{"line":68,"column":17},"end":{"line":68,"column":53}},{"start":{"line":68,"column":53},"end":{"line":68,"column":null}}],"line":68},"9":{"loc":{"start":{"line":69,"column":16},"end":{"line":69,"column":null}},"type":"binary-expr","locations":[{"start":{"line":69,"column":16},"end":{"line":69,"column":51}},{"start":{"line":69,"column":51},"end":{"line":69,"column":null}}],"line":69},"10":{"loc":{"start":{"line":70,"column":21},"end":{"line":70,"column":null}},"type":"binary-expr","locations":[{"start":{"line":70,"column":21},"end":{"line":70,"column":61}},{"start":{"line":70,"column":61},"end":{"line":70,"column":null}}],"line":70},"11":{"loc":{"start":{"line":78,"column":4},"end":{"line":78,"column":null}},"type":"if","locations":[{"start":{"line":78,"column":4},"end":{"line":78,"column":null}},{"start":{},"end":{}}],"line":78},"12":{"loc":{"start":{"line":83,"column":4},"end":{"line":83,"column":null}},"type":"if","locations":[{"start":{"line":83,"column":4},"end":{"line":83,"column":null}},{"start":{},"end":{}}],"line":83},"13":{"loc":{"start":{"line":90,"column":2},"end":{"line":90,"column":null}},"type":"if","locations":[{"start":{"line":90,"column":2},"end":{"line":90,"column":null}},{"start":{},"end":{}}],"line":90},"14":{"loc":{"start":{"line":94,"column":4},"end":{"line":112,"column":null}},"type":"switch","locations":[{"start":{"line":95,"column":6},"end":{"line":97,"column":null}},{"start":{"line":98,"column":6},"end":{"line":100,"column":null}},{"start":{"line":101,"column":6},"end":{"line":106,"column":null}},{"start":{"line":108,"column":6},"end":{"line":110,"column":null}},{"start":{"line":111,"column":6},"end":{"line":112,"column":null}}],"line":94},"15":{"loc":{"start":{"line":104,"column":26},"end":{"line":104,"column":null}},"type":"cond-expr","locations":[{"start":{"line":104,"column":35},"end":{"line":104,"column":78}},{"start":{"line":104,"column":78},"end":{"line":104,"column":null}}],"line":104},"16":{"loc":{"start":{"line":105,"column":27},"end":{"line":105,"column":null}},"type":"cond-expr","locations":[{"start":{"line":105,"column":72},"end":{"line":105,"column":79}},{"start":{"line":105,"column":79},"end":{"line":105,"column":null}}],"line":105},"17":{"loc":{"start":{"line":140,"column":4},"end":{"line":141,"column":null}},"type":"if","locations":[{"start":{"line":140,"column":4},"end":{"line":141,"column":null}},{"start":{},"end":{}}],"line":140},"18":{"loc":{"start":{"line":152,"column":2},"end":{"line":159,"column":null}},"type":"if","locations":[{"start":{"line":152,"column":2},"end":{"line":159,"column":null}},{"start":{"line":154,"column":13},"end":{"line":159,"column":null}}],"line":152},"19":{"loc":{"start":{"line":154,"column":13},"end":{"line":159,"column":null}},"type":"if","locations":[{"start":{"line":154,"column":13},"end":{"line":159,"column":null}},{"start":{"line":156,"column":13},"end":{"line":159,"column":null}}],"line":154},"20":{"loc":{"start":{"line":156,"column":13},"end":{"line":159,"column":null}},"type":"if","locations":[{"start":{"line":156,"column":13},"end":{"line":159,"column":null}},{"start":{"line":158,"column":13},"end":{"line":159,"column":null}}],"line":156},"21":{"loc":{"start":{"line":158,"column":13},"end":{"line":159,"column":null}},"type":"if","locations":[{"start":{"line":158,"column":13},"end":{"line":159,"column":null}},{"start":{},"end":{}}],"line":158},"22":{"loc":{"start":{"line":182,"column":4},"end":{"line":188,"column":null}},"type":"if","locations":[{"start":{"line":182,"column":4},"end":{"line":188,"column":null}},{"start":{},"end":{}}],"line":182},"23":{"loc":{"start":{"line":195,"column":66},"end":{"line":195,"column":111}},"type":"default-arg","locations":[{"start":{"line":195,"column":90},"end":{"line":195,"column":111}}],"line":195},"24":{"loc":{"start":{"line":199,"column":9},"end":{"line":199,"column":null}},"type":"binary-expr","locations":[{"start":{"line":199,"column":9},"end":{"line":199,"column":32}},{"start":{"line":199,"column":32},"end":{"line":199,"column":null}}],"line":199}},"s":{"0":1,"1":11,"2":5,"3":5,"4":2,"5":2,"6":2,"7":2,"8":1,"9":1,"10":1,"11":1,"12":0,"13":11,"14":5,"15":5,"16":5,"17":15,"18":15,"19":15,"20":15,"21":14,"22":14,"23":14,"24":5,"25":10,"26":9,"27":9,"28":5,"29":5,"30":15,"31":2,"32":13,"33":13,"34":16,"35":6,"36":6,"37":3,"38":3,"39":3,"40":3,"41":3,"42":3,"43":3,"44":2,"45":2,"46":2,"47":13,"48":11,"49":11,"50":11,"51":11,"52":66,"53":66,"54":66,"55":11,"56":11,"57":11,"58":11,"59":11,"60":11,"61":11,"62":10,"63":4,"64":7,"65":6,"66":2,"67":5,"68":4,"69":1,"70":4,"71":3,"72":1,"73":11,"74":11,"75":11,"76":11,"77":77,"78":77,"79":77,"80":1,"81":11,"82":5,"83":5,"84":5,"85":5},"f":{"0":11,"1":5,"2":15,"3":15,"4":11,"5":10,"6":6,"7":4,"8":3,"9":11,"10":5},"b":{"0":[5,2,2,1,1,0],"1":[5,0],"2":[5,5],"3":[4,1],"4":[1,0],"5":[15,14],"6":[15,15],"7":[15,15],"8":[15,15],"9":[15,14],"10":[15,15],"11":[5,9],"12":[5,4],"13":[2,13],"14":[6,3,3,2,2],"15":[3,0],"16":[3,0],"17":[11,55],"18":[4,7],"19":[2,5],"20":[1,4],"21":[1,3],"22":[1,76],"23":[5],"24":[5,4]},"meta":{"lastBranch":25,"lastFunction":11,"lastStatement":86,"seen":{"s:12:50:16:Infinity":0,"f:18:9:18:29":0,"b:22:4:29:Infinity:30:4:32:Infinity:33:4:35:Infinity:36:4:38:Infinity:39:4:41:Infinity:42:4:43:Infinity":0,"s:21:2:43:Infinity":1,"s:23:6:28:Infinity":2,"b:25:12:27:Infinity:28:12:28:Infinity":1,"b:24:8:24:40:24:40:24:Infinity":2,"b:26:14:26:Infinity:27:14:27:Infinity":3,"s:29:6:29:Infinity":3,"s:31:6:31:Infinity":4,"s:32:6:32:Infinity":5,"s:34:6:34:Infinity":6,"s:35:6:35:Infinity":7,"s:37:6:37:Infinity":8,"b:37:65:37:81:37:81:37:Infinity":4,"s:38:6:38:Infinity":9,"s:40:6:40:Infinity":10,"s:41:6:41:Infinity":11,"s:43:6:43:Infinity":12,"s:46:2:46:Infinity":13,"f:49:9:49:33":1,"s:50:32:56:Infinity":14,"s:58:8:58:75":15,"s:59:2:59:Infinity":16,"f:62:9:62:27":2,"s:63:28:63:58":17,"b:63:28:63:56:63:56:63:58":5,"s:65:55:71:Infinity":18,"b:66:24:66:67:66:67:66:Infinity":6,"b:67:17:67:53:67:53:67:Infinity":7,"b:68:17:68:53:68:53:68:Infinity":8,"b:69:16:69:51:69:51:69:Infinity":9,"b:70:21:70:61:70:61:70:Infinity":10,"s:73:36:73:Infinity":19,"s:75:2:78:Infinity":20,"s:76:16:76:Infinity":21,"s:77:16:77:42":22,"b:78:4:78:Infinity:undefined:undefined:undefined:undefined":11,"s:78:4:78:Infinity":23,"s:78:19:78:Infinity":24,"s:81:2:83:Infinity":25,"s:82:16:82:Infinity":26,"b:83:4:83:Infinity:undefined:undefined:undefined:undefined":12,"s:83:4:83:Infinity":27,"s:83:28:83:Infinity":28,"s:86:2:86:Infinity":29,"f:89:9:89:33":3,"b:90:2:90:Infinity:undefined:undefined:undefined:undefined":13,"s:90:2:90:Infinity":30,"s:90:28:90:Infinity":31,"s:92:24:92:Infinity":32,"s:93:2:112:Infinity":33,"b:95:6:97:Infinity:98:6:100:Infinity:101:6:106:Infinity:108:6:110:Infinity:111:6:112:Infinity":14,"s:94:4:112:Infinity":34,"s:96:8:96:Infinity":35,"s:97:8:97:Infinity":36,"s:99:8:99:Infinity":37,"s:100:8:100:Infinity":38,"s:102:23:102:Infinity":39,"s:103:23:103:Infinity":40,"s:104:26:104:Infinity":41,"b:104:35:104:78:104:78:104:Infinity":15,"s:105:8:105:Infinity":42,"b:105:72:105:79:105:79:105:Infinity":16,"s:106:8:106:Infinity":43,"s:109:8:109:Infinity":44,"s:110:8:110:Infinity":45,"s:112:8:112:Infinity":46,"s:116:2:116:Infinity":47,"f:119:16:119:Infinity":4,"s:124:26:124:Infinity":48,"s:125:36:125:38":49,"s:127:96:134:Infinity":50,"s:136:2:141:Infinity":51,"s:137:21:137:Infinity":52,"s:138:21:138:Infinity":53,"b:140:4:141:Infinity:undefined:undefined:undefined:undefined":17,"s:140:4:141:Infinity":54,"s:141:6:141:Infinity":55,"s:145:25:145:80":56,"s:146:2:146:Infinity":57,"s:148:19:148:62":58,"s:149:21:149:70":59,"s:151:31:151:Infinity":60,"b:152:2:159:Infinity:154:13:159:Infinity":18,"s:152:2:159:Infinity":61,"f:152:14:152:19":5,"s:152:24:152:62":62,"s:153:4:153:Infinity":63,"b:154:13:159:Infinity:156:13:159:Infinity":19,"s:154:13:159:Infinity":64,"f:154:21:154:26":6,"s:154:31:154:62":65,"s:155:4:155:Infinity":66,"b:156:13:159:Infinity:158:13:159:Infinity":20,"s:156:13:159:Infinity":67,"f:156:21:156:26":7,"s:156:31:156:62":68,"s:157:4:157:Infinity":69,"b:158:13:159:Infinity:undefined:undefined:undefined:undefined":21,"s:158:13:159:Infinity":70,"f:158:21:158:26":8,"s:158:31:158:61":71,"s:159:4:159:Infinity":72,"s:162:2:171:Infinity":73,"f:174:9:174:30":9,"s:175:36:175:38":74,"s:177:43:177:Infinity":75,"s:179:2:188:Infinity":76,"s:180:19:180:Infinity":77,"s:181:19:181:Infinity":78,"b:182:4:188:Infinity:undefined:undefined:undefined:undefined":22,"s:182:4:188:Infinity":79,"s:183:6:188:Infinity":80,"s:192:2:192:Infinity":81,"f:195:16:195:35":10,"b:195:90:195:111":23,"s:196:36:196:Infinity":82,"s:197:20:197:58":83,"s:198:17:198:51":84,"s:199:2:199:Infinity":85,"b:199:9:199:32:199:32:199:Infinity":24}}} +,"/home/mike/code/ShieldAI/services/hometitle/src/index.ts": {"path":"/home/mike/code/ShieldAI/services/hometitle/src/index.ts","statementMap":{},"fnMap":{},"branchMap":{},"s":{},"f":{},"b":{},"meta":{"lastBranch":0,"lastFunction":0,"lastStatement":0,"seen":{}}} +,"/home/mike/code/ShieldAI/services/hometitle/src/matcher.service.ts": {"path":"/home/mike/code/ShieldAI/services/hometitle/src/matcher.service.ts","statementMap":{"0":{"start":{"line":11,"column":39},"end":{"line":16,"column":null}},"1":{"start":{"line":18,"column":24},"end":{"line":21,"column":2}},"2":{"start":{"line":23,"column":24},"end":{"line":26,"column":2}},"3":{"start":{"line":28,"column":48},"end":{"line":44,"column":null}},"4":{"start":{"line":46,"column":77},"end":{"line":51,"column":null}},"5":{"start":{"line":54,"column":29},"end":{"line":55,"column":null}},"6":{"start":{"line":55,"column":4},"end":{"line":55,"column":83}},"7":{"start":{"line":55,"column":52},"end":{"line":55,"column":83}},"8":{"start":{"line":58,"column":2},"end":{"line":65,"column":null}},"9":{"start":{"line":58,"column":15},"end":{"line":58,"column":18}},"10":{"start":{"line":59,"column":4},"end":{"line":65,"column":null}},"11":{"start":{"line":59,"column":17},"end":{"line":59,"column":20}},"12":{"start":{"line":60,"column":19},"end":{"line":60,"column":null}},"13":{"start":{"line":61,"column":6},"end":{"line":65,"column":null}},"14":{"start":{"line":69,"column":2},"end":{"line":69,"column":null}},"15":{"start":{"line":73,"column":2},"end":{"line":73,"column":null}},"16":{"start":{"line":73,"column":20},"end":{"line":73,"column":null}},"17":{"start":{"line":74,"column":2},"end":{"line":74,"column":null}},"18":{"start":{"line":78,"column":2},"end":{"line":83,"column":null}},"19":{"start":{"line":87,"column":16},"end":{"line":87,"column":37}},"20":{"start":{"line":88,"column":16},"end":{"line":88,"column":48}},"21":{"start":{"line":90,"column":18},"end":{"line":90,"column":null}},"22":{"start":{"line":91,"column":17},"end":{"line":91,"column":null}},"23":{"start":{"line":92,"column":19},"end":{"line":92,"column":null}},"24":{"start":{"line":93,"column":29},"end":{"line":93,"column":31}},"25":{"start":{"line":95,"column":2},"end":{"line":95,"column":null}},"26":{"start":{"line":95,"column":26},"end":{"line":95,"column":null}},"27":{"start":{"line":97,"column":17},"end":{"line":97,"column":null}},"28":{"start":{"line":98,"column":2},"end":{"line":99,"column":null}},"29":{"start":{"line":99,"column":4},"end":{"line":99,"column":null}},"30":{"start":{"line":102,"column":15},"end":{"line":102,"column":null}},"31":{"start":{"line":103,"column":2},"end":{"line":104,"column":null}},"32":{"start":{"line":104,"column":4},"end":{"line":104,"column":null}},"33":{"start":{"line":107,"column":20},"end":{"line":107,"column":49}},"34":{"start":{"line":109,"column":2},"end":{"line":117,"column":null}},"35":{"start":{"line":110,"column":4},"end":{"line":110,"column":null}},"36":{"start":{"line":111,"column":13},"end":{"line":117,"column":null}},"37":{"start":{"line":112,"column":4},"end":{"line":112,"column":null}},"38":{"start":{"line":113,"column":4},"end":{"line":113,"column":null}},"39":{"start":{"line":115,"column":4},"end":{"line":115,"column":null}},"40":{"start":{"line":116,"column":4},"end":{"line":116,"column":null}},"41":{"start":{"line":117,"column":4},"end":{"line":117,"column":null}},"42":{"start":{"line":120,"column":2},"end":{"line":121,"column":null}},"43":{"start":{"line":121,"column":4},"end":{"line":121,"column":null}},"44":{"start":{"line":123,"column":2},"end":{"line":126,"column":null}},"45":{"start":{"line":124,"column":24},"end":{"line":124,"column":45}},"46":{"start":{"line":125,"column":4},"end":{"line":126,"column":null}},"47":{"start":{"line":126,"column":6},"end":{"line":126,"column":null}},"48":{"start":{"line":126,"column":27},"end":{"line":126,"column":null}},"49":{"start":{"line":130,"column":2},"end":{"line":130,"column":null}},"50":{"start":{"line":134,"column":16},"end":{"line":134,"column":37}},"51":{"start":{"line":135,"column":2},"end":{"line":135,"column":null}},"52":{"start":{"line":139,"column":16},"end":{"line":147,"column":19}},"53":{"start":{"line":148,"column":2},"end":{"line":148,"column":null}},"54":{"start":{"line":152,"column":17},"end":{"line":152,"column":null}},"55":{"start":{"line":153,"column":22},"end":{"line":153,"column":36}},"56":{"start":{"line":154,"column":22},"end":{"line":154,"column":36}},"57":{"start":{"line":156,"column":2},"end":{"line":156,"column":null}},"58":{"start":{"line":156,"column":36},"end":{"line":156,"column":null}},"59":{"start":{"line":157,"column":2},"end":{"line":157,"column":null}},"60":{"start":{"line":157,"column":36},"end":{"line":157,"column":null}},"61":{"start":{"line":159,"column":2},"end":{"line":159,"column":null}},"62":{"start":{"line":159,"column":35},"end":{"line":159,"column":null}},"63":{"start":{"line":161,"column":15},"end":{"line":161,"column":60}},"64":{"start":{"line":162,"column":17},"end":{"line":162,"column":65}},"65":{"start":{"line":163,"column":16},"end":{"line":163,"column":45}},"66":{"start":{"line":165,"column":2},"end":{"line":165,"column":null}},"67":{"start":{"line":169,"column":12},"end":{"line":169,"column":null}},"68":{"start":{"line":170,"column":8},"end":{"line":170,"column":null}},"69":{"start":{"line":171,"column":8},"end":{"line":171,"column":null}},"70":{"start":{"line":173,"column":4},"end":{"line":177,"column":24}},"71":{"start":{"line":178,"column":12},"end":{"line":178,"column":58}},"72":{"start":{"line":179,"column":2},"end":{"line":179,"column":null}},"73":{"start":{"line":183,"column":21},"end":{"line":183,"column":null}},"74":{"start":{"line":184,"column":20},"end":{"line":184,"column":null}},"75":{"start":{"line":185,"column":22},"end":{"line":185,"column":null}},"76":{"start":{"line":187,"column":26},"end":{"line":187,"column":null}},"77":{"start":{"line":188,"column":2},"end":{"line":196,"column":null}},"78":{"start":{"line":189,"column":25},"end":{"line":189,"column":76}},"79":{"start":{"line":189,"column":59},"end":{"line":189,"column":74}},"80":{"start":{"line":190,"column":25},"end":{"line":190,"column":76}},"81":{"start":{"line":190,"column":59},"end":{"line":190,"column":74}},"82":{"start":{"line":191,"column":18},"end":{"line":191,"column":null}},"83":{"start":{"line":192,"column":4},"end":{"line":193,"column":null}},"84":{"start":{"line":193,"column":6},"end":{"line":193,"column":null}},"85":{"start":{"line":193,"column":34},"end":{"line":193,"column":null}},"86":{"start":{"line":195,"column":18},"end":{"line":195,"column":64}},"87":{"start":{"line":196,"column":4},"end":{"line":196,"column":null}},"88":{"start":{"line":199,"column":20},"end":{"line":199,"column":null}},"89":{"start":{"line":200,"column":2},"end":{"line":200,"column":null}},"90":{"start":{"line":204,"column":22},"end":{"line":204,"column":null}},"91":{"start":{"line":205,"column":22},"end":{"line":205,"column":null}},"92":{"start":{"line":206,"column":20},"end":{"line":209,"column":null}},"93":{"start":{"line":210,"column":20},"end":{"line":210,"column":null}},"94":{"start":{"line":211,"column":20},"end":{"line":211,"column":null}},"95":{"start":{"line":212,"column":21},"end":{"line":212,"column":null}},"96":{"start":{"line":213,"column":19},"end":{"line":213,"column":null}},"97":{"start":{"line":216,"column":17},"end":{"line":216,"column":null}},"98":{"start":{"line":218,"column":2},"end":{"line":221,"column":null}},"99":{"start":{"line":219,"column":4},"end":{"line":219,"column":null}},"100":{"start":{"line":220,"column":20},"end":{"line":220,"column":null}},"101":{"start":{"line":221,"column":4},"end":{"line":221,"column":null}},"102":{"start":{"line":225,"column":5},"end":{"line":232,"column":null}},"103":{"start":{"line":234,"column":2},"end":{"line":234,"column":null}},"104":{"start":{"line":244,"column":26},"end":{"line":244,"column":null}},"105":{"start":{"line":246,"column":18},"end":{"line":246,"column":34}},"106":{"start":{"line":247,"column":18},"end":{"line":247,"column":34}},"107":{"start":{"line":249,"column":20},"end":{"line":249,"column":54}},"108":{"start":{"line":251,"column":53},"end":{"line":251,"column":109}},"109":{"start":{"line":253,"column":28},"end":{"line":253,"column":null}},"110":{"start":{"line":255,"column":21},"end":{"line":255,"column":76}},"111":{"start":{"line":256,"column":20},"end":{"line":256,"column":73}},"112":{"start":{"line":257,"column":22},"end":{"line":257,"column":79}},"113":{"start":{"line":258,"column":22},"end":{"line":258,"column":85}},"114":{"start":{"line":259,"column":22},"end":{"line":259,"column":98}},"115":{"start":{"line":260,"column":20},"end":{"line":262,"column":null}},"116":{"start":{"line":264,"column":20},"end":{"line":264,"column":79}},"117":{"start":{"line":265,"column":20},"end":{"line":265,"column":67}},"118":{"start":{"line":266,"column":21},"end":{"line":266,"column":70}},"119":{"start":{"line":267,"column":19},"end":{"line":267,"column":64}},"120":{"start":{"line":269,"column":22},"end":{"line":269,"column":48}},"121":{"start":{"line":270,"column":22},"end":{"line":270,"column":48}},"122":{"start":{"line":272,"column":15},"end":{"line":274,"column":null}},"123":{"start":{"line":277,"column":32},"end":{"line":294,"column":null}},"124":{"start":{"line":296,"column":2},"end":{"line":302,"column":null}},"125":{"start":{"line":306,"column":2},"end":{"line":306,"column":null}}},"fnMap":{"0":{"name":"levenshteinDistance","decl":{"start":{"line":53,"column":9},"end":{"line":53,"column":29}},"loc":{"start":{"line":53,"column":59},"end":{"line":69,"column":null}},"line":53},"1":{"name":"(anonymous_1)","decl":{"start":{"line":54,"column":64},"end":{"line":54,"column":67}},"loc":{"start":{"line":55,"column":4},"end":{"line":55,"column":83}},"line":55},"2":{"name":"(anonymous_2)","decl":{"start":{"line":55,"column":39},"end":{"line":55,"column":42}},"loc":{"start":{"line":55,"column":52},"end":{"line":55,"column":83}},"line":55},"3":{"name":"similarityScore","decl":{"start":{"line":72,"column":9},"end":{"line":72,"column":25}},"loc":{"start":{"line":72,"column":67},"end":{"line":74,"column":null}},"line":72},"4":{"name":"normalizeString","decl":{"start":{"line":77,"column":9},"end":{"line":77,"column":25}},"loc":{"start":{"line":77,"column":46},"end":{"line":83,"column":null}},"line":77},"5":{"name":"parseName","decl":{"start":{"line":86,"column":9},"end":{"line":86,"column":19}},"loc":{"start":{"line":86,"column":51},"end":{"line":130,"column":null}},"line":86},"6":{"name":"normalizeStreetType","decl":{"start":{"line":133,"column":9},"end":{"line":133,"column":29}},"loc":{"start":{"line":133,"column":51},"end":{"line":135,"column":null}},"line":133},"7":{"name":"normalizeAddress","decl":{"start":{"line":138,"column":9},"end":{"line":138,"column":26}},"loc":{"start":{"line":138,"column":49},"end":{"line":148,"column":null}},"line":138},"8":{"name":"computeFieldMatch","decl":{"start":{"line":151,"column":9},"end":{"line":151,"column":27}},"loc":{"start":{"line":151,"column":108},"end":{"line":165,"column":null}},"line":151},"9":{"name":"haversineDistance","decl":{"start":{"line":168,"column":9},"end":{"line":168,"column":27}},"loc":{"start":{"line":168,"column":91},"end":{"line":179,"column":null}},"line":168},"10":{"name":"computeNameScore","decl":{"start":{"line":182,"column":9},"end":{"line":182,"column":26}},"loc":{"start":{"line":182,"column":88},"end":{"line":200,"column":null}},"line":182},"11":{"name":"(anonymous_11)","decl":{"start":{"line":189,"column":50},"end":{"line":189,"column":54}},"loc":{"start":{"line":189,"column":59},"end":{"line":189,"column":74}},"line":189},"12":{"name":"(anonymous_12)","decl":{"start":{"line":190,"column":50},"end":{"line":190,"column":54}},"loc":{"start":{"line":190,"column":59},"end":{"line":190,"column":74}},"line":190},"13":{"name":"computeAddressScore","decl":{"start":{"line":203,"column":9},"end":{"line":203,"column":29}},"loc":{"start":{"line":203,"column":132},"end":{"line":234,"column":null}},"line":203},"14":{"name":"matchRecords","decl":{"start":{"line":237,"column":16},"end":{"line":237,"column":null}},"loc":{"start":{"line":243,"column":15},"end":{"line":302,"column":null}},"line":243},"15":{"name":"getConfigForPropertyType","decl":{"start":{"line":305,"column":16},"end":{"line":305,"column":41}},"loc":{"start":{"line":305,"column":77},"end":{"line":306,"column":null}},"line":305}},"branchMap":{"0":{"loc":{"start":{"line":55,"column":52},"end":{"line":55,"column":83}},"type":"cond-expr","locations":[{"start":{"line":55,"column":62},"end":{"line":55,"column":66}},{"start":{"line":55,"column":66},"end":{"line":55,"column":83}}],"line":55},"1":{"loc":{"start":{"line":55,"column":66},"end":{"line":55,"column":83}},"type":"cond-expr","locations":[{"start":{"line":55,"column":76},"end":{"line":55,"column":80}},{"start":{"line":55,"column":80},"end":{"line":55,"column":83}}],"line":55},"2":{"loc":{"start":{"line":60,"column":19},"end":{"line":60,"column":null}},"type":"cond-expr","locations":[{"start":{"line":60,"column":43},"end":{"line":60,"column":47}},{"start":{"line":60,"column":47},"end":{"line":60,"column":null}}],"line":60},"3":{"loc":{"start":{"line":73,"column":2},"end":{"line":73,"column":null}},"type":"if","locations":[{"start":{"line":73,"column":2},"end":{"line":73,"column":null}},{"start":{},"end":{}}],"line":73},"4":{"loc":{"start":{"line":95,"column":2},"end":{"line":95,"column":null}},"type":"if","locations":[{"start":{"line":95,"column":2},"end":{"line":95,"column":null}},{"start":{},"end":{}}],"line":95},"5":{"loc":{"start":{"line":98,"column":9},"end":{"line":98,"column":72}},"type":"binary-expr","locations":[{"start":{"line":98,"column":9},"end":{"line":98,"column":36}},{"start":{"line":98,"column":36},"end":{"line":98,"column":72}}],"line":98},"6":{"loc":{"start":{"line":103,"column":9},"end":{"line":103,"column":72}},"type":"binary-expr","locations":[{"start":{"line":103,"column":9},"end":{"line":103,"column":34}},{"start":{"line":103,"column":34},"end":{"line":103,"column":72}}],"line":103},"7":{"loc":{"start":{"line":109,"column":2},"end":{"line":117,"column":null}},"type":"if","locations":[{"start":{"line":109,"column":2},"end":{"line":117,"column":null}},{"start":{"line":111,"column":13},"end":{"line":117,"column":null}}],"line":109},"8":{"loc":{"start":{"line":111,"column":13},"end":{"line":117,"column":null}},"type":"if","locations":[{"start":{"line":111,"column":13},"end":{"line":117,"column":null}},{"start":{"line":114,"column":9},"end":{"line":117,"column":null}}],"line":111},"9":{"loc":{"start":{"line":120,"column":2},"end":{"line":121,"column":null}},"type":"if","locations":[{"start":{"line":120,"column":2},"end":{"line":121,"column":null}},{"start":{},"end":{}}],"line":120},"10":{"loc":{"start":{"line":123,"column":2},"end":{"line":126,"column":null}},"type":"if","locations":[{"start":{"line":123,"column":2},"end":{"line":126,"column":null}},{"start":{},"end":{}}],"line":123},"11":{"loc":{"start":{"line":126,"column":6},"end":{"line":126,"column":null}},"type":"if","locations":[{"start":{"line":126,"column":6},"end":{"line":126,"column":null}},{"start":{},"end":{}}],"line":126},"12":{"loc":{"start":{"line":135,"column":9},"end":{"line":135,"column":null}},"type":"binary-expr","locations":[{"start":{"line":135,"column":9},"end":{"line":135,"column":35}},{"start":{"line":135,"column":35},"end":{"line":135,"column":null}}],"line":135},"13":{"loc":{"start":{"line":142,"column":4},"end":{"line":142,"column":null}},"type":"cond-expr","locations":[{"start":{"line":142,"column":22},"end":{"line":142,"column":58}},{"start":{"line":142,"column":61},"end":{"line":142,"column":null}}],"line":142},"14":{"loc":{"start":{"line":143,"column":4},"end":{"line":143,"column":null}},"type":"cond-expr","locations":[{"start":{"line":143,"column":16},"end":{"line":143,"column":42}},{"start":{"line":143,"column":45},"end":{"line":143,"column":null}}],"line":143},"15":{"loc":{"start":{"line":152,"column":17},"end":{"line":152,"column":null}},"type":"binary-expr","locations":[{"start":{"line":152,"column":17},"end":{"line":152,"column":32}},{"start":{"line":152,"column":32},"end":{"line":152,"column":null}}],"line":152},"16":{"loc":{"start":{"line":156,"column":2},"end":{"line":156,"column":null}},"type":"if","locations":[{"start":{"line":156,"column":2},"end":{"line":156,"column":null}},{"start":{},"end":{}}],"line":156},"17":{"loc":{"start":{"line":156,"column":6},"end":{"line":156,"column":36}},"type":"binary-expr","locations":[{"start":{"line":156,"column":6},"end":{"line":156,"column":22}},{"start":{"line":156,"column":22},"end":{"line":156,"column":36}}],"line":156},"18":{"loc":{"start":{"line":157,"column":2},"end":{"line":157,"column":null}},"type":"if","locations":[{"start":{"line":157,"column":2},"end":{"line":157,"column":null}},{"start":{},"end":{}}],"line":157},"19":{"loc":{"start":{"line":157,"column":6},"end":{"line":157,"column":36}},"type":"binary-expr","locations":[{"start":{"line":157,"column":6},"end":{"line":157,"column":22}},{"start":{"line":157,"column":22},"end":{"line":157,"column":36}}],"line":157},"20":{"loc":{"start":{"line":159,"column":2},"end":{"line":159,"column":null}},"type":"if","locations":[{"start":{"line":159,"column":2},"end":{"line":159,"column":null}},{"start":{},"end":{}}],"line":159},"21":{"loc":{"start":{"line":188,"column":2},"end":{"line":196,"column":null}},"type":"if","locations":[{"start":{"line":188,"column":2},"end":{"line":196,"column":null}},{"start":{},"end":{}}],"line":188},"22":{"loc":{"start":{"line":188,"column":6},"end":{"line":188,"column":66}},"type":"binary-expr","locations":[{"start":{"line":188,"column":6},"end":{"line":188,"column":37}},{"start":{"line":188,"column":37},"end":{"line":188,"column":66}}],"line":188},"23":{"loc":{"start":{"line":193,"column":6},"end":{"line":193,"column":null}},"type":"if","locations":[{"start":{"line":193,"column":6},"end":{"line":193,"column":null}},{"start":{},"end":{}}],"line":193},"24":{"loc":{"start":{"line":196,"column":24},"end":{"line":196,"column":null}},"type":"cond-expr","locations":[{"start":{"line":196,"column":36},"end":{"line":196,"column":54}},{"start":{"line":196,"column":54},"end":{"line":196,"column":null}}],"line":196},"25":{"loc":{"start":{"line":207,"column":4},"end":{"line":207,"column":null}},"type":"cond-expr","locations":[{"start":{"line":207,"column":23},"end":{"line":207,"column":60}},{"start":{"line":207,"column":63},"end":{"line":207,"column":null}}],"line":207},"26":{"loc":{"start":{"line":208,"column":4},"end":{"line":208,"column":null}},"type":"cond-expr","locations":[{"start":{"line":208,"column":23},"end":{"line":208,"column":60}},{"start":{"line":208,"column":63},"end":{"line":208,"column":null}}],"line":208},"27":{"loc":{"start":{"line":210,"column":38},"end":{"line":210,"column":56}},"type":"binary-expr","locations":[{"start":{"line":210,"column":38},"end":{"line":210,"column":52}},{"start":{"line":210,"column":52},"end":{"line":210,"column":56}}],"line":210},"28":{"loc":{"start":{"line":210,"column":56},"end":{"line":210,"column":73}},"type":"binary-expr","locations":[{"start":{"line":210,"column":56},"end":{"line":210,"column":70}},{"start":{"line":210,"column":70},"end":{"line":210,"column":73}}],"line":210},"29":{"loc":{"start":{"line":218,"column":2},"end":{"line":221,"column":null}},"type":"if","locations":[{"start":{"line":218,"column":2},"end":{"line":221,"column":null}},{"start":{},"end":{}}],"line":218},"30":{"loc":{"start":{"line":218,"column":6},"end":{"line":218,"column":78}},"type":"binary-expr","locations":[{"start":{"line":218,"column":6},"end":{"line":218,"column":24}},{"start":{"line":218,"column":24},"end":{"line":218,"column":43}},{"start":{"line":218,"column":43},"end":{"line":218,"column":61}},{"start":{"line":218,"column":61},"end":{"line":218,"column":78}}],"line":218},"31":{"loc":{"start":{"line":221,"column":15},"end":{"line":221,"column":116}},"type":"cond-expr","locations":[{"start":{"line":221,"column":46},"end":{"line":221,"column":52}},{"start":{"line":221,"column":52},"end":{"line":221,"column":116}}],"line":221},"32":{"loc":{"start":{"line":232,"column":17},"end":{"line":232,"column":null}},"type":"cond-expr","locations":[{"start":{"line":232,"column":51},"end":{"line":232,"column":58}},{"start":{"line":232,"column":58},"end":{"line":232,"column":null}}],"line":232},"33":{"loc":{"start":{"line":261,"column":4},"end":{"line":261,"column":null}},"type":"cond-expr","locations":[{"start":{"line":261,"column":26},"end":{"line":261,"column":66}},{"start":{"line":261,"column":69},"end":{"line":261,"column":null}}],"line":261},"34":{"loc":{"start":{"line":262,"column":4},"end":{"line":262,"column":null}},"type":"cond-expr","locations":[{"start":{"line":262,"column":26},"end":{"line":262,"column":66}},{"start":{"line":262,"column":69},"end":{"line":262,"column":null}}],"line":262},"35":{"loc":{"start":{"line":264,"column":38},"end":{"line":264,"column":59}},"type":"binary-expr","locations":[{"start":{"line":264,"column":38},"end":{"line":264,"column":55}},{"start":{"line":264,"column":55},"end":{"line":264,"column":59}}],"line":264},"36":{"loc":{"start":{"line":264,"column":59},"end":{"line":264,"column":79}},"type":"binary-expr","locations":[{"start":{"line":264,"column":59},"end":{"line":264,"column":76}},{"start":{"line":264,"column":76},"end":{"line":264,"column":79}}],"line":264}},"s":{"0":2,"1":2,"2":2,"3":2,"4":2,"5":56,"6":379,"7":2622,"8":56,"9":56,"10":323,"11":323,"12":1950,"13":1950,"14":56,"15":39,"16":1,"17":38,"18":848,"19":37,"20":37,"21":37,"22":37,"23":37,"24":37,"25":37,"26":1,"27":36,"28":36,"29":2,"30":36,"31":36,"32":2,"33":36,"34":36,"35":1,"36":35,"37":31,"38":31,"39":4,"40":4,"41":4,"42":36,"43":0,"44":36,"45":4,"46":4,"47":4,"48":2,"49":36,"50":69,"51":69,"52":30,"53":30,"54":300,"55":300,"56":300,"57":300,"58":48,"59":252,"60":2,"61":250,"62":250,"63":36,"64":36,"65":36,"66":36,"67":9,"68":9,"69":9,"70":9,"71":9,"72":9,"73":15,"74":15,"75":15,"76":15,"77":15,"78":1,"79":1,"80":1,"81":0,"82":1,"83":1,"84":1,"85":0,"86":1,"87":1,"88":15,"89":15,"90":15,"91":15,"92":15,"93":15,"94":15,"95":15,"96":15,"97":15,"98":15,"99":9,"100":9,"101":9,"102":15,"103":15,"104":15,"105":15,"106":15,"107":15,"108":15,"109":15,"110":15,"111":15,"112":15,"113":15,"114":15,"115":15,"116":15,"117":15,"118":15,"119":15,"120":15,"121":15,"122":15,"123":15,"124":15,"125":3},"f":{"0":56,"1":379,"2":2622,"3":39,"4":848,"5":37,"6":69,"7":30,"8":300,"9":9,"10":15,"11":1,"12":0,"13":15,"14":15,"15":3},"b":{"0":[349,2273],"1":[323,1950],"2":[212,1738],"3":[1,38],"4":[1,36],"5":[36,38],"6":[36,37],"7":[1,35],"8":[31,4],"9":[0,36],"10":[4,32],"11":[2,2],"12":[69,0],"13":[20,10],"14":[19,11],"15":[300,270],"16":[48,252],"17":[300,48],"18":[2,250],"19":[252,252],"20":[214,36],"21":[1,14],"22":[15,14],"23":[0,1],"24":[1,0],"25":[10,5],"26":[10,5],"27":[15,5],"28":[15,6],"29":[9,6],"30":[15,10,10,9],"31":[9,0],"32":[9,6],"33":[10,5],"34":[10,5],"35":[15,5],"36":[15,6]},"meta":{"lastBranch":37,"lastFunction":16,"lastStatement":126,"seen":{"s:11:39:16:Infinity":0,"s:18:24:21:2":1,"s:23:24:26:2":2,"s:28:48:44:Infinity":3,"s:46:77:51:Infinity":4,"f:53:9:53:29":0,"s:54:29:55:Infinity":5,"f:54:64:54:67":1,"s:55:4:55:83":6,"f:55:39:55:42":2,"s:55:52:55:83":7,"b:55:62:55:66:55:66:55:83":0,"b:55:76:55:80:55:80:55:83":1,"s:58:2:65:Infinity":8,"s:58:15:58:18":9,"s:59:4:65:Infinity":10,"s:59:17:59:20":11,"s:60:19:60:Infinity":12,"b:60:43:60:47:60:47:60:Infinity":2,"s:61:6:65:Infinity":13,"s:69:2:69:Infinity":14,"f:72:9:72:25":3,"b:73:2:73:Infinity:undefined:undefined:undefined:undefined":3,"s:73:2:73:Infinity":15,"s:73:20:73:Infinity":16,"s:74:2:74:Infinity":17,"f:77:9:77:25":4,"s:78:2:83:Infinity":18,"f:86:9:86:19":5,"s:87:16:87:37":19,"s:88:16:88:48":20,"s:90:18:90:Infinity":21,"s:91:17:91:Infinity":22,"s:92:19:92:Infinity":23,"s:93:29:93:31":24,"b:95:2:95:Infinity:undefined:undefined:undefined:undefined":4,"s:95:2:95:Infinity":25,"s:95:26:95:Infinity":26,"s:97:17:97:Infinity":27,"s:98:2:99:Infinity":28,"b:98:9:98:36:98:36:98:72":5,"s:99:4:99:Infinity":29,"s:102:15:102:Infinity":30,"s:103:2:104:Infinity":31,"b:103:9:103:34:103:34:103:72":6,"s:104:4:104:Infinity":32,"s:107:20:107:49":33,"b:109:2:117:Infinity:111:13:117:Infinity":7,"s:109:2:117:Infinity":34,"s:110:4:110:Infinity":35,"b:111:13:117:Infinity:114:9:117:Infinity":8,"s:111:13:117:Infinity":36,"s:112:4:112:Infinity":37,"s:113:4:113:Infinity":38,"s:115:4:115:Infinity":39,"s:116:4:116:Infinity":40,"s:117:4:117:Infinity":41,"b:120:2:121:Infinity:undefined:undefined:undefined:undefined":9,"s:120:2:121:Infinity":42,"s:121:4:121:Infinity":43,"b:123:2:126:Infinity:undefined:undefined:undefined:undefined":10,"s:123:2:126:Infinity":44,"s:124:24:124:45":45,"s:125:4:126:Infinity":46,"b:126:6:126:Infinity:undefined:undefined:undefined:undefined":11,"s:126:6:126:Infinity":47,"s:126:27:126:Infinity":48,"s:130:2:130:Infinity":49,"f:133:9:133:29":6,"s:134:16:134:37":50,"s:135:2:135:Infinity":51,"b:135:9:135:35:135:35:135:Infinity":12,"f:138:9:138:26":7,"s:139:16:147:19":52,"b:142:22:142:58:142:61:142:Infinity":13,"b:143:16:143:42:143:45:143:Infinity":14,"s:148:2:148:Infinity":53,"f:151:9:151:27":8,"s:152:17:152:Infinity":54,"b:152:17:152:32:152:32:152:Infinity":15,"s:153:22:153:36":55,"s:154:22:154:36":56,"b:156:2:156:Infinity:undefined:undefined:undefined:undefined":16,"s:156:2:156:Infinity":57,"b:156:6:156:22:156:22:156:36":17,"s:156:36:156:Infinity":58,"b:157:2:157:Infinity:undefined:undefined:undefined:undefined":18,"s:157:2:157:Infinity":59,"b:157:6:157:22:157:22:157:36":19,"s:157:36:157:Infinity":60,"b:159:2:159:Infinity:undefined:undefined:undefined:undefined":20,"s:159:2:159:Infinity":61,"s:159:35:159:Infinity":62,"s:161:15:161:60":63,"s:162:17:162:65":64,"s:163:16:163:45":65,"s:165:2:165:Infinity":66,"f:168:9:168:27":9,"s:169:12:169:Infinity":67,"s:170:8:170:Infinity":68,"s:171:8:171:Infinity":69,"s:173:4:177:24":70,"s:178:12:178:58":71,"s:179:2:179:Infinity":72,"f:182:9:182:26":10,"s:183:21:183:Infinity":73,"s:184:20:184:Infinity":74,"s:185:22:185:Infinity":75,"s:187:26:187:Infinity":76,"b:188:2:196:Infinity:undefined:undefined:undefined:undefined":21,"s:188:2:196:Infinity":77,"b:188:6:188:37:188:37:188:66":22,"s:189:25:189:76":78,"f:189:50:189:54":11,"s:189:59:189:74":79,"s:190:25:190:76":80,"f:190:50:190:54":12,"s:190:59:190:74":81,"s:191:18:191:Infinity":82,"s:192:4:193:Infinity":83,"b:193:6:193:Infinity:undefined:undefined:undefined:undefined":23,"s:193:6:193:Infinity":84,"s:193:34:193:Infinity":85,"s:195:18:195:64":86,"s:196:4:196:Infinity":87,"b:196:36:196:54:196:54:196:Infinity":24,"s:199:20:199:Infinity":88,"s:200:2:200:Infinity":89,"f:203:9:203:29":13,"s:204:22:204:Infinity":90,"s:205:22:205:Infinity":91,"s:206:20:209:Infinity":92,"b:207:23:207:60:207:63:207:Infinity":25,"b:208:23:208:60:208:63:208:Infinity":26,"s:210:20:210:Infinity":93,"b:210:38:210:52:210:52:210:56":27,"b:210:56:210:70:210:70:210:73":28,"s:211:20:211:Infinity":94,"s:212:21:212:Infinity":95,"s:213:19:213:Infinity":96,"s:216:17:216:Infinity":97,"b:218:2:221:Infinity:undefined:undefined:undefined:undefined":29,"s:218:2:221:Infinity":98,"b:218:6:218:24:218:24:218:43:218:43:218:61:218:61:218:78":30,"s:219:4:219:Infinity":99,"s:220:20:220:Infinity":100,"s:221:4:221:Infinity":101,"b:221:46:221:52:221:52:221:116":31,"s:225:5:232:Infinity":102,"b:232:51:232:58:232:58:232:Infinity":32,"s:234:2:234:Infinity":103,"f:237:16:237:Infinity":14,"s:244:26:244:Infinity":104,"s:246:18:246:34":105,"s:247:18:247:34":106,"s:249:20:249:54":107,"s:251:53:251:109":108,"s:253:28:253:Infinity":109,"s:255:21:255:76":110,"s:256:20:256:73":111,"s:257:22:257:79":112,"s:258:22:258:85":113,"s:259:22:259:98":114,"s:260:20:262:Infinity":115,"b:261:26:261:66:261:69:261:Infinity":33,"b:262:26:262:66:262:69:262:Infinity":34,"s:264:20:264:79":116,"b:264:38:264:55:264:55:264:59":35,"b:264:59:264:76:264:76:264:79":36,"s:265:20:265:67":117,"s:266:21:266:70":118,"s:267:19:267:64":119,"s:269:22:269:48":120,"s:270:22:270:48":121,"s:272:15:274:Infinity":122,"s:277:32:294:Infinity":123,"s:296:2:302:Infinity":124,"f:305:16:305:41":15,"s:306:2:306:Infinity":125}}} +,"/home/mike/code/ShieldAI/services/hometitle/src/types.ts": {"path":"/home/mike/code/ShieldAI/services/hometitle/src/types.ts","statementMap":{},"fnMap":{},"branchMap":{},"s":{},"f":{},"b":{},"meta":{"lastBranch":0,"lastFunction":0,"lastStatement":0,"seen":{}}} +} diff --git a/services/hometitle/coverage/favicon.png b/services/hometitle/coverage/favicon.png new file mode 100644 index 0000000..c1525b8 Binary files /dev/null and b/services/hometitle/coverage/favicon.png differ diff --git a/services/hometitle/coverage/index.html b/services/hometitle/coverage/index.html new file mode 100644 index 0000000..3822708 --- /dev/null +++ b/services/hometitle/coverage/index.html @@ -0,0 +1,161 @@ + + + + + + Code coverage report for All files + + + + + + + + + +
+
+

All files

+
+ +
+ 98.11% + Statements + 208/212 +
+ + +
+ 92.42% + Branches + 122/132 +
+ + +
+ 96.29% + Functions + 26/27 +
+ + +
+ 98.96% + Lines + 191/193 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
change-detector.ts +
+
98.83%85/8691.07%51/56100%11/1198.73%78/79
index.ts +
+
0%0/00%0/00%0/00%0/0
matcher.service.ts +
+
97.61%123/12693.42%71/7693.75%15/1699.12%113/114
types.ts +
+
0%0/00%0/00%0/00%0/0
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/services/hometitle/coverage/index.ts.html b/services/hometitle/coverage/index.ts.html new file mode 100644 index 0000000..d516e68 --- /dev/null +++ b/services/hometitle/coverage/index.ts.html @@ -0,0 +1,187 @@ + + + + + + Code coverage report for index.ts + + + + + + + + + +
+
+

All files index.ts

+
+ +
+ 0% + Statements + 0/0 +
+ + +
+ 0% + Branches + 0/0 +
+ + +
+ 0% + Functions + 0/0 +
+ + +
+ 0% + Lines + 0/0 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
export {
+  matchRecords,
+  getConfigForPropertyType,
+  parseName,
+  normalizeString,
+  normalizeStreetType,
+  levenshteinDistance,
+  similarityScore,
+} from './matcher.service';
+ 
+export {
+  detectChanges,
+  shouldTriggerAlert,
+  classifyFieldChange,
+  determineSeverity,
+  computeChangeConfidence,
+} from './change-detector';
+ 
+export type {
+  PropertyRecord,
+  Address,
+  PropertyType,
+  PropertySnapshot,
+  MatchResult,
+  MatchDetails,
+  FieldMatch,
+  ChangeDetectionResult,
+  ChangeType,
+  Severity,
+  PropertyChange,
+  MatchingConfig,
+  DetectionConfig,
+  NormalizedTokens,
+} from './types';
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/services/hometitle/coverage/lcov-report/base.css b/services/hometitle/coverage/lcov-report/base.css new file mode 100644 index 0000000..f418035 --- /dev/null +++ b/services/hometitle/coverage/lcov-report/base.css @@ -0,0 +1,224 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/services/hometitle/coverage/lcov-report/block-navigation.js b/services/hometitle/coverage/lcov-report/block-navigation.js new file mode 100644 index 0000000..530d1ed --- /dev/null +++ b/services/hometitle/coverage/lcov-report/block-navigation.js @@ -0,0 +1,87 @@ +/* eslint-disable */ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selector that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); + } + + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } + + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } + + makeCurrent(nextIndex); + } + + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); + } + + return function jump(event) { + if ( + document.getElementById('fileSearch') === document.activeElement && + document.activeElement != null + ) { + // if we're currently focused on the search input, we don't want to navigate + return; + } + + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); +window.addEventListener('keydown', jumpToCode); diff --git a/services/hometitle/coverage/lcov-report/change-detector.ts.html b/services/hometitle/coverage/lcov-report/change-detector.ts.html new file mode 100644 index 0000000..f10287e --- /dev/null +++ b/services/hometitle/coverage/lcov-report/change-detector.ts.html @@ -0,0 +1,691 @@ + + + + + + Code coverage report for change-detector.ts + + + + + + + + + +
+
+

All files change-detector.ts

+
+ +
+ 98.83% + Statements + 85/86 +
+ + +
+ 91.07% + Branches + 51/56 +
+ + +
+ 100% + Functions + 11/11 +
+ + +
+ 98.73% + Lines + 78/79 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203  +  +  +  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +11x +  +5x +  +  +  +  +  +5x +  +2x +2x +  +2x +2x +  +1x +1x +  +1x +1x +  +  +  +  +11x +  +  +  +5x +  +  +  +  +  +  +  +5x +5x +  +  +  +15x +  +15x +  +  +  +  +  +  +  +15x +  +15x +14x +14x +14x +  +  +10x +9x +9x +  +  +5x +  +  +  +15x +  +13x +13x +16x +  +6x +6x +  +3x +3x +  +3x +3x +3x +3x +3x +  +  +2x +2x +  +2x +  +  +  +13x +  +  +  +  +  +  +  +11x +11x +  +11x +  +  +  +  +  +  +  +  +11x +66x +66x +  +66x +11x +  +  +  +11x +11x +  +11x +11x +  +11x +11x +4x +7x +2x +5x +1x +4x +1x +  +  +11x +  +  +  +  +  +  +  +  +  +  +  +  +11x +  +11x +  +11x +77x +77x +77x +1x +  +  +  +  +  +  +  +  +11x +  +  +  +5x +5x +5x +5x +  +  +  + 
import {
+  PropertySnapshot,
+  ChangeDetectionResult,
+  ChangeType,
+  Severity,
+  PropertyChange,
+  DetectionConfig,
+  Address,
+} from './types';
+import { matchRecords } from './matcher.service';
+ 
+const DEFAULT_DETECTION_CONFIG: DetectionConfig = {
+  ownershipNameThreshold: 0.7,
+  deedDateSensitivity: 0.9,
+  taxAmountChangePercent: 15,
+};
+ 
+function classifyFieldChange(field: string, oldValue: unknown, newValue: unknown, config: DetectionConfig): PropertyChange {
+  let changeType: ChangeType;
+ 
+  switch (field) {
+    case 'ownerName':
+      changeType =
+        typeof oldValue === 'string' && typeof newValue === 'string'
+          ? isSignificantNameChange(oldValue, newValue, config)
+            ? 'ownership_transfer'
+            : 'metadata_change'
+          : 'ownership_transfer';
+      break;
+    case 'deedDate':
+      changeType = 'deed_change';
+      break;
+    case 'taxAmount':
+      changeType = 'tax_change';
+      break;
+    case 'lienCount':
+      changeType = (newValue as number) > (oldValue as number) ? 'lien_filing' : 'metadata_change';
+      break;
+    case 'taxId':
+      changeType = 'deed_change';
+      break;
+    default:
+      changeType = 'metadata_change';
+  }
+ 
+  return { field, oldValue, newValue, changeType };
+}
+ 
+function isSignificantNameChange(oldName: string, newName: string, config: DetectionConfig): boolean {
+  const dummyAddress: Address = {
+    streetNumber: '0',
+    streetName: 'dummy',
+    city: 'dummy',
+    state: 'XX',
+    zip: '00000',
+  };
+ 
+  const result = matchRecords(oldName, dummyAddress, newName, dummyAddress);
+  return result.nameScore < config.ownershipNameThreshold;
+}
+ 
+function determineSeverity(changes: PropertyChange[], config: DetectionConfig): Severity {
+  const severityOverrides = config.severityOverrides || {};
+ 
+  const typeToSeverity: Record<ChangeType, Severity> = {
+    ownership_transfer: severityOverrides['ownership_transfer'] || 'major',
+    deed_change: severityOverrides['deed_change'] || 'moderate',
+    lien_filing: severityOverrides['lien_filing'] || 'moderate',
+    tax_change: severityOverrides['tax_change'] || 'minor',
+    metadata_change: severityOverrides['metadata_change'] || 'minor',
+  };
+ 
+  const severityOrder: Severity[] = ['major', 'moderate', 'minor'];
+ 
+  for (const change of changes) {
+    const sev = typeToSeverity[change.changeType];
+    const idx = severityOrder.indexOf(sev);
+    if (idx === 0) return 'major';
+  }
+ 
+  for (const change of changes) {
+    const sev = typeToSeverity[change.changeType];
+    if (sev === 'moderate') return 'moderate';
+  }
+ 
+  return 'minor';
+}
+ 
+function computeChangeConfidence(changes: PropertyChange[], config: DetectionConfig): number {
+  if (changes.length === 0) return 0;
+ 
+  let totalConfidence = 0;
+  for (const change of changes) {
+    switch (change.changeType) {
+      case 'ownership_transfer':
+        totalConfidence += 0.95;
+        break;
+      case 'deed_change':
+        totalConfidence += config.deedDateSensitivity;
+        break;
+      case 'tax_change': {
+        const oldVal = change.oldValue as number;
+        const newVal = change.newValue as number;
+        const pctChange = oldVal ? Math.abs(newVal - oldVal) / oldVal * 100 : 100;
+        totalConfidence += pctChange >= config.taxAmountChangePercent ? 0.85 : 0.5;
+        break;
+      }
+      case 'lien_filing':
+        totalConfidence += 0.9;
+        break;
+      default:
+        totalConfidence += 0.4;
+    }
+  }
+ 
+  return Math.round((totalConfidence / changes.length) * 1000) / 1000;
+}
+ 
+export function detectChanges(
+  previous: PropertySnapshot,
+  current: PropertySnapshot,
+  config?: Partial<DetectionConfig>,
+): ChangeDetectionResult {
+  const effectiveConfig = { ...DEFAULT_DETECTION_CONFIG, ...config };
+  const changes: PropertyChange[] = [];
+ 
+  const fieldsToCompare: (keyof Omit<PropertySnapshot, 'id' | 'capturedAt' | 'propertyId'>)[] = [
+    'ownerName',
+    'deedDate',
+    'taxId',
+    'taxAmount',
+    'lienCount',
+    'propertyType',
+  ];
+ 
+  for (const field of fieldsToCompare) {
+    const oldValue = previous[field];
+    const newValue = current[field];
+ 
+    if (oldValue !== newValue) {
+      changes.push(classifyFieldChange(field, oldValue, newValue, effectiveConfig));
+    }
+  }
+ 
+  const addressChanges = detectAddressChanges(previous.address, current.address);
+  changes.push(...addressChanges);
+ 
+  const severity = determineSeverity(changes, effectiveConfig);
+  const confidence = computeChangeConfidence(changes, effectiveConfig);
+ 
+  let changeType: ChangeType = 'metadata_change';
+  if (changes.some(c => c.changeType === 'ownership_transfer')) {
+    changeType = 'ownership_transfer';
+  } else if (changes.some(c => c.changeType === 'deed_change')) {
+    changeType = 'deed_change';
+  } else if (changes.some(c => c.changeType === 'lien_filing')) {
+    changeType = 'lien_filing';
+  } else if (changes.some(c => c.changeType === 'tax_change')) {
+    changeType = 'tax_change';
+  }
+ 
+  return {
+    propertyId: previous.propertyId,
+    changeType,
+    severity,
+    confidence,
+    changes,
+    previousSnapshot: previous,
+    currentSnapshot: current,
+    detectedAt: new Date().toISOString(),
+  };
+}
+ 
+function detectAddressChanges(oldAddr: Address, newAddr: Address): PropertyChange[] {
+  const changes: PropertyChange[] = [];
+ 
+  const addressFields: (keyof Address)[] = ['streetNumber', 'streetName', 'streetType', 'unit', 'city', 'state', 'zip'];
+ 
+  for (const field of addressFields) {
+    const oldVal = oldAddr[field];
+    const newVal = newAddr[field];
+    if (oldVal !== newVal) {
+      changes.push({
+        field: `address.${field}`,
+        oldValue: oldVal,
+        newValue: newVal,
+        changeType: 'metadata_change',
+      });
+    }
+  }
+ 
+  return changes;
+}
+ 
+export function shouldTriggerAlert(result: ChangeDetectionResult, minSeverity: Severity = 'moderate'): boolean {
+  const severityOrder: Severity[] = ['minor', 'moderate', 'major'];
+  const resultIdx = severityOrder.indexOf(result.severity);
+  const minIdx = severityOrder.indexOf(minSeverity);
+  return resultIdx >= minIdx && result.confidence >= 0.7;
+}
+ 
+export { classifyFieldChange, determineSeverity, computeChangeConfidence };
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/services/hometitle/coverage/lcov-report/favicon.png b/services/hometitle/coverage/lcov-report/favicon.png new file mode 100644 index 0000000..c1525b8 Binary files /dev/null and b/services/hometitle/coverage/lcov-report/favicon.png differ diff --git a/services/hometitle/coverage/lcov-report/index.html b/services/hometitle/coverage/lcov-report/index.html new file mode 100644 index 0000000..f9d2698 --- /dev/null +++ b/services/hometitle/coverage/lcov-report/index.html @@ -0,0 +1,161 @@ + + + + + + Code coverage report for All files + + + + + + + + + +
+
+

All files

+
+ +
+ 98.11% + Statements + 208/212 +
+ + +
+ 92.42% + Branches + 122/132 +
+ + +
+ 96.29% + Functions + 26/27 +
+ + +
+ 98.96% + Lines + 191/193 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
change-detector.ts +
+
98.83%85/8691.07%51/56100%11/1198.73%78/79
index.ts +
+
0%0/00%0/00%0/00%0/0
matcher.service.ts +
+
97.61%123/12693.42%71/7693.75%15/1699.12%113/114
types.ts +
+
0%0/00%0/00%0/00%0/0
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/services/hometitle/coverage/lcov-report/index.ts.html b/services/hometitle/coverage/lcov-report/index.ts.html new file mode 100644 index 0000000..0adb0d0 --- /dev/null +++ b/services/hometitle/coverage/lcov-report/index.ts.html @@ -0,0 +1,187 @@ + + + + + + Code coverage report for index.ts + + + + + + + + + +
+
+

All files index.ts

+
+ +
+ 0% + Statements + 0/0 +
+ + +
+ 0% + Branches + 0/0 +
+ + +
+ 0% + Functions + 0/0 +
+ + +
+ 0% + Lines + 0/0 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
export {
+  matchRecords,
+  getConfigForPropertyType,
+  parseName,
+  normalizeString,
+  normalizeStreetType,
+  levenshteinDistance,
+  similarityScore,
+} from './matcher.service';
+ 
+export {
+  detectChanges,
+  shouldTriggerAlert,
+  classifyFieldChange,
+  determineSeverity,
+  computeChangeConfidence,
+} from './change-detector';
+ 
+export type {
+  PropertyRecord,
+  Address,
+  PropertyType,
+  PropertySnapshot,
+  MatchResult,
+  MatchDetails,
+  FieldMatch,
+  ChangeDetectionResult,
+  ChangeType,
+  Severity,
+  PropertyChange,
+  MatchingConfig,
+  DetectionConfig,
+  NormalizedTokens,
+} from './types';
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/services/hometitle/coverage/lcov-report/matcher.service.ts.html b/services/hometitle/coverage/lcov-report/matcher.service.ts.html new file mode 100644 index 0000000..9000dbd --- /dev/null +++ b/services/hometitle/coverage/lcov-report/matcher.service.ts.html @@ -0,0 +1,1012 @@ + + + + + + Code coverage report for matcher.service.ts + + + + + + + + + +
+
+

All files matcher.service.ts

+
+ +
+ 97.61% + Statements + 123/126 +
+ + +
+ 93.42% + Branches + 71/76 +
+ + +
+ 93.75% + Functions + 15/16 +
+ + +
+ 99.12% + Lines + 113/114 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310  +  +  +  +  +  +  +  +  +  +2x +  +  +  +  +  +  +2x +  +  +  +  +2x +  +  +  +  +2x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +2x +  +  +  +  +  +  +  +56x +2622x +  +  +56x +323x +1950x +1950x +  +  +  +  +  +  +  +56x +  +  +  +39x +38x +  +  +  +848x +  +  +  +  +  +  +  +  +37x +37x +  +37x +37x +37x +37x +  +37x +  +36x +36x +2x +  +  +36x +36x +2x +  +  +36x +  +36x +1x +35x +31x +31x +  +4x +4x +4x +  +  +36x +  +  +36x +4x +4x +4x +  +  +  +36x +  +  +  +69x +69x +  +  +  +30x +  +  +  +  +  +  +  +  +30x +  +  +  +300x +300x +300x +  +300x +252x +  +250x +  +36x +36x +36x +  +36x +  +  +  +9x +9x +9x +  +9x +  +  +  +  +9x +9x +  +  +  +15x +15x +15x +  +15x +15x +1x +1x +1x +1x +1x +  +1x +1x +  +  +15x +15x +  +  +  +15x +15x +15x +  +  +  +15x +15x +15x +15x +  +  +15x +  +15x +9x +9x +9x +  +  +  +15x +  +  +  +  +  +  +  +  +15x +  +  +  +  +  +  +  +  +  +15x +  +15x +15x +  +15x +  +15x +  +15x +  +15x +15x +15x +15x +15x +15x +  +  +  +15x +15x +15x +15x +  +15x +15x +  +15x +  +  +  +  +15x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +15x +  +  +  +  +  +  +  +  +  +3x +  +  +  + 
import {
+  Address,
+  MatchResult,
+  MatchDetails,
+  FieldMatch,
+  MatchingConfig,
+  NormalizedTokens,
+  PropertyType,
+} from './types';
+ 
+const DEFAULT_CONFIG: MatchingConfig = {
+  nameThreshold: 0.85,
+  addressThreshold: 0.9,
+  overallThreshold: 0.85,
+  geocodingRadiusMeters: 100,
+};
+ 
+const COMMON_PREFIXES = new Set([
+  'mr', 'mrs', 'ms', 'miss', 'dr', 'prof', 'jr', 'sr', 'junior', 'senior',
+  'ii', 'iii', 'iv', 'rev', 'st', 'hon', 'esq',
+]);
+ 
+const COMMON_SUFFIXES = new Set([
+  'jr', 'sr', 'junior', 'senior', 'ii', 'iii', 'iv', 'v', 'esq',
+  'phd', 'md', 'llm', 'cpa',
+]);
+ 
+const STREET_TYPE_MAP: Record<string, string> = {
+  'st': 'street', 'street': 'street',
+  'ave': 'avenue', 'avenue': 'avenue',
+  'blvd': 'boulevard', 'boulevard': 'boulevard',
+  'dr': 'drive', 'drive': 'drive',
+  'ln': 'lane', 'lane': 'lane',
+  'ct': 'court', 'court': 'court',
+  'pl': 'place', 'place': 'place',
+  'rd': 'road', 'road': 'road',
+  'way': 'way',
+  'trl': 'trail', 'trail': 'trail',
+  'hwy': 'highway', 'highway': 'highway',
+  'pkwy': 'parkway', 'parkway': 'parkway',
+  'cir': 'circle', 'circle': 'circle',
+  'sq': 'square', 'square': 'square',
+  'ter': 'terrace', 'terrace': 'terrace',
+};
+ 
+const PROPERTY_TYPE_CONFIGS: Record<PropertyType, Partial<MatchingConfig>> = {
+  'residential': { nameThreshold: 0.85, addressThreshold: 0.9 },
+  'commercial': { nameThreshold: 0.8, addressThreshold: 0.9 },
+  'land': { nameThreshold: 0.8, addressThreshold: 0.85 },
+  'multi-family': { nameThreshold: 0.8, addressThreshold: 0.9 },
+};
+ 
+function levenshteinDistance(a: string, b: string): number {
+  const matrix: number[][] = Array.from({ length: b.length + 1 }, (_, i) =>
+    Array.from({ length: a.length + 1 }, (_, j) => (i === 0 ? j : j === 0 ? i : 0))
+  );
+ 
+  for (let i = 1; i <= b.length; i++) {
+    for (let j = 1; j <= a.length; j++) {
+      const cost = a[j - 1] === b[i - 1] ? 0 : 1;
+      matrix[i][j] = Math.min(
+        matrix[i - 1][j] + 1,
+        matrix[i][j - 1] + 1,
+        matrix[i - 1][j - 1] + cost,
+      );
+    }
+  }
+ 
+  return matrix[b.length][a.length];
+}
+ 
+function similarityScore(distance: number, maxLen: number): number {
+  if (maxLen === 0) return 1.0;
+  return 1.0 - distance / maxLen;
+}
+ 
+function normalizeString(str: string): string {
+  return str
+    .toLowerCase()
+    .replace(/[''']/g, '')
+    .replace(/[^a-z0-9\s]/g, ' ')
+    .replace(/\s+/g, ' ')
+    .trim();
+}
+ 
+function parseName(name: string): NormalizedTokens {
+  const clean = normalizeString(name);
+  const parts = clean.split(' ').filter(Boolean);
+ 
+  let firstName = '';
+  let lastName = '';
+  let middleName = '';
+  const initials: string[] = [];
+ 
+  if (parts.length === 0) return { firstName, lastName, middleName, initials };
+ 
+  let startIdx = 0;
+  while (startIdx < parts.length && COMMON_PREFIXES.has(parts[startIdx])) {
+    startIdx++;
+  }
+ 
+  let endIdx = parts.length;
+  while (endIdx > startIdx + 1 && COMMON_SUFFIXES.has(parts[endIdx - 1])) {
+    endIdx--;
+  }
+ 
+  const coreParts = parts.slice(startIdx, endIdx);
+ 
+  if (coreParts.length === 1) {
+    lastName = coreParts[0];
+  } else if (coreParts.length === 2) {
+    firstName = coreParts[0];
+    lastName = coreParts[1];
+  } else {
+    firstName = coreParts[0];
+    lastName = coreParts[coreParts.length - 1];
+    middleName = coreParts.slice(1, -1).join(' ');
+  }
+ 
+  Iif (firstName.length === 1) {
+    initials.push(firstName);
+  }
+  if (middleName) {
+    const middleParts = middleName.split(' ');
+    for (const mp of middleParts) {
+      if (mp.length === 1) initials.push(mp);
+    }
+  }
+ 
+  return { firstName, lastName, middleName, initials };
+}
+ 
+function normalizeStreetType(type: string): string {
+  const clean = normalizeString(type);
+  return STREET_TYPE_MAP[clean] || clean;
+}
+ 
+function normalizeAddress(addr: Address): string {
+  const parts = [
+    addr.streetNumber,
+    normalizeString(addr.streetName),
+    addr.streetType ? normalizeStreetType(addr.streetType) : '',
+    addr.unit ? normalizeString(addr.unit) : '',
+    normalizeString(addr.city),
+    addr.state.toLowerCase(),
+    addr.zip,
+  ].filter(Boolean);
+  return parts.join(' ');
+}
+ 
+function computeFieldMatch(valueA: string, valueB: string, normalizeFn?: (v: string) => string): FieldMatch {
+  const normFn = normalizeFn || normalizeString;
+  const normalizedA = normFn(valueA);
+  const normalizedB = normFn(valueB);
+ 
+  if (!normalizedA && !normalizedB) return { valueA, valueB, normalizedA, normalizedB, score: 1.0 };
+  if (!normalizedA || !normalizedB) return { valueA, valueB, normalizedA, normalizedB, score: 0.0 };
+ 
+  if (normalizedA === normalizedB) return { valueA, valueB, normalizedA, normalizedB, score: 1.0 };
+ 
+  const dist = levenshteinDistance(normalizedA, normalizedB);
+  const maxLen = Math.max(normalizedA.length, normalizedB.length);
+  const score = similarityScore(dist, maxLen);
+ 
+  return { valueA, valueB, normalizedA, normalizedB, score: Math.round(score * 1000) / 1000 };
+}
+ 
+function haversineDistance(lat1: number, lon1: number, lat2: number, lon2: number): number {
+  const R = 6371000;
+  const dLat = ((lat2 - lat1) * Math.PI) / 180;
+  const dLon = ((lon2 - lon1) * Math.PI) / 180;
+  const a =
+    Math.sin(dLat / 2) * Math.sin(dLat / 2) +
+    Math.cos((lat1 * Math.PI) / 180) *
+      Math.cos((lat2 * Math.PI) / 180) *
+      Math.sin(dLon / 2) *
+      Math.sin(dLon / 2);
+  const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
+  return R * c;
+}
+ 
+function computeNameScore(tokensA: NormalizedTokens, tokensB: NormalizedTokens): number {
+  const firstScore = computeFieldMatch(tokensA.firstName, tokensB.firstName).score;
+  const lastScore = computeFieldMatch(tokensA.lastName, tokensB.lastName).score;
+  const middleScore = computeFieldMatch(tokensA.middleName, tokensB.middleName).score;
+ 
+  let initialMatchScore = 1.0;
+  if (tokensA.initials.length > 0 || tokensB.initials.length > 0) {
+    const allInitialsA = new Set(tokensA.initials.map(i => i.toLowerCase()));
+    const allInitialsB = new Set(tokensB.initials.map(i => i.toLowerCase()));
+    let matched = 0;
+    for (const init of allInitialsA) {
+      Iif (allInitialsB.has(init)) matched++;
+    }
+    const total = Math.max(allInitialsA.size, allInitialsB.size);
+    initialMatchScore = total > 0 ? matched / total : 1.0;
+  }
+ 
+  const weighted = (lastScore * 0.45) + (firstScore * 0.35) + (middleScore * 0.1) + (initialMatchScore * 0.1);
+  return Math.round(weighted * 1000) / 1000;
+}
+ 
+function computeAddressScore(addrA: Address, addrB: Address, config: MatchingConfig): { score: number; geocodingDistance?: number } {
+  const numberMatch = computeFieldMatch(addrA.streetNumber, addrB.streetNumber).score;
+  const streetMatch = computeFieldMatch(addrA.streetName, addrB.streetName, normalizeString).score;
+  const typeMatch = computeFieldMatch(
+    addrA.streetType ? normalizeStreetType(addrA.streetType) : '',
+    addrB.streetType ? normalizeStreetType(addrB.streetType) : '',
+  ).score;
+  const unitMatch = computeFieldMatch(addrA.unit || '', addrB.unit || '').score;
+  const cityMatch = computeFieldMatch(addrA.city, addrB.city).score;
+  const stateMatch = computeFieldMatch(addrA.state, addrB.state).score;
+  const zipMatch = computeFieldMatch(addrA.zip, addrB.zip).score;
+ 
+  let geocodingDistance: number | undefined;
+  let geoScore = 0.0;
+ 
+  if (addrA.latitude && addrA.longitude && addrB.latitude && addrB.longitude) {
+    geocodingDistance = haversineDistance(addrA.latitude, addrA.longitude, addrB.latitude, addrB.longitude);
+    const maxDist = config.geocodingRadiusMeters;
+    geoScore = geocodingDistance <= maxDist ? 1.0 : Math.max(0, 1.0 - (geocodingDistance - maxDist) / (maxDist * 5));
+  }
+ 
+  const weighted =
+    (numberMatch * 0.2) +
+    (streetMatch * 0.25) +
+    (typeMatch * 0.1) +
+    (unitMatch * 0.1) +
+    (cityMatch * 0.1) +
+    (stateMatch * 0.1) +
+    (zipMatch * 0.1) +
+    (geoScore * (geocodingDistance !== undefined ? 0.05 : 0));
+ 
+  return { score: Math.round(weighted * 1000) / 1000, geocodingDistance };
+}
+ 
+export function matchRecords(
+  nameA: string,
+  addressA: Address,
+  nameB: string,
+  addressB: Address,
+  config?: Partial<MatchingConfig>,
+): MatchResult {
+  const effectiveConfig = { ...DEFAULT_CONFIG, ...config };
+ 
+  const tokensA = parseName(nameA);
+  const tokensB = parseName(nameB);
+ 
+  const nameScore = computeNameScore(tokensA, tokensB);
+ 
+  const { score: addressScore, geocodingDistance } = computeAddressScore(addressA, addressB, effectiveConfig);
+ 
+  const overallConfidence = Math.round((nameScore * 0.5 + addressScore * 0.5) * 1000) / 1000;
+ 
+  const firstMatch = computeFieldMatch(tokensA.firstName, tokensB.firstName);
+  const lastMatch = computeFieldMatch(tokensA.lastName, tokensB.lastName);
+  const middleMatch = computeFieldMatch(tokensA.middleName, tokensB.middleName);
+  const numberMatch = computeFieldMatch(addressA.streetNumber, addressB.streetNumber);
+  const streetMatch = computeFieldMatch(addressA.streetName, addressB.streetName, normalizeString);
+  const typeMatch = computeFieldMatch(
+    addressA.streetType ? normalizeStreetType(addressA.streetType) : '',
+    addressB.streetType ? normalizeStreetType(addressB.streetType) : '',
+  );
+  const unitMatch = computeFieldMatch(addressA.unit || '', addressB.unit || '');
+  const cityMatch = computeFieldMatch(addressA.city, addressB.city);
+  const stateMatch = computeFieldMatch(addressA.state, addressB.state);
+  const zipMatch = computeFieldMatch(addressA.zip, addressB.zip);
+ 
+  const normalizedA = normalizeAddress(addressA);
+  const normalizedB = normalizeAddress(addressB);
+ 
+  const dist = levenshteinDistance(
+    normalizeString(nameA),
+    normalizeString(nameB),
+  );
+ 
+  const details: MatchDetails = {
+    nameNormalized: [normalizeString(nameA), normalizeString(nameB)],
+    addressNormalized: [normalizedA, normalizedB],
+    levenshteinDistance: dist,
+    geocodingDistance,
+    fields: {
+      firstName: firstMatch,
+      lastName: lastMatch,
+      middleName: middleMatch,
+      streetNumber: numberMatch,
+      streetName: streetMatch,
+      streetType: typeMatch,
+      unit: unitMatch,
+      city: cityMatch,
+      state: stateMatch,
+      zip: zipMatch,
+    },
+  };
+ 
+  return {
+    nameScore,
+    addressScore,
+    overallConfidence,
+    isMatch: overallConfidence >= effectiveConfig.overallThreshold,
+    details,
+  };
+}
+ 
+export function getConfigForPropertyType(type: PropertyType): MatchingConfig {
+  return { ...DEFAULT_CONFIG, ...PROPERTY_TYPE_CONFIGS[type] };
+}
+ 
+export { parseName, normalizeString, normalizeStreetType, levenshteinDistance, similarityScore };
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/services/hometitle/coverage/lcov-report/prettify.css b/services/hometitle/coverage/lcov-report/prettify.css new file mode 100644 index 0000000..b317a7c --- /dev/null +++ b/services/hometitle/coverage/lcov-report/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/services/hometitle/coverage/lcov-report/prettify.js b/services/hometitle/coverage/lcov-report/prettify.js new file mode 100644 index 0000000..b322523 --- /dev/null +++ b/services/hometitle/coverage/lcov-report/prettify.js @@ -0,0 +1,2 @@ +/* eslint-disable */ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/services/hometitle/coverage/lcov-report/sort-arrow-sprite.png b/services/hometitle/coverage/lcov-report/sort-arrow-sprite.png new file mode 100644 index 0000000..6ed6831 Binary files /dev/null and b/services/hometitle/coverage/lcov-report/sort-arrow-sprite.png differ diff --git a/services/hometitle/coverage/lcov-report/sorter.js b/services/hometitle/coverage/lcov-report/sorter.js new file mode 100644 index 0000000..4ed70ae --- /dev/null +++ b/services/hometitle/coverage/lcov-report/sorter.js @@ -0,0 +1,210 @@ +/* eslint-disable */ +var addSorting = (function() { + 'use strict'; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { + return document.querySelector('.coverage-summary'); + } + // returns the thead element of the summary table + function getTableHeader() { + return getTable().querySelector('thead tr'); + } + // returns the tbody element of the summary table + function getTableBody() { + return getTable().querySelector('tbody'); + } + // returns the th element for nth column + function getNthColumn(n) { + return getTableHeader().querySelectorAll('th')[n]; + } + + function onFilterInput() { + const searchValue = document.getElementById('fileSearch').value; + const rows = document.getElementsByTagName('tbody')[0].children; + + // Try to create a RegExp from the searchValue. If it fails (invalid regex), + // it will be treated as a plain text search + let searchRegex; + try { + searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive + } catch (error) { + searchRegex = null; + } + + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + let isMatch = false; + + if (searchRegex) { + // If a valid regex was created, use it for matching + isMatch = searchRegex.test(row.textContent); + } else { + // Otherwise, fall back to the original plain text search + isMatch = row.textContent + .toLowerCase() + .includes(searchValue.toLowerCase()); + } + + row.style.display = isMatch ? '' : 'none'; + } + } + + // loads the search box + function addSearchBox() { + var template = document.getElementById('filterTemplate'); + var templateClone = template.content.cloneNode(true); + templateClone.getElementById('fileSearch').oninput = onFilterInput; + template.parentElement.appendChild(templateClone); + } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = + colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function(a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function(a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc + ? ' sorted-desc' + : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function() { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i = 0; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function() { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(); + addSearchBox(); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/services/hometitle/coverage/lcov-report/types.ts.html b/services/hometitle/coverage/lcov-report/types.ts.html new file mode 100644 index 0000000..c1f861a --- /dev/null +++ b/services/hometitle/coverage/lcov-report/types.ts.html @@ -0,0 +1,427 @@ + + + + + + Code coverage report for types.ts + + + + + + + + + +
+
+

All files types.ts

+
+ +
+ 0% + Statements + 0/0 +
+ + +
+ 0% + Branches + 0/0 +
+ + +
+ 0% + Functions + 0/0 +
+ + +
+ 0% + Lines + 0/0 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
export interface PropertyRecord {
+  id: string;
+  ownerName: string;
+  address: Address;
+  deedDate?: string;
+  taxId?: string;
+  propertyType: PropertyType;
+  metadata?: Record<string, unknown>;
+}
+ 
+export interface Address {
+  streetNumber: string;
+  streetName: string;
+  streetType?: string;
+  unit?: string;
+  city: string;
+  state: string;
+  zip: string;
+  latitude?: number;
+  longitude?: number;
+}
+ 
+export type PropertyType = 'residential' | 'commercial' | 'land' | 'multi-family';
+ 
+export interface PropertySnapshot {
+  id: string;
+  propertyId: string;
+  capturedAt: string;
+  ownerName: string;
+  address: Address;
+  deedDate?: string;
+  taxId?: string;
+  propertyType: PropertyType;
+  taxAmount?: number;
+  lienCount?: number;
+}
+ 
+export interface MatchResult {
+  nameScore: number;
+  addressScore: number;
+  overallConfidence: number;
+  isMatch: boolean;
+  details: MatchDetails;
+}
+ 
+export interface MatchDetails {
+  nameNormalized: string[];
+  addressNormalized: string[];
+  levenshteinDistance: number;
+  geocodingDistance?: number;
+  fields: {
+    firstName: FieldMatch;
+    lastName: FieldMatch;
+    middleName: FieldMatch;
+    streetNumber: FieldMatch;
+    streetName: FieldMatch;
+    streetType: FieldMatch;
+    unit: FieldMatch;
+    city: FieldMatch;
+    state: FieldMatch;
+    zip: FieldMatch;
+  };
+}
+ 
+export interface FieldMatch {
+  valueA: string;
+  valueB: string;
+  normalizedA: string;
+  normalizedB: string;
+  score: number;
+}
+ 
+export interface ChangeDetectionResult {
+  propertyId: string;
+  changeType: ChangeType;
+  severity: Severity;
+  confidence: number;
+  changes: PropertyChange[];
+  previousSnapshot: PropertySnapshot;
+  currentSnapshot: PropertySnapshot;
+  detectedAt: string;
+}
+ 
+export type ChangeType = 'tax_change' | 'deed_change' | 'ownership_transfer' | 'lien_filing' | 'metadata_change';
+ 
+export type Severity = 'minor' | 'moderate' | 'major';
+ 
+export interface PropertyChange {
+  field: string;
+  oldValue: unknown;
+  newValue: unknown;
+  changeType: ChangeType;
+}
+ 
+export interface MatchingConfig {
+  nameThreshold: number;
+  addressThreshold: number;
+  overallThreshold: number;
+  geocodingRadiusMeters: number;
+}
+ 
+export interface DetectionConfig {
+  ownershipNameThreshold: number;
+  deedDateSensitivity: number;
+  taxAmountChangePercent: number;
+  severityOverrides?: Record<ChangeType, Severity>;
+}
+ 
+export interface NormalizedTokens {
+  firstName: string;
+  lastName: string;
+  middleName: string;
+  initials: string[];
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/services/hometitle/coverage/lcov.info b/services/hometitle/coverage/lcov.info new file mode 100644 index 0000000..689c408 --- /dev/null +++ b/services/hometitle/coverage/lcov.info @@ -0,0 +1,415 @@ +TN: +SF:src/change-detector.ts +FN:18,classifyFieldChange +FN:49,isSignificantNameChange +FN:62,determineSeverity +FN:89,computeChangeConfidence +FN:119,detectChanges +FN:152,(anonymous_5) +FN:154,(anonymous_6) +FN:156,(anonymous_7) +FN:158,(anonymous_8) +FN:174,detectAddressChanges +FN:195,shouldTriggerAlert +FNF:11 +FNH:11 +FNDA:11,classifyFieldChange +FNDA:5,isSignificantNameChange +FNDA:15,determineSeverity +FNDA:15,computeChangeConfidence +FNDA:11,detectChanges +FNDA:10,(anonymous_5) +FNDA:6,(anonymous_6) +FNDA:4,(anonymous_7) +FNDA:3,(anonymous_8) +FNDA:11,detectAddressChanges +FNDA:5,shouldTriggerAlert +DA:12,1 +DA:21,11 +DA:23,5 +DA:29,5 +DA:31,2 +DA:32,2 +DA:34,2 +DA:35,2 +DA:37,1 +DA:38,1 +DA:40,1 +DA:41,1 +DA:43,0 +DA:46,11 +DA:50,5 +DA:58,5 +DA:59,5 +DA:63,15 +DA:65,15 +DA:73,15 +DA:75,15 +DA:76,14 +DA:77,14 +DA:78,14 +DA:81,10 +DA:82,9 +DA:83,9 +DA:86,5 +DA:90,15 +DA:92,13 +DA:93,13 +DA:94,16 +DA:96,6 +DA:97,6 +DA:99,3 +DA:100,3 +DA:102,3 +DA:103,3 +DA:104,3 +DA:105,3 +DA:106,3 +DA:109,2 +DA:110,2 +DA:112,2 +DA:116,13 +DA:124,11 +DA:125,11 +DA:127,11 +DA:136,11 +DA:137,66 +DA:138,66 +DA:140,66 +DA:141,11 +DA:145,11 +DA:146,11 +DA:148,11 +DA:149,11 +DA:151,11 +DA:152,11 +DA:153,4 +DA:154,7 +DA:155,2 +DA:156,5 +DA:157,1 +DA:158,4 +DA:159,1 +DA:162,11 +DA:175,11 +DA:177,11 +DA:179,11 +DA:180,77 +DA:181,77 +DA:182,77 +DA:183,1 +DA:192,11 +DA:196,5 +DA:197,5 +DA:198,5 +DA:199,5 +LF:79 +LH:78 +BRDA:21,0,0,5 +BRDA:21,0,1,2 +BRDA:21,0,2,2 +BRDA:21,0,3,1 +BRDA:21,0,4,1 +BRDA:21,0,5,0 +BRDA:24,1,0,5 +BRDA:24,1,1,0 +BRDA:24,2,0,5 +BRDA:24,2,1,5 +BRDA:25,3,0,4 +BRDA:25,3,1,1 +BRDA:37,4,0,1 +BRDA:37,4,1,0 +BRDA:63,5,0,15 +BRDA:63,5,1,14 +BRDA:66,6,0,15 +BRDA:66,6,1,15 +BRDA:67,7,0,15 +BRDA:67,7,1,15 +BRDA:68,8,0,15 +BRDA:68,8,1,15 +BRDA:69,9,0,15 +BRDA:69,9,1,14 +BRDA:70,10,0,15 +BRDA:70,10,1,15 +BRDA:78,11,0,5 +BRDA:78,11,1,9 +BRDA:83,12,0,5 +BRDA:83,12,1,4 +BRDA:90,13,0,2 +BRDA:90,13,1,13 +BRDA:94,14,0,6 +BRDA:94,14,1,3 +BRDA:94,14,2,3 +BRDA:94,14,3,2 +BRDA:94,14,4,2 +BRDA:104,15,0,3 +BRDA:104,15,1,0 +BRDA:105,16,0,3 +BRDA:105,16,1,0 +BRDA:140,17,0,11 +BRDA:140,17,1,55 +BRDA:152,18,0,4 +BRDA:152,18,1,7 +BRDA:154,19,0,2 +BRDA:154,19,1,5 +BRDA:156,20,0,1 +BRDA:156,20,1,4 +BRDA:158,21,0,1 +BRDA:158,21,1,3 +BRDA:182,22,0,1 +BRDA:182,22,1,76 +BRDA:195,23,0,5 +BRDA:199,24,0,5 +BRDA:199,24,1,4 +BRF:56 +BRH:51 +end_of_record +TN: +SF:src/index.ts +FNF:0 +FNH:0 +LF:0 +LH:0 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/matcher.service.ts +FN:53,levenshteinDistance +FN:54,(anonymous_1) +FN:55,(anonymous_2) +FN:72,similarityScore +FN:77,normalizeString +FN:86,parseName +FN:133,normalizeStreetType +FN:138,normalizeAddress +FN:151,computeFieldMatch +FN:168,haversineDistance +FN:182,computeNameScore +FN:189,(anonymous_11) +FN:190,(anonymous_12) +FN:203,computeAddressScore +FN:237,matchRecords +FN:305,getConfigForPropertyType +FNF:16 +FNH:15 +FNDA:56,levenshteinDistance +FNDA:379,(anonymous_1) +FNDA:2622,(anonymous_2) +FNDA:39,similarityScore +FNDA:848,normalizeString +FNDA:37,parseName +FNDA:69,normalizeStreetType +FNDA:30,normalizeAddress +FNDA:300,computeFieldMatch +FNDA:9,haversineDistance +FNDA:15,computeNameScore +FNDA:1,(anonymous_11) +FNDA:0,(anonymous_12) +FNDA:15,computeAddressScore +FNDA:15,matchRecords +FNDA:3,getConfigForPropertyType +DA:11,2 +DA:18,2 +DA:23,2 +DA:28,2 +DA:46,2 +DA:54,56 +DA:55,2622 +DA:58,56 +DA:59,323 +DA:60,1950 +DA:61,1950 +DA:69,56 +DA:73,39 +DA:74,38 +DA:78,848 +DA:87,37 +DA:88,37 +DA:90,37 +DA:91,37 +DA:92,37 +DA:93,37 +DA:95,37 +DA:97,36 +DA:98,36 +DA:99,2 +DA:102,36 +DA:103,36 +DA:104,2 +DA:107,36 +DA:109,36 +DA:110,1 +DA:111,35 +DA:112,31 +DA:113,31 +DA:115,4 +DA:116,4 +DA:117,4 +DA:120,36 +DA:121,0 +DA:123,36 +DA:124,4 +DA:125,4 +DA:126,4 +DA:130,36 +DA:134,69 +DA:135,69 +DA:139,30 +DA:148,30 +DA:152,300 +DA:153,300 +DA:154,300 +DA:156,300 +DA:157,252 +DA:159,250 +DA:161,36 +DA:162,36 +DA:163,36 +DA:165,36 +DA:169,9 +DA:170,9 +DA:171,9 +DA:173,9 +DA:178,9 +DA:179,9 +DA:183,15 +DA:184,15 +DA:185,15 +DA:187,15 +DA:188,15 +DA:189,1 +DA:190,1 +DA:191,1 +DA:192,1 +DA:193,1 +DA:195,1 +DA:196,1 +DA:199,15 +DA:200,15 +DA:204,15 +DA:205,15 +DA:206,15 +DA:210,15 +DA:211,15 +DA:212,15 +DA:213,15 +DA:216,15 +DA:218,15 +DA:219,9 +DA:220,9 +DA:221,9 +DA:225,15 +DA:234,15 +DA:244,15 +DA:246,15 +DA:247,15 +DA:249,15 +DA:251,15 +DA:253,15 +DA:255,15 +DA:256,15 +DA:257,15 +DA:258,15 +DA:259,15 +DA:260,15 +DA:264,15 +DA:265,15 +DA:266,15 +DA:267,15 +DA:269,15 +DA:270,15 +DA:272,15 +DA:277,15 +DA:296,15 +DA:306,3 +LF:114 +LH:113 +BRDA:55,0,0,349 +BRDA:55,0,1,2273 +BRDA:55,1,0,323 +BRDA:55,1,1,1950 +BRDA:60,2,0,212 +BRDA:60,2,1,1738 +BRDA:73,3,0,1 +BRDA:73,3,1,38 +BRDA:95,4,0,1 +BRDA:95,4,1,36 +BRDA:98,5,0,36 +BRDA:98,5,1,38 +BRDA:103,6,0,36 +BRDA:103,6,1,37 +BRDA:109,7,0,1 +BRDA:109,7,1,35 +BRDA:111,8,0,31 +BRDA:111,8,1,4 +BRDA:120,9,0,0 +BRDA:120,9,1,36 +BRDA:123,10,0,4 +BRDA:123,10,1,32 +BRDA:126,11,0,2 +BRDA:126,11,1,2 +BRDA:135,12,0,69 +BRDA:135,12,1,0 +BRDA:142,13,0,20 +BRDA:142,13,1,10 +BRDA:143,14,0,19 +BRDA:143,14,1,11 +BRDA:152,15,0,300 +BRDA:152,15,1,270 +BRDA:156,16,0,48 +BRDA:156,16,1,252 +BRDA:156,17,0,300 +BRDA:156,17,1,48 +BRDA:157,18,0,2 +BRDA:157,18,1,250 +BRDA:157,19,0,252 +BRDA:157,19,1,252 +BRDA:159,20,0,214 +BRDA:159,20,1,36 +BRDA:188,21,0,1 +BRDA:188,21,1,14 +BRDA:188,22,0,15 +BRDA:188,22,1,14 +BRDA:193,23,0,0 +BRDA:193,23,1,1 +BRDA:196,24,0,1 +BRDA:196,24,1,0 +BRDA:207,25,0,10 +BRDA:207,25,1,5 +BRDA:208,26,0,10 +BRDA:208,26,1,5 +BRDA:210,27,0,15 +BRDA:210,27,1,5 +BRDA:210,28,0,15 +BRDA:210,28,1,6 +BRDA:218,29,0,9 +BRDA:218,29,1,6 +BRDA:218,30,0,15 +BRDA:218,30,1,10 +BRDA:218,30,2,10 +BRDA:218,30,3,9 +BRDA:221,31,0,9 +BRDA:221,31,1,0 +BRDA:232,32,0,9 +BRDA:232,32,1,6 +BRDA:261,33,0,10 +BRDA:261,33,1,5 +BRDA:262,34,0,10 +BRDA:262,34,1,5 +BRDA:264,35,0,15 +BRDA:264,35,1,5 +BRDA:264,36,0,15 +BRDA:264,36,1,6 +BRF:76 +BRH:71 +end_of_record +TN: +SF:src/types.ts +FNF:0 +FNH:0 +LF:0 +LH:0 +BRF:0 +BRH:0 +end_of_record diff --git a/services/hometitle/coverage/matcher.service.ts.html b/services/hometitle/coverage/matcher.service.ts.html new file mode 100644 index 0000000..90ab31c --- /dev/null +++ b/services/hometitle/coverage/matcher.service.ts.html @@ -0,0 +1,1012 @@ + + + + + + Code coverage report for matcher.service.ts + + + + + + + + + +
+
+

All files matcher.service.ts

+
+ +
+ 97.61% + Statements + 123/126 +
+ + +
+ 93.42% + Branches + 71/76 +
+ + +
+ 93.75% + Functions + 15/16 +
+ + +
+ 99.12% + Lines + 113/114 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310  +  +  +  +  +  +  +  +  +  +2x +  +  +  +  +  +  +2x +  +  +  +  +2x +  +  +  +  +2x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +2x +  +  +  +  +  +  +  +56x +2622x +  +  +56x +323x +1950x +1950x +  +  +  +  +  +  +  +56x +  +  +  +39x +38x +  +  +  +848x +  +  +  +  +  +  +  +  +37x +37x +  +37x +37x +37x +37x +  +37x +  +36x +36x +2x +  +  +36x +36x +2x +  +  +36x +  +36x +1x +35x +31x +31x +  +4x +4x +4x +  +  +36x +  +  +36x +4x +4x +4x +  +  +  +36x +  +  +  +69x +69x +  +  +  +30x +  +  +  +  +  +  +  +  +30x +  +  +  +300x +300x +300x +  +300x +252x +  +250x +  +36x +36x +36x +  +36x +  +  +  +9x +9x +9x +  +9x +  +  +  +  +9x +9x +  +  +  +15x +15x +15x +  +15x +15x +1x +1x +1x +1x +1x +  +1x +1x +  +  +15x +15x +  +  +  +15x +15x +15x +  +  +  +15x +15x +15x +15x +  +  +15x +  +15x +9x +9x +9x +  +  +  +15x +  +  +  +  +  +  +  +  +15x +  +  +  +  +  +  +  +  +  +15x +  +15x +15x +  +15x +  +15x +  +15x +  +15x +15x +15x +15x +15x +15x +  +  +  +15x +15x +15x +15x +  +15x +15x +  +15x +  +  +  +  +15x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +15x +  +  +  +  +  +  +  +  +  +3x +  +  +  + 
import {
+  Address,
+  MatchResult,
+  MatchDetails,
+  FieldMatch,
+  MatchingConfig,
+  NormalizedTokens,
+  PropertyType,
+} from './types';
+ 
+const DEFAULT_CONFIG: MatchingConfig = {
+  nameThreshold: 0.85,
+  addressThreshold: 0.9,
+  overallThreshold: 0.85,
+  geocodingRadiusMeters: 100,
+};
+ 
+const COMMON_PREFIXES = new Set([
+  'mr', 'mrs', 'ms', 'miss', 'dr', 'prof', 'jr', 'sr', 'junior', 'senior',
+  'ii', 'iii', 'iv', 'rev', 'st', 'hon', 'esq',
+]);
+ 
+const COMMON_SUFFIXES = new Set([
+  'jr', 'sr', 'junior', 'senior', 'ii', 'iii', 'iv', 'v', 'esq',
+  'phd', 'md', 'llm', 'cpa',
+]);
+ 
+const STREET_TYPE_MAP: Record<string, string> = {
+  'st': 'street', 'street': 'street',
+  'ave': 'avenue', 'avenue': 'avenue',
+  'blvd': 'boulevard', 'boulevard': 'boulevard',
+  'dr': 'drive', 'drive': 'drive',
+  'ln': 'lane', 'lane': 'lane',
+  'ct': 'court', 'court': 'court',
+  'pl': 'place', 'place': 'place',
+  'rd': 'road', 'road': 'road',
+  'way': 'way',
+  'trl': 'trail', 'trail': 'trail',
+  'hwy': 'highway', 'highway': 'highway',
+  'pkwy': 'parkway', 'parkway': 'parkway',
+  'cir': 'circle', 'circle': 'circle',
+  'sq': 'square', 'square': 'square',
+  'ter': 'terrace', 'terrace': 'terrace',
+};
+ 
+const PROPERTY_TYPE_CONFIGS: Record<PropertyType, Partial<MatchingConfig>> = {
+  'residential': { nameThreshold: 0.85, addressThreshold: 0.9 },
+  'commercial': { nameThreshold: 0.8, addressThreshold: 0.9 },
+  'land': { nameThreshold: 0.8, addressThreshold: 0.85 },
+  'multi-family': { nameThreshold: 0.8, addressThreshold: 0.9 },
+};
+ 
+function levenshteinDistance(a: string, b: string): number {
+  const matrix: number[][] = Array.from({ length: b.length + 1 }, (_, i) =>
+    Array.from({ length: a.length + 1 }, (_, j) => (i === 0 ? j : j === 0 ? i : 0))
+  );
+ 
+  for (let i = 1; i <= b.length; i++) {
+    for (let j = 1; j <= a.length; j++) {
+      const cost = a[j - 1] === b[i - 1] ? 0 : 1;
+      matrix[i][j] = Math.min(
+        matrix[i - 1][j] + 1,
+        matrix[i][j - 1] + 1,
+        matrix[i - 1][j - 1] + cost,
+      );
+    }
+  }
+ 
+  return matrix[b.length][a.length];
+}
+ 
+function similarityScore(distance: number, maxLen: number): number {
+  if (maxLen === 0) return 1.0;
+  return 1.0 - distance / maxLen;
+}
+ 
+function normalizeString(str: string): string {
+  return str
+    .toLowerCase()
+    .replace(/[''']/g, '')
+    .replace(/[^a-z0-9\s]/g, ' ')
+    .replace(/\s+/g, ' ')
+    .trim();
+}
+ 
+function parseName(name: string): NormalizedTokens {
+  const clean = normalizeString(name);
+  const parts = clean.split(' ').filter(Boolean);
+ 
+  let firstName = '';
+  let lastName = '';
+  let middleName = '';
+  const initials: string[] = [];
+ 
+  if (parts.length === 0) return { firstName, lastName, middleName, initials };
+ 
+  let startIdx = 0;
+  while (startIdx < parts.length && COMMON_PREFIXES.has(parts[startIdx])) {
+    startIdx++;
+  }
+ 
+  let endIdx = parts.length;
+  while (endIdx > startIdx + 1 && COMMON_SUFFIXES.has(parts[endIdx - 1])) {
+    endIdx--;
+  }
+ 
+  const coreParts = parts.slice(startIdx, endIdx);
+ 
+  if (coreParts.length === 1) {
+    lastName = coreParts[0];
+  } else if (coreParts.length === 2) {
+    firstName = coreParts[0];
+    lastName = coreParts[1];
+  } else {
+    firstName = coreParts[0];
+    lastName = coreParts[coreParts.length - 1];
+    middleName = coreParts.slice(1, -1).join(' ');
+  }
+ 
+  Iif (firstName.length === 1) {
+    initials.push(firstName);
+  }
+  if (middleName) {
+    const middleParts = middleName.split(' ');
+    for (const mp of middleParts) {
+      if (mp.length === 1) initials.push(mp);
+    }
+  }
+ 
+  return { firstName, lastName, middleName, initials };
+}
+ 
+function normalizeStreetType(type: string): string {
+  const clean = normalizeString(type);
+  return STREET_TYPE_MAP[clean] || clean;
+}
+ 
+function normalizeAddress(addr: Address): string {
+  const parts = [
+    addr.streetNumber,
+    normalizeString(addr.streetName),
+    addr.streetType ? normalizeStreetType(addr.streetType) : '',
+    addr.unit ? normalizeString(addr.unit) : '',
+    normalizeString(addr.city),
+    addr.state.toLowerCase(),
+    addr.zip,
+  ].filter(Boolean);
+  return parts.join(' ');
+}
+ 
+function computeFieldMatch(valueA: string, valueB: string, normalizeFn?: (v: string) => string): FieldMatch {
+  const normFn = normalizeFn || normalizeString;
+  const normalizedA = normFn(valueA);
+  const normalizedB = normFn(valueB);
+ 
+  if (!normalizedA && !normalizedB) return { valueA, valueB, normalizedA, normalizedB, score: 1.0 };
+  if (!normalizedA || !normalizedB) return { valueA, valueB, normalizedA, normalizedB, score: 0.0 };
+ 
+  if (normalizedA === normalizedB) return { valueA, valueB, normalizedA, normalizedB, score: 1.0 };
+ 
+  const dist = levenshteinDistance(normalizedA, normalizedB);
+  const maxLen = Math.max(normalizedA.length, normalizedB.length);
+  const score = similarityScore(dist, maxLen);
+ 
+  return { valueA, valueB, normalizedA, normalizedB, score: Math.round(score * 1000) / 1000 };
+}
+ 
+function haversineDistance(lat1: number, lon1: number, lat2: number, lon2: number): number {
+  const R = 6371000;
+  const dLat = ((lat2 - lat1) * Math.PI) / 180;
+  const dLon = ((lon2 - lon1) * Math.PI) / 180;
+  const a =
+    Math.sin(dLat / 2) * Math.sin(dLat / 2) +
+    Math.cos((lat1 * Math.PI) / 180) *
+      Math.cos((lat2 * Math.PI) / 180) *
+      Math.sin(dLon / 2) *
+      Math.sin(dLon / 2);
+  const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
+  return R * c;
+}
+ 
+function computeNameScore(tokensA: NormalizedTokens, tokensB: NormalizedTokens): number {
+  const firstScore = computeFieldMatch(tokensA.firstName, tokensB.firstName).score;
+  const lastScore = computeFieldMatch(tokensA.lastName, tokensB.lastName).score;
+  const middleScore = computeFieldMatch(tokensA.middleName, tokensB.middleName).score;
+ 
+  let initialMatchScore = 1.0;
+  if (tokensA.initials.length > 0 || tokensB.initials.length > 0) {
+    const allInitialsA = new Set(tokensA.initials.map(i => i.toLowerCase()));
+    const allInitialsB = new Set(tokensB.initials.map(i => i.toLowerCase()));
+    let matched = 0;
+    for (const init of allInitialsA) {
+      Iif (allInitialsB.has(init)) matched++;
+    }
+    const total = Math.max(allInitialsA.size, allInitialsB.size);
+    initialMatchScore = total > 0 ? matched / total : 1.0;
+  }
+ 
+  const weighted = (lastScore * 0.45) + (firstScore * 0.35) + (middleScore * 0.1) + (initialMatchScore * 0.1);
+  return Math.round(weighted * 1000) / 1000;
+}
+ 
+function computeAddressScore(addrA: Address, addrB: Address, config: MatchingConfig): { score: number; geocodingDistance?: number } {
+  const numberMatch = computeFieldMatch(addrA.streetNumber, addrB.streetNumber).score;
+  const streetMatch = computeFieldMatch(addrA.streetName, addrB.streetName, normalizeString).score;
+  const typeMatch = computeFieldMatch(
+    addrA.streetType ? normalizeStreetType(addrA.streetType) : '',
+    addrB.streetType ? normalizeStreetType(addrB.streetType) : '',
+  ).score;
+  const unitMatch = computeFieldMatch(addrA.unit || '', addrB.unit || '').score;
+  const cityMatch = computeFieldMatch(addrA.city, addrB.city).score;
+  const stateMatch = computeFieldMatch(addrA.state, addrB.state).score;
+  const zipMatch = computeFieldMatch(addrA.zip, addrB.zip).score;
+ 
+  let geocodingDistance: number | undefined;
+  let geoScore = 0.0;
+ 
+  if (addrA.latitude && addrA.longitude && addrB.latitude && addrB.longitude) {
+    geocodingDistance = haversineDistance(addrA.latitude, addrA.longitude, addrB.latitude, addrB.longitude);
+    const maxDist = config.geocodingRadiusMeters;
+    geoScore = geocodingDistance <= maxDist ? 1.0 : Math.max(0, 1.0 - (geocodingDistance - maxDist) / (maxDist * 5));
+  }
+ 
+  const weighted =
+    (numberMatch * 0.2) +
+    (streetMatch * 0.25) +
+    (typeMatch * 0.1) +
+    (unitMatch * 0.1) +
+    (cityMatch * 0.1) +
+    (stateMatch * 0.1) +
+    (zipMatch * 0.1) +
+    (geoScore * (geocodingDistance !== undefined ? 0.05 : 0));
+ 
+  return { score: Math.round(weighted * 1000) / 1000, geocodingDistance };
+}
+ 
+export function matchRecords(
+  nameA: string,
+  addressA: Address,
+  nameB: string,
+  addressB: Address,
+  config?: Partial<MatchingConfig>,
+): MatchResult {
+  const effectiveConfig = { ...DEFAULT_CONFIG, ...config };
+ 
+  const tokensA = parseName(nameA);
+  const tokensB = parseName(nameB);
+ 
+  const nameScore = computeNameScore(tokensA, tokensB);
+ 
+  const { score: addressScore, geocodingDistance } = computeAddressScore(addressA, addressB, effectiveConfig);
+ 
+  const overallConfidence = Math.round((nameScore * 0.5 + addressScore * 0.5) * 1000) / 1000;
+ 
+  const firstMatch = computeFieldMatch(tokensA.firstName, tokensB.firstName);
+  const lastMatch = computeFieldMatch(tokensA.lastName, tokensB.lastName);
+  const middleMatch = computeFieldMatch(tokensA.middleName, tokensB.middleName);
+  const numberMatch = computeFieldMatch(addressA.streetNumber, addressB.streetNumber);
+  const streetMatch = computeFieldMatch(addressA.streetName, addressB.streetName, normalizeString);
+  const typeMatch = computeFieldMatch(
+    addressA.streetType ? normalizeStreetType(addressA.streetType) : '',
+    addressB.streetType ? normalizeStreetType(addressB.streetType) : '',
+  );
+  const unitMatch = computeFieldMatch(addressA.unit || '', addressB.unit || '');
+  const cityMatch = computeFieldMatch(addressA.city, addressB.city);
+  const stateMatch = computeFieldMatch(addressA.state, addressB.state);
+  const zipMatch = computeFieldMatch(addressA.zip, addressB.zip);
+ 
+  const normalizedA = normalizeAddress(addressA);
+  const normalizedB = normalizeAddress(addressB);
+ 
+  const dist = levenshteinDistance(
+    normalizeString(nameA),
+    normalizeString(nameB),
+  );
+ 
+  const details: MatchDetails = {
+    nameNormalized: [normalizeString(nameA), normalizeString(nameB)],
+    addressNormalized: [normalizedA, normalizedB],
+    levenshteinDistance: dist,
+    geocodingDistance,
+    fields: {
+      firstName: firstMatch,
+      lastName: lastMatch,
+      middleName: middleMatch,
+      streetNumber: numberMatch,
+      streetName: streetMatch,
+      streetType: typeMatch,
+      unit: unitMatch,
+      city: cityMatch,
+      state: stateMatch,
+      zip: zipMatch,
+    },
+  };
+ 
+  return {
+    nameScore,
+    addressScore,
+    overallConfidence,
+    isMatch: overallConfidence >= effectiveConfig.overallThreshold,
+    details,
+  };
+}
+ 
+export function getConfigForPropertyType(type: PropertyType): MatchingConfig {
+  return { ...DEFAULT_CONFIG, ...PROPERTY_TYPE_CONFIGS[type] };
+}
+ 
+export { parseName, normalizeString, normalizeStreetType, levenshteinDistance, similarityScore };
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/services/hometitle/coverage/prettify.css b/services/hometitle/coverage/prettify.css new file mode 100644 index 0000000..b317a7c --- /dev/null +++ b/services/hometitle/coverage/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/services/hometitle/coverage/prettify.js b/services/hometitle/coverage/prettify.js new file mode 100644 index 0000000..b322523 --- /dev/null +++ b/services/hometitle/coverage/prettify.js @@ -0,0 +1,2 @@ +/* eslint-disable */ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/services/hometitle/coverage/sort-arrow-sprite.png b/services/hometitle/coverage/sort-arrow-sprite.png new file mode 100644 index 0000000..6ed6831 Binary files /dev/null and b/services/hometitle/coverage/sort-arrow-sprite.png differ diff --git a/services/hometitle/coverage/sorter.js b/services/hometitle/coverage/sorter.js new file mode 100644 index 0000000..4ed70ae --- /dev/null +++ b/services/hometitle/coverage/sorter.js @@ -0,0 +1,210 @@ +/* eslint-disable */ +var addSorting = (function() { + 'use strict'; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { + return document.querySelector('.coverage-summary'); + } + // returns the thead element of the summary table + function getTableHeader() { + return getTable().querySelector('thead tr'); + } + // returns the tbody element of the summary table + function getTableBody() { + return getTable().querySelector('tbody'); + } + // returns the th element for nth column + function getNthColumn(n) { + return getTableHeader().querySelectorAll('th')[n]; + } + + function onFilterInput() { + const searchValue = document.getElementById('fileSearch').value; + const rows = document.getElementsByTagName('tbody')[0].children; + + // Try to create a RegExp from the searchValue. If it fails (invalid regex), + // it will be treated as a plain text search + let searchRegex; + try { + searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive + } catch (error) { + searchRegex = null; + } + + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + let isMatch = false; + + if (searchRegex) { + // If a valid regex was created, use it for matching + isMatch = searchRegex.test(row.textContent); + } else { + // Otherwise, fall back to the original plain text search + isMatch = row.textContent + .toLowerCase() + .includes(searchValue.toLowerCase()); + } + + row.style.display = isMatch ? '' : 'none'; + } + } + + // loads the search box + function addSearchBox() { + var template = document.getElementById('filterTemplate'); + var templateClone = template.content.cloneNode(true); + templateClone.getElementById('fileSearch').oninput = onFilterInput; + template.parentElement.appendChild(templateClone); + } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = + colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function(a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function(a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc + ? ' sorted-desc' + : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function() { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i = 0; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function() { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(); + addSearchBox(); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/services/hometitle/coverage/types.ts.html b/services/hometitle/coverage/types.ts.html new file mode 100644 index 0000000..4fce112 --- /dev/null +++ b/services/hometitle/coverage/types.ts.html @@ -0,0 +1,427 @@ + + + + + + Code coverage report for types.ts + + + + + + + + + +
+
+

All files types.ts

+
+ +
+ 0% + Statements + 0/0 +
+ + +
+ 0% + Branches + 0/0 +
+ + +
+ 0% + Functions + 0/0 +
+ + +
+ 0% + Lines + 0/0 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  + 
export interface PropertyRecord {
+  id: string;
+  ownerName: string;
+  address: Address;
+  deedDate?: string;
+  taxId?: string;
+  propertyType: PropertyType;
+  metadata?: Record<string, unknown>;
+}
+ 
+export interface Address {
+  streetNumber: string;
+  streetName: string;
+  streetType?: string;
+  unit?: string;
+  city: string;
+  state: string;
+  zip: string;
+  latitude?: number;
+  longitude?: number;
+}
+ 
+export type PropertyType = 'residential' | 'commercial' | 'land' | 'multi-family';
+ 
+export interface PropertySnapshot {
+  id: string;
+  propertyId: string;
+  capturedAt: string;
+  ownerName: string;
+  address: Address;
+  deedDate?: string;
+  taxId?: string;
+  propertyType: PropertyType;
+  taxAmount?: number;
+  lienCount?: number;
+}
+ 
+export interface MatchResult {
+  nameScore: number;
+  addressScore: number;
+  overallConfidence: number;
+  isMatch: boolean;
+  details: MatchDetails;
+}
+ 
+export interface MatchDetails {
+  nameNormalized: string[];
+  addressNormalized: string[];
+  levenshteinDistance: number;
+  geocodingDistance?: number;
+  fields: {
+    firstName: FieldMatch;
+    lastName: FieldMatch;
+    middleName: FieldMatch;
+    streetNumber: FieldMatch;
+    streetName: FieldMatch;
+    streetType: FieldMatch;
+    unit: FieldMatch;
+    city: FieldMatch;
+    state: FieldMatch;
+    zip: FieldMatch;
+  };
+}
+ 
+export interface FieldMatch {
+  valueA: string;
+  valueB: string;
+  normalizedA: string;
+  normalizedB: string;
+  score: number;
+}
+ 
+export interface ChangeDetectionResult {
+  propertyId: string;
+  changeType: ChangeType;
+  severity: Severity;
+  confidence: number;
+  changes: PropertyChange[];
+  previousSnapshot: PropertySnapshot;
+  currentSnapshot: PropertySnapshot;
+  detectedAt: string;
+}
+ 
+export type ChangeType = 'tax_change' | 'deed_change' | 'ownership_transfer' | 'lien_filing' | 'metadata_change';
+ 
+export type Severity = 'minor' | 'moderate' | 'major';
+ 
+export interface PropertyChange {
+  field: string;
+  oldValue: unknown;
+  newValue: unknown;
+  changeType: ChangeType;
+}
+ 
+export interface MatchingConfig {
+  nameThreshold: number;
+  addressThreshold: number;
+  overallThreshold: number;
+  geocodingRadiusMeters: number;
+}
+ 
+export interface DetectionConfig {
+  ownershipNameThreshold: number;
+  deedDateSensitivity: number;
+  taxAmountChangePercent: number;
+  severityOverrides?: Record<ChangeType, Severity>;
+}
+ 
+export interface NormalizedTokens {
+  firstName: string;
+  lastName: string;
+  middleName: string;
+  initials: string[];
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/services/hometitle/package.json b/services/hometitle/package.json new file mode 100644 index 0000000..1e01891 --- /dev/null +++ b/services/hometitle/package.json @@ -0,0 +1,22 @@ +{ + "name": "@shieldai/hometitle", + "version": "0.1.0", + "main": "./dist/index.js", + "types": "./dist/index.js", + "scripts": { + "build": "tsc", + "test": "vitest run", + "test:coverage": "vitest run --coverage", + "lint": "eslint src/" + }, + "dependencies": { + "@shieldai/types": "workspace:*" + }, + "devDependencies": { + "vitest": "^4.1.5", + "@vitest/coverage-v8": "^4.1.5" + }, + "exports": { + ".": "./src/index.ts" + } +} diff --git a/services/hometitle/src/change-detector.ts b/services/hometitle/src/change-detector.ts new file mode 100644 index 0000000..93be0a2 --- /dev/null +++ b/services/hometitle/src/change-detector.ts @@ -0,0 +1,202 @@ +import { + PropertySnapshot, + ChangeDetectionResult, + ChangeType, + Severity, + PropertyChange, + DetectionConfig, + Address, +} from './types'; +import { matchRecords } from './matcher.service'; + +const DEFAULT_DETECTION_CONFIG: DetectionConfig = { + ownershipNameThreshold: 0.7, + deedDateSensitivity: 0.9, + taxAmountChangePercent: 15, +}; + +function classifyFieldChange(field: string, oldValue: unknown, newValue: unknown, config: DetectionConfig): PropertyChange { + let changeType: ChangeType; + + switch (field) { + case 'ownerName': + changeType = + typeof oldValue === 'string' && typeof newValue === 'string' + ? isSignificantNameChange(oldValue, newValue, config) + ? 'ownership_transfer' + : 'metadata_change' + : 'ownership_transfer'; + break; + case 'deedDate': + changeType = 'deed_change'; + break; + case 'taxAmount': + changeType = 'tax_change'; + break; + case 'lienCount': + changeType = (newValue as number) > (oldValue as number) ? 'lien_filing' : 'metadata_change'; + break; + case 'taxId': + changeType = 'deed_change'; + break; + default: + changeType = 'metadata_change'; + } + + return { field, oldValue, newValue, changeType }; +} + +function isSignificantNameChange(oldName: string, newName: string, config: DetectionConfig): boolean { + const dummyAddress: Address = { + streetNumber: '0', + streetName: 'dummy', + city: 'dummy', + state: 'XX', + zip: '00000', + }; + + const result = matchRecords(oldName, dummyAddress, newName, dummyAddress); + return result.nameScore < config.ownershipNameThreshold; +} + +function determineSeverity(changes: PropertyChange[], config: DetectionConfig): Severity { + const severityOverrides = config.severityOverrides || {}; + + const typeToSeverity: Record = { + ownership_transfer: severityOverrides['ownership_transfer'] || 'major', + deed_change: severityOverrides['deed_change'] || 'moderate', + lien_filing: severityOverrides['lien_filing'] || 'moderate', + tax_change: severityOverrides['tax_change'] || 'minor', + metadata_change: severityOverrides['metadata_change'] || 'minor', + }; + + const severityOrder: Severity[] = ['major', 'moderate', 'minor']; + + for (const change of changes) { + const sev = typeToSeverity[change.changeType]; + const idx = severityOrder.indexOf(sev); + if (idx === 0) return 'major'; + } + + for (const change of changes) { + const sev = typeToSeverity[change.changeType]; + if (sev === 'moderate') return 'moderate'; + } + + return 'minor'; +} + +function computeChangeConfidence(changes: PropertyChange[], config: DetectionConfig): number { + if (changes.length === 0) return 0; + + let totalConfidence = 0; + for (const change of changes) { + switch (change.changeType) { + case 'ownership_transfer': + totalConfidence += 0.95; + break; + case 'deed_change': + totalConfidence += config.deedDateSensitivity; + break; + case 'tax_change': { + const oldVal = change.oldValue as number; + const newVal = change.newValue as number; + const pctChange = oldVal ? Math.abs(newVal - oldVal) / oldVal * 100 : 100; + totalConfidence += pctChange >= config.taxAmountChangePercent ? 0.85 : 0.5; + break; + } + case 'lien_filing': + totalConfidence += 0.9; + break; + default: + totalConfidence += 0.4; + } + } + + return Math.round((totalConfidence / changes.length) * 1000) / 1000; +} + +export function detectChanges( + previous: PropertySnapshot, + current: PropertySnapshot, + config?: Partial, +): ChangeDetectionResult { + const effectiveConfig = { ...DEFAULT_DETECTION_CONFIG, ...config }; + const changes: PropertyChange[] = []; + + const fieldsToCompare: (keyof Omit)[] = [ + 'ownerName', + 'deedDate', + 'taxId', + 'taxAmount', + 'lienCount', + 'propertyType', + ]; + + for (const field of fieldsToCompare) { + const oldValue = previous[field]; + const newValue = current[field]; + + if (oldValue !== newValue) { + changes.push(classifyFieldChange(field, oldValue, newValue, effectiveConfig)); + } + } + + const addressChanges = detectAddressChanges(previous.address, current.address); + changes.push(...addressChanges); + + const severity = determineSeverity(changes, effectiveConfig); + const confidence = computeChangeConfidence(changes, effectiveConfig); + + let changeType: ChangeType = 'metadata_change'; + if (changes.some(c => c.changeType === 'ownership_transfer')) { + changeType = 'ownership_transfer'; + } else if (changes.some(c => c.changeType === 'deed_change')) { + changeType = 'deed_change'; + } else if (changes.some(c => c.changeType === 'lien_filing')) { + changeType = 'lien_filing'; + } else if (changes.some(c => c.changeType === 'tax_change')) { + changeType = 'tax_change'; + } + + return { + propertyId: previous.propertyId, + changeType, + severity, + confidence, + changes, + previousSnapshot: previous, + currentSnapshot: current, + detectedAt: new Date().toISOString(), + }; +} + +function detectAddressChanges(oldAddr: Address, newAddr: Address): PropertyChange[] { + const changes: PropertyChange[] = []; + + const addressFields: (keyof Address)[] = ['streetNumber', 'streetName', 'streetType', 'unit', 'city', 'state', 'zip']; + + for (const field of addressFields) { + const oldVal = oldAddr[field]; + const newVal = newAddr[field]; + if (oldVal !== newVal) { + changes.push({ + field: `address.${field}`, + oldValue: oldVal, + newValue: newVal, + changeType: 'metadata_change', + }); + } + } + + return changes; +} + +export function shouldTriggerAlert(result: ChangeDetectionResult, minSeverity: Severity = 'moderate'): boolean { + const severityOrder: Severity[] = ['minor', 'moderate', 'major']; + const resultIdx = severityOrder.indexOf(result.severity); + const minIdx = severityOrder.indexOf(minSeverity); + return resultIdx >= minIdx && result.confidence >= 0.7; +} + +export { classifyFieldChange, determineSeverity, computeChangeConfidence }; diff --git a/services/hometitle/src/index.ts b/services/hometitle/src/index.ts new file mode 100644 index 0000000..c5f8ba1 --- /dev/null +++ b/services/hometitle/src/index.ts @@ -0,0 +1,34 @@ +export { + matchRecords, + getConfigForPropertyType, + parseName, + normalizeString, + normalizeStreetType, + levenshteinDistance, + similarityScore, +} from './matcher.service'; + +export { + detectChanges, + shouldTriggerAlert, + classifyFieldChange, + determineSeverity, + computeChangeConfidence, +} from './change-detector'; + +export type { + PropertyRecord, + Address, + PropertyType, + PropertySnapshot, + MatchResult, + MatchDetails, + FieldMatch, + ChangeDetectionResult, + ChangeType, + Severity, + PropertyChange, + MatchingConfig, + DetectionConfig, + NormalizedTokens, +} from './types'; diff --git a/services/hometitle/src/matcher.service.ts b/services/hometitle/src/matcher.service.ts new file mode 100644 index 0000000..311b63d --- /dev/null +++ b/services/hometitle/src/matcher.service.ts @@ -0,0 +1,309 @@ +import { + Address, + MatchResult, + MatchDetails, + FieldMatch, + MatchingConfig, + NormalizedTokens, + PropertyType, +} from './types'; + +const DEFAULT_CONFIG: MatchingConfig = { + nameThreshold: 0.85, + addressThreshold: 0.9, + overallThreshold: 0.85, + geocodingRadiusMeters: 100, +}; + +const COMMON_PREFIXES = new Set([ + 'mr', 'mrs', 'ms', 'miss', 'dr', 'prof', 'jr', 'sr', 'junior', 'senior', + 'ii', 'iii', 'iv', 'rev', 'st', 'hon', 'esq', +]); + +const COMMON_SUFFIXES = new Set([ + 'jr', 'sr', 'junior', 'senior', 'ii', 'iii', 'iv', 'v', 'esq', + 'phd', 'md', 'llm', 'cpa', +]); + +const STREET_TYPE_MAP: Record = { + 'st': 'street', 'street': 'street', + 'ave': 'avenue', 'avenue': 'avenue', + 'blvd': 'boulevard', 'boulevard': 'boulevard', + 'dr': 'drive', 'drive': 'drive', + 'ln': 'lane', 'lane': 'lane', + 'ct': 'court', 'court': 'court', + 'pl': 'place', 'place': 'place', + 'rd': 'road', 'road': 'road', + 'way': 'way', + 'trl': 'trail', 'trail': 'trail', + 'hwy': 'highway', 'highway': 'highway', + 'pkwy': 'parkway', 'parkway': 'parkway', + 'cir': 'circle', 'circle': 'circle', + 'sq': 'square', 'square': 'square', + 'ter': 'terrace', 'terrace': 'terrace', +}; + +const PROPERTY_TYPE_CONFIGS: Record> = { + 'residential': { nameThreshold: 0.85, addressThreshold: 0.9 }, + 'commercial': { nameThreshold: 0.8, addressThreshold: 0.9 }, + 'land': { nameThreshold: 0.8, addressThreshold: 0.85 }, + 'multi-family': { nameThreshold: 0.8, addressThreshold: 0.9 }, +}; + +function levenshteinDistance(a: string, b: string): number { + const matrix: number[][] = Array.from({ length: b.length + 1 }, (_, i) => + Array.from({ length: a.length + 1 }, (_, j) => (i === 0 ? j : j === 0 ? i : 0)) + ); + + for (let i = 1; i <= b.length; i++) { + for (let j = 1; j <= a.length; j++) { + const cost = a[j - 1] === b[i - 1] ? 0 : 1; + matrix[i][j] = Math.min( + matrix[i - 1][j] + 1, + matrix[i][j - 1] + 1, + matrix[i - 1][j - 1] + cost, + ); + } + } + + return matrix[b.length][a.length]; +} + +function similarityScore(distance: number, maxLen: number): number { + if (maxLen === 0) return 1.0; + return 1.0 - distance / maxLen; +} + +function normalizeString(str: string): string { + return str + .toLowerCase() + .replace(/[''']/g, '') + .replace(/[^a-z0-9\s]/g, ' ') + .replace(/\s+/g, ' ') + .trim(); +} + +function parseName(name: string): NormalizedTokens { + const clean = normalizeString(name); + const parts = clean.split(' ').filter(Boolean); + + let firstName = ''; + let lastName = ''; + let middleName = ''; + const initials: string[] = []; + + if (parts.length === 0) return { firstName, lastName, middleName, initials }; + + let startIdx = 0; + while (startIdx < parts.length && COMMON_PREFIXES.has(parts[startIdx])) { + startIdx++; + } + + let endIdx = parts.length; + while (endIdx > startIdx + 1 && COMMON_SUFFIXES.has(parts[endIdx - 1])) { + endIdx--; + } + + const coreParts = parts.slice(startIdx, endIdx); + + if (coreParts.length === 1) { + lastName = coreParts[0]; + } else if (coreParts.length === 2) { + firstName = coreParts[0]; + lastName = coreParts[1]; + } else { + firstName = coreParts[0]; + lastName = coreParts[coreParts.length - 1]; + middleName = coreParts.slice(1, -1).join(' '); + } + + if (firstName.length === 1) { + initials.push(firstName); + } + if (middleName) { + const middleParts = middleName.split(' '); + for (const mp of middleParts) { + if (mp.length === 1) initials.push(mp); + } + } + + return { firstName, lastName, middleName, initials }; +} + +function normalizeStreetType(type: string): string { + const clean = normalizeString(type); + return STREET_TYPE_MAP[clean] || clean; +} + +function normalizeAddress(addr: Address): string { + const parts = [ + addr.streetNumber, + normalizeString(addr.streetName), + addr.streetType ? normalizeStreetType(addr.streetType) : '', + addr.unit ? normalizeString(addr.unit) : '', + normalizeString(addr.city), + addr.state.toLowerCase(), + addr.zip, + ].filter(Boolean); + return parts.join(' '); +} + +function computeFieldMatch(valueA: string, valueB: string, normalizeFn?: (v: string) => string): FieldMatch { + const normFn = normalizeFn || normalizeString; + const normalizedA = normFn(valueA); + const normalizedB = normFn(valueB); + + if (!normalizedA && !normalizedB) return { valueA, valueB, normalizedA, normalizedB, score: 1.0 }; + if (!normalizedA || !normalizedB) return { valueA, valueB, normalizedA, normalizedB, score: 0.0 }; + + if (normalizedA === normalizedB) return { valueA, valueB, normalizedA, normalizedB, score: 1.0 }; + + const dist = levenshteinDistance(normalizedA, normalizedB); + const maxLen = Math.max(normalizedA.length, normalizedB.length); + const score = similarityScore(dist, maxLen); + + return { valueA, valueB, normalizedA, normalizedB, score: Math.round(score * 1000) / 1000 }; +} + +function haversineDistance(lat1: number, lon1: number, lat2: number, lon2: number): number { + const R = 6371000; + const dLat = ((lat2 - lat1) * Math.PI) / 180; + const dLon = ((lon2 - lon1) * Math.PI) / 180; + const a = + Math.sin(dLat / 2) * Math.sin(dLat / 2) + + Math.cos((lat1 * Math.PI) / 180) * + Math.cos((lat2 * Math.PI) / 180) * + Math.sin(dLon / 2) * + Math.sin(dLon / 2); + const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); + return R * c; +} + +function computeNameScore(tokensA: NormalizedTokens, tokensB: NormalizedTokens): number { + const firstScore = computeFieldMatch(tokensA.firstName, tokensB.firstName).score; + const lastScore = computeFieldMatch(tokensA.lastName, tokensB.lastName).score; + const middleScore = computeFieldMatch(tokensA.middleName, tokensB.middleName).score; + + let initialMatchScore = 1.0; + if (tokensA.initials.length > 0 || tokensB.initials.length > 0) { + const allInitialsA = new Set(tokensA.initials.map(i => i.toLowerCase())); + const allInitialsB = new Set(tokensB.initials.map(i => i.toLowerCase())); + let matched = 0; + for (const init of allInitialsA) { + if (allInitialsB.has(init)) matched++; + } + const total = Math.max(allInitialsA.size, allInitialsB.size); + initialMatchScore = total > 0 ? matched / total : 1.0; + } + + const weighted = (lastScore * 0.45) + (firstScore * 0.35) + (middleScore * 0.1) + (initialMatchScore * 0.1); + return Math.round(weighted * 1000) / 1000; +} + +function computeAddressScore(addrA: Address, addrB: Address, config: MatchingConfig): { score: number; geocodingDistance?: number } { + const numberMatch = computeFieldMatch(addrA.streetNumber, addrB.streetNumber).score; + const streetMatch = computeFieldMatch(addrA.streetName, addrB.streetName, normalizeString).score; + const typeMatch = computeFieldMatch( + addrA.streetType ? normalizeStreetType(addrA.streetType) : '', + addrB.streetType ? normalizeStreetType(addrB.streetType) : '', + ).score; + const unitMatch = computeFieldMatch(addrA.unit || '', addrB.unit || '').score; + const cityMatch = computeFieldMatch(addrA.city, addrB.city).score; + const stateMatch = computeFieldMatch(addrA.state, addrB.state).score; + const zipMatch = computeFieldMatch(addrA.zip, addrB.zip).score; + + let geocodingDistance: number | undefined; + let geoScore = 0.0; + + if (addrA.latitude && addrA.longitude && addrB.latitude && addrB.longitude) { + geocodingDistance = haversineDistance(addrA.latitude, addrA.longitude, addrB.latitude, addrB.longitude); + const maxDist = config.geocodingRadiusMeters; + geoScore = geocodingDistance <= maxDist ? 1.0 : Math.max(0, 1.0 - (geocodingDistance - maxDist) / (maxDist * 5)); + } + + const weighted = + (numberMatch * 0.2) + + (streetMatch * 0.25) + + (typeMatch * 0.1) + + (unitMatch * 0.1) + + (cityMatch * 0.1) + + (stateMatch * 0.1) + + (zipMatch * 0.1) + + (geoScore * (geocodingDistance !== undefined ? 0.05 : 0)); + + return { score: Math.round(weighted * 1000) / 1000, geocodingDistance }; +} + +export function matchRecords( + nameA: string, + addressA: Address, + nameB: string, + addressB: Address, + config?: Partial, +): MatchResult { + const effectiveConfig = { ...DEFAULT_CONFIG, ...config }; + + const tokensA = parseName(nameA); + const tokensB = parseName(nameB); + + const nameScore = computeNameScore(tokensA, tokensB); + + const { score: addressScore, geocodingDistance } = computeAddressScore(addressA, addressB, effectiveConfig); + + const overallConfidence = Math.round((nameScore * 0.5 + addressScore * 0.5) * 1000) / 1000; + + const firstMatch = computeFieldMatch(tokensA.firstName, tokensB.firstName); + const lastMatch = computeFieldMatch(tokensA.lastName, tokensB.lastName); + const middleMatch = computeFieldMatch(tokensA.middleName, tokensB.middleName); + const numberMatch = computeFieldMatch(addressA.streetNumber, addressB.streetNumber); + const streetMatch = computeFieldMatch(addressA.streetName, addressB.streetName, normalizeString); + const typeMatch = computeFieldMatch( + addressA.streetType ? normalizeStreetType(addressA.streetType) : '', + addressB.streetType ? normalizeStreetType(addressB.streetType) : '', + ); + const unitMatch = computeFieldMatch(addressA.unit || '', addressB.unit || ''); + const cityMatch = computeFieldMatch(addressA.city, addressB.city); + const stateMatch = computeFieldMatch(addressA.state, addressB.state); + const zipMatch = computeFieldMatch(addressA.zip, addressB.zip); + + const normalizedA = normalizeAddress(addressA); + const normalizedB = normalizeAddress(addressB); + + const dist = levenshteinDistance( + normalizeString(nameA), + normalizeString(nameB), + ); + + const details: MatchDetails = { + nameNormalized: [normalizeString(nameA), normalizeString(nameB)], + addressNormalized: [normalizedA, normalizedB], + levenshteinDistance: dist, + geocodingDistance, + fields: { + firstName: firstMatch, + lastName: lastMatch, + middleName: middleMatch, + streetNumber: numberMatch, + streetName: streetMatch, + streetType: typeMatch, + unit: unitMatch, + city: cityMatch, + state: stateMatch, + zip: zipMatch, + }, + }; + + return { + nameScore, + addressScore, + overallConfidence, + isMatch: overallConfidence >= effectiveConfig.overallThreshold, + details, + }; +} + +export function getConfigForPropertyType(type: PropertyType): MatchingConfig { + return { ...DEFAULT_CONFIG, ...PROPERTY_TYPE_CONFIGS[type] }; +} + +export { parseName, normalizeString, normalizeStreetType, levenshteinDistance, similarityScore }; diff --git a/services/hometitle/src/types.ts b/services/hometitle/src/types.ts new file mode 100644 index 0000000..1b56da6 --- /dev/null +++ b/services/hometitle/src/types.ts @@ -0,0 +1,114 @@ +export interface PropertyRecord { + id: string; + ownerName: string; + address: Address; + deedDate?: string; + taxId?: string; + propertyType: PropertyType; + metadata?: Record; +} + +export interface Address { + streetNumber: string; + streetName: string; + streetType?: string; + unit?: string; + city: string; + state: string; + zip: string; + latitude?: number; + longitude?: number; +} + +export type PropertyType = 'residential' | 'commercial' | 'land' | 'multi-family'; + +export interface PropertySnapshot { + id: string; + propertyId: string; + capturedAt: string; + ownerName: string; + address: Address; + deedDate?: string; + taxId?: string; + propertyType: PropertyType; + taxAmount?: number; + lienCount?: number; +} + +export interface MatchResult { + nameScore: number; + addressScore: number; + overallConfidence: number; + isMatch: boolean; + details: MatchDetails; +} + +export interface MatchDetails { + nameNormalized: string[]; + addressNormalized: string[]; + levenshteinDistance: number; + geocodingDistance?: number; + fields: { + firstName: FieldMatch; + lastName: FieldMatch; + middleName: FieldMatch; + streetNumber: FieldMatch; + streetName: FieldMatch; + streetType: FieldMatch; + unit: FieldMatch; + city: FieldMatch; + state: FieldMatch; + zip: FieldMatch; + }; +} + +export interface FieldMatch { + valueA: string; + valueB: string; + normalizedA: string; + normalizedB: string; + score: number; +} + +export interface ChangeDetectionResult { + propertyId: string; + changeType: ChangeType; + severity: Severity; + confidence: number; + changes: PropertyChange[]; + previousSnapshot: PropertySnapshot; + currentSnapshot: PropertySnapshot; + detectedAt: string; +} + +export type ChangeType = 'tax_change' | 'deed_change' | 'ownership_transfer' | 'lien_filing' | 'metadata_change'; + +export type Severity = 'minor' | 'moderate' | 'major'; + +export interface PropertyChange { + field: string; + oldValue: unknown; + newValue: unknown; + changeType: ChangeType; +} + +export interface MatchingConfig { + nameThreshold: number; + addressThreshold: number; + overallThreshold: number; + geocodingRadiusMeters: number; +} + +export interface DetectionConfig { + ownershipNameThreshold: number; + deedDateSensitivity: number; + taxAmountChangePercent: number; + severityOverrides?: Record; +} + +export interface NormalizedTokens { + firstName: string; + lastName: string; + middleName: string; + initials: string[]; +} diff --git a/services/hometitle/test/change-detector.test.ts b/services/hometitle/test/change-detector.test.ts new file mode 100644 index 0000000..11c9337 --- /dev/null +++ b/services/hometitle/test/change-detector.test.ts @@ -0,0 +1,305 @@ +import { describe, it, expect } from 'vitest'; +import { + detectChanges, + shouldTriggerAlert, + determineSeverity, + computeChangeConfidence, +} from '../src/change-detector'; +import { PropertySnapshot, PropertyChange, DetectionConfig } from '../src/types'; + +const baselineSnapshot: PropertySnapshot = { + id: 'snap-1', + propertyId: 'prop-001', + capturedAt: '2026-01-01T00:00:00Z', + ownerName: 'John Doe', + address: { + streetNumber: '123', + streetName: 'main', + streetType: 'st', + city: 'springfield', + state: 'IL', + zip: '62701', + }, + deedDate: '2020-03-15', + taxId: 'tax-123', + propertyType: 'residential', + taxAmount: 2500, + lienCount: 0, +}; + +describe('detectChanges', () => { + it('detects ownership transfer via name change', () => { + const current = { + ...baselineSnapshot, + id: 'snap-2', + capturedAt: '2026-02-01T00:00:00Z', + ownerName: 'Jane Smith', + }; + const result = detectChanges(baselineSnapshot, current); + expect(result.changeType).toBe('ownership_transfer'); + expect(result.severity).toBe('major'); + expect(result.changes.some(c => c.field === 'ownerName')).toBe(true); + }); + + it('detects deed change via deed date update', () => { + const current = { + ...baselineSnapshot, + id: 'snap-2', + capturedAt: '2026-02-01T00:00:00Z', + deedDate: '2026-01-15', + }; + const result = detectChanges(baselineSnapshot, current); + expect(result.changes.some(c => c.changeType === 'deed_change')).toBe(true); + expect(result.severity).toBe('moderate'); + }); + + it('detects tax change', () => { + const current = { + ...baselineSnapshot, + id: 'snap-2', + capturedAt: '2026-02-01T00:00:00Z', + taxAmount: 3200, + }; + const result = detectChanges(baselineSnapshot, current); + expect(result.changes.some(c => c.changeType === 'tax_change')).toBe(true); + expect(result.severity).toBe('minor'); + }); + + it('detects lien filing when lien count increases', () => { + const current = { + ...baselineSnapshot, + id: 'snap-2', + capturedAt: '2026-02-01T00:00:00Z', + lienCount: 1, + }; + const result = detectChanges(baselineSnapshot, current); + expect(result.changes.some(c => c.changeType === 'lien_filing')).toBe(true); + expect(result.severity).toBe('moderate'); + }); + + it('detects multiple changes with highest severity', () => { + const current = { + ...baselineSnapshot, + id: 'snap-2', + capturedAt: '2026-02-01T00:00:00Z', + ownerName: 'Jane Smith', + deedDate: '2026-01-15', + taxAmount: 3200, + }; + const result = detectChanges(baselineSnapshot, current); + expect(result.severity).toBe('major'); + expect(result.changes.length).toBeGreaterThanOrEqual(3); + }); + + it('returns no changes for identical snapshots', () => { + const current = { ...baselineSnapshot, id: 'snap-2', capturedAt: '2026-02-01T00:00:00Z' }; + const result = detectChanges(baselineSnapshot, current); + expect(result.changes.length).toBe(0); + expect(result.severity).toBe('minor'); + }); + + it('detects address changes as metadata changes', () => { + const current = { + ...baselineSnapshot, + id: 'snap-2', + capturedAt: '2026-02-01T00:00:00Z', + address: { + ...baselineSnapshot.address, + streetNumber: '125', + }, + }; + const result = detectChanges(baselineSnapshot, current); + expect(result.changes.some(c => c.field === 'address.streetNumber')).toBe(true); + }); + + it('detects tax ID change as deed change', () => { + const current = { + ...baselineSnapshot, + id: 'snap-2', + capturedAt: '2026-02-01T00:00:00Z', + taxId: 'tax-456', + }; + const result = detectChanges(baselineSnapshot, current); + expect(result.changes.some(c => c.changeType === 'deed_change')).toBe(true); + }); + + it('respects configurable ownership threshold', () => { + const config: DetectionConfig = { + ownershipNameThreshold: 0.5, + deedDateSensitivity: 0.9, + taxAmountChangePercent: 15, + }; + const current = { + ...baselineSnapshot, + id: 'snap-2', + capturedAt: '2026-02-01T00:00:00Z', + ownerName: 'Jon Doe', + }; + const result = detectChanges(baselineSnapshot, current, config); + expect(result.changes.some(c => c.field === 'ownerName')).toBe(true); + }); + + it('populates previous and current snapshots in result', () => { + const current = { + ...baselineSnapshot, + id: 'snap-2', + capturedAt: '2026-02-01T00:00:00Z', + ownerName: 'Jane Smith', + }; + const result = detectChanges(baselineSnapshot, current); + expect(result.previousSnapshot).toBe(baselineSnapshot); + expect(result.currentSnapshot).toBe(current); + }); + + it('includes detectedAt timestamp', () => { + const current = { + ...baselineSnapshot, + id: 'snap-2', + capturedAt: '2026-02-01T00:00:00Z', + ownerName: 'Jane Smith', + }; + const result = detectChanges(baselineSnapshot, current); + expect(result.detectedAt).toBeDefined(); + expect(new Date(result.detectedAt).getTime()).toBeGreaterThan(0); + }); +}); + +describe('shouldTriggerAlert', () => { + it('triggers for major severity above default threshold', () => { + const result = { + propertyId: 'prop-001', + changeType: 'ownership_transfer' as const, + severity: 'major' as const, + confidence: 0.95, + changes: [], + previousSnapshot: baselineSnapshot, + currentSnapshot: baselineSnapshot, + detectedAt: new Date().toISOString(), + }; + expect(shouldTriggerAlert(result)).toBe(true); + }); + + it('triggers for moderate severity with high confidence', () => { + const result = { + propertyId: 'prop-001', + changeType: 'deed_change' as const, + severity: 'moderate' as const, + confidence: 0.85, + changes: [], + previousSnapshot: baselineSnapshot, + currentSnapshot: baselineSnapshot, + detectedAt: new Date().toISOString(), + }; + expect(shouldTriggerAlert(result)).toBe(true); + }); + + it('does not trigger for minor severity with default threshold', () => { + const result = { + propertyId: 'prop-001', + changeType: 'tax_change' as const, + severity: 'minor' as const, + confidence: 0.85, + changes: [], + previousSnapshot: baselineSnapshot, + currentSnapshot: baselineSnapshot, + detectedAt: new Date().toISOString(), + }; + expect(shouldTriggerAlert(result)).toBe(false); + }); + + it('does not trigger when confidence below 0.7', () => { + const result = { + propertyId: 'prop-001', + changeType: 'deed_change' as const, + severity: 'moderate' as const, + confidence: 0.5, + changes: [], + previousSnapshot: baselineSnapshot, + currentSnapshot: baselineSnapshot, + detectedAt: new Date().toISOString(), + }; + expect(shouldTriggerAlert(result)).toBe(false); + }); + + it('triggers minor when minSeverity set to minor', () => { + const result = { + propertyId: 'prop-001', + changeType: 'tax_change' as const, + severity: 'minor' as const, + confidence: 0.85, + changes: [], + previousSnapshot: baselineSnapshot, + currentSnapshot: baselineSnapshot, + detectedAt: new Date().toISOString(), + }; + expect(shouldTriggerAlert(result, 'minor')).toBe(true); + }); +}); + +describe('determineSeverity', () => { + it('returns major when ownership transfer present', () => { + const changes: PropertyChange[] = [ + { field: 'ownerName', oldValue: 'John', newValue: 'Jane', changeType: 'ownership_transfer' }, + ]; + expect(determineSeverity(changes, { ownershipNameThreshold: 0.7, deedDateSensitivity: 0.9, taxAmountChangePercent: 15 })).toBe('major'); + }); + + it('returns moderate when only deed change', () => { + const changes: PropertyChange[] = [ + { field: 'deedDate', oldValue: '2020-01-01', newValue: '2026-01-01', changeType: 'deed_change' }, + ]; + expect(determineSeverity(changes, { ownershipNameThreshold: 0.7, deedDateSensitivity: 0.9, taxAmountChangePercent: 15 })).toBe('moderate'); + }); + + it('returns minor when only metadata changes', () => { + const changes: PropertyChange[] = [ + { field: 'propertyType', oldValue: 'residential', newValue: 'commercial', changeType: 'metadata_change' }, + ]; + expect(determineSeverity(changes, { ownershipNameThreshold: 0.7, deedDateSensitivity: 0.9, taxAmountChangePercent: 15 })).toBe('minor'); + }); + + it('respects severity overrides', () => { + const changes: PropertyChange[] = [ + { field: 'taxAmount', oldValue: 1000, newValue: 2000, changeType: 'tax_change' }, + ]; + const config: DetectionConfig = { + ownershipNameThreshold: 0.7, + deedDateSensitivity: 0.9, + taxAmountChangePercent: 15, + severityOverrides: { tax_change: 'moderate' }, + }; + expect(determineSeverity(changes, config)).toBe('moderate'); + }); +}); + +describe('computeChangeConfidence', () => { + it('returns 0 for empty changes', () => { + expect(computeChangeConfidence([], { ownershipNameThreshold: 0.7, deedDateSensitivity: 0.9, taxAmountChangePercent: 15 })).toBe(0); + }); + + it('returns high confidence for ownership transfer', () => { + const changes: PropertyChange[] = [ + { field: 'ownerName', oldValue: 'John', newValue: 'Jane', changeType: 'ownership_transfer' }, + ]; + const conf = computeChangeConfidence(changes, { ownershipNameThreshold: 0.7, deedDateSensitivity: 0.9, taxAmountChangePercent: 15 }); + expect(conf).toBeCloseTo(0.95, 2); + }); + + it('returns high confidence for lien filing', () => { + const changes: PropertyChange[] = [ + { field: 'lienCount', oldValue: 0, newValue: 1, changeType: 'lien_filing' }, + ]; + const conf = computeChangeConfidence(changes, { ownershipNameThreshold: 0.7, deedDateSensitivity: 0.9, taxAmountChangePercent: 15 }); + expect(conf).toBeCloseTo(0.9, 2); + }); + + it('averages confidence across multiple changes', () => { + const changes: PropertyChange[] = [ + { field: 'ownerName', oldValue: 'John', newValue: 'Jane', changeType: 'ownership_transfer' }, + { field: 'taxAmount', oldValue: 1000, newValue: 2000, changeType: 'tax_change' }, + ]; + const conf = computeChangeConfidence(changes, { ownershipNameThreshold: 0.7, deedDateSensitivity: 0.9, taxAmountChangePercent: 15 }); + expect(conf).toBeGreaterThan(0.7); + expect(conf).toBeLessThan(1.0); + }); +}); diff --git a/services/hometitle/test/matcher.test.ts b/services/hometitle/test/matcher.test.ts new file mode 100644 index 0000000..0ec93d8 --- /dev/null +++ b/services/hometitle/test/matcher.test.ts @@ -0,0 +1,272 @@ +import { describe, it, expect } from 'vitest'; +import { + matchRecords, + parseName, + normalizeString, + normalizeStreetType, + levenshteinDistance, + similarityScore, + getConfigForPropertyType, +} from '../src/matcher.service'; +import { Address } from '../src/types'; + +const baselineAddress: Address = { + streetNumber: '123', + streetName: 'main', + streetType: 'st', + unit: 'apt 4b', + city: 'springfield', + state: 'IL', + zip: '62701', + latitude: 39.7817, + longitude: -89.6501, +}; + +describe('levenshteinDistance', () => { + it('returns 0 for identical strings', () => { + expect(levenshteinDistance('hello', 'hello')).toBe(0); + }); + + it('computes distance for different strings', () => { + expect(levenshteinDistance('kitten', 'sitting')).toBe(3); + }); + + it('handles empty strings', () => { + expect(levenshteinDistance('', 'hello')).toBe(5); + expect(levenshteinDistance('hello', '')).toBe(5); + }); + + it('handles single character differences', () => { + expect(levenshteinDistance('cat', 'bat')).toBe(1); + }); +}); + +describe('similarityScore', () => { + it('returns 1.0 for zero distance', () => { + expect(similarityScore(0, 5)).toBe(1.0); + }); + + it('returns 0.0 when distance equals max length', () => { + expect(similarityScore(5, 5)).toBe(0.0); + }); + + it('returns 1.0 for empty strings', () => { + expect(similarityScore(0, 0)).toBe(1.0); + }); +}); + +describe('normalizeString', () => { + it('lowercases and trims', () => { + expect(normalizeString(' Hello World ')).toBe('hello world'); + }); + + it('removes special characters', () => { + expect(normalizeString('O\'Brien-Jr!')).toBe('obrien jr'); + }); + + it('collapses multiple spaces', () => { + expect(normalizeString('John Doe')).toBe('john doe'); + }); +}); + +describe('parseName', () => { + it('parses first and last name', () => { + const tokens = parseName('John Doe'); + expect(tokens.firstName).toBe('john'); + expect(tokens.lastName).toBe('doe'); + expect(tokens.middleName).toBe(''); + }); + + it('parses name with middle name', () => { + const tokens = parseName('John Robert Doe'); + expect(tokens.firstName).toBe('john'); + expect(tokens.lastName).toBe('doe'); + expect(tokens.middleName).toBe('robert'); + }); + + it('strips prefixes', () => { + const tokens = parseName('Dr. John Doe'); + expect(tokens.firstName).toBe('john'); + expect(tokens.lastName).toBe('doe'); + }); + + it('strips suffixes', () => { + const tokens = parseName('John Doe Jr'); + expect(tokens.firstName).toBe('john'); + expect(tokens.lastName).toBe('doe'); + }); + + it('handles single name', () => { + const tokens = parseName('Madonna'); + expect(tokens.lastName).toBe('madonna'); + expect(tokens.firstName).toBe(''); + }); + + it('extracts initials from middle names', () => { + const tokens = parseName('John M Doe'); + expect(tokens.initials).toContain('m'); + }); + + it('handles empty name', () => { + const tokens = parseName(''); + expect(tokens.firstName).toBe(''); + expect(tokens.lastName).toBe(''); + expect(tokens.middleName).toBe(''); + }); +}); + +describe('normalizeStreetType', () => { + it('expands abbreviations', () => { + expect(normalizeStreetType('st')).toBe('street'); + expect(normalizeStreetType('ave')).toBe('avenue'); + expect(normalizeStreetType('blvd')).toBe('boulevard'); + expect(normalizeStreetType('ct')).toBe('court'); + expect(normalizeStreetType('ln')).toBe('lane'); + expect(normalizeStreetType('dr')).toBe('drive'); + }); + + it('normalizes full names', () => { + expect(normalizeStreetType('Street')).toBe('street'); + expect(normalizeStreetType('Avenue')).toBe('avenue'); + }); + + it('passes through unknown types', () => { + expect(normalizeStreetType('way')).toBe('way'); + }); +}); + +describe('matchRecords', () => { + it('matches identical records with high confidence', () => { + const result = matchRecords( + 'John Doe', + { ...baselineAddress }, + 'John Doe', + { ...baselineAddress }, + ); + expect(result.nameScore).toBeCloseTo(1.0, 2); + expect(result.addressScore).toBeGreaterThan(0.95); + expect(result.isMatch).toBe(true); + }); + + it('matches names with different prefixes', () => { + const result = matchRecords( + 'Dr. John Doe', + { ...baselineAddress }, + 'John Doe', + { ...baselineAddress }, + ); + expect(result.nameScore).toBeGreaterThan(0.8); + expect(result.isMatch).toBe(true); + }); + + it('matches names with different suffixes', () => { + const result = matchRecords( + 'John Doe Jr', + { ...baselineAddress }, + 'John Doe', + { ...baselineAddress }, + ); + expect(result.nameScore).toBeGreaterThan(0.8); + }); + + it('matches names with typos via Levenshtein', () => { + const result = matchRecords( + 'Jhon Doe', + { ...baselineAddress }, + 'John Doe', + { ...baselineAddress }, + ); + expect(result.nameScore).toBeGreaterThan(0.7); + expect(result.details.levenshteinDistance).toBeGreaterThan(0); + }); + + it('handles middle initial matching', () => { + const result = matchRecords( + 'John M Doe', + { ...baselineAddress }, + 'John Michael Doe', + { ...baselineAddress }, + ); + expect(result.nameScore).toBeGreaterThan(0.7); + }); + + it('matches addresses with different street type formats', () => { + const addrA: Address = { ...baselineAddress, streetType: 'st' }; + const addrB: Address = { ...baselineAddress, streetType: 'street' }; + const result = matchRecords('John Doe', addrA, 'John Doe', addrB); + expect(result.addressScore).toBeGreaterThan(0.9); + }); + + it('uses geocoding proximity when coordinates available', () => { + const addrA: Address = { + ...baselineAddress, + latitude: 39.7817, + longitude: -89.6501, + }; + const addrB: Address = { + ...baselineAddress, + latitude: 39.782, + longitude: -89.6505, + }; + const result = matchRecords('John Doe', addrA, 'John Doe', addrB); + expect(result.details.geocodingDistance).toBeDefined(); + expect(result.details.geocodingDistance!).toBeLessThan(100); + }); + + it('returns false for completely different records', () => { + const result = matchRecords( + 'John Doe', + baselineAddress, + 'Jane Smith', + { + streetNumber: '999', + streetName: 'oak', + streetType: 'ave', + city: 'chicago', + state: 'IL', + zip: '60601', + }, + ); + expect(result.isMatch).toBe(false); + }); + + it('provides detailed field-level match info', () => { + const result = matchRecords( + 'John Doe', + baselineAddress, + 'John Doe', + baselineAddress, + ); + expect(result.details.fields.firstName.score).toBe(1.0); + expect(result.details.fields.lastName.score).toBe(1.0); + expect(result.details.fields.streetNumber.score).toBe(1.0); + }); + + it('reports normalized address strings', () => { + const result = matchRecords( + 'John Doe', + baselineAddress, + 'John Doe', + baselineAddress, + ); + expect(result.details.addressNormalized[0]).toBe(result.details.addressNormalized[1]); + }); +}); + +describe('getConfigForPropertyType', () => { + it('returns residential config with higher thresholds', () => { + const config = getConfigForPropertyType('residential'); + expect(config.nameThreshold).toBe(0.85); + expect(config.addressThreshold).toBe(0.9); + }); + + it('returns commercial config with lower name threshold', () => { + const config = getConfigForPropertyType('commercial'); + expect(config.nameThreshold).toBe(0.8); + }); + + it('returns land config with lower address threshold', () => { + const config = getConfigForPropertyType('land'); + expect(config.addressThreshold).toBe(0.85); + }); +}); diff --git a/services/hometitle/tsconfig.json b/services/hometitle/tsconfig.json new file mode 100644 index 0000000..e459899 --- /dev/null +++ b/services/hometitle/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + }, + "include": ["src/**/*.ts"] +} diff --git a/services/hometitle/vitest.config.ts b/services/hometitle/vitest.config.ts new file mode 100644 index 0000000..fe01a0a --- /dev/null +++ b/services/hometitle/vitest.config.ts @@ -0,0 +1,26 @@ +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + globals: true, + environment: 'node', + include: ['src/**/*.test.ts', 'test/**/*.test.ts'], + coverage: { + provider: 'v8', + reporter: ['text', 'json', 'html', 'lcov'], + reportsDirectory: './coverage', + include: ['src/**/*.ts'], + exclude: [ + 'src/**/*.d.ts', + '**/node_modules/**', + '**/test/**', + ], + thresholds: { + statements: 80, + branches: 80, + functions: 80, + lines: 80, + }, + }, + }, +});