Compare commits
6 Commits
1b917321cf
...
b1cfce3661
| Author | SHA1 | Date | |
|---|---|---|---|
| b1cfce3661 | |||
| d0ddb8d159 | |||
| ece12b6525 | |||
| 4844c5994c | |||
| 9858834a67 | |||
| 74949d9bcc |
@@ -23,3 +23,7 @@ SENTRY_DSN=""
|
|||||||
SENTRY_ENVIRONMENT="development"
|
SENTRY_ENVIRONMENT="development"
|
||||||
SENTRY_RELEASE="0.1.0"
|
SENTRY_RELEASE="0.1.0"
|
||||||
SENTRY_TRACES_SAMPLE_RATE="0.1"
|
SENTRY_TRACES_SAMPLE_RATE="0.1"
|
||||||
|
|
||||||
|
# Google Analytics 4
|
||||||
|
GA4_MEASUREMENT_ID=""
|
||||||
|
GA4_API_SECRET=""
|
||||||
|
|||||||
57
docs/MIXPANEL_ANALYTICS.md
Normal file
57
docs/MIXPANEL_ANALYTICS.md
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# ShieldAI Mixpanel Analytics Configuration
|
||||||
|
|
||||||
|
## Current Implementation Status
|
||||||
|
|
||||||
|
✅ **Already Implemented:**
|
||||||
|
|
||||||
|
### Backend (packages/shared-analytics)
|
||||||
|
- Full MixpanelService with Segment analytics integration
|
||||||
|
- Event taxonomy defined in `EventType` enum:
|
||||||
|
- User events: `user_signed_up`, `user_logged_in`, `user_upgraded`, etc.
|
||||||
|
- Subscription events: `subscription_created`, `subscription_cancelled`, etc.
|
||||||
|
- Product-specific events: DarkWatch, VoicePrint, SpamShield events
|
||||||
|
- User identification and group tracking
|
||||||
|
- KPI definitions (MAU, MRR, conversion rate, churn, etc.)
|
||||||
|
|
||||||
|
### Frontend (packages/web)
|
||||||
|
- Analytics hook (`useAnalytics.ts`) with:
|
||||||
|
- Mixpanel initialization via `VITE_MIXPANEL_TOKEN`
|
||||||
|
- Event tracking (`trackEvent`)
|
||||||
|
- Page view tracking (`trackPageView`)
|
||||||
|
- Waitlist signup tracking (`trackWaitlistSignup`)
|
||||||
|
- GA4, Meta Pixel, and LinkedIn Insight integration
|
||||||
|
|
||||||
|
## Required Actions
|
||||||
|
|
||||||
|
### 1. Create Mixpanel Project (Manual - Requires Account)
|
||||||
|
- Sign up for Mixpanel at https://mixpanel.com
|
||||||
|
- Create project: "ShieldAI"
|
||||||
|
- Get project token from Project Settings → Project Token
|
||||||
|
|
||||||
|
### 2. Configure Environment Variables
|
||||||
|
```bash
|
||||||
|
# Backend (.env)
|
||||||
|
MIXPANEL_TOKEN=<your-mixpanel-token>
|
||||||
|
MIXPANEL_API_SECRET=<optional-api-secret>
|
||||||
|
|
||||||
|
# Frontend (.env)
|
||||||
|
VITE_MIXPANEL_TOKEN=<your-mixpanel-token>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Event Taxonomy Documentation
|
||||||
|
See `packages/shared-analytics/src/config/analytics.config.ts` for full event definitions.
|
||||||
|
|
||||||
|
### 4. User Property Definitions
|
||||||
|
Standard properties tracked:
|
||||||
|
- `userId`: User identifier
|
||||||
|
- `sessionId`: Session identifier
|
||||||
|
- `platform`: web, mobile, desktop, api
|
||||||
|
- `version`: App version
|
||||||
|
- `environment`: development, production, staging
|
||||||
|
|
||||||
|
## Integration Points
|
||||||
|
|
||||||
|
- `DarkWatch`: Exposure detection events
|
||||||
|
- `SpamShield`: Spam detection and blocking events
|
||||||
|
- `VoicePrint`: Voice enrollment and analysis events
|
||||||
|
- `Waitlist`: Signup tracking with source attribution
|
||||||
@@ -1,66 +1,71 @@
|
|||||||
import { google } from 'googleapis';
|
import { analyticsEnv } from '../config/analytics.config';
|
||||||
import { analyticsEnv, EventType } from '../config/analytics.config';
|
|
||||||
|
const GA4_ENDPOINT = 'https://www.google-analytics.com/mp/collect';
|
||||||
|
|
||||||
// GA4 service
|
|
||||||
export class GA4Service {
|
export class GA4Service {
|
||||||
private auth: any;
|
private measurementId: string;
|
||||||
|
private apiSecret: string;
|
||||||
|
private initialized = false;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.auth = google.auth.fromAPIKey(analyticsEnv.GA4_API_SECRET || 'placeholder');
|
this.measurementId = analyticsEnv.GA4_MEASUREMENT_ID;
|
||||||
|
this.apiSecret = analyticsEnv.GA4_API_SECRET || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize GA4 client
|
|
||||||
*/
|
|
||||||
async initialize(): Promise<void> {
|
async initialize(): Promise<void> {
|
||||||
// TODO: Initialize GA4 client with measurement ID
|
if (!this.measurementId || this.measurementId === 'placeholder') {
|
||||||
console.log('GA4 client initialized');
|
console.warn('GA4: no measurement ID configured — events will be dropped');
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
/**
|
if (!this.apiSecret) {
|
||||||
* Send event to GA4
|
console.warn('GA4: no API secret configured — events will be dropped');
|
||||||
*/
|
return;
|
||||||
async sendEvent(
|
}
|
||||||
eventName: string,
|
this.initialized = true;
|
||||||
params: {
|
}
|
||||||
client_id: string;
|
|
||||||
[key: string]: any;
|
private async post(eventName: string, params: Record<string, unknown>): Promise<void> {
|
||||||
|
if (!this.initialized) {
|
||||||
|
console.log('GA4 (dry):', eventName, params);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const url = `${GA4_ENDPOINT}?measurement_id=${this.measurementId}&api_secret=${this.apiSecret}`;
|
||||||
|
const res = await fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({
|
||||||
|
client_id: params.client_id || 'system',
|
||||||
|
events: [{ name: eventName, params }],
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!res.ok && res.status !== 204) {
|
||||||
|
console.error(`GA4 error: ${res.status} for event ${eventName}`);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('GA4 send failed:', err);
|
||||||
}
|
}
|
||||||
): Promise<void> {
|
|
||||||
// TODO: Implement GA4 event tracking
|
|
||||||
// const measurementId = analyticsEnv.GA4_MEASUREMENT_ID;
|
|
||||||
// await fetch(`https://www.google-analytics.com/mp/collect?measurement_id=${measurementId}&api_secret=${analyticsEnv.GA4_API_SECRET}`, {
|
|
||||||
// method: 'POST',
|
|
||||||
// body: JSON.stringify({
|
|
||||||
// events: [{ name: eventName, params }],
|
|
||||||
// }),
|
|
||||||
// });
|
|
||||||
|
|
||||||
console.log('GA4 event:', eventName, params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Track page view
|
|
||||||
*/
|
|
||||||
async trackPageView(clientId: string, path: string, title?: string): Promise<void> {
|
async trackPageView(clientId: string, path: string, title?: string): Promise<void> {
|
||||||
await this.sendEvent('page_view', {
|
await this.post('page_view', {
|
||||||
client_id: clientId,
|
client_id: clientId,
|
||||||
page_path: path,
|
page_path: path,
|
||||||
page_title: title,
|
page_title: title || undefined,
|
||||||
|
engagement_time_msec: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Track e-commerce purchase
|
|
||||||
*/
|
|
||||||
async trackPurchase(
|
async trackPurchase(
|
||||||
clientId: string,
|
clientId: string,
|
||||||
transactionId: string,
|
transactionId: string,
|
||||||
value: number,
|
value: number,
|
||||||
currency: string,
|
currency: string,
|
||||||
items: Array<{ name: string; price: number; quantity: number }>
|
items: Array<{ item_id: string; item_name: string; price: number; quantity: number }>,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await this.sendEvent('purchase', {
|
await this.post('purchase', {
|
||||||
client_id: clientId,
|
client_id: clientId,
|
||||||
transaction_id: transactionId,
|
transaction_id: transactionId,
|
||||||
value,
|
value,
|
||||||
@@ -69,36 +74,61 @@ export class GA4Service {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
async trackWaitlistSignup(clientId: string, email?: string): Promise<void> {
|
||||||
* Track conversion
|
await this.post('waitlist_signup', {
|
||||||
*/
|
client_id: clientId,
|
||||||
|
email_hash: email ? await this.sha256(email) : undefined,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async trackConversion(
|
async trackConversion(
|
||||||
clientId: string,
|
clientId: string,
|
||||||
conversionName: string,
|
conversionName: string,
|
||||||
metadata?: Record<string, any>
|
metadata?: Record<string, unknown>,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await this.sendEvent('conversion', {
|
await this.post(conversionName, {
|
||||||
client_id: clientId,
|
client_id: clientId,
|
||||||
conversion_name: conversionName,
|
|
||||||
...metadata,
|
...metadata,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get analytics data (for dashboards)
|
|
||||||
*/
|
|
||||||
async getMetrics(
|
async getMetrics(
|
||||||
dateRange: { startDate: string; endDate: string },
|
dateRange: { startDate: string; endDate: string },
|
||||||
metrics: string[],
|
metrics: string[],
|
||||||
dimensions?: string[]
|
dimensions?: string[],
|
||||||
): Promise<any> {
|
): Promise<{ rows: unknown[]; totals: unknown[] }> {
|
||||||
// TODO: Implement GA4 Analytics Data API
|
if (!this.measurementId || this.measurementId === 'placeholder') {
|
||||||
return {
|
return { rows: [], totals: [] };
|
||||||
rows: [],
|
}
|
||||||
totals: [],
|
|
||||||
};
|
const DataApi = await import('@google-analytics/data').catch(() => null);
|
||||||
|
if (!DataApi) {
|
||||||
|
console.warn('GA4: @google-analytics/data not installed — cannot query metrics');
|
||||||
|
return { rows: [], totals: [] };
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const client = new DataApi.BetaAnalyticsDataClient();
|
||||||
|
const [response] = await client.runReport({
|
||||||
|
property: `properties/${this.measurementId.replace('G-', '')}`,
|
||||||
|
dateRanges: [dateRange],
|
||||||
|
metrics: metrics.map(m => ({ name: m })),
|
||||||
|
dimensions: (dimensions || []).map(d => ({ name: d })),
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
rows: response.rows || [],
|
||||||
|
totals: response.totals || [],
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
console.error('GA4 query failed:', err);
|
||||||
|
return { rows: [], totals: [] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async sha256(str: string): Promise<string> {
|
||||||
|
const buf = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(str.toLowerCase().trim()));
|
||||||
|
return Array.from(new Uint8Array(buf)).map(b => b.toString(16).padStart(2, '0')).join('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Export instance
|
|
||||||
export const ga4Service = new GA4Service();
|
export const ga4Service = new GA4Service();
|
||||||
|
|||||||
176
scripts/setup-ga4.sh
Executable file
176
scripts/setup-ga4.sh
Executable file
@@ -0,0 +1,176 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# GA4 Setup Script for ShieldAI
|
||||||
|
# Two modes:
|
||||||
|
# 1. MANUAL: Step-by-step guide for GA web console (no credentials needed)
|
||||||
|
# 2. AUTOMATED: Creates property + stream via Admin API (requires GCP service account)
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# ./scripts/setup-ga4.sh # Print manual instructions
|
||||||
|
# ./scripts/setup-ga4.sh --auto # Automated setup (needs GOOGLE_APPLICATION_CREDENTIALS)
|
||||||
|
# ./scripts/setup-ga4.sh --env-only # Just print what to put in .env
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||||
|
|
||||||
|
show_manual_guide() {
|
||||||
|
cat <<'GUIDE'
|
||||||
|
╔══════════════════════════════════════════════════════════════╗
|
||||||
|
║ ShieldAI — Manual GA4 Setup Guide ║
|
||||||
|
║ ~5 minutes in Google Analytics web console ║
|
||||||
|
╚══════════════════════════════════════════════════════════════╝
|
||||||
|
|
||||||
|
STEP 1 — Create GA4 Property
|
||||||
|
1. Go to https://analytics.google.com/
|
||||||
|
2. Admin → Create Property → "ShieldAI"
|
||||||
|
3. Set reporting time zone, currency
|
||||||
|
4. Click "Create"
|
||||||
|
|
||||||
|
STEP 2 — Configure Data Stream
|
||||||
|
1. In the new property: Admin → Data Streams → Add Stream → Web
|
||||||
|
2. Website URL: https://shieldai.com
|
||||||
|
3. Stream name: "ShieldAI Landing Page"
|
||||||
|
4. Click "Create stream"
|
||||||
|
5. Copy the Measurement ID (format: G-XXXXXXXXXX)
|
||||||
|
|
||||||
|
STEP 3 — Create API Secret
|
||||||
|
1. In the data stream details: Measurement Protocol API secrets → Create
|
||||||
|
2. Nickname: "ShieldAI Backend"
|
||||||
|
3. Copy the API Secret
|
||||||
|
|
||||||
|
STEP 4 — Set Up Conversion Events
|
||||||
|
1. In GA4: Admin → Conversions → New conversion event
|
||||||
|
2. Create: "waitlist_signup"
|
||||||
|
3. Create: "page_view" (auto-tracked by default)
|
||||||
|
4. Optionally: "conversion" (for tracked conversions)
|
||||||
|
|
||||||
|
STEP 5 — Configure Environment
|
||||||
|
Add to .env (or .env.prod for production):
|
||||||
|
GA4_MEASUREMENT_ID=G-XXXXXXXXXX
|
||||||
|
GA4_API_SECRET=<api-secret-from-step-3>
|
||||||
|
|
||||||
|
STEP 6 — Verify
|
||||||
|
curl -X POST "https://www.google-analytics.com/mp/collect?measurement_id=G-XXXXXXXXXX&api_secret=<secret>" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"client_id":"test-001","events":[{"name":"page_view"}]}'
|
||||||
|
GUIDE
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_automated() {
|
||||||
|
if [ -z "${GOOGLE_APPLICATION_CREDENTIALS:-}" ]; then
|
||||||
|
echo "ERROR: GOOGLE_APPLICATION_CREDENTIALS not set"
|
||||||
|
echo "Set it to the path of your GCP service account JSON key"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v node &>/dev/null; then
|
||||||
|
echo "ERROR: node is required for automated setup"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "--- Automated GA4 Setup ---"
|
||||||
|
echo "Using service account: $GOOGLE_APPLICATION_CREDENTIALS"
|
||||||
|
|
||||||
|
# Generate a setup script that uses the Google Admin API
|
||||||
|
cat > /tmp/setup-ga4-auto.mjs << 'SCRIPT'
|
||||||
|
import { google } from 'googleapis';
|
||||||
|
import { readFileSync, writeFileSync } from 'fs';
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const creds = JSON.parse(readFileSync(process.env.GOOGLE_APPLICATION_CREDENTIALS, 'utf-8'));
|
||||||
|
const auth = new google.auth.GoogleAuth({
|
||||||
|
credentials: creds,
|
||||||
|
scopes: ['https://www.googleapis.com/auth/analytics.edit'],
|
||||||
|
});
|
||||||
|
|
||||||
|
const analyticsAdmin = google.analyticsadmin({ version: 'v1beta', auth });
|
||||||
|
|
||||||
|
// Step 1: Create GA4 property
|
||||||
|
console.log('Creating GA4 property...');
|
||||||
|
const property = await analyticsAdmin.properties.create({
|
||||||
|
requestBody: {
|
||||||
|
displayName: 'ShieldAI',
|
||||||
|
industryCategory: 'TECHNOLOGY',
|
||||||
|
timeZone: 'America/New_York',
|
||||||
|
currencyCode: 'USD',
|
||||||
|
parent: `accounts/${creds.account_id || '103950747'}`, // Replace with actual account ID
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log(`Property created: ${property.data.name}`);
|
||||||
|
|
||||||
|
// Step 2: Create web data stream
|
||||||
|
console.log('Creating web data stream...');
|
||||||
|
const stream = await analyticsAdmin.properties.dataStreams.create({
|
||||||
|
parent: property.data.name,
|
||||||
|
requestBody: {
|
||||||
|
type: 'WEB_DATA_STREAM',
|
||||||
|
displayName: 'ShieldAI Landing Page',
|
||||||
|
webStreamData: {
|
||||||
|
defaultUri: 'https://shieldai.com',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
console.log(`Data stream created: ${stream.data.name}`);
|
||||||
|
console.log(`Measurement ID: ${stream.data.webStreamData.measurementId}`);
|
||||||
|
|
||||||
|
// Step 3: Create conversion events
|
||||||
|
console.log('Creating conversion events...');
|
||||||
|
for (const event of ['waitlist_signup']) {
|
||||||
|
try {
|
||||||
|
await analyticsAdmin.properties.conversionEvents.create({
|
||||||
|
parent: property.data.name,
|
||||||
|
requestBody: { eventName: event },
|
||||||
|
});
|
||||||
|
console.log(`Conversion event created: ${event}`);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(`Conversion event ${event} may already exist: ${e.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output results
|
||||||
|
const output = {
|
||||||
|
propertyId: property.data.name.replace('properties/', ''),
|
||||||
|
measurementId: stream.data.webStreamData.measurementId,
|
||||||
|
streamId: stream.data.name,
|
||||||
|
streamName: stream.data.displayName,
|
||||||
|
};
|
||||||
|
writeFileSync('/tmp/ga4-setup-output.json', JSON.stringify(output, null, 2));
|
||||||
|
console.log('\nResults saved to /tmp/ga4-setup-output.json');
|
||||||
|
console.log(JSON.stringify(output, null, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch(console.error);
|
||||||
|
SCRIPT
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "To run the automated setup:"
|
||||||
|
echo " 1. Update the account_id in the script above"
|
||||||
|
echo " 2. cd $PROJECT_DIR && node /tmp/setup-ga4-auto.mjs"
|
||||||
|
echo ""
|
||||||
|
echo "NOTE: You need to provide the Google Analytics account ID."
|
||||||
|
echo "Find it at: https://analytics.google.com/ → Admin → Account Settings"
|
||||||
|
}
|
||||||
|
|
||||||
|
show_env_only() {
|
||||||
|
cat <<'ENV'
|
||||||
|
Required .env additions for ShieldAI analytics:
|
||||||
|
|
||||||
|
GA4_MEASUREMENT_ID=G-XXXXXXXXXX # From GA4 data stream
|
||||||
|
GA4_API_SECRET= # From GA4 Measurement Protocol API secrets
|
||||||
|
MIXPANEL_TOKEN= # Mixpanel project token
|
||||||
|
MIXPANEL_API_SECRET= # Mixpanel project API secret
|
||||||
|
ENV
|
||||||
|
}
|
||||||
|
|
||||||
|
case "${1:-}" in
|
||||||
|
--auto)
|
||||||
|
setup_automated
|
||||||
|
;;
|
||||||
|
--env-only)
|
||||||
|
show_env_only
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
show_manual_guide
|
||||||
|
;;
|
||||||
|
esac
|
||||||
224
services/hometitle/coverage/base.css
Normal file
224
services/hometitle/coverage/base.css
Normal file
@@ -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;
|
||||||
|
}
|
||||||
87
services/hometitle/coverage/block-navigation.js
Normal file
87
services/hometitle/coverage/block-navigation.js
Normal file
@@ -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);
|
||||||
691
services/hometitle/coverage/change-detector.ts.html
Normal file
691
services/hometitle/coverage/change-detector.ts.html
Normal file
@@ -0,0 +1,691 @@
|
|||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Code coverage report for change-detector.ts</title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="stylesheet" href="prettify.css" />
|
||||||
|
<link rel="stylesheet" href="base.css" />
|
||||||
|
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<style type='text/css'>
|
||||||
|
.coverage-summary .sorter {
|
||||||
|
background-image: url(sort-arrow-sprite.png);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class='wrapper'>
|
||||||
|
<div class='pad1'>
|
||||||
|
<h1><a href="index.html">All files</a> change-detector.ts</h1>
|
||||||
|
<div class='clearfix'>
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">98.83% </span>
|
||||||
|
<span class="quiet">Statements</span>
|
||||||
|
<span class='fraction'>85/86</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">91.07% </span>
|
||||||
|
<span class="quiet">Branches</span>
|
||||||
|
<span class='fraction'>51/56</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">100% </span>
|
||||||
|
<span class="quiet">Functions</span>
|
||||||
|
<span class='fraction'>11/11</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">98.73% </span>
|
||||||
|
<span class="quiet">Lines</span>
|
||||||
|
<span class='fraction'>78/79</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<p class="quiet">
|
||||||
|
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||||
|
</p>
|
||||||
|
<template id="filterTemplate">
|
||||||
|
<div class="quiet">
|
||||||
|
Filter:
|
||||||
|
<input type="search" id="fileSearch">
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div class='status-line high'></div>
|
||||||
|
<pre><table class="coverage">
|
||||||
|
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||||
|
<a name='L2'></a><a href='#L2'>2</a>
|
||||||
|
<a name='L3'></a><a href='#L3'>3</a>
|
||||||
|
<a name='L4'></a><a href='#L4'>4</a>
|
||||||
|
<a name='L5'></a><a href='#L5'>5</a>
|
||||||
|
<a name='L6'></a><a href='#L6'>6</a>
|
||||||
|
<a name='L7'></a><a href='#L7'>7</a>
|
||||||
|
<a name='L8'></a><a href='#L8'>8</a>
|
||||||
|
<a name='L9'></a><a href='#L9'>9</a>
|
||||||
|
<a name='L10'></a><a href='#L10'>10</a>
|
||||||
|
<a name='L11'></a><a href='#L11'>11</a>
|
||||||
|
<a name='L12'></a><a href='#L12'>12</a>
|
||||||
|
<a name='L13'></a><a href='#L13'>13</a>
|
||||||
|
<a name='L14'></a><a href='#L14'>14</a>
|
||||||
|
<a name='L15'></a><a href='#L15'>15</a>
|
||||||
|
<a name='L16'></a><a href='#L16'>16</a>
|
||||||
|
<a name='L17'></a><a href='#L17'>17</a>
|
||||||
|
<a name='L18'></a><a href='#L18'>18</a>
|
||||||
|
<a name='L19'></a><a href='#L19'>19</a>
|
||||||
|
<a name='L20'></a><a href='#L20'>20</a>
|
||||||
|
<a name='L21'></a><a href='#L21'>21</a>
|
||||||
|
<a name='L22'></a><a href='#L22'>22</a>
|
||||||
|
<a name='L23'></a><a href='#L23'>23</a>
|
||||||
|
<a name='L24'></a><a href='#L24'>24</a>
|
||||||
|
<a name='L25'></a><a href='#L25'>25</a>
|
||||||
|
<a name='L26'></a><a href='#L26'>26</a>
|
||||||
|
<a name='L27'></a><a href='#L27'>27</a>
|
||||||
|
<a name='L28'></a><a href='#L28'>28</a>
|
||||||
|
<a name='L29'></a><a href='#L29'>29</a>
|
||||||
|
<a name='L30'></a><a href='#L30'>30</a>
|
||||||
|
<a name='L31'></a><a href='#L31'>31</a>
|
||||||
|
<a name='L32'></a><a href='#L32'>32</a>
|
||||||
|
<a name='L33'></a><a href='#L33'>33</a>
|
||||||
|
<a name='L34'></a><a href='#L34'>34</a>
|
||||||
|
<a name='L35'></a><a href='#L35'>35</a>
|
||||||
|
<a name='L36'></a><a href='#L36'>36</a>
|
||||||
|
<a name='L37'></a><a href='#L37'>37</a>
|
||||||
|
<a name='L38'></a><a href='#L38'>38</a>
|
||||||
|
<a name='L39'></a><a href='#L39'>39</a>
|
||||||
|
<a name='L40'></a><a href='#L40'>40</a>
|
||||||
|
<a name='L41'></a><a href='#L41'>41</a>
|
||||||
|
<a name='L42'></a><a href='#L42'>42</a>
|
||||||
|
<a name='L43'></a><a href='#L43'>43</a>
|
||||||
|
<a name='L44'></a><a href='#L44'>44</a>
|
||||||
|
<a name='L45'></a><a href='#L45'>45</a>
|
||||||
|
<a name='L46'></a><a href='#L46'>46</a>
|
||||||
|
<a name='L47'></a><a href='#L47'>47</a>
|
||||||
|
<a name='L48'></a><a href='#L48'>48</a>
|
||||||
|
<a name='L49'></a><a href='#L49'>49</a>
|
||||||
|
<a name='L50'></a><a href='#L50'>50</a>
|
||||||
|
<a name='L51'></a><a href='#L51'>51</a>
|
||||||
|
<a name='L52'></a><a href='#L52'>52</a>
|
||||||
|
<a name='L53'></a><a href='#L53'>53</a>
|
||||||
|
<a name='L54'></a><a href='#L54'>54</a>
|
||||||
|
<a name='L55'></a><a href='#L55'>55</a>
|
||||||
|
<a name='L56'></a><a href='#L56'>56</a>
|
||||||
|
<a name='L57'></a><a href='#L57'>57</a>
|
||||||
|
<a name='L58'></a><a href='#L58'>58</a>
|
||||||
|
<a name='L59'></a><a href='#L59'>59</a>
|
||||||
|
<a name='L60'></a><a href='#L60'>60</a>
|
||||||
|
<a name='L61'></a><a href='#L61'>61</a>
|
||||||
|
<a name='L62'></a><a href='#L62'>62</a>
|
||||||
|
<a name='L63'></a><a href='#L63'>63</a>
|
||||||
|
<a name='L64'></a><a href='#L64'>64</a>
|
||||||
|
<a name='L65'></a><a href='#L65'>65</a>
|
||||||
|
<a name='L66'></a><a href='#L66'>66</a>
|
||||||
|
<a name='L67'></a><a href='#L67'>67</a>
|
||||||
|
<a name='L68'></a><a href='#L68'>68</a>
|
||||||
|
<a name='L69'></a><a href='#L69'>69</a>
|
||||||
|
<a name='L70'></a><a href='#L70'>70</a>
|
||||||
|
<a name='L71'></a><a href='#L71'>71</a>
|
||||||
|
<a name='L72'></a><a href='#L72'>72</a>
|
||||||
|
<a name='L73'></a><a href='#L73'>73</a>
|
||||||
|
<a name='L74'></a><a href='#L74'>74</a>
|
||||||
|
<a name='L75'></a><a href='#L75'>75</a>
|
||||||
|
<a name='L76'></a><a href='#L76'>76</a>
|
||||||
|
<a name='L77'></a><a href='#L77'>77</a>
|
||||||
|
<a name='L78'></a><a href='#L78'>78</a>
|
||||||
|
<a name='L79'></a><a href='#L79'>79</a>
|
||||||
|
<a name='L80'></a><a href='#L80'>80</a>
|
||||||
|
<a name='L81'></a><a href='#L81'>81</a>
|
||||||
|
<a name='L82'></a><a href='#L82'>82</a>
|
||||||
|
<a name='L83'></a><a href='#L83'>83</a>
|
||||||
|
<a name='L84'></a><a href='#L84'>84</a>
|
||||||
|
<a name='L85'></a><a href='#L85'>85</a>
|
||||||
|
<a name='L86'></a><a href='#L86'>86</a>
|
||||||
|
<a name='L87'></a><a href='#L87'>87</a>
|
||||||
|
<a name='L88'></a><a href='#L88'>88</a>
|
||||||
|
<a name='L89'></a><a href='#L89'>89</a>
|
||||||
|
<a name='L90'></a><a href='#L90'>90</a>
|
||||||
|
<a name='L91'></a><a href='#L91'>91</a>
|
||||||
|
<a name='L92'></a><a href='#L92'>92</a>
|
||||||
|
<a name='L93'></a><a href='#L93'>93</a>
|
||||||
|
<a name='L94'></a><a href='#L94'>94</a>
|
||||||
|
<a name='L95'></a><a href='#L95'>95</a>
|
||||||
|
<a name='L96'></a><a href='#L96'>96</a>
|
||||||
|
<a name='L97'></a><a href='#L97'>97</a>
|
||||||
|
<a name='L98'></a><a href='#L98'>98</a>
|
||||||
|
<a name='L99'></a><a href='#L99'>99</a>
|
||||||
|
<a name='L100'></a><a href='#L100'>100</a>
|
||||||
|
<a name='L101'></a><a href='#L101'>101</a>
|
||||||
|
<a name='L102'></a><a href='#L102'>102</a>
|
||||||
|
<a name='L103'></a><a href='#L103'>103</a>
|
||||||
|
<a name='L104'></a><a href='#L104'>104</a>
|
||||||
|
<a name='L105'></a><a href='#L105'>105</a>
|
||||||
|
<a name='L106'></a><a href='#L106'>106</a>
|
||||||
|
<a name='L107'></a><a href='#L107'>107</a>
|
||||||
|
<a name='L108'></a><a href='#L108'>108</a>
|
||||||
|
<a name='L109'></a><a href='#L109'>109</a>
|
||||||
|
<a name='L110'></a><a href='#L110'>110</a>
|
||||||
|
<a name='L111'></a><a href='#L111'>111</a>
|
||||||
|
<a name='L112'></a><a href='#L112'>112</a>
|
||||||
|
<a name='L113'></a><a href='#L113'>113</a>
|
||||||
|
<a name='L114'></a><a href='#L114'>114</a>
|
||||||
|
<a name='L115'></a><a href='#L115'>115</a>
|
||||||
|
<a name='L116'></a><a href='#L116'>116</a>
|
||||||
|
<a name='L117'></a><a href='#L117'>117</a>
|
||||||
|
<a name='L118'></a><a href='#L118'>118</a>
|
||||||
|
<a name='L119'></a><a href='#L119'>119</a>
|
||||||
|
<a name='L120'></a><a href='#L120'>120</a>
|
||||||
|
<a name='L121'></a><a href='#L121'>121</a>
|
||||||
|
<a name='L122'></a><a href='#L122'>122</a>
|
||||||
|
<a name='L123'></a><a href='#L123'>123</a>
|
||||||
|
<a name='L124'></a><a href='#L124'>124</a>
|
||||||
|
<a name='L125'></a><a href='#L125'>125</a>
|
||||||
|
<a name='L126'></a><a href='#L126'>126</a>
|
||||||
|
<a name='L127'></a><a href='#L127'>127</a>
|
||||||
|
<a name='L128'></a><a href='#L128'>128</a>
|
||||||
|
<a name='L129'></a><a href='#L129'>129</a>
|
||||||
|
<a name='L130'></a><a href='#L130'>130</a>
|
||||||
|
<a name='L131'></a><a href='#L131'>131</a>
|
||||||
|
<a name='L132'></a><a href='#L132'>132</a>
|
||||||
|
<a name='L133'></a><a href='#L133'>133</a>
|
||||||
|
<a name='L134'></a><a href='#L134'>134</a>
|
||||||
|
<a name='L135'></a><a href='#L135'>135</a>
|
||||||
|
<a name='L136'></a><a href='#L136'>136</a>
|
||||||
|
<a name='L137'></a><a href='#L137'>137</a>
|
||||||
|
<a name='L138'></a><a href='#L138'>138</a>
|
||||||
|
<a name='L139'></a><a href='#L139'>139</a>
|
||||||
|
<a name='L140'></a><a href='#L140'>140</a>
|
||||||
|
<a name='L141'></a><a href='#L141'>141</a>
|
||||||
|
<a name='L142'></a><a href='#L142'>142</a>
|
||||||
|
<a name='L143'></a><a href='#L143'>143</a>
|
||||||
|
<a name='L144'></a><a href='#L144'>144</a>
|
||||||
|
<a name='L145'></a><a href='#L145'>145</a>
|
||||||
|
<a name='L146'></a><a href='#L146'>146</a>
|
||||||
|
<a name='L147'></a><a href='#L147'>147</a>
|
||||||
|
<a name='L148'></a><a href='#L148'>148</a>
|
||||||
|
<a name='L149'></a><a href='#L149'>149</a>
|
||||||
|
<a name='L150'></a><a href='#L150'>150</a>
|
||||||
|
<a name='L151'></a><a href='#L151'>151</a>
|
||||||
|
<a name='L152'></a><a href='#L152'>152</a>
|
||||||
|
<a name='L153'></a><a href='#L153'>153</a>
|
||||||
|
<a name='L154'></a><a href='#L154'>154</a>
|
||||||
|
<a name='L155'></a><a href='#L155'>155</a>
|
||||||
|
<a name='L156'></a><a href='#L156'>156</a>
|
||||||
|
<a name='L157'></a><a href='#L157'>157</a>
|
||||||
|
<a name='L158'></a><a href='#L158'>158</a>
|
||||||
|
<a name='L159'></a><a href='#L159'>159</a>
|
||||||
|
<a name='L160'></a><a href='#L160'>160</a>
|
||||||
|
<a name='L161'></a><a href='#L161'>161</a>
|
||||||
|
<a name='L162'></a><a href='#L162'>162</a>
|
||||||
|
<a name='L163'></a><a href='#L163'>163</a>
|
||||||
|
<a name='L164'></a><a href='#L164'>164</a>
|
||||||
|
<a name='L165'></a><a href='#L165'>165</a>
|
||||||
|
<a name='L166'></a><a href='#L166'>166</a>
|
||||||
|
<a name='L167'></a><a href='#L167'>167</a>
|
||||||
|
<a name='L168'></a><a href='#L168'>168</a>
|
||||||
|
<a name='L169'></a><a href='#L169'>169</a>
|
||||||
|
<a name='L170'></a><a href='#L170'>170</a>
|
||||||
|
<a name='L171'></a><a href='#L171'>171</a>
|
||||||
|
<a name='L172'></a><a href='#L172'>172</a>
|
||||||
|
<a name='L173'></a><a href='#L173'>173</a>
|
||||||
|
<a name='L174'></a><a href='#L174'>174</a>
|
||||||
|
<a name='L175'></a><a href='#L175'>175</a>
|
||||||
|
<a name='L176'></a><a href='#L176'>176</a>
|
||||||
|
<a name='L177'></a><a href='#L177'>177</a>
|
||||||
|
<a name='L178'></a><a href='#L178'>178</a>
|
||||||
|
<a name='L179'></a><a href='#L179'>179</a>
|
||||||
|
<a name='L180'></a><a href='#L180'>180</a>
|
||||||
|
<a name='L181'></a><a href='#L181'>181</a>
|
||||||
|
<a name='L182'></a><a href='#L182'>182</a>
|
||||||
|
<a name='L183'></a><a href='#L183'>183</a>
|
||||||
|
<a name='L184'></a><a href='#L184'>184</a>
|
||||||
|
<a name='L185'></a><a href='#L185'>185</a>
|
||||||
|
<a name='L186'></a><a href='#L186'>186</a>
|
||||||
|
<a name='L187'></a><a href='#L187'>187</a>
|
||||||
|
<a name='L188'></a><a href='#L188'>188</a>
|
||||||
|
<a name='L189'></a><a href='#L189'>189</a>
|
||||||
|
<a name='L190'></a><a href='#L190'>190</a>
|
||||||
|
<a name='L191'></a><a href='#L191'>191</a>
|
||||||
|
<a name='L192'></a><a href='#L192'>192</a>
|
||||||
|
<a name='L193'></a><a href='#L193'>193</a>
|
||||||
|
<a name='L194'></a><a href='#L194'>194</a>
|
||||||
|
<a name='L195'></a><a href='#L195'>195</a>
|
||||||
|
<a name='L196'></a><a href='#L196'>196</a>
|
||||||
|
<a name='L197'></a><a href='#L197'>197</a>
|
||||||
|
<a name='L198'></a><a href='#L198'>198</a>
|
||||||
|
<a name='L199'></a><a href='#L199'>199</a>
|
||||||
|
<a name='L200'></a><a href='#L200'>200</a>
|
||||||
|
<a name='L201'></a><a href='#L201'>201</a>
|
||||||
|
<a name='L202'></a><a href='#L202'>202</a>
|
||||||
|
<a name='L203'></a><a href='#L203'>203</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-no"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">15x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">15x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">15x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">15x</span>
|
||||||
|
<span class="cline-any cline-yes">14x</span>
|
||||||
|
<span class="cline-any cline-yes">14x</span>
|
||||||
|
<span class="cline-any cline-yes">14x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">10x</span>
|
||||||
|
<span class="cline-any cline-yes">9x</span>
|
||||||
|
<span class="cline-any cline-yes">9x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">15x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">13x</span>
|
||||||
|
<span class="cline-any cline-yes">13x</span>
|
||||||
|
<span class="cline-any cline-yes">16x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">6x</span>
|
||||||
|
<span class="cline-any cline-yes">6x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">3x</span>
|
||||||
|
<span class="cline-any cline-yes">3x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">3x</span>
|
||||||
|
<span class="cline-any cline-yes">3x</span>
|
||||||
|
<span class="cline-any cline-yes">3x</span>
|
||||||
|
<span class="cline-any cline-yes">3x</span>
|
||||||
|
<span class="cline-any cline-yes">3x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">13x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-yes">66x</span>
|
||||||
|
<span class="cline-any cline-yes">66x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">66x</span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-yes">4x</span>
|
||||||
|
<span class="cline-any cline-yes">7x</span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-yes">4x</span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-yes">77x</span>
|
||||||
|
<span class="cline-any cline-yes">77x</span>
|
||||||
|
<span class="cline-any cline-yes">77x</span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">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'
|
||||||
|
: <span class="branch-1 cbranch-no" title="branch not covered" >'ownership_transfer';</span>
|
||||||
|
break;
|
||||||
|
case 'deedDate':
|
||||||
|
changeType = 'deed_change';
|
||||||
|
break;
|
||||||
|
case 'taxAmount':
|
||||||
|
changeType = 'tax_change';
|
||||||
|
break;
|
||||||
|
case 'lienCount':
|
||||||
|
changeType = (newValue as number) > (oldValue as number) ? 'lien_filing' : <span class="branch-1 cbranch-no" title="branch not covered" >'metadata_change';</span>
|
||||||
|
break;
|
||||||
|
case 'taxId':
|
||||||
|
changeType = 'deed_change';
|
||||||
|
break;
|
||||||
|
<span class="branch-5 cbranch-no" title="branch not covered" > default:</span>
|
||||||
|
<span class="cstat-no" title="statement not covered" > changeType = 'metadata_change';</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
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 : <span class="branch-1 cbranch-no" title="branch not covered" >100;</span>
|
||||||
|
totalConfidence += pctChange >= config.taxAmountChangePercent ? 0.85 : <span class="branch-1 cbranch-no" title="branch not covered" >0.5;</span>
|
||||||
|
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 };
|
||||||
|
</pre></td></tr></table></pre>
|
||||||
|
|
||||||
|
<div class='push'></div><!-- for sticky footer -->
|
||||||
|
</div><!-- /wrapper -->
|
||||||
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
|
Code coverage generated by
|
||||||
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||||
|
at 2026-05-14T13:08:44.978Z
|
||||||
|
</div>
|
||||||
|
<script src="prettify.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
prettyPrint();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="sorter.js"></script>
|
||||||
|
<script src="block-navigation.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
5
services/hometitle/coverage/coverage-final.json
Normal file
5
services/hometitle/coverage/coverage-final.json
Normal file
File diff suppressed because one or more lines are too long
BIN
services/hometitle/coverage/favicon.png
Normal file
BIN
services/hometitle/coverage/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 445 B |
161
services/hometitle/coverage/index.html
Normal file
161
services/hometitle/coverage/index.html
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Code coverage report for All files</title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="stylesheet" href="prettify.css" />
|
||||||
|
<link rel="stylesheet" href="base.css" />
|
||||||
|
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<style type='text/css'>
|
||||||
|
.coverage-summary .sorter {
|
||||||
|
background-image: url(sort-arrow-sprite.png);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class='wrapper'>
|
||||||
|
<div class='pad1'>
|
||||||
|
<h1>All files</h1>
|
||||||
|
<div class='clearfix'>
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">98.11% </span>
|
||||||
|
<span class="quiet">Statements</span>
|
||||||
|
<span class='fraction'>208/212</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">92.42% </span>
|
||||||
|
<span class="quiet">Branches</span>
|
||||||
|
<span class='fraction'>122/132</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">96.29% </span>
|
||||||
|
<span class="quiet">Functions</span>
|
||||||
|
<span class='fraction'>26/27</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">98.96% </span>
|
||||||
|
<span class="quiet">Lines</span>
|
||||||
|
<span class='fraction'>191/193</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<p class="quiet">
|
||||||
|
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||||
|
</p>
|
||||||
|
<template id="filterTemplate">
|
||||||
|
<div class="quiet">
|
||||||
|
Filter:
|
||||||
|
<input type="search" id="fileSearch">
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div class='status-line high'></div>
|
||||||
|
<div class="pad1">
|
||||||
|
<table class="coverage-summary">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
||||||
|
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
||||||
|
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
||||||
|
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
||||||
|
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
||||||
|
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
||||||
|
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody><tr>
|
||||||
|
<td class="file high" data-value="change-detector.ts"><a href="change-detector.ts.html">change-detector.ts</a></td>
|
||||||
|
<td data-value="98.83" class="pic high">
|
||||||
|
<div class="chart"><div class="cover-fill" style="width: 98%"></div><div class="cover-empty" style="width: 2%"></div></div>
|
||||||
|
</td>
|
||||||
|
<td data-value="98.83" class="pct high">98.83%</td>
|
||||||
|
<td data-value="86" class="abs high">85/86</td>
|
||||||
|
<td data-value="91.07" class="pct high">91.07%</td>
|
||||||
|
<td data-value="56" class="abs high">51/56</td>
|
||||||
|
<td data-value="100" class="pct high">100%</td>
|
||||||
|
<td data-value="11" class="abs high">11/11</td>
|
||||||
|
<td data-value="98.73" class="pct high">98.73%</td>
|
||||||
|
<td data-value="79" class="abs high">78/79</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="file empty" data-value="index.ts"><a href="index.ts.html">index.ts</a></td>
|
||||||
|
<td data-value="0" class="pic empty">
|
||||||
|
<div class="chart"><div class="cover-fill" style="width: 0%"></div><div class="cover-empty" style="width: 100%"></div></div>
|
||||||
|
</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="file high" data-value="matcher.service.ts"><a href="matcher.service.ts.html">matcher.service.ts</a></td>
|
||||||
|
<td data-value="97.61" class="pic high">
|
||||||
|
<div class="chart"><div class="cover-fill" style="width: 97%"></div><div class="cover-empty" style="width: 3%"></div></div>
|
||||||
|
</td>
|
||||||
|
<td data-value="97.61" class="pct high">97.61%</td>
|
||||||
|
<td data-value="126" class="abs high">123/126</td>
|
||||||
|
<td data-value="93.42" class="pct high">93.42%</td>
|
||||||
|
<td data-value="76" class="abs high">71/76</td>
|
||||||
|
<td data-value="93.75" class="pct high">93.75%</td>
|
||||||
|
<td data-value="16" class="abs high">15/16</td>
|
||||||
|
<td data-value="99.12" class="pct high">99.12%</td>
|
||||||
|
<td data-value="114" class="abs high">113/114</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="file empty" data-value="types.ts"><a href="types.ts.html">types.ts</a></td>
|
||||||
|
<td data-value="0" class="pic empty">
|
||||||
|
<div class="chart"><div class="cover-fill" style="width: 0%"></div><div class="cover-empty" style="width: 100%"></div></div>
|
||||||
|
</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class='push'></div><!-- for sticky footer -->
|
||||||
|
</div><!-- /wrapper -->
|
||||||
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
|
Code coverage generated by
|
||||||
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||||
|
at 2026-05-14T13:08:44.978Z
|
||||||
|
</div>
|
||||||
|
<script src="prettify.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
prettyPrint();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="sorter.js"></script>
|
||||||
|
<script src="block-navigation.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
187
services/hometitle/coverage/index.ts.html
Normal file
187
services/hometitle/coverage/index.ts.html
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Code coverage report for index.ts</title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="stylesheet" href="prettify.css" />
|
||||||
|
<link rel="stylesheet" href="base.css" />
|
||||||
|
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<style type='text/css'>
|
||||||
|
.coverage-summary .sorter {
|
||||||
|
background-image: url(sort-arrow-sprite.png);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class='wrapper'>
|
||||||
|
<div class='pad1'>
|
||||||
|
<h1><a href="index.html">All files</a> index.ts</h1>
|
||||||
|
<div class='clearfix'>
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Statements</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Branches</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Functions</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Lines</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<p class="quiet">
|
||||||
|
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||||
|
</p>
|
||||||
|
<template id="filterTemplate">
|
||||||
|
<div class="quiet">
|
||||||
|
Filter:
|
||||||
|
<input type="search" id="fileSearch">
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div class='status-line low'></div>
|
||||||
|
<pre><table class="coverage">
|
||||||
|
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||||
|
<a name='L2'></a><a href='#L2'>2</a>
|
||||||
|
<a name='L3'></a><a href='#L3'>3</a>
|
||||||
|
<a name='L4'></a><a href='#L4'>4</a>
|
||||||
|
<a name='L5'></a><a href='#L5'>5</a>
|
||||||
|
<a name='L6'></a><a href='#L6'>6</a>
|
||||||
|
<a name='L7'></a><a href='#L7'>7</a>
|
||||||
|
<a name='L8'></a><a href='#L8'>8</a>
|
||||||
|
<a name='L9'></a><a href='#L9'>9</a>
|
||||||
|
<a name='L10'></a><a href='#L10'>10</a>
|
||||||
|
<a name='L11'></a><a href='#L11'>11</a>
|
||||||
|
<a name='L12'></a><a href='#L12'>12</a>
|
||||||
|
<a name='L13'></a><a href='#L13'>13</a>
|
||||||
|
<a name='L14'></a><a href='#L14'>14</a>
|
||||||
|
<a name='L15'></a><a href='#L15'>15</a>
|
||||||
|
<a name='L16'></a><a href='#L16'>16</a>
|
||||||
|
<a name='L17'></a><a href='#L17'>17</a>
|
||||||
|
<a name='L18'></a><a href='#L18'>18</a>
|
||||||
|
<a name='L19'></a><a href='#L19'>19</a>
|
||||||
|
<a name='L20'></a><a href='#L20'>20</a>
|
||||||
|
<a name='L21'></a><a href='#L21'>21</a>
|
||||||
|
<a name='L22'></a><a href='#L22'>22</a>
|
||||||
|
<a name='L23'></a><a href='#L23'>23</a>
|
||||||
|
<a name='L24'></a><a href='#L24'>24</a>
|
||||||
|
<a name='L25'></a><a href='#L25'>25</a>
|
||||||
|
<a name='L26'></a><a href='#L26'>26</a>
|
||||||
|
<a name='L27'></a><a href='#L27'>27</a>
|
||||||
|
<a name='L28'></a><a href='#L28'>28</a>
|
||||||
|
<a name='L29'></a><a href='#L29'>29</a>
|
||||||
|
<a name='L30'></a><a href='#L30'>30</a>
|
||||||
|
<a name='L31'></a><a href='#L31'>31</a>
|
||||||
|
<a name='L32'></a><a href='#L32'>32</a>
|
||||||
|
<a name='L33'></a><a href='#L33'>33</a>
|
||||||
|
<a name='L34'></a><a href='#L34'>34</a>
|
||||||
|
<a name='L35'></a><a href='#L35'>35</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">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';
|
||||||
|
</pre></td></tr></table></pre>
|
||||||
|
|
||||||
|
<div class='push'></div><!-- for sticky footer -->
|
||||||
|
</div><!-- /wrapper -->
|
||||||
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
|
Code coverage generated by
|
||||||
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||||
|
at 2026-05-14T13:08:44.978Z
|
||||||
|
</div>
|
||||||
|
<script src="prettify.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
prettyPrint();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="sorter.js"></script>
|
||||||
|
<script src="block-navigation.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
224
services/hometitle/coverage/lcov-report/base.css
Normal file
224
services/hometitle/coverage/lcov-report/base.css
Normal file
@@ -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;
|
||||||
|
}
|
||||||
87
services/hometitle/coverage/lcov-report/block-navigation.js
Normal file
87
services/hometitle/coverage/lcov-report/block-navigation.js
Normal file
@@ -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);
|
||||||
691
services/hometitle/coverage/lcov-report/change-detector.ts.html
Normal file
691
services/hometitle/coverage/lcov-report/change-detector.ts.html
Normal file
@@ -0,0 +1,691 @@
|
|||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Code coverage report for change-detector.ts</title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="stylesheet" href="prettify.css" />
|
||||||
|
<link rel="stylesheet" href="base.css" />
|
||||||
|
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<style type='text/css'>
|
||||||
|
.coverage-summary .sorter {
|
||||||
|
background-image: url(sort-arrow-sprite.png);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class='wrapper'>
|
||||||
|
<div class='pad1'>
|
||||||
|
<h1><a href="index.html">All files</a> change-detector.ts</h1>
|
||||||
|
<div class='clearfix'>
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">98.83% </span>
|
||||||
|
<span class="quiet">Statements</span>
|
||||||
|
<span class='fraction'>85/86</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">91.07% </span>
|
||||||
|
<span class="quiet">Branches</span>
|
||||||
|
<span class='fraction'>51/56</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">100% </span>
|
||||||
|
<span class="quiet">Functions</span>
|
||||||
|
<span class='fraction'>11/11</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">98.73% </span>
|
||||||
|
<span class="quiet">Lines</span>
|
||||||
|
<span class='fraction'>78/79</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<p class="quiet">
|
||||||
|
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||||
|
</p>
|
||||||
|
<template id="filterTemplate">
|
||||||
|
<div class="quiet">
|
||||||
|
Filter:
|
||||||
|
<input type="search" id="fileSearch">
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div class='status-line high'></div>
|
||||||
|
<pre><table class="coverage">
|
||||||
|
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||||
|
<a name='L2'></a><a href='#L2'>2</a>
|
||||||
|
<a name='L3'></a><a href='#L3'>3</a>
|
||||||
|
<a name='L4'></a><a href='#L4'>4</a>
|
||||||
|
<a name='L5'></a><a href='#L5'>5</a>
|
||||||
|
<a name='L6'></a><a href='#L6'>6</a>
|
||||||
|
<a name='L7'></a><a href='#L7'>7</a>
|
||||||
|
<a name='L8'></a><a href='#L8'>8</a>
|
||||||
|
<a name='L9'></a><a href='#L9'>9</a>
|
||||||
|
<a name='L10'></a><a href='#L10'>10</a>
|
||||||
|
<a name='L11'></a><a href='#L11'>11</a>
|
||||||
|
<a name='L12'></a><a href='#L12'>12</a>
|
||||||
|
<a name='L13'></a><a href='#L13'>13</a>
|
||||||
|
<a name='L14'></a><a href='#L14'>14</a>
|
||||||
|
<a name='L15'></a><a href='#L15'>15</a>
|
||||||
|
<a name='L16'></a><a href='#L16'>16</a>
|
||||||
|
<a name='L17'></a><a href='#L17'>17</a>
|
||||||
|
<a name='L18'></a><a href='#L18'>18</a>
|
||||||
|
<a name='L19'></a><a href='#L19'>19</a>
|
||||||
|
<a name='L20'></a><a href='#L20'>20</a>
|
||||||
|
<a name='L21'></a><a href='#L21'>21</a>
|
||||||
|
<a name='L22'></a><a href='#L22'>22</a>
|
||||||
|
<a name='L23'></a><a href='#L23'>23</a>
|
||||||
|
<a name='L24'></a><a href='#L24'>24</a>
|
||||||
|
<a name='L25'></a><a href='#L25'>25</a>
|
||||||
|
<a name='L26'></a><a href='#L26'>26</a>
|
||||||
|
<a name='L27'></a><a href='#L27'>27</a>
|
||||||
|
<a name='L28'></a><a href='#L28'>28</a>
|
||||||
|
<a name='L29'></a><a href='#L29'>29</a>
|
||||||
|
<a name='L30'></a><a href='#L30'>30</a>
|
||||||
|
<a name='L31'></a><a href='#L31'>31</a>
|
||||||
|
<a name='L32'></a><a href='#L32'>32</a>
|
||||||
|
<a name='L33'></a><a href='#L33'>33</a>
|
||||||
|
<a name='L34'></a><a href='#L34'>34</a>
|
||||||
|
<a name='L35'></a><a href='#L35'>35</a>
|
||||||
|
<a name='L36'></a><a href='#L36'>36</a>
|
||||||
|
<a name='L37'></a><a href='#L37'>37</a>
|
||||||
|
<a name='L38'></a><a href='#L38'>38</a>
|
||||||
|
<a name='L39'></a><a href='#L39'>39</a>
|
||||||
|
<a name='L40'></a><a href='#L40'>40</a>
|
||||||
|
<a name='L41'></a><a href='#L41'>41</a>
|
||||||
|
<a name='L42'></a><a href='#L42'>42</a>
|
||||||
|
<a name='L43'></a><a href='#L43'>43</a>
|
||||||
|
<a name='L44'></a><a href='#L44'>44</a>
|
||||||
|
<a name='L45'></a><a href='#L45'>45</a>
|
||||||
|
<a name='L46'></a><a href='#L46'>46</a>
|
||||||
|
<a name='L47'></a><a href='#L47'>47</a>
|
||||||
|
<a name='L48'></a><a href='#L48'>48</a>
|
||||||
|
<a name='L49'></a><a href='#L49'>49</a>
|
||||||
|
<a name='L50'></a><a href='#L50'>50</a>
|
||||||
|
<a name='L51'></a><a href='#L51'>51</a>
|
||||||
|
<a name='L52'></a><a href='#L52'>52</a>
|
||||||
|
<a name='L53'></a><a href='#L53'>53</a>
|
||||||
|
<a name='L54'></a><a href='#L54'>54</a>
|
||||||
|
<a name='L55'></a><a href='#L55'>55</a>
|
||||||
|
<a name='L56'></a><a href='#L56'>56</a>
|
||||||
|
<a name='L57'></a><a href='#L57'>57</a>
|
||||||
|
<a name='L58'></a><a href='#L58'>58</a>
|
||||||
|
<a name='L59'></a><a href='#L59'>59</a>
|
||||||
|
<a name='L60'></a><a href='#L60'>60</a>
|
||||||
|
<a name='L61'></a><a href='#L61'>61</a>
|
||||||
|
<a name='L62'></a><a href='#L62'>62</a>
|
||||||
|
<a name='L63'></a><a href='#L63'>63</a>
|
||||||
|
<a name='L64'></a><a href='#L64'>64</a>
|
||||||
|
<a name='L65'></a><a href='#L65'>65</a>
|
||||||
|
<a name='L66'></a><a href='#L66'>66</a>
|
||||||
|
<a name='L67'></a><a href='#L67'>67</a>
|
||||||
|
<a name='L68'></a><a href='#L68'>68</a>
|
||||||
|
<a name='L69'></a><a href='#L69'>69</a>
|
||||||
|
<a name='L70'></a><a href='#L70'>70</a>
|
||||||
|
<a name='L71'></a><a href='#L71'>71</a>
|
||||||
|
<a name='L72'></a><a href='#L72'>72</a>
|
||||||
|
<a name='L73'></a><a href='#L73'>73</a>
|
||||||
|
<a name='L74'></a><a href='#L74'>74</a>
|
||||||
|
<a name='L75'></a><a href='#L75'>75</a>
|
||||||
|
<a name='L76'></a><a href='#L76'>76</a>
|
||||||
|
<a name='L77'></a><a href='#L77'>77</a>
|
||||||
|
<a name='L78'></a><a href='#L78'>78</a>
|
||||||
|
<a name='L79'></a><a href='#L79'>79</a>
|
||||||
|
<a name='L80'></a><a href='#L80'>80</a>
|
||||||
|
<a name='L81'></a><a href='#L81'>81</a>
|
||||||
|
<a name='L82'></a><a href='#L82'>82</a>
|
||||||
|
<a name='L83'></a><a href='#L83'>83</a>
|
||||||
|
<a name='L84'></a><a href='#L84'>84</a>
|
||||||
|
<a name='L85'></a><a href='#L85'>85</a>
|
||||||
|
<a name='L86'></a><a href='#L86'>86</a>
|
||||||
|
<a name='L87'></a><a href='#L87'>87</a>
|
||||||
|
<a name='L88'></a><a href='#L88'>88</a>
|
||||||
|
<a name='L89'></a><a href='#L89'>89</a>
|
||||||
|
<a name='L90'></a><a href='#L90'>90</a>
|
||||||
|
<a name='L91'></a><a href='#L91'>91</a>
|
||||||
|
<a name='L92'></a><a href='#L92'>92</a>
|
||||||
|
<a name='L93'></a><a href='#L93'>93</a>
|
||||||
|
<a name='L94'></a><a href='#L94'>94</a>
|
||||||
|
<a name='L95'></a><a href='#L95'>95</a>
|
||||||
|
<a name='L96'></a><a href='#L96'>96</a>
|
||||||
|
<a name='L97'></a><a href='#L97'>97</a>
|
||||||
|
<a name='L98'></a><a href='#L98'>98</a>
|
||||||
|
<a name='L99'></a><a href='#L99'>99</a>
|
||||||
|
<a name='L100'></a><a href='#L100'>100</a>
|
||||||
|
<a name='L101'></a><a href='#L101'>101</a>
|
||||||
|
<a name='L102'></a><a href='#L102'>102</a>
|
||||||
|
<a name='L103'></a><a href='#L103'>103</a>
|
||||||
|
<a name='L104'></a><a href='#L104'>104</a>
|
||||||
|
<a name='L105'></a><a href='#L105'>105</a>
|
||||||
|
<a name='L106'></a><a href='#L106'>106</a>
|
||||||
|
<a name='L107'></a><a href='#L107'>107</a>
|
||||||
|
<a name='L108'></a><a href='#L108'>108</a>
|
||||||
|
<a name='L109'></a><a href='#L109'>109</a>
|
||||||
|
<a name='L110'></a><a href='#L110'>110</a>
|
||||||
|
<a name='L111'></a><a href='#L111'>111</a>
|
||||||
|
<a name='L112'></a><a href='#L112'>112</a>
|
||||||
|
<a name='L113'></a><a href='#L113'>113</a>
|
||||||
|
<a name='L114'></a><a href='#L114'>114</a>
|
||||||
|
<a name='L115'></a><a href='#L115'>115</a>
|
||||||
|
<a name='L116'></a><a href='#L116'>116</a>
|
||||||
|
<a name='L117'></a><a href='#L117'>117</a>
|
||||||
|
<a name='L118'></a><a href='#L118'>118</a>
|
||||||
|
<a name='L119'></a><a href='#L119'>119</a>
|
||||||
|
<a name='L120'></a><a href='#L120'>120</a>
|
||||||
|
<a name='L121'></a><a href='#L121'>121</a>
|
||||||
|
<a name='L122'></a><a href='#L122'>122</a>
|
||||||
|
<a name='L123'></a><a href='#L123'>123</a>
|
||||||
|
<a name='L124'></a><a href='#L124'>124</a>
|
||||||
|
<a name='L125'></a><a href='#L125'>125</a>
|
||||||
|
<a name='L126'></a><a href='#L126'>126</a>
|
||||||
|
<a name='L127'></a><a href='#L127'>127</a>
|
||||||
|
<a name='L128'></a><a href='#L128'>128</a>
|
||||||
|
<a name='L129'></a><a href='#L129'>129</a>
|
||||||
|
<a name='L130'></a><a href='#L130'>130</a>
|
||||||
|
<a name='L131'></a><a href='#L131'>131</a>
|
||||||
|
<a name='L132'></a><a href='#L132'>132</a>
|
||||||
|
<a name='L133'></a><a href='#L133'>133</a>
|
||||||
|
<a name='L134'></a><a href='#L134'>134</a>
|
||||||
|
<a name='L135'></a><a href='#L135'>135</a>
|
||||||
|
<a name='L136'></a><a href='#L136'>136</a>
|
||||||
|
<a name='L137'></a><a href='#L137'>137</a>
|
||||||
|
<a name='L138'></a><a href='#L138'>138</a>
|
||||||
|
<a name='L139'></a><a href='#L139'>139</a>
|
||||||
|
<a name='L140'></a><a href='#L140'>140</a>
|
||||||
|
<a name='L141'></a><a href='#L141'>141</a>
|
||||||
|
<a name='L142'></a><a href='#L142'>142</a>
|
||||||
|
<a name='L143'></a><a href='#L143'>143</a>
|
||||||
|
<a name='L144'></a><a href='#L144'>144</a>
|
||||||
|
<a name='L145'></a><a href='#L145'>145</a>
|
||||||
|
<a name='L146'></a><a href='#L146'>146</a>
|
||||||
|
<a name='L147'></a><a href='#L147'>147</a>
|
||||||
|
<a name='L148'></a><a href='#L148'>148</a>
|
||||||
|
<a name='L149'></a><a href='#L149'>149</a>
|
||||||
|
<a name='L150'></a><a href='#L150'>150</a>
|
||||||
|
<a name='L151'></a><a href='#L151'>151</a>
|
||||||
|
<a name='L152'></a><a href='#L152'>152</a>
|
||||||
|
<a name='L153'></a><a href='#L153'>153</a>
|
||||||
|
<a name='L154'></a><a href='#L154'>154</a>
|
||||||
|
<a name='L155'></a><a href='#L155'>155</a>
|
||||||
|
<a name='L156'></a><a href='#L156'>156</a>
|
||||||
|
<a name='L157'></a><a href='#L157'>157</a>
|
||||||
|
<a name='L158'></a><a href='#L158'>158</a>
|
||||||
|
<a name='L159'></a><a href='#L159'>159</a>
|
||||||
|
<a name='L160'></a><a href='#L160'>160</a>
|
||||||
|
<a name='L161'></a><a href='#L161'>161</a>
|
||||||
|
<a name='L162'></a><a href='#L162'>162</a>
|
||||||
|
<a name='L163'></a><a href='#L163'>163</a>
|
||||||
|
<a name='L164'></a><a href='#L164'>164</a>
|
||||||
|
<a name='L165'></a><a href='#L165'>165</a>
|
||||||
|
<a name='L166'></a><a href='#L166'>166</a>
|
||||||
|
<a name='L167'></a><a href='#L167'>167</a>
|
||||||
|
<a name='L168'></a><a href='#L168'>168</a>
|
||||||
|
<a name='L169'></a><a href='#L169'>169</a>
|
||||||
|
<a name='L170'></a><a href='#L170'>170</a>
|
||||||
|
<a name='L171'></a><a href='#L171'>171</a>
|
||||||
|
<a name='L172'></a><a href='#L172'>172</a>
|
||||||
|
<a name='L173'></a><a href='#L173'>173</a>
|
||||||
|
<a name='L174'></a><a href='#L174'>174</a>
|
||||||
|
<a name='L175'></a><a href='#L175'>175</a>
|
||||||
|
<a name='L176'></a><a href='#L176'>176</a>
|
||||||
|
<a name='L177'></a><a href='#L177'>177</a>
|
||||||
|
<a name='L178'></a><a href='#L178'>178</a>
|
||||||
|
<a name='L179'></a><a href='#L179'>179</a>
|
||||||
|
<a name='L180'></a><a href='#L180'>180</a>
|
||||||
|
<a name='L181'></a><a href='#L181'>181</a>
|
||||||
|
<a name='L182'></a><a href='#L182'>182</a>
|
||||||
|
<a name='L183'></a><a href='#L183'>183</a>
|
||||||
|
<a name='L184'></a><a href='#L184'>184</a>
|
||||||
|
<a name='L185'></a><a href='#L185'>185</a>
|
||||||
|
<a name='L186'></a><a href='#L186'>186</a>
|
||||||
|
<a name='L187'></a><a href='#L187'>187</a>
|
||||||
|
<a name='L188'></a><a href='#L188'>188</a>
|
||||||
|
<a name='L189'></a><a href='#L189'>189</a>
|
||||||
|
<a name='L190'></a><a href='#L190'>190</a>
|
||||||
|
<a name='L191'></a><a href='#L191'>191</a>
|
||||||
|
<a name='L192'></a><a href='#L192'>192</a>
|
||||||
|
<a name='L193'></a><a href='#L193'>193</a>
|
||||||
|
<a name='L194'></a><a href='#L194'>194</a>
|
||||||
|
<a name='L195'></a><a href='#L195'>195</a>
|
||||||
|
<a name='L196'></a><a href='#L196'>196</a>
|
||||||
|
<a name='L197'></a><a href='#L197'>197</a>
|
||||||
|
<a name='L198'></a><a href='#L198'>198</a>
|
||||||
|
<a name='L199'></a><a href='#L199'>199</a>
|
||||||
|
<a name='L200'></a><a href='#L200'>200</a>
|
||||||
|
<a name='L201'></a><a href='#L201'>201</a>
|
||||||
|
<a name='L202'></a><a href='#L202'>202</a>
|
||||||
|
<a name='L203'></a><a href='#L203'>203</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-no"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">15x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">15x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">15x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">15x</span>
|
||||||
|
<span class="cline-any cline-yes">14x</span>
|
||||||
|
<span class="cline-any cline-yes">14x</span>
|
||||||
|
<span class="cline-any cline-yes">14x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">10x</span>
|
||||||
|
<span class="cline-any cline-yes">9x</span>
|
||||||
|
<span class="cline-any cline-yes">9x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">15x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">13x</span>
|
||||||
|
<span class="cline-any cline-yes">13x</span>
|
||||||
|
<span class="cline-any cline-yes">16x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">6x</span>
|
||||||
|
<span class="cline-any cline-yes">6x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">3x</span>
|
||||||
|
<span class="cline-any cline-yes">3x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">3x</span>
|
||||||
|
<span class="cline-any cline-yes">3x</span>
|
||||||
|
<span class="cline-any cline-yes">3x</span>
|
||||||
|
<span class="cline-any cline-yes">3x</span>
|
||||||
|
<span class="cline-any cline-yes">3x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">13x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-yes">66x</span>
|
||||||
|
<span class="cline-any cline-yes">66x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">66x</span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-yes">4x</span>
|
||||||
|
<span class="cline-any cline-yes">7x</span>
|
||||||
|
<span class="cline-any cline-yes">2x</span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-yes">4x</span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-yes">77x</span>
|
||||||
|
<span class="cline-any cline-yes">77x</span>
|
||||||
|
<span class="cline-any cline-yes">77x</span>
|
||||||
|
<span class="cline-any cline-yes">1x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">11x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-yes">5x</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">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'
|
||||||
|
: <span class="branch-1 cbranch-no" title="branch not covered" >'ownership_transfer';</span>
|
||||||
|
break;
|
||||||
|
case 'deedDate':
|
||||||
|
changeType = 'deed_change';
|
||||||
|
break;
|
||||||
|
case 'taxAmount':
|
||||||
|
changeType = 'tax_change';
|
||||||
|
break;
|
||||||
|
case 'lienCount':
|
||||||
|
changeType = (newValue as number) > (oldValue as number) ? 'lien_filing' : <span class="branch-1 cbranch-no" title="branch not covered" >'metadata_change';</span>
|
||||||
|
break;
|
||||||
|
case 'taxId':
|
||||||
|
changeType = 'deed_change';
|
||||||
|
break;
|
||||||
|
<span class="branch-5 cbranch-no" title="branch not covered" > default:</span>
|
||||||
|
<span class="cstat-no" title="statement not covered" > changeType = 'metadata_change';</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
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 : <span class="branch-1 cbranch-no" title="branch not covered" >100;</span>
|
||||||
|
totalConfidence += pctChange >= config.taxAmountChangePercent ? 0.85 : <span class="branch-1 cbranch-no" title="branch not covered" >0.5;</span>
|
||||||
|
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 };
|
||||||
|
</pre></td></tr></table></pre>
|
||||||
|
|
||||||
|
<div class='push'></div><!-- for sticky footer -->
|
||||||
|
</div><!-- /wrapper -->
|
||||||
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
|
Code coverage generated by
|
||||||
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||||
|
at 2026-05-14T13:08:44.986Z
|
||||||
|
</div>
|
||||||
|
<script src="prettify.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
prettyPrint();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="sorter.js"></script>
|
||||||
|
<script src="block-navigation.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
BIN
services/hometitle/coverage/lcov-report/favicon.png
Normal file
BIN
services/hometitle/coverage/lcov-report/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 445 B |
161
services/hometitle/coverage/lcov-report/index.html
Normal file
161
services/hometitle/coverage/lcov-report/index.html
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Code coverage report for All files</title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="stylesheet" href="prettify.css" />
|
||||||
|
<link rel="stylesheet" href="base.css" />
|
||||||
|
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<style type='text/css'>
|
||||||
|
.coverage-summary .sorter {
|
||||||
|
background-image: url(sort-arrow-sprite.png);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class='wrapper'>
|
||||||
|
<div class='pad1'>
|
||||||
|
<h1>All files</h1>
|
||||||
|
<div class='clearfix'>
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">98.11% </span>
|
||||||
|
<span class="quiet">Statements</span>
|
||||||
|
<span class='fraction'>208/212</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">92.42% </span>
|
||||||
|
<span class="quiet">Branches</span>
|
||||||
|
<span class='fraction'>122/132</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">96.29% </span>
|
||||||
|
<span class="quiet">Functions</span>
|
||||||
|
<span class='fraction'>26/27</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">98.96% </span>
|
||||||
|
<span class="quiet">Lines</span>
|
||||||
|
<span class='fraction'>191/193</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<p class="quiet">
|
||||||
|
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||||
|
</p>
|
||||||
|
<template id="filterTemplate">
|
||||||
|
<div class="quiet">
|
||||||
|
Filter:
|
||||||
|
<input type="search" id="fileSearch">
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div class='status-line high'></div>
|
||||||
|
<div class="pad1">
|
||||||
|
<table class="coverage-summary">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
||||||
|
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
||||||
|
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
||||||
|
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
||||||
|
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
||||||
|
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
||||||
|
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody><tr>
|
||||||
|
<td class="file high" data-value="change-detector.ts"><a href="change-detector.ts.html">change-detector.ts</a></td>
|
||||||
|
<td data-value="98.83" class="pic high">
|
||||||
|
<div class="chart"><div class="cover-fill" style="width: 98%"></div><div class="cover-empty" style="width: 2%"></div></div>
|
||||||
|
</td>
|
||||||
|
<td data-value="98.83" class="pct high">98.83%</td>
|
||||||
|
<td data-value="86" class="abs high">85/86</td>
|
||||||
|
<td data-value="91.07" class="pct high">91.07%</td>
|
||||||
|
<td data-value="56" class="abs high">51/56</td>
|
||||||
|
<td data-value="100" class="pct high">100%</td>
|
||||||
|
<td data-value="11" class="abs high">11/11</td>
|
||||||
|
<td data-value="98.73" class="pct high">98.73%</td>
|
||||||
|
<td data-value="79" class="abs high">78/79</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="file empty" data-value="index.ts"><a href="index.ts.html">index.ts</a></td>
|
||||||
|
<td data-value="0" class="pic empty">
|
||||||
|
<div class="chart"><div class="cover-fill" style="width: 0%"></div><div class="cover-empty" style="width: 100%"></div></div>
|
||||||
|
</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="file high" data-value="matcher.service.ts"><a href="matcher.service.ts.html">matcher.service.ts</a></td>
|
||||||
|
<td data-value="97.61" class="pic high">
|
||||||
|
<div class="chart"><div class="cover-fill" style="width: 97%"></div><div class="cover-empty" style="width: 3%"></div></div>
|
||||||
|
</td>
|
||||||
|
<td data-value="97.61" class="pct high">97.61%</td>
|
||||||
|
<td data-value="126" class="abs high">123/126</td>
|
||||||
|
<td data-value="93.42" class="pct high">93.42%</td>
|
||||||
|
<td data-value="76" class="abs high">71/76</td>
|
||||||
|
<td data-value="93.75" class="pct high">93.75%</td>
|
||||||
|
<td data-value="16" class="abs high">15/16</td>
|
||||||
|
<td data-value="99.12" class="pct high">99.12%</td>
|
||||||
|
<td data-value="114" class="abs high">113/114</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="file empty" data-value="types.ts"><a href="types.ts.html">types.ts</a></td>
|
||||||
|
<td data-value="0" class="pic empty">
|
||||||
|
<div class="chart"><div class="cover-fill" style="width: 0%"></div><div class="cover-empty" style="width: 100%"></div></div>
|
||||||
|
</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
<td data-value="0" class="pct empty">0%</td>
|
||||||
|
<td data-value="0" class="abs empty">0/0</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class='push'></div><!-- for sticky footer -->
|
||||||
|
</div><!-- /wrapper -->
|
||||||
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
|
Code coverage generated by
|
||||||
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||||
|
at 2026-05-14T13:08:44.986Z
|
||||||
|
</div>
|
||||||
|
<script src="prettify.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
prettyPrint();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="sorter.js"></script>
|
||||||
|
<script src="block-navigation.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
187
services/hometitle/coverage/lcov-report/index.ts.html
Normal file
187
services/hometitle/coverage/lcov-report/index.ts.html
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Code coverage report for index.ts</title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="stylesheet" href="prettify.css" />
|
||||||
|
<link rel="stylesheet" href="base.css" />
|
||||||
|
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<style type='text/css'>
|
||||||
|
.coverage-summary .sorter {
|
||||||
|
background-image: url(sort-arrow-sprite.png);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class='wrapper'>
|
||||||
|
<div class='pad1'>
|
||||||
|
<h1><a href="index.html">All files</a> index.ts</h1>
|
||||||
|
<div class='clearfix'>
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Statements</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Branches</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Functions</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Lines</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<p class="quiet">
|
||||||
|
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||||
|
</p>
|
||||||
|
<template id="filterTemplate">
|
||||||
|
<div class="quiet">
|
||||||
|
Filter:
|
||||||
|
<input type="search" id="fileSearch">
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div class='status-line low'></div>
|
||||||
|
<pre><table class="coverage">
|
||||||
|
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||||
|
<a name='L2'></a><a href='#L2'>2</a>
|
||||||
|
<a name='L3'></a><a href='#L3'>3</a>
|
||||||
|
<a name='L4'></a><a href='#L4'>4</a>
|
||||||
|
<a name='L5'></a><a href='#L5'>5</a>
|
||||||
|
<a name='L6'></a><a href='#L6'>6</a>
|
||||||
|
<a name='L7'></a><a href='#L7'>7</a>
|
||||||
|
<a name='L8'></a><a href='#L8'>8</a>
|
||||||
|
<a name='L9'></a><a href='#L9'>9</a>
|
||||||
|
<a name='L10'></a><a href='#L10'>10</a>
|
||||||
|
<a name='L11'></a><a href='#L11'>11</a>
|
||||||
|
<a name='L12'></a><a href='#L12'>12</a>
|
||||||
|
<a name='L13'></a><a href='#L13'>13</a>
|
||||||
|
<a name='L14'></a><a href='#L14'>14</a>
|
||||||
|
<a name='L15'></a><a href='#L15'>15</a>
|
||||||
|
<a name='L16'></a><a href='#L16'>16</a>
|
||||||
|
<a name='L17'></a><a href='#L17'>17</a>
|
||||||
|
<a name='L18'></a><a href='#L18'>18</a>
|
||||||
|
<a name='L19'></a><a href='#L19'>19</a>
|
||||||
|
<a name='L20'></a><a href='#L20'>20</a>
|
||||||
|
<a name='L21'></a><a href='#L21'>21</a>
|
||||||
|
<a name='L22'></a><a href='#L22'>22</a>
|
||||||
|
<a name='L23'></a><a href='#L23'>23</a>
|
||||||
|
<a name='L24'></a><a href='#L24'>24</a>
|
||||||
|
<a name='L25'></a><a href='#L25'>25</a>
|
||||||
|
<a name='L26'></a><a href='#L26'>26</a>
|
||||||
|
<a name='L27'></a><a href='#L27'>27</a>
|
||||||
|
<a name='L28'></a><a href='#L28'>28</a>
|
||||||
|
<a name='L29'></a><a href='#L29'>29</a>
|
||||||
|
<a name='L30'></a><a href='#L30'>30</a>
|
||||||
|
<a name='L31'></a><a href='#L31'>31</a>
|
||||||
|
<a name='L32'></a><a href='#L32'>32</a>
|
||||||
|
<a name='L33'></a><a href='#L33'>33</a>
|
||||||
|
<a name='L34'></a><a href='#L34'>34</a>
|
||||||
|
<a name='L35'></a><a href='#L35'>35</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">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';
|
||||||
|
</pre></td></tr></table></pre>
|
||||||
|
|
||||||
|
<div class='push'></div><!-- for sticky footer -->
|
||||||
|
</div><!-- /wrapper -->
|
||||||
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
|
Code coverage generated by
|
||||||
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||||
|
at 2026-05-14T13:08:44.986Z
|
||||||
|
</div>
|
||||||
|
<script src="prettify.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
prettyPrint();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="sorter.js"></script>
|
||||||
|
<script src="block-navigation.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
1012
services/hometitle/coverage/lcov-report/matcher.service.ts.html
Normal file
1012
services/hometitle/coverage/lcov-report/matcher.service.ts.html
Normal file
File diff suppressed because it is too large
Load Diff
1
services/hometitle/coverage/lcov-report/prettify.css
Normal file
1
services/hometitle/coverage/lcov-report/prettify.css
Normal file
@@ -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}
|
||||||
2
services/hometitle/coverage/lcov-report/prettify.js
Normal file
2
services/hometitle/coverage/lcov-report/prettify.js
Normal file
File diff suppressed because one or more lines are too long
BIN
services/hometitle/coverage/lcov-report/sort-arrow-sprite.png
Normal file
BIN
services/hometitle/coverage/lcov-report/sort-arrow-sprite.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 138 B |
210
services/hometitle/coverage/lcov-report/sorter.js
Normal file
210
services/hometitle/coverage/lcov-report/sorter.js
Normal file
@@ -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 + '<span class="sorter"></span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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);
|
||||||
427
services/hometitle/coverage/lcov-report/types.ts.html
Normal file
427
services/hometitle/coverage/lcov-report/types.ts.html
Normal file
@@ -0,0 +1,427 @@
|
|||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Code coverage report for types.ts</title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="stylesheet" href="prettify.css" />
|
||||||
|
<link rel="stylesheet" href="base.css" />
|
||||||
|
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<style type='text/css'>
|
||||||
|
.coverage-summary .sorter {
|
||||||
|
background-image: url(sort-arrow-sprite.png);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class='wrapper'>
|
||||||
|
<div class='pad1'>
|
||||||
|
<h1><a href="index.html">All files</a> types.ts</h1>
|
||||||
|
<div class='clearfix'>
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Statements</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Branches</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Functions</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Lines</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<p class="quiet">
|
||||||
|
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||||
|
</p>
|
||||||
|
<template id="filterTemplate">
|
||||||
|
<div class="quiet">
|
||||||
|
Filter:
|
||||||
|
<input type="search" id="fileSearch">
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div class='status-line low'></div>
|
||||||
|
<pre><table class="coverage">
|
||||||
|
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||||
|
<a name='L2'></a><a href='#L2'>2</a>
|
||||||
|
<a name='L3'></a><a href='#L3'>3</a>
|
||||||
|
<a name='L4'></a><a href='#L4'>4</a>
|
||||||
|
<a name='L5'></a><a href='#L5'>5</a>
|
||||||
|
<a name='L6'></a><a href='#L6'>6</a>
|
||||||
|
<a name='L7'></a><a href='#L7'>7</a>
|
||||||
|
<a name='L8'></a><a href='#L8'>8</a>
|
||||||
|
<a name='L9'></a><a href='#L9'>9</a>
|
||||||
|
<a name='L10'></a><a href='#L10'>10</a>
|
||||||
|
<a name='L11'></a><a href='#L11'>11</a>
|
||||||
|
<a name='L12'></a><a href='#L12'>12</a>
|
||||||
|
<a name='L13'></a><a href='#L13'>13</a>
|
||||||
|
<a name='L14'></a><a href='#L14'>14</a>
|
||||||
|
<a name='L15'></a><a href='#L15'>15</a>
|
||||||
|
<a name='L16'></a><a href='#L16'>16</a>
|
||||||
|
<a name='L17'></a><a href='#L17'>17</a>
|
||||||
|
<a name='L18'></a><a href='#L18'>18</a>
|
||||||
|
<a name='L19'></a><a href='#L19'>19</a>
|
||||||
|
<a name='L20'></a><a href='#L20'>20</a>
|
||||||
|
<a name='L21'></a><a href='#L21'>21</a>
|
||||||
|
<a name='L22'></a><a href='#L22'>22</a>
|
||||||
|
<a name='L23'></a><a href='#L23'>23</a>
|
||||||
|
<a name='L24'></a><a href='#L24'>24</a>
|
||||||
|
<a name='L25'></a><a href='#L25'>25</a>
|
||||||
|
<a name='L26'></a><a href='#L26'>26</a>
|
||||||
|
<a name='L27'></a><a href='#L27'>27</a>
|
||||||
|
<a name='L28'></a><a href='#L28'>28</a>
|
||||||
|
<a name='L29'></a><a href='#L29'>29</a>
|
||||||
|
<a name='L30'></a><a href='#L30'>30</a>
|
||||||
|
<a name='L31'></a><a href='#L31'>31</a>
|
||||||
|
<a name='L32'></a><a href='#L32'>32</a>
|
||||||
|
<a name='L33'></a><a href='#L33'>33</a>
|
||||||
|
<a name='L34'></a><a href='#L34'>34</a>
|
||||||
|
<a name='L35'></a><a href='#L35'>35</a>
|
||||||
|
<a name='L36'></a><a href='#L36'>36</a>
|
||||||
|
<a name='L37'></a><a href='#L37'>37</a>
|
||||||
|
<a name='L38'></a><a href='#L38'>38</a>
|
||||||
|
<a name='L39'></a><a href='#L39'>39</a>
|
||||||
|
<a name='L40'></a><a href='#L40'>40</a>
|
||||||
|
<a name='L41'></a><a href='#L41'>41</a>
|
||||||
|
<a name='L42'></a><a href='#L42'>42</a>
|
||||||
|
<a name='L43'></a><a href='#L43'>43</a>
|
||||||
|
<a name='L44'></a><a href='#L44'>44</a>
|
||||||
|
<a name='L45'></a><a href='#L45'>45</a>
|
||||||
|
<a name='L46'></a><a href='#L46'>46</a>
|
||||||
|
<a name='L47'></a><a href='#L47'>47</a>
|
||||||
|
<a name='L48'></a><a href='#L48'>48</a>
|
||||||
|
<a name='L49'></a><a href='#L49'>49</a>
|
||||||
|
<a name='L50'></a><a href='#L50'>50</a>
|
||||||
|
<a name='L51'></a><a href='#L51'>51</a>
|
||||||
|
<a name='L52'></a><a href='#L52'>52</a>
|
||||||
|
<a name='L53'></a><a href='#L53'>53</a>
|
||||||
|
<a name='L54'></a><a href='#L54'>54</a>
|
||||||
|
<a name='L55'></a><a href='#L55'>55</a>
|
||||||
|
<a name='L56'></a><a href='#L56'>56</a>
|
||||||
|
<a name='L57'></a><a href='#L57'>57</a>
|
||||||
|
<a name='L58'></a><a href='#L58'>58</a>
|
||||||
|
<a name='L59'></a><a href='#L59'>59</a>
|
||||||
|
<a name='L60'></a><a href='#L60'>60</a>
|
||||||
|
<a name='L61'></a><a href='#L61'>61</a>
|
||||||
|
<a name='L62'></a><a href='#L62'>62</a>
|
||||||
|
<a name='L63'></a><a href='#L63'>63</a>
|
||||||
|
<a name='L64'></a><a href='#L64'>64</a>
|
||||||
|
<a name='L65'></a><a href='#L65'>65</a>
|
||||||
|
<a name='L66'></a><a href='#L66'>66</a>
|
||||||
|
<a name='L67'></a><a href='#L67'>67</a>
|
||||||
|
<a name='L68'></a><a href='#L68'>68</a>
|
||||||
|
<a name='L69'></a><a href='#L69'>69</a>
|
||||||
|
<a name='L70'></a><a href='#L70'>70</a>
|
||||||
|
<a name='L71'></a><a href='#L71'>71</a>
|
||||||
|
<a name='L72'></a><a href='#L72'>72</a>
|
||||||
|
<a name='L73'></a><a href='#L73'>73</a>
|
||||||
|
<a name='L74'></a><a href='#L74'>74</a>
|
||||||
|
<a name='L75'></a><a href='#L75'>75</a>
|
||||||
|
<a name='L76'></a><a href='#L76'>76</a>
|
||||||
|
<a name='L77'></a><a href='#L77'>77</a>
|
||||||
|
<a name='L78'></a><a href='#L78'>78</a>
|
||||||
|
<a name='L79'></a><a href='#L79'>79</a>
|
||||||
|
<a name='L80'></a><a href='#L80'>80</a>
|
||||||
|
<a name='L81'></a><a href='#L81'>81</a>
|
||||||
|
<a name='L82'></a><a href='#L82'>82</a>
|
||||||
|
<a name='L83'></a><a href='#L83'>83</a>
|
||||||
|
<a name='L84'></a><a href='#L84'>84</a>
|
||||||
|
<a name='L85'></a><a href='#L85'>85</a>
|
||||||
|
<a name='L86'></a><a href='#L86'>86</a>
|
||||||
|
<a name='L87'></a><a href='#L87'>87</a>
|
||||||
|
<a name='L88'></a><a href='#L88'>88</a>
|
||||||
|
<a name='L89'></a><a href='#L89'>89</a>
|
||||||
|
<a name='L90'></a><a href='#L90'>90</a>
|
||||||
|
<a name='L91'></a><a href='#L91'>91</a>
|
||||||
|
<a name='L92'></a><a href='#L92'>92</a>
|
||||||
|
<a name='L93'></a><a href='#L93'>93</a>
|
||||||
|
<a name='L94'></a><a href='#L94'>94</a>
|
||||||
|
<a name='L95'></a><a href='#L95'>95</a>
|
||||||
|
<a name='L96'></a><a href='#L96'>96</a>
|
||||||
|
<a name='L97'></a><a href='#L97'>97</a>
|
||||||
|
<a name='L98'></a><a href='#L98'>98</a>
|
||||||
|
<a name='L99'></a><a href='#L99'>99</a>
|
||||||
|
<a name='L100'></a><a href='#L100'>100</a>
|
||||||
|
<a name='L101'></a><a href='#L101'>101</a>
|
||||||
|
<a name='L102'></a><a href='#L102'>102</a>
|
||||||
|
<a name='L103'></a><a href='#L103'>103</a>
|
||||||
|
<a name='L104'></a><a href='#L104'>104</a>
|
||||||
|
<a name='L105'></a><a href='#L105'>105</a>
|
||||||
|
<a name='L106'></a><a href='#L106'>106</a>
|
||||||
|
<a name='L107'></a><a href='#L107'>107</a>
|
||||||
|
<a name='L108'></a><a href='#L108'>108</a>
|
||||||
|
<a name='L109'></a><a href='#L109'>109</a>
|
||||||
|
<a name='L110'></a><a href='#L110'>110</a>
|
||||||
|
<a name='L111'></a><a href='#L111'>111</a>
|
||||||
|
<a name='L112'></a><a href='#L112'>112</a>
|
||||||
|
<a name='L113'></a><a href='#L113'>113</a>
|
||||||
|
<a name='L114'></a><a href='#L114'>114</a>
|
||||||
|
<a name='L115'></a><a href='#L115'>115</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">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[];
|
||||||
|
}
|
||||||
|
</pre></td></tr></table></pre>
|
||||||
|
|
||||||
|
<div class='push'></div><!-- for sticky footer -->
|
||||||
|
</div><!-- /wrapper -->
|
||||||
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
|
Code coverage generated by
|
||||||
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||||
|
at 2026-05-14T13:08:44.986Z
|
||||||
|
</div>
|
||||||
|
<script src="prettify.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
prettyPrint();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="sorter.js"></script>
|
||||||
|
<script src="block-navigation.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
415
services/hometitle/coverage/lcov.info
Normal file
415
services/hometitle/coverage/lcov.info
Normal file
@@ -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
|
||||||
1012
services/hometitle/coverage/matcher.service.ts.html
Normal file
1012
services/hometitle/coverage/matcher.service.ts.html
Normal file
File diff suppressed because it is too large
Load Diff
1
services/hometitle/coverage/prettify.css
Normal file
1
services/hometitle/coverage/prettify.css
Normal file
@@ -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}
|
||||||
2
services/hometitle/coverage/prettify.js
Normal file
2
services/hometitle/coverage/prettify.js
Normal file
File diff suppressed because one or more lines are too long
BIN
services/hometitle/coverage/sort-arrow-sprite.png
Normal file
BIN
services/hometitle/coverage/sort-arrow-sprite.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 138 B |
210
services/hometitle/coverage/sorter.js
Normal file
210
services/hometitle/coverage/sorter.js
Normal file
@@ -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 + '<span class="sorter"></span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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);
|
||||||
427
services/hometitle/coverage/types.ts.html
Normal file
427
services/hometitle/coverage/types.ts.html
Normal file
@@ -0,0 +1,427 @@
|
|||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Code coverage report for types.ts</title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="stylesheet" href="prettify.css" />
|
||||||
|
<link rel="stylesheet" href="base.css" />
|
||||||
|
<link rel="shortcut icon" type="image/x-icon" href="favicon.png" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<style type='text/css'>
|
||||||
|
.coverage-summary .sorter {
|
||||||
|
background-image: url(sort-arrow-sprite.png);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class='wrapper'>
|
||||||
|
<div class='pad1'>
|
||||||
|
<h1><a href="index.html">All files</a> types.ts</h1>
|
||||||
|
<div class='clearfix'>
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Statements</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Branches</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Functions</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='fl pad1y space-right2'>
|
||||||
|
<span class="strong">0% </span>
|
||||||
|
<span class="quiet">Lines</span>
|
||||||
|
<span class='fraction'>0/0</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<p class="quiet">
|
||||||
|
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
||||||
|
</p>
|
||||||
|
<template id="filterTemplate">
|
||||||
|
<div class="quiet">
|
||||||
|
Filter:
|
||||||
|
<input type="search" id="fileSearch">
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div class='status-line low'></div>
|
||||||
|
<pre><table class="coverage">
|
||||||
|
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
||||||
|
<a name='L2'></a><a href='#L2'>2</a>
|
||||||
|
<a name='L3'></a><a href='#L3'>3</a>
|
||||||
|
<a name='L4'></a><a href='#L4'>4</a>
|
||||||
|
<a name='L5'></a><a href='#L5'>5</a>
|
||||||
|
<a name='L6'></a><a href='#L6'>6</a>
|
||||||
|
<a name='L7'></a><a href='#L7'>7</a>
|
||||||
|
<a name='L8'></a><a href='#L8'>8</a>
|
||||||
|
<a name='L9'></a><a href='#L9'>9</a>
|
||||||
|
<a name='L10'></a><a href='#L10'>10</a>
|
||||||
|
<a name='L11'></a><a href='#L11'>11</a>
|
||||||
|
<a name='L12'></a><a href='#L12'>12</a>
|
||||||
|
<a name='L13'></a><a href='#L13'>13</a>
|
||||||
|
<a name='L14'></a><a href='#L14'>14</a>
|
||||||
|
<a name='L15'></a><a href='#L15'>15</a>
|
||||||
|
<a name='L16'></a><a href='#L16'>16</a>
|
||||||
|
<a name='L17'></a><a href='#L17'>17</a>
|
||||||
|
<a name='L18'></a><a href='#L18'>18</a>
|
||||||
|
<a name='L19'></a><a href='#L19'>19</a>
|
||||||
|
<a name='L20'></a><a href='#L20'>20</a>
|
||||||
|
<a name='L21'></a><a href='#L21'>21</a>
|
||||||
|
<a name='L22'></a><a href='#L22'>22</a>
|
||||||
|
<a name='L23'></a><a href='#L23'>23</a>
|
||||||
|
<a name='L24'></a><a href='#L24'>24</a>
|
||||||
|
<a name='L25'></a><a href='#L25'>25</a>
|
||||||
|
<a name='L26'></a><a href='#L26'>26</a>
|
||||||
|
<a name='L27'></a><a href='#L27'>27</a>
|
||||||
|
<a name='L28'></a><a href='#L28'>28</a>
|
||||||
|
<a name='L29'></a><a href='#L29'>29</a>
|
||||||
|
<a name='L30'></a><a href='#L30'>30</a>
|
||||||
|
<a name='L31'></a><a href='#L31'>31</a>
|
||||||
|
<a name='L32'></a><a href='#L32'>32</a>
|
||||||
|
<a name='L33'></a><a href='#L33'>33</a>
|
||||||
|
<a name='L34'></a><a href='#L34'>34</a>
|
||||||
|
<a name='L35'></a><a href='#L35'>35</a>
|
||||||
|
<a name='L36'></a><a href='#L36'>36</a>
|
||||||
|
<a name='L37'></a><a href='#L37'>37</a>
|
||||||
|
<a name='L38'></a><a href='#L38'>38</a>
|
||||||
|
<a name='L39'></a><a href='#L39'>39</a>
|
||||||
|
<a name='L40'></a><a href='#L40'>40</a>
|
||||||
|
<a name='L41'></a><a href='#L41'>41</a>
|
||||||
|
<a name='L42'></a><a href='#L42'>42</a>
|
||||||
|
<a name='L43'></a><a href='#L43'>43</a>
|
||||||
|
<a name='L44'></a><a href='#L44'>44</a>
|
||||||
|
<a name='L45'></a><a href='#L45'>45</a>
|
||||||
|
<a name='L46'></a><a href='#L46'>46</a>
|
||||||
|
<a name='L47'></a><a href='#L47'>47</a>
|
||||||
|
<a name='L48'></a><a href='#L48'>48</a>
|
||||||
|
<a name='L49'></a><a href='#L49'>49</a>
|
||||||
|
<a name='L50'></a><a href='#L50'>50</a>
|
||||||
|
<a name='L51'></a><a href='#L51'>51</a>
|
||||||
|
<a name='L52'></a><a href='#L52'>52</a>
|
||||||
|
<a name='L53'></a><a href='#L53'>53</a>
|
||||||
|
<a name='L54'></a><a href='#L54'>54</a>
|
||||||
|
<a name='L55'></a><a href='#L55'>55</a>
|
||||||
|
<a name='L56'></a><a href='#L56'>56</a>
|
||||||
|
<a name='L57'></a><a href='#L57'>57</a>
|
||||||
|
<a name='L58'></a><a href='#L58'>58</a>
|
||||||
|
<a name='L59'></a><a href='#L59'>59</a>
|
||||||
|
<a name='L60'></a><a href='#L60'>60</a>
|
||||||
|
<a name='L61'></a><a href='#L61'>61</a>
|
||||||
|
<a name='L62'></a><a href='#L62'>62</a>
|
||||||
|
<a name='L63'></a><a href='#L63'>63</a>
|
||||||
|
<a name='L64'></a><a href='#L64'>64</a>
|
||||||
|
<a name='L65'></a><a href='#L65'>65</a>
|
||||||
|
<a name='L66'></a><a href='#L66'>66</a>
|
||||||
|
<a name='L67'></a><a href='#L67'>67</a>
|
||||||
|
<a name='L68'></a><a href='#L68'>68</a>
|
||||||
|
<a name='L69'></a><a href='#L69'>69</a>
|
||||||
|
<a name='L70'></a><a href='#L70'>70</a>
|
||||||
|
<a name='L71'></a><a href='#L71'>71</a>
|
||||||
|
<a name='L72'></a><a href='#L72'>72</a>
|
||||||
|
<a name='L73'></a><a href='#L73'>73</a>
|
||||||
|
<a name='L74'></a><a href='#L74'>74</a>
|
||||||
|
<a name='L75'></a><a href='#L75'>75</a>
|
||||||
|
<a name='L76'></a><a href='#L76'>76</a>
|
||||||
|
<a name='L77'></a><a href='#L77'>77</a>
|
||||||
|
<a name='L78'></a><a href='#L78'>78</a>
|
||||||
|
<a name='L79'></a><a href='#L79'>79</a>
|
||||||
|
<a name='L80'></a><a href='#L80'>80</a>
|
||||||
|
<a name='L81'></a><a href='#L81'>81</a>
|
||||||
|
<a name='L82'></a><a href='#L82'>82</a>
|
||||||
|
<a name='L83'></a><a href='#L83'>83</a>
|
||||||
|
<a name='L84'></a><a href='#L84'>84</a>
|
||||||
|
<a name='L85'></a><a href='#L85'>85</a>
|
||||||
|
<a name='L86'></a><a href='#L86'>86</a>
|
||||||
|
<a name='L87'></a><a href='#L87'>87</a>
|
||||||
|
<a name='L88'></a><a href='#L88'>88</a>
|
||||||
|
<a name='L89'></a><a href='#L89'>89</a>
|
||||||
|
<a name='L90'></a><a href='#L90'>90</a>
|
||||||
|
<a name='L91'></a><a href='#L91'>91</a>
|
||||||
|
<a name='L92'></a><a href='#L92'>92</a>
|
||||||
|
<a name='L93'></a><a href='#L93'>93</a>
|
||||||
|
<a name='L94'></a><a href='#L94'>94</a>
|
||||||
|
<a name='L95'></a><a href='#L95'>95</a>
|
||||||
|
<a name='L96'></a><a href='#L96'>96</a>
|
||||||
|
<a name='L97'></a><a href='#L97'>97</a>
|
||||||
|
<a name='L98'></a><a href='#L98'>98</a>
|
||||||
|
<a name='L99'></a><a href='#L99'>99</a>
|
||||||
|
<a name='L100'></a><a href='#L100'>100</a>
|
||||||
|
<a name='L101'></a><a href='#L101'>101</a>
|
||||||
|
<a name='L102'></a><a href='#L102'>102</a>
|
||||||
|
<a name='L103'></a><a href='#L103'>103</a>
|
||||||
|
<a name='L104'></a><a href='#L104'>104</a>
|
||||||
|
<a name='L105'></a><a href='#L105'>105</a>
|
||||||
|
<a name='L106'></a><a href='#L106'>106</a>
|
||||||
|
<a name='L107'></a><a href='#L107'>107</a>
|
||||||
|
<a name='L108'></a><a href='#L108'>108</a>
|
||||||
|
<a name='L109'></a><a href='#L109'>109</a>
|
||||||
|
<a name='L110'></a><a href='#L110'>110</a>
|
||||||
|
<a name='L111'></a><a href='#L111'>111</a>
|
||||||
|
<a name='L112'></a><a href='#L112'>112</a>
|
||||||
|
<a name='L113'></a><a href='#L113'>113</a>
|
||||||
|
<a name='L114'></a><a href='#L114'>114</a>
|
||||||
|
<a name='L115'></a><a href='#L115'>115</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">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[];
|
||||||
|
}
|
||||||
|
</pre></td></tr></table></pre>
|
||||||
|
|
||||||
|
<div class='push'></div><!-- for sticky footer -->
|
||||||
|
</div><!-- /wrapper -->
|
||||||
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
|
Code coverage generated by
|
||||||
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
||||||
|
at 2026-05-14T13:08:44.978Z
|
||||||
|
</div>
|
||||||
|
<script src="prettify.js"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
prettyPrint();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="sorter.js"></script>
|
||||||
|
<script src="block-navigation.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
22
services/hometitle/package.json
Normal file
22
services/hometitle/package.json
Normal file
@@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
366
services/hometitle/src/alert.pipeline.ts
Normal file
366
services/hometitle/src/alert.pipeline.ts
Normal file
@@ -0,0 +1,366 @@
|
|||||||
|
import { prisma, AlertSeverity, AlertChannel } from '@shieldai/db';
|
||||||
|
import {
|
||||||
|
NotificationService,
|
||||||
|
loadNotificationConfig,
|
||||||
|
} from '@shieldai/shared-notifications';
|
||||||
|
import {
|
||||||
|
ChangeDetectionResult,
|
||||||
|
ChangeType,
|
||||||
|
Severity,
|
||||||
|
PropertyAlert,
|
||||||
|
AlertSeverityLevel,
|
||||||
|
NotificationChannel,
|
||||||
|
AlertPipelineConfig,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
|
const DEFAULT_CONFIG: AlertPipelineConfig = {
|
||||||
|
dedupWindowMs: 24 * 60 * 60 * 1000,
|
||||||
|
minSeverity: 'warning',
|
||||||
|
premiumTierChannels: ['email', 'push', 'sms'],
|
||||||
|
defaultChannels: ['email'],
|
||||||
|
};
|
||||||
|
|
||||||
|
const SEVERITY_MAP: Record<Severity, AlertSeverityLevel> = {
|
||||||
|
critical: 'critical',
|
||||||
|
warning: 'warning',
|
||||||
|
info: 'info',
|
||||||
|
};
|
||||||
|
|
||||||
|
const CHANGE_TYPE_LABELS: Record<ChangeType, string> = {
|
||||||
|
ownership_transfer: 'Ownership Transfer',
|
||||||
|
deed_change: 'Deed Change',
|
||||||
|
lien_filing: 'Lien Filing',
|
||||||
|
tax_change: 'Tax Assessment Change',
|
||||||
|
metadata_change: 'Property Metadata Change',
|
||||||
|
};
|
||||||
|
|
||||||
|
export class HomeTitleAlertPipeline {
|
||||||
|
private notificationService: NotificationService;
|
||||||
|
private config: AlertPipelineConfig;
|
||||||
|
private pendingDedup = new Map<string, number>();
|
||||||
|
|
||||||
|
constructor(config?: Partial<AlertPipelineConfig>) {
|
||||||
|
this.config = { ...DEFAULT_CONFIG, ...config };
|
||||||
|
this.notificationService = NotificationService.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
async processChangeDetection(
|
||||||
|
result: ChangeDetectionResult,
|
||||||
|
subscriptionId: string,
|
||||||
|
userId: string,
|
||||||
|
): Promise<PropertyAlert | null> {
|
||||||
|
const severity = this.mapSeverity(result.severity);
|
||||||
|
const shouldAlert = this.shouldAlert(result, severity);
|
||||||
|
|
||||||
|
if (!shouldAlert) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dedupKey = this.buildDedupKey(userId, result.propertyId, result.changeType);
|
||||||
|
|
||||||
|
const isDuplicate = await this.checkDedup(dedupKey);
|
||||||
|
if (isDuplicate) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const subscription = await prisma.subscription.findUnique({
|
||||||
|
where: { id: subscriptionId },
|
||||||
|
select: { tier: true },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!subscription) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const channels = this.getChannelsForTier(subscription.tier);
|
||||||
|
const title = this.buildTitle(result);
|
||||||
|
const message = this.buildMessage(result);
|
||||||
|
|
||||||
|
const alert = await prisma.alert.create({
|
||||||
|
data: {
|
||||||
|
subscriptionId,
|
||||||
|
userId,
|
||||||
|
type: 'system_warning',
|
||||||
|
title,
|
||||||
|
message,
|
||||||
|
severity: severity as AlertSeverity,
|
||||||
|
channel: channels as AlertChannel[],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await this.recordDedup(dedupKey);
|
||||||
|
|
||||||
|
const propertyAlert: PropertyAlert = {
|
||||||
|
id: alert.id,
|
||||||
|
propertyId: result.propertyId,
|
||||||
|
subscriptionId,
|
||||||
|
userId,
|
||||||
|
changeType: result.changeType,
|
||||||
|
severity,
|
||||||
|
title,
|
||||||
|
message,
|
||||||
|
changeDetectionResult: result,
|
||||||
|
channel: channels,
|
||||||
|
dedupKey,
|
||||||
|
createdAt: alert.createdAt.toISOString(),
|
||||||
|
};
|
||||||
|
|
||||||
|
await this.createNormalizedAlert(result, userId, subscriptionId, alert.id, severity);
|
||||||
|
|
||||||
|
if (subscription.tier === 'premium') {
|
||||||
|
await this.dispatchNotification(propertyAlert, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return propertyAlert;
|
||||||
|
}
|
||||||
|
|
||||||
|
async processBatch(
|
||||||
|
results: ChangeDetectionResult[],
|
||||||
|
subscriptionId: string,
|
||||||
|
userId: string,
|
||||||
|
): Promise<PropertyAlert[]> {
|
||||||
|
const alerts: PropertyAlert[] = [];
|
||||||
|
|
||||||
|
for (const result of results) {
|
||||||
|
const alert = await this.processChangeDetection(result, subscriptionId, userId);
|
||||||
|
if (alert) {
|
||||||
|
alerts.push(alert);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alerts.length > 1) {
|
||||||
|
await this.createCorrelationGroup(alerts, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return alerts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private shouldAlert(result: ChangeDetectionResult, severity: AlertSeverityLevel): boolean {
|
||||||
|
const severityOrder: Severity[] = ['info', 'warning', 'critical'];
|
||||||
|
const minSeverityOrder: Severity[] = ['info', 'warning', 'critical'];
|
||||||
|
const resultIdx = severityOrder.indexOf(result.severity);
|
||||||
|
const minIdx = minSeverityOrder.indexOf(this.config.minSeverity);
|
||||||
|
|
||||||
|
return resultIdx >= minIdx && result.confidence >= 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
private mapSeverity(severity: Severity): AlertSeverityLevel {
|
||||||
|
return SEVERITY_MAP[severity] || 'info';
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildDedupKey(userId: string, propertyId: string, changeType: ChangeType): string {
|
||||||
|
return `hometitle:${userId}:${propertyId}:${changeType}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async checkDedup(dedupKey: string): Promise<boolean> {
|
||||||
|
const parts = dedupKey.split(':');
|
||||||
|
const userId = parts[1] ?? '';
|
||||||
|
const propertyId = parts[2] ?? '';
|
||||||
|
|
||||||
|
const recentAlert = await prisma.alert.findFirst({
|
||||||
|
where: {
|
||||||
|
userId: userId,
|
||||||
|
title: {
|
||||||
|
contains: propertyId,
|
||||||
|
},
|
||||||
|
createdAt: {
|
||||||
|
gte: new Date(Date.now() - this.config.dedupWindowMs),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderBy: { createdAt: 'desc' },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (recentAlert) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const inMemoryExpiry = this.pendingDedup.get(dedupKey);
|
||||||
|
if (inMemoryExpiry && Date.now() < inMemoryExpiry) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async recordDedup(dedupKey: string): Promise<void> {
|
||||||
|
this.pendingDedup.set(
|
||||||
|
dedupKey,
|
||||||
|
Date.now() + this.config.dedupWindowMs,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getChannelsForTier(tier: string): NotificationChannel[] {
|
||||||
|
if (tier === 'premium') {
|
||||||
|
return [...this.config.premiumTierChannels];
|
||||||
|
}
|
||||||
|
return [...this.config.defaultChannels];
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildTitle(result: ChangeDetectionResult): string {
|
||||||
|
const label = CHANGE_TYPE_LABELS[result.changeType] || 'Property Change';
|
||||||
|
const severityUpper = result.severity.toUpperCase();
|
||||||
|
return `[${severityUpper}] ${label} detected`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildMessage(result: ChangeDetectionResult): string {
|
||||||
|
const changes = result.changes
|
||||||
|
.map(c => `- ${c.field}: ${String(c.oldValue)} → ${String(c.newValue)}`)
|
||||||
|
.join('\n');
|
||||||
|
|
||||||
|
return `Change detected on property ${result.propertyId}.\n\nChanges:\n${changes}\n\nConfidence: ${(result.confidence * 100).toFixed(1)}%`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async createNormalizedAlert(
|
||||||
|
result: ChangeDetectionResult,
|
||||||
|
userId: string,
|
||||||
|
subscriptionId: string,
|
||||||
|
sourceAlertId: string,
|
||||||
|
severity: AlertSeverityLevel,
|
||||||
|
): Promise<void> {
|
||||||
|
const normalizedSeverity = this.mapToNormalizedSeverity(severity);
|
||||||
|
|
||||||
|
await prisma.normalizedAlert.create({
|
||||||
|
data: {
|
||||||
|
source: 'DARKWATCH' as any,
|
||||||
|
category: this.mapToAlertCategory(result.changeType) as any,
|
||||||
|
severity: normalizedSeverity as any,
|
||||||
|
userId,
|
||||||
|
title: this.buildTitle(result),
|
||||||
|
description: this.buildMessage(result),
|
||||||
|
entities: JSON.stringify({
|
||||||
|
propertyId: result.propertyId,
|
||||||
|
changeType: result.changeType,
|
||||||
|
subscriptionId,
|
||||||
|
}),
|
||||||
|
sourceAlertId,
|
||||||
|
payload: JSON.stringify({
|
||||||
|
confidence: result.confidence,
|
||||||
|
changes: result.changes,
|
||||||
|
detectedAt: result.detectedAt,
|
||||||
|
}),
|
||||||
|
createdAt: new Date(result.detectedAt),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async createCorrelationGroup(
|
||||||
|
alerts: PropertyAlert[],
|
||||||
|
userId: string,
|
||||||
|
): Promise<void> {
|
||||||
|
const entities = JSON.stringify({
|
||||||
|
propertyIds: [...new Set(alerts.map(a => a.propertyId))],
|
||||||
|
changeTypes: [...new Set(alerts.map(a => a.changeType))],
|
||||||
|
});
|
||||||
|
|
||||||
|
const highestSeverity = alerts.reduce((max, alert) => {
|
||||||
|
const order: AlertSeverityLevel[] = ['info', 'warning', 'critical'];
|
||||||
|
return order.indexOf(alert.severity) > order.indexOf(max) ? alert.severity : max;
|
||||||
|
}, 'info' as AlertSeverityLevel);
|
||||||
|
|
||||||
|
const group = await prisma.correlationGroup.create({
|
||||||
|
data: {
|
||||||
|
userId,
|
||||||
|
entities,
|
||||||
|
highestSeverity: this.mapToNormalizedSeverity(highestSeverity) as any,
|
||||||
|
status: 'ACTIVE',
|
||||||
|
alertCount: alerts.length,
|
||||||
|
summary: `${alerts.length} property change alert${alerts.length > 1 ? 's' : ''} correlated`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await prisma.normalizedAlert.updateMany({
|
||||||
|
where: {
|
||||||
|
sourceAlertId: { in: alerts.map(a => a.id) },
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
groupId: group.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async dispatchNotification(
|
||||||
|
alert: PropertyAlert,
|
||||||
|
userId: string,
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
const user = await prisma.user.findUnique({
|
||||||
|
where: { id: userId },
|
||||||
|
select: { email: true, name: true, phone: true },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!user?.email) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const htmlMessage = `<p>${alert.message.replace(/\n/g, '<br>')}</p>
|
||||||
|
<p><strong>Property:</strong> ${alert.propertyId}</p>
|
||||||
|
<p><strong>Change Type:</strong> ${CHANGE_TYPE_LABELS[alert.changeType]}</p>
|
||||||
|
<p><strong>Severity:</strong> ${alert.severity.toUpperCase()}</p>`;
|
||||||
|
|
||||||
|
for (const channel of alert.channel) {
|
||||||
|
switch (channel) {
|
||||||
|
case 'email':
|
||||||
|
await this.notificationService.send({
|
||||||
|
channel: 'email',
|
||||||
|
to: user.email,
|
||||||
|
subject: alert.title,
|
||||||
|
htmlBody: htmlMessage,
|
||||||
|
textBody: alert.message,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'push':
|
||||||
|
await this.notificationService.send({
|
||||||
|
channel: 'push',
|
||||||
|
userId,
|
||||||
|
title: alert.title,
|
||||||
|
body: alert.message.slice(0, 200),
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'sms':
|
||||||
|
await this.notificationService.send({
|
||||||
|
channel: 'sms',
|
||||||
|
to: user.phone ?? '',
|
||||||
|
body: `[ShieldAI] ${alert.title}: ${alert.message.slice(0, 140)}`,
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[HomeTitleAlertPipeline] Notification dispatch error:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private mapToNormalizedSeverity(severity: AlertSeverityLevel): string {
|
||||||
|
const map: Record<AlertSeverityLevel, string> = {
|
||||||
|
info: 'INFO',
|
||||||
|
warning: 'WARNING',
|
||||||
|
critical: 'CRITICAL',
|
||||||
|
};
|
||||||
|
return map[severity] || 'INFO';
|
||||||
|
}
|
||||||
|
|
||||||
|
private mapToAlertCategory(changeType: ChangeType): string {
|
||||||
|
const map: Record<ChangeType, string> = {
|
||||||
|
ownership_transfer: 'HOME_TITLE',
|
||||||
|
deed_change: 'HOME_TITLE',
|
||||||
|
lien_filing: 'HOME_TITLE',
|
||||||
|
tax_change: 'HOME_TITLE',
|
||||||
|
metadata_change: 'HOME_TITLE',
|
||||||
|
};
|
||||||
|
return map[changeType] || 'HOME_TITLE';
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanupExpiredDedups(): number {
|
||||||
|
const now = Date.now();
|
||||||
|
let cleaned = 0;
|
||||||
|
for (const [key, expiry] of this.pendingDedup) {
|
||||||
|
if (now >= expiry) {
|
||||||
|
this.pendingDedup.delete(key);
|
||||||
|
cleaned++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleaned;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const homeTitleAlertPipeline = new HomeTitleAlertPipeline();
|
||||||
202
services/hometitle/src/change-detector.ts
Normal file
202
services/hometitle/src/change-detector.ts
Normal file
@@ -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<ChangeType, Severity> = {
|
||||||
|
ownership_transfer: (severityOverrides as Record<string, Severity>)['ownership_transfer'] || 'critical',
|
||||||
|
deed_change: (severityOverrides as Record<string, Severity>)['deed_change'] || 'warning',
|
||||||
|
lien_filing: (severityOverrides as Record<string, Severity>)['lien_filing'] || 'warning',
|
||||||
|
tax_change: (severityOverrides as Record<string, Severity>)['tax_change'] || 'info',
|
||||||
|
metadata_change: (severityOverrides as Record<string, Severity>)['metadata_change'] || 'info',
|
||||||
|
};
|
||||||
|
|
||||||
|
const severityOrder: Severity[] = ['critical', 'warning', 'info'];
|
||||||
|
|
||||||
|
for (const change of changes) {
|
||||||
|
const sev = typeToSeverity[change.changeType];
|
||||||
|
const idx = severityOrder.indexOf(sev);
|
||||||
|
if (idx === 0) return 'critical';
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const change of changes) {
|
||||||
|
const sev = typeToSeverity[change.changeType];
|
||||||
|
if (sev === 'warning') return 'warning';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'info';
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = 'warning'): boolean {
|
||||||
|
const severityOrder: Severity[] = ['info', 'warning', 'critical'];
|
||||||
|
const resultIdx = severityOrder.indexOf(result.severity);
|
||||||
|
const minIdx = severityOrder.indexOf(minSeverity);
|
||||||
|
return resultIdx >= minIdx && result.confidence >= 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { classifyFieldChange, determineSeverity, computeChangeConfidence };
|
||||||
43
services/hometitle/src/index.ts
Normal file
43
services/hometitle/src/index.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
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,
|
||||||
|
AlertSeverityLevel,
|
||||||
|
PropertyAlert,
|
||||||
|
NotificationChannel,
|
||||||
|
AlertPipelineConfig,
|
||||||
|
SchedulerConfig,
|
||||||
|
ScheduledScanResult,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
|
export { HomeTitleAlertPipeline, homeTitleAlertPipeline } from './alert.pipeline';
|
||||||
|
export { HomeTitleSchedulerService, homeTitleScheduler } from './scheduler.service';
|
||||||
309
services/hometitle/src/matcher.service.ts
Normal file
309
services/hometitle/src/matcher.service.ts
Normal file
@@ -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<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(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
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<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 };
|
||||||
234
services/hometitle/src/scheduler.service.ts
Normal file
234
services/hometitle/src/scheduler.service.ts
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
import { prisma } from '@shieldai/db';
|
||||||
|
import { detectChanges, shouldTriggerAlert } from './change-detector';
|
||||||
|
import { homeTitleAlertPipeline } from './alert.pipeline';
|
||||||
|
import {
|
||||||
|
PropertySnapshot,
|
||||||
|
SchedulerConfig,
|
||||||
|
ScheduledScanResult,
|
||||||
|
} from './types';
|
||||||
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
|
const DEFAULT_SCHEDULER_CONFIG: SchedulerConfig = {
|
||||||
|
scanIntervalMinutes: 60,
|
||||||
|
premiumScanIntervalMinutes: 30,
|
||||||
|
maxPropertiesPerScan: 100,
|
||||||
|
enabled: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
export class HomeTitleSchedulerService {
|
||||||
|
private config: SchedulerConfig;
|
||||||
|
private timerId: NodeJS.Timeout | null = null;
|
||||||
|
private running = false;
|
||||||
|
private lastScanResult: ScheduledScanResult | null = null;
|
||||||
|
|
||||||
|
constructor(config?: Partial<SchedulerConfig>) {
|
||||||
|
this.config = { ...DEFAULT_SCHEDULER_CONFIG, ...config };
|
||||||
|
}
|
||||||
|
|
||||||
|
getConfig(): SchedulerConfig {
|
||||||
|
return { ...this.config };
|
||||||
|
}
|
||||||
|
|
||||||
|
updateConfig(partial: Partial<SchedulerConfig>): void {
|
||||||
|
this.config = { ...this.config, ...partial };
|
||||||
|
if (partial.scanIntervalMinutes && this.timerId) {
|
||||||
|
this.stop();
|
||||||
|
this.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
start(): void {
|
||||||
|
if (!this.config.enabled) return;
|
||||||
|
|
||||||
|
const intervalMs = this.config.scanIntervalMinutes * 60 * 1000;
|
||||||
|
this.running = true;
|
||||||
|
|
||||||
|
this.timerId = setInterval(async () => {
|
||||||
|
if (this.running) {
|
||||||
|
try {
|
||||||
|
const result = await this.runScan();
|
||||||
|
this.lastScanResult = result;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[HomeTitleScheduler] Scan error:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, intervalMs);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`[HomeTitleScheduler] Started with ${this.config.scanIntervalMinutes}min interval`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
stop(): void {
|
||||||
|
this.running = false;
|
||||||
|
if (this.timerId) {
|
||||||
|
clearInterval(this.timerId);
|
||||||
|
this.timerId = null;
|
||||||
|
}
|
||||||
|
console.log('[HomeTitleScheduler] Stopped');
|
||||||
|
}
|
||||||
|
|
||||||
|
async runScan(): Promise<ScheduledScanResult> {
|
||||||
|
const scanId = uuidv4();
|
||||||
|
const startedAt = new Date().toISOString();
|
||||||
|
const errors: string[] = [];
|
||||||
|
let changesDetected = 0;
|
||||||
|
let alertsCreated = 0;
|
||||||
|
let notificationsSent = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const subscriptions = await prisma.subscription.findMany({
|
||||||
|
where: {
|
||||||
|
status: 'active',
|
||||||
|
tier: { in: ['plus', 'premium'] },
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
userId: true,
|
||||||
|
tier: true,
|
||||||
|
},
|
||||||
|
take: this.config.maxPropertiesPerScan,
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const subscription of subscriptions) {
|
||||||
|
try {
|
||||||
|
const propertySnapshots = await this.fetchLatestSnapshots(
|
||||||
|
subscription.userId,
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const snapshot of propertySnapshots) {
|
||||||
|
const previousSnapshot = await this.fetchPreviousSnapshot(
|
||||||
|
snapshot.propertyId,
|
||||||
|
snapshot.id,
|
||||||
|
snapshot.capturedAt,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!previousSnapshot) continue;
|
||||||
|
|
||||||
|
const result = detectChanges(previousSnapshot, snapshot);
|
||||||
|
|
||||||
|
if (shouldTriggerAlert(result, 'moderate')) {
|
||||||
|
changesDetected++;
|
||||||
|
|
||||||
|
const alert = await homeTitleAlertPipeline.processChangeDetection(
|
||||||
|
result,
|
||||||
|
subscription.id,
|
||||||
|
subscription.userId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (alert) {
|
||||||
|
alertsCreated++;
|
||||||
|
if (subscription.tier === 'premium') {
|
||||||
|
notificationsSent++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
const errorMsg = `Subscription ${subscription.id}: ${error instanceof Error ? error.message : String(error)}`;
|
||||||
|
errors.push(errorMsg);
|
||||||
|
console.error(`[HomeTitleScheduler] Subscription scan error:`, errorMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
const errorMsg = `Scan ${scanId}: ${error instanceof Error ? error.message : String(error)}`;
|
||||||
|
errors.push(errorMsg);
|
||||||
|
console.error(`[HomeTitleScheduler] Scan error:`, errorMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
const completedAt = new Date().toISOString();
|
||||||
|
|
||||||
|
const scanResult: ScheduledScanResult = {
|
||||||
|
scanId,
|
||||||
|
propertiesScanned: changesDetected,
|
||||||
|
changesDetected,
|
||||||
|
alertsCreated,
|
||||||
|
notificationsSent,
|
||||||
|
errors,
|
||||||
|
startedAt,
|
||||||
|
completedAt,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.lastScanResult = scanResult;
|
||||||
|
|
||||||
|
return scanResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
getLastScanResult(): ScheduledScanResult | null {
|
||||||
|
return this.lastScanResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
isRunning(): boolean {
|
||||||
|
return this.running;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async fetchLatestSnapshots(userId: string): Promise<PropertySnapshot[]> {
|
||||||
|
const rawSnapshots = await prisma.$queryRaw<
|
||||||
|
Array<Record<string, unknown>>
|
||||||
|
>`
|
||||||
|
SELECT "id", "propertyId", "capturedAt", "ownerName",
|
||||||
|
"deedDate", "taxId", "propertyType",
|
||||||
|
"taxAmount", "lienCount"
|
||||||
|
FROM "PropertySnapshot"
|
||||||
|
WHERE "propertyId" IN (
|
||||||
|
SELECT "propertyId" FROM "WatchlistItem"
|
||||||
|
WHERE "subscriptionId" IN (
|
||||||
|
SELECT "id" FROM "Subscription" WHERE "userId" = ${userId}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
ORDER BY "capturedAt" DESC
|
||||||
|
LIMIT ${this.config.maxPropertiesPerScan}
|
||||||
|
`;
|
||||||
|
|
||||||
|
return rawSnapshots.map(row => ({
|
||||||
|
id: String(row.id),
|
||||||
|
propertyId: String(row.propertyId),
|
||||||
|
capturedAt: String(row.capturedAt),
|
||||||
|
ownerName: String(row.ownerName),
|
||||||
|
address: row.address ? JSON.parse(String(row.address)) : {},
|
||||||
|
deedDate: row.deedDate ? String(row.deedDate) : undefined,
|
||||||
|
taxId: row.taxId ? String(row.taxId) : undefined,
|
||||||
|
propertyType: String(row.propertyType) as PropertySnapshot['propertyType'],
|
||||||
|
taxAmount: row.taxAmount ? Number(row.taxAmount) : undefined,
|
||||||
|
lienCount: row.lienCount ? Number(row.lienCount) : undefined,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async fetchPreviousSnapshot(
|
||||||
|
propertyId: string,
|
||||||
|
currentSnapshotId: string,
|
||||||
|
currentCapturedAt: string,
|
||||||
|
): Promise<PropertySnapshot | null> {
|
||||||
|
const rawSnapshots = await prisma.$queryRaw<
|
||||||
|
Array<Record<string, unknown>>
|
||||||
|
>`
|
||||||
|
SELECT "id", "propertyId", "capturedAt", "ownerName",
|
||||||
|
"deedDate", "taxId", "propertyType",
|
||||||
|
"taxAmount", "lienCount"
|
||||||
|
FROM "PropertySnapshot"
|
||||||
|
WHERE "propertyId" = ${propertyId}
|
||||||
|
AND "capturedAt" < ${currentCapturedAt}
|
||||||
|
AND "id" != ${currentSnapshotId}
|
||||||
|
ORDER BY "capturedAt" DESC
|
||||||
|
LIMIT 1
|
||||||
|
`;
|
||||||
|
|
||||||
|
if (rawSnapshots.length === 0) return null;
|
||||||
|
|
||||||
|
const row = rawSnapshots[0];
|
||||||
|
return {
|
||||||
|
id: String(row.id),
|
||||||
|
propertyId: String(row.propertyId),
|
||||||
|
capturedAt: String(row.capturedAt),
|
||||||
|
ownerName: String(row.ownerName),
|
||||||
|
address: row.address ? JSON.parse(String(row.address)) : {},
|
||||||
|
deedDate: row.deedDate ? String(row.deedDate) : undefined,
|
||||||
|
taxId: row.taxId ? String(row.taxId) : undefined,
|
||||||
|
propertyType: String(row.propertyType) as PropertySnapshot['propertyType'],
|
||||||
|
taxAmount: row.taxAmount ? Number(row.taxAmount) : undefined,
|
||||||
|
lienCount: row.lienCount ? Number(row.lienCount) : undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const homeTitleScheduler = new HomeTitleSchedulerService();
|
||||||
166
services/hometitle/src/types.ts
Normal file
166
services/hometitle/src/types.ts
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
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 = 'info' | 'warning' | 'critical';
|
||||||
|
|
||||||
|
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[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Alert Pipeline Types
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
export type AlertSeverityLevel = 'info' | 'warning' | 'critical';
|
||||||
|
|
||||||
|
export interface PropertyAlert {
|
||||||
|
id: string;
|
||||||
|
propertyId: string;
|
||||||
|
subscriptionId: string;
|
||||||
|
userId: string;
|
||||||
|
changeType: ChangeType;
|
||||||
|
severity: AlertSeverityLevel;
|
||||||
|
title: string;
|
||||||
|
message: string;
|
||||||
|
changeDetectionResult: ChangeDetectionResult;
|
||||||
|
channel: NotificationChannel[];
|
||||||
|
dedupKey: string;
|
||||||
|
createdAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NotificationChannel = 'email' | 'sms' | 'push';
|
||||||
|
|
||||||
|
export interface AlertPipelineConfig {
|
||||||
|
dedupWindowMs: number;
|
||||||
|
minSeverity: Severity;
|
||||||
|
premiumTierChannels: NotificationChannel[];
|
||||||
|
defaultChannels: NotificationChannel[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Scheduler Types
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
export interface SchedulerConfig {
|
||||||
|
scanIntervalMinutes: number;
|
||||||
|
premiumScanIntervalMinutes: number;
|
||||||
|
maxPropertiesPerScan: number;
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScheduledScanResult {
|
||||||
|
scanId: string;
|
||||||
|
propertiesScanned: number;
|
||||||
|
changesDetected: number;
|
||||||
|
alertsCreated: number;
|
||||||
|
notificationsSent: number;
|
||||||
|
errors: string[];
|
||||||
|
startedAt: string;
|
||||||
|
completedAt: string;
|
||||||
|
}
|
||||||
429
services/hometitle/test/alert.pipeline.test.ts
Normal file
429
services/hometitle/test/alert.pipeline.test.ts
Normal file
@@ -0,0 +1,429 @@
|
|||||||
|
import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest';
|
||||||
|
import { HomeTitleAlertPipeline } from '../src/alert.pipeline';
|
||||||
|
import {
|
||||||
|
ChangeDetectionResult,
|
||||||
|
PropertySnapshot,
|
||||||
|
ChangeType,
|
||||||
|
Severity,
|
||||||
|
} from '../src/types';
|
||||||
|
|
||||||
|
// All mocks inside vi.hoisted() to avoid vitest hoisting issues
|
||||||
|
const mockedDb = vi.hoisted(() => {
|
||||||
|
const mocks = {
|
||||||
|
subscription: { findUnique: vi.fn() },
|
||||||
|
alert: { create: vi.fn(), findFirst: vi.fn() },
|
||||||
|
normalizedAlert: { create: vi.fn(), updateMany: vi.fn() },
|
||||||
|
correlationGroup: { create: vi.fn() },
|
||||||
|
user: { findUnique: vi.fn() },
|
||||||
|
};
|
||||||
|
return mocks;
|
||||||
|
});
|
||||||
|
|
||||||
|
vi.mock('@shieldai/db', () => {
|
||||||
|
const mocks = vi.hoisted ? mockedDb : {
|
||||||
|
subscription: { findUnique: vi.fn() },
|
||||||
|
alert: { create: vi.fn(), findFirst: vi.fn() },
|
||||||
|
normalizedAlert: { create: vi.fn(), updateMany: vi.fn() },
|
||||||
|
correlationGroup: { create: vi.fn() },
|
||||||
|
user: { findUnique: vi.fn() },
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
prisma: mocks,
|
||||||
|
AlertSeverity: { INFO: 'INFO', WARNING: 'WARNING', CRITICAL: 'CRITICAL' },
|
||||||
|
AlertChannel: { EMAIL: 'email', PUSH: 'push', SMS: 'sms' },
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
vi.mock('@shieldai/shared-notifications', () => {
|
||||||
|
const mockSend = vi.fn().mockResolvedValue({ notificationId: 'mock-notif', status: 'sent' });
|
||||||
|
class MockNotificationService {
|
||||||
|
send = mockSend;
|
||||||
|
static getInstance() { return new MockNotificationService(); }
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
NotificationService: MockNotificationService,
|
||||||
|
loadNotificationConfig: () => ({ apiKey: 'test-key', baseUrl: 'http://localhost:3000' }),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
function buildChangeResult(overrides: Partial<ChangeDetectionResult> = {}): ChangeDetectionResult {
|
||||||
|
return {
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
changeType: 'ownership_transfer' as ChangeType,
|
||||||
|
severity: 'critical' as Severity,
|
||||||
|
confidence: 0.95,
|
||||||
|
changes: [
|
||||||
|
{ field: 'ownerName', oldValue: 'John Doe', newValue: 'Jane Smith', changeType: 'ownership_transfer' as ChangeType },
|
||||||
|
],
|
||||||
|
previousSnapshot: {
|
||||||
|
id: 'snap-1',
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
capturedAt: '2026-01-01T00:00:00Z',
|
||||||
|
ownerName: 'John Doe',
|
||||||
|
address: { streetNumber: '123', streetName: 'main', city: 'springfield', state: 'IL', zip: '62701' },
|
||||||
|
propertyType: 'residential',
|
||||||
|
} as PropertySnapshot,
|
||||||
|
currentSnapshot: {
|
||||||
|
id: 'snap-2',
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
capturedAt: '2026-02-01T00:00:00Z',
|
||||||
|
ownerName: 'Jane Smith',
|
||||||
|
address: { streetNumber: '123', streetName: 'main', city: 'springfield', state: 'IL', zip: '62701' },
|
||||||
|
propertyType: 'residential',
|
||||||
|
} as PropertySnapshot,
|
||||||
|
detectedAt: '2026-05-14T12:00:00Z',
|
||||||
|
...overrides,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('HomeTitleAlertPipeline', () => {
|
||||||
|
let pipeline: HomeTitleAlertPipeline;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
mockedDb.subscription.findUnique.mockClear();
|
||||||
|
mockedDb.alert.findFirst.mockClear();
|
||||||
|
mockedDb.alert.create.mockClear();
|
||||||
|
mockedDb.normalizedAlert.create.mockClear();
|
||||||
|
mockedDb.normalizedAlert.updateMany.mockClear();
|
||||||
|
mockedDb.correlationGroup.create.mockClear();
|
||||||
|
mockedDb.user.findUnique.mockClear();
|
||||||
|
|
||||||
|
pipeline = new HomeTitleAlertPipeline();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.useRealTimers();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('processChangeDetection', () => {
|
||||||
|
it('creates alert for critical severity change', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue({ tier: 'premium' });
|
||||||
|
mockedDb.alert.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.alert.create.mockResolvedValue({
|
||||||
|
id: 'alert-001',
|
||||||
|
subscriptionId: 'sub-001',
|
||||||
|
userId: 'user-001',
|
||||||
|
type: 'system_warning',
|
||||||
|
title: '[CRITICAL] Ownership Transfer detected',
|
||||||
|
message: 'Change detected',
|
||||||
|
severity: 'CRITICAL',
|
||||||
|
channel: ['email', 'push', 'sms'],
|
||||||
|
createdAt: new Date('2026-05-14T12:00:00Z'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = buildChangeResult({
|
||||||
|
changeType: 'ownership_transfer',
|
||||||
|
severity: 'critical',
|
||||||
|
confidence: 0.95,
|
||||||
|
});
|
||||||
|
|
||||||
|
const alert = await pipeline.processChangeDetection(result, 'sub-001', 'user-001');
|
||||||
|
|
||||||
|
expect(alert).toBeDefined();
|
||||||
|
expect(alert?.changeType).toBe('ownership_transfer');
|
||||||
|
expect(alert?.severity).toBe('critical');
|
||||||
|
expect(mockedDb.alert.create).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('creates alert for warning severity change', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue({ tier: 'plus' });
|
||||||
|
mockedDb.alert.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.alert.create.mockResolvedValue({
|
||||||
|
id: 'alert-002',
|
||||||
|
subscriptionId: 'sub-001',
|
||||||
|
userId: 'user-001',
|
||||||
|
type: 'system_warning',
|
||||||
|
title: '[WARNING] Deed Change detected',
|
||||||
|
message: 'Change detected',
|
||||||
|
severity: 'WARNING',
|
||||||
|
channel: ['email', 'push'],
|
||||||
|
createdAt: new Date('2026-05-14T12:00:00Z'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = buildChangeResult({
|
||||||
|
changeType: 'deed_change',
|
||||||
|
severity: 'warning',
|
||||||
|
confidence: 0.85,
|
||||||
|
});
|
||||||
|
|
||||||
|
const alert = await pipeline.processChangeDetection(result, 'sub-001', 'user-001');
|
||||||
|
|
||||||
|
expect(alert).toBeDefined();
|
||||||
|
expect(alert?.changeType).toBe('deed_change');
|
||||||
|
expect(alert?.severity).toBe('warning');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns null when subscription not found', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(null);
|
||||||
|
|
||||||
|
const result = buildChangeResult();
|
||||||
|
const alert = await pipeline.processChangeDetection(result, 'sub-999', 'user-001');
|
||||||
|
|
||||||
|
expect(alert).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns null for minor severity with default minSeverity', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue({ tier: 'premium' });
|
||||||
|
|
||||||
|
const result = buildChangeResult({
|
||||||
|
changeType: 'tax_change',
|
||||||
|
severity: 'minor',
|
||||||
|
confidence: 0.85,
|
||||||
|
});
|
||||||
|
|
||||||
|
const alert = await pipeline.processChangeDetection(result, 'sub-001', 'user-001');
|
||||||
|
|
||||||
|
expect(alert).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns null when confidence below threshold', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue({ tier: 'premium' });
|
||||||
|
|
||||||
|
const result = buildChangeResult({
|
||||||
|
confidence: 0.5,
|
||||||
|
});
|
||||||
|
|
||||||
|
const alert = await pipeline.processChangeDetection(result, 'sub-001', 'user-001');
|
||||||
|
|
||||||
|
expect(alert).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('deduplicates alerts within 24h window', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue({ tier: 'premium' });
|
||||||
|
mockedDb.alert.findFirst.mockResolvedValue({ id: 'existing-alert' });
|
||||||
|
|
||||||
|
const result = buildChangeResult();
|
||||||
|
const first = await pipeline.processChangeDetection(result, 'sub-001', 'user-001');
|
||||||
|
const second = await pipeline.processChangeDetection(result, 'sub-001', 'user-001');
|
||||||
|
|
||||||
|
expect(first).toBeDefined();
|
||||||
|
expect(second).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('creates normalized alert for integration with correlation engine', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue({ tier: 'premium' });
|
||||||
|
mockedDb.alert.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.alert.create.mockResolvedValue({
|
||||||
|
id: 'alert-003',
|
||||||
|
subscriptionId: 'sub-001',
|
||||||
|
userId: 'user-001',
|
||||||
|
type: 'system_warning',
|
||||||
|
title: '[MAJOR] Ownership Transfer detected',
|
||||||
|
message: 'Change detected',
|
||||||
|
severity: 'CRITICAL',
|
||||||
|
channel: ['email', 'push', 'sms'],
|
||||||
|
createdAt: new Date('2026-05-14T12:00:00Z'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = buildChangeResult();
|
||||||
|
await pipeline.processChangeDetection(result, 'sub-001', 'user-001');
|
||||||
|
|
||||||
|
expect(mockedDb.normalizedAlert.create).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
data: expect.objectContaining({
|
||||||
|
source: 'DARKWATCH',
|
||||||
|
userId: 'user-001',
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('dispatches notifications for premium tier', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue({ tier: 'premium' });
|
||||||
|
mockedDb.alert.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.alert.create.mockResolvedValue({
|
||||||
|
id: 'alert-004',
|
||||||
|
subscriptionId: 'sub-001',
|
||||||
|
userId: 'user-001',
|
||||||
|
type: 'system_warning',
|
||||||
|
title: '[MAJOR] Ownership Transfer detected',
|
||||||
|
message: 'Change detected on property prop-001.\n\nChanges:\n- ownerName: John Doe → Jane Smith',
|
||||||
|
severity: 'CRITICAL',
|
||||||
|
channel: ['email', 'push', 'sms'],
|
||||||
|
createdAt: new Date('2026-05-14T12:00:00Z'),
|
||||||
|
});
|
||||||
|
mockedDb.user.findUnique.mockResolvedValue({
|
||||||
|
email: 'test@example.com',
|
||||||
|
name: 'Test User',
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = buildChangeResult();
|
||||||
|
await pipeline.processChangeDetection(result, 'sub-001', 'user-001');
|
||||||
|
|
||||||
|
// Notification service was instantiated (no error thrown)
|
||||||
|
expect(mockedDb.user.findUnique).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('records dedup key in memory', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue({ tier: 'premium' });
|
||||||
|
mockedDb.alert.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.alert.create.mockResolvedValue({
|
||||||
|
id: 'alert-005',
|
||||||
|
subscriptionId: 'sub-001',
|
||||||
|
userId: 'user-001',
|
||||||
|
type: 'system_warning',
|
||||||
|
title: '[MAJOR] Ownership Transfer detected',
|
||||||
|
message: 'Change',
|
||||||
|
severity: 'CRITICAL',
|
||||||
|
channel: ['email'],
|
||||||
|
createdAt: new Date('2026-05-14T12:00:00Z'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = buildChangeResult({ changeType: 'ownership_transfer' });
|
||||||
|
await pipeline.processChangeDetection(result, 'sub-001', 'user-001');
|
||||||
|
|
||||||
|
// No expired dedups at this point
|
||||||
|
const cleanupCount = pipeline.cleanupExpiredDedups();
|
||||||
|
expect(cleanupCount).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('processBatch', () => {
|
||||||
|
it('processes multiple change results', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue({ tier: 'premium' });
|
||||||
|
mockedDb.alert.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.alert.create.mockResolvedValue({
|
||||||
|
id: 'alert-batch-1',
|
||||||
|
subscriptionId: 'sub-001',
|
||||||
|
userId: 'user-001',
|
||||||
|
type: 'system_warning',
|
||||||
|
title: '[CRITICAL] Ownership Transfer detected',
|
||||||
|
message: 'Change 1',
|
||||||
|
severity: 'CRITICAL',
|
||||||
|
channel: ['email'],
|
||||||
|
createdAt: new Date('2026-05-14T12:00:00Z'),
|
||||||
|
});
|
||||||
|
mockedDb.user.findUnique.mockResolvedValue({ email: 'test@example.com', name: 'Test' });
|
||||||
|
mockedDb.correlationGroup.create.mockResolvedValue({ id: 'group-001' });
|
||||||
|
|
||||||
|
const results = [
|
||||||
|
buildChangeResult({ changeType: 'ownership_transfer', propertyId: 'prop-001' }),
|
||||||
|
buildChangeResult({ changeType: 'deed_change', propertyId: 'prop-002' }),
|
||||||
|
];
|
||||||
|
|
||||||
|
const alerts = await pipeline.processBatch(results, 'sub-001', 'user-001');
|
||||||
|
|
||||||
|
expect(alerts.length).toBe(2);
|
||||||
|
expect(mockedDb.alert.create).toHaveBeenCalledTimes(results.length);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('creates correlation group for multiple alerts', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue({ tier: 'premium' });
|
||||||
|
mockedDb.alert.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.alert.create.mockResolvedValue({
|
||||||
|
id: 'alert-batch-' + Date.now(),
|
||||||
|
subscriptionId: 'sub-001',
|
||||||
|
userId: 'user-001',
|
||||||
|
type: 'system_warning',
|
||||||
|
title: '[CRITICAL] Ownership Transfer detected',
|
||||||
|
message: 'Change',
|
||||||
|
severity: 'CRITICAL',
|
||||||
|
channel: ['email'],
|
||||||
|
createdAt: new Date('2026-05-14T12:00:00Z'),
|
||||||
|
});
|
||||||
|
mockedDb.user.findUnique.mockResolvedValue({ email: 'test@example.com', name: 'Test' });
|
||||||
|
mockedDb.correlationGroup.create.mockResolvedValue({ id: 'group-002' });
|
||||||
|
|
||||||
|
const results = [
|
||||||
|
buildChangeResult({ changeType: 'ownership_transfer', propertyId: 'prop-001' }),
|
||||||
|
buildChangeResult({ changeType: 'deed_change', propertyId: 'prop-002' }),
|
||||||
|
];
|
||||||
|
|
||||||
|
await pipeline.processBatch(results, 'sub-001', 'user-001');
|
||||||
|
|
||||||
|
expect(mockedDb.correlationGroup.create).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns empty array when all results are deduplicated', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue({ tier: 'premium' });
|
||||||
|
mockedDb.alert.findFirst.mockResolvedValue({ id: 'existing-alert' });
|
||||||
|
|
||||||
|
const results = [
|
||||||
|
buildChangeResult({ changeType: 'ownership_transfer', propertyId: 'prop-001' }),
|
||||||
|
];
|
||||||
|
|
||||||
|
const alerts = await pipeline.processBatch(results, 'sub-001', 'user-001');
|
||||||
|
expect(alerts).toEqual([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('cleanupExpiredDedups', () => {
|
||||||
|
it('removes expired dedup entries', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue({ tier: 'premium' });
|
||||||
|
mockedDb.alert.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.alert.create.mockResolvedValue({
|
||||||
|
id: 'alert-cleanup',
|
||||||
|
subscriptionId: 'sub-001',
|
||||||
|
userId: 'user-001',
|
||||||
|
type: 'system_warning',
|
||||||
|
title: '[CRITICAL] Ownership Transfer detected',
|
||||||
|
message: 'Change',
|
||||||
|
severity: 'CRITICAL',
|
||||||
|
channel: ['email'],
|
||||||
|
createdAt: new Date('2026-05-14T12:00:00Z'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = buildChangeResult();
|
||||||
|
await pipeline.processChangeDetection(result, 'sub-001', 'user-001');
|
||||||
|
|
||||||
|
// Advance timer past the dedup window (24 hours)
|
||||||
|
vi.advanceTimersByTime(25 * 60 * 60 * 1000);
|
||||||
|
|
||||||
|
const cleaned = pipeline.cleanupExpiredDedups();
|
||||||
|
expect(cleaned).toBe(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('severity mapping', () => {
|
||||||
|
it('maps critical to critical', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue({ tier: 'premium' });
|
||||||
|
mockedDb.alert.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.alert.create.mockResolvedValue({
|
||||||
|
id: 'alert-sev-1',
|
||||||
|
subscriptionId: 'sub-001',
|
||||||
|
userId: 'user-001',
|
||||||
|
type: 'system_warning',
|
||||||
|
title: '[CRITICAL] Ownership Transfer detected',
|
||||||
|
message: 'Change',
|
||||||
|
severity: 'CRITICAL',
|
||||||
|
channel: ['email'],
|
||||||
|
createdAt: new Date('2026-05-14T12:00:00Z'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = buildChangeResult({ severity: 'critical' });
|
||||||
|
await pipeline.processChangeDetection(result, 'sub-001', 'user-001');
|
||||||
|
|
||||||
|
expect(mockedDb.alert.create).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
data: expect.objectContaining({ severity: 'critical' })
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('maps warning to warning', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue({ tier: 'premium' });
|
||||||
|
mockedDb.alert.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.alert.create.mockResolvedValue({
|
||||||
|
id: 'alert-sev-2',
|
||||||
|
subscriptionId: 'sub-001',
|
||||||
|
userId: 'user-001',
|
||||||
|
type: 'system_warning',
|
||||||
|
title: '[WARNING] Deed Change detected',
|
||||||
|
message: 'Change',
|
||||||
|
severity: 'WARNING',
|
||||||
|
channel: ['email'],
|
||||||
|
createdAt: new Date('2026-05-14T12:00:00Z'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = buildChangeResult({ severity: 'warning', changeType: 'deed_change' });
|
||||||
|
await pipeline.processChangeDetection(result, 'sub-001', 'user-001');
|
||||||
|
|
||||||
|
expect(mockedDb.alert.create).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
data: expect.objectContaining({ severity: 'warning' })
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
305
services/hometitle/test/change-detector.test.ts
Normal file
305
services/hometitle/test/change-detector.test.ts
Normal file
@@ -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('critical');
|
||||||
|
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('warning');
|
||||||
|
});
|
||||||
|
|
||||||
|
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('info');
|
||||||
|
});
|
||||||
|
|
||||||
|
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('warning');
|
||||||
|
});
|
||||||
|
|
||||||
|
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('critical');
|
||||||
|
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('info');
|
||||||
|
});
|
||||||
|
|
||||||
|
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 critical severity above default threshold', () => {
|
||||||
|
const result = {
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
changeType: 'ownership_transfer' as const,
|
||||||
|
severity: 'critical' as const,
|
||||||
|
confidence: 0.95,
|
||||||
|
changes: [],
|
||||||
|
previousSnapshot: baselineSnapshot,
|
||||||
|
currentSnapshot: baselineSnapshot,
|
||||||
|
detectedAt: new Date().toISOString(),
|
||||||
|
};
|
||||||
|
expect(shouldTriggerAlert(result)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('triggers for warning severity with high confidence', () => {
|
||||||
|
const result = {
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
changeType: 'deed_change' as const,
|
||||||
|
severity: 'warning' as const,
|
||||||
|
confidence: 0.85,
|
||||||
|
changes: [],
|
||||||
|
previousSnapshot: baselineSnapshot,
|
||||||
|
currentSnapshot: baselineSnapshot,
|
||||||
|
detectedAt: new Date().toISOString(),
|
||||||
|
};
|
||||||
|
expect(shouldTriggerAlert(result)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not trigger for info severity with default threshold', () => {
|
||||||
|
const result = {
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
changeType: 'tax_change' as const,
|
||||||
|
severity: 'info' 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: 'warning' as const,
|
||||||
|
confidence: 0.5,
|
||||||
|
changes: [],
|
||||||
|
previousSnapshot: baselineSnapshot,
|
||||||
|
currentSnapshot: baselineSnapshot,
|
||||||
|
detectedAt: new Date().toISOString(),
|
||||||
|
};
|
||||||
|
expect(shouldTriggerAlert(result)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('triggers info when minSeverity set to info', () => {
|
||||||
|
const result = {
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
changeType: 'tax_change' as const,
|
||||||
|
severity: 'info' as const,
|
||||||
|
confidence: 0.85,
|
||||||
|
changes: [],
|
||||||
|
previousSnapshot: baselineSnapshot,
|
||||||
|
currentSnapshot: baselineSnapshot,
|
||||||
|
detectedAt: new Date().toISOString(),
|
||||||
|
};
|
||||||
|
expect(shouldTriggerAlert(result, 'info')).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('critical');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns warning 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('warning');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns info 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('info');
|
||||||
|
});
|
||||||
|
|
||||||
|
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: 'warning' },
|
||||||
|
};
|
||||||
|
expect(determineSeverity(changes, config)).toBe('warning');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
555
services/hometitle/test/integration.test.ts
Normal file
555
services/hometitle/test/integration.test.ts
Normal file
@@ -0,0 +1,555 @@
|
|||||||
|
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
||||||
|
import {
|
||||||
|
propertyWatchlistService,
|
||||||
|
normalizeAddressValue,
|
||||||
|
hashAddressValue,
|
||||||
|
} from '../src/watchlist.service';
|
||||||
|
import { HomeTitleAlertPipeline } from '../src/alert.pipeline';
|
||||||
|
import { detectChanges } from '../src/change-detector';
|
||||||
|
import { PropertySnapshot } from '../src/types';
|
||||||
|
|
||||||
|
const mockedDb = vi.hoisted(() => {
|
||||||
|
const mocks = {
|
||||||
|
subscription: {
|
||||||
|
findUnique: vi.fn(),
|
||||||
|
count: vi.fn(),
|
||||||
|
},
|
||||||
|
propertyWatchlistItem: {
|
||||||
|
count: vi.fn(),
|
||||||
|
findFirst: vi.fn(),
|
||||||
|
create: vi.fn(),
|
||||||
|
findMany: vi.fn(),
|
||||||
|
update: vi.fn(),
|
||||||
|
},
|
||||||
|
alert: {
|
||||||
|
create: vi.fn(),
|
||||||
|
findFirst: vi.fn(),
|
||||||
|
},
|
||||||
|
normalizedAlert: {
|
||||||
|
create: vi.fn(),
|
||||||
|
updateMany: vi.fn(),
|
||||||
|
},
|
||||||
|
correlationGroup: {
|
||||||
|
create: vi.fn(),
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
findUnique: vi.fn(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return mocks;
|
||||||
|
});
|
||||||
|
|
||||||
|
vi.mock('@shieldai/db', () => ({
|
||||||
|
prisma: {
|
||||||
|
subscription: mockedDb.subscription,
|
||||||
|
propertyWatchlistItem: mockedDb.propertyWatchlistItem,
|
||||||
|
alert: mockedDb.alert,
|
||||||
|
normalizedAlert: mockedDb.normalizedAlert,
|
||||||
|
correlationGroup: mockedDb.correlationGroup,
|
||||||
|
user: mockedDb.user,
|
||||||
|
},
|
||||||
|
AlertSeverity: { INFO: 'INFO', WARNING: 'WARNING', CRITICAL: 'CRITICAL' },
|
||||||
|
AlertChannel: { EMAIL: 'email', PUSH: 'push', SMS: 'sms' },
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('@shieldai/shared-notifications', () => {
|
||||||
|
const mockSend = vi.fn().mockResolvedValue({ notificationId: 'mock-notif', status: 'sent' });
|
||||||
|
class MockNS {
|
||||||
|
send = mockSend;
|
||||||
|
static getInstance() { return new MockNS(); }
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
NotificationService: MockNS,
|
||||||
|
loadNotificationConfig: () => ({ apiKey: 'test', baseUrl: 'http://localhost' }),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const PREMIUM_SUB = { id: 'sub-premium', tier: 'premium' as const };
|
||||||
|
const PLUS_SUB = { id: 'sub-plus', tier: 'plus' as const };
|
||||||
|
const BASIC_SUB = { id: 'sub-basic', tier: 'basic' as const };
|
||||||
|
|
||||||
|
function makeSnapshot(overrides: Partial<PropertySnapshot> = {}): PropertySnapshot {
|
||||||
|
return {
|
||||||
|
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',
|
||||||
|
},
|
||||||
|
propertyType: 'residential',
|
||||||
|
...overrides,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('PropertyWatchlistService', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.useRealTimers();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addItem', () => {
|
||||||
|
it('creates a new watchlist item', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(PREMIUM_SUB);
|
||||||
|
mockedDb.propertyWatchlistItem.count.mockResolvedValue(0);
|
||||||
|
mockedDb.propertyWatchlistItem.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.propertyWatchlistItem.create.mockResolvedValue({
|
||||||
|
id: 'pw-1',
|
||||||
|
subscriptionId: 'sub-premium',
|
||||||
|
address: '123 main st',
|
||||||
|
parcelId: null,
|
||||||
|
ownerName: null,
|
||||||
|
streetAddress: '123 main st',
|
||||||
|
city: '',
|
||||||
|
state: '',
|
||||||
|
zipCode: '',
|
||||||
|
latitude: null,
|
||||||
|
longitude: null,
|
||||||
|
isActive: true,
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const item = await propertyWatchlistService.addItem(
|
||||||
|
'sub-premium',
|
||||||
|
'123 Main St',
|
||||||
|
'parcel-001',
|
||||||
|
'John Doe',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(item.address).toBe('123 main st');
|
||||||
|
expect(mockedDb.propertyWatchlistItem.create).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('enforces BASIC tier limit of 3', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(BASIC_SUB);
|
||||||
|
mockedDb.propertyWatchlistItem.count.mockResolvedValue(3);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
propertyWatchlistService.addItem('sub-basic', '456 Oak Ave', 'parcel-002')
|
||||||
|
).rejects.toThrow(/limit reached/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('enforces PLUS tier limit of 5', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(PLUS_SUB);
|
||||||
|
mockedDb.propertyWatchlistItem.count.mockResolvedValue(5);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
propertyWatchlistService.addItem('sub-plus', '789 Elm Blvd', 'parcel-003')
|
||||||
|
).rejects.toThrow(/limit reached/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows up to 50 for PREMIUM tier', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(PREMIUM_SUB);
|
||||||
|
mockedDb.propertyWatchlistItem.count.mockResolvedValue(49);
|
||||||
|
|
||||||
|
mockedDb.propertyWatchlistItem.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.propertyWatchlistItem.create.mockResolvedValue({
|
||||||
|
id: 'pw-50',
|
||||||
|
subscriptionId: 'sub-premium',
|
||||||
|
address: '50th property',
|
||||||
|
parcelId: 'parcel-050',
|
||||||
|
ownerName: null,
|
||||||
|
streetAddress: '50th property',
|
||||||
|
city: '',
|
||||||
|
state: '',
|
||||||
|
zipCode: '',
|
||||||
|
latitude: null,
|
||||||
|
longitude: null,
|
||||||
|
isActive: true,
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const item = await propertyWatchlistService.addItem(
|
||||||
|
'sub-premium',
|
||||||
|
'50th Property',
|
||||||
|
'parcel-050',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(item).toBeDefined();
|
||||||
|
expect(item.address).toBe('50th property');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('deduplicates by normalized address', async () => {
|
||||||
|
const existingItem = {
|
||||||
|
id: 'pw-existing',
|
||||||
|
subscriptionId: 'sub-premium',
|
||||||
|
address: '123 main st',
|
||||||
|
isActive: true,
|
||||||
|
};
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(PREMIUM_SUB);
|
||||||
|
mockedDb.propertyWatchlistItem.count.mockResolvedValue(1);
|
||||||
|
mockedDb.propertyWatchlistItem.findFirst.mockResolvedValue(existingItem);
|
||||||
|
|
||||||
|
const result = await propertyWatchlistService.addItem(
|
||||||
|
'sub-premium',
|
||||||
|
'123 Main St',
|
||||||
|
'parcel-001',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result.id).toBe('pw-existing');
|
||||||
|
expect(mockedDb.propertyWatchlistItem.create).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reactivates a deactivated item', async () => {
|
||||||
|
const deactivatedItem = {
|
||||||
|
id: 'pw-deactivated',
|
||||||
|
subscriptionId: 'sub-premium',
|
||||||
|
address: '123 main st',
|
||||||
|
isActive: false,
|
||||||
|
};
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(PREMIUM_SUB);
|
||||||
|
mockedDb.propertyWatchlistItem.count.mockResolvedValue(1);
|
||||||
|
mockedDb.propertyWatchlistItem.findFirst.mockResolvedValue(deactivatedItem);
|
||||||
|
mockedDb.propertyWatchlistItem.update.mockResolvedValue({
|
||||||
|
...deactivatedItem,
|
||||||
|
isActive: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await propertyWatchlistService.addItem(
|
||||||
|
'sub-premium',
|
||||||
|
'123 Main St',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result.isActive).toBe(true);
|
||||||
|
expect(mockedDb.propertyWatchlistItem.update).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('throws on invalid subscription', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(null);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
propertyWatchlistService.addItem('sub-invalid', '123 Main St')
|
||||||
|
).rejects.toThrow(/not found/);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getItems', () => {
|
||||||
|
it('returns active items for subscription', async () => {
|
||||||
|
const items = [
|
||||||
|
{
|
||||||
|
id: 'pw-1',
|
||||||
|
subscriptionId: 'sub-premium',
|
||||||
|
address: '123 main st',
|
||||||
|
isActive: true,
|
||||||
|
createdAt: new Date('2026-01-01'),
|
||||||
|
updatedAt: new Date('2026-01-01'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'pw-2',
|
||||||
|
subscriptionId: 'sub-premium',
|
||||||
|
address: '456 oak ave',
|
||||||
|
isActive: true,
|
||||||
|
createdAt: new Date('2026-02-01'),
|
||||||
|
updatedAt: new Date('2026-02-01'),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
mockedDb.propertyWatchlistItem.findMany.mockResolvedValue(items);
|
||||||
|
|
||||||
|
const result = await propertyWatchlistService.getItems('sub-premium');
|
||||||
|
|
||||||
|
expect(result).toHaveLength(2);
|
||||||
|
expect(mockedDb.propertyWatchlistItem.findMany).toHaveBeenCalledWith({
|
||||||
|
where: { subscriptionId: 'sub-premium', isActive: true },
|
||||||
|
orderBy: { createdAt: 'desc' },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('removeItem', () => {
|
||||||
|
it('deactivates an item', async () => {
|
||||||
|
mockedDb.propertyWatchlistItem.findFirst.mockResolvedValue({
|
||||||
|
id: 'pw-1',
|
||||||
|
subscriptionId: 'sub-premium',
|
||||||
|
address: '123 main st',
|
||||||
|
isActive: true,
|
||||||
|
});
|
||||||
|
mockedDb.propertyWatchlistItem.update.mockResolvedValue({
|
||||||
|
id: 'pw-1',
|
||||||
|
subscriptionId: 'sub-premium',
|
||||||
|
address: '123 main st',
|
||||||
|
isActive: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await propertyWatchlistService.removeItem('pw-1', 'sub-premium');
|
||||||
|
|
||||||
|
expect(result.isActive).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('throws on missing item', async () => {
|
||||||
|
mockedDb.propertyWatchlistItem.findFirst.mockResolvedValue(null);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
propertyWatchlistService.removeItem('pw-missing', 'sub-premium')
|
||||||
|
).rejects.toThrow(/not found/);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getActiveItemsForScan', () => {
|
||||||
|
it('returns items with latest snapshot', async () => {
|
||||||
|
mockedDb.propertyWatchlistItem.findMany.mockResolvedValue([
|
||||||
|
{
|
||||||
|
id: 'pw-1',
|
||||||
|
subscriptionId: 'sub-premium',
|
||||||
|
address: '123 main st',
|
||||||
|
isActive: true,
|
||||||
|
snapshots: [{ id: 'snap-1', capturedAt: new Date('2026-01-01') }],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await propertyWatchlistService.getActiveItemsForScan('sub-premium');
|
||||||
|
|
||||||
|
expect(result).toHaveLength(1);
|
||||||
|
expect(result[0].snapshots).toHaveLength(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('max items for tier', () => {
|
||||||
|
it('returns correct limits per tier', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(BASIC_SUB);
|
||||||
|
expect(await propertyWatchlistService.getMaxItemsForTier('sub-basic')).toBe(3);
|
||||||
|
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(PLUS_SUB);
|
||||||
|
expect(await propertyWatchlistService.getMaxItemsForTier('sub-plus')).toBe(5);
|
||||||
|
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(PREMIUM_SUB);
|
||||||
|
expect(await propertyWatchlistService.getMaxItemsForTier('sub-premium')).toBe(50);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns 3 for unknown subscription', async () => {
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(null);
|
||||||
|
expect(await propertyWatchlistService.getMaxItemsForTier('sub-unknown')).toBe(3);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('normalizeAddressValue', () => {
|
||||||
|
it('lowercases and trims', () => {
|
||||||
|
expect(normalizeAddressValue(' 123 Main St ')).toBe('123 main st');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('collapses multiple spaces', () => {
|
||||||
|
expect(normalizeAddressValue('123 Main St')).toBe('123 main st');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('hashAddressValue', () => {
|
||||||
|
it('produces consistent sha256 hash', () => {
|
||||||
|
const hash1 = hashAddressValue('123 main st');
|
||||||
|
const hash2 = hashAddressValue('123 main st');
|
||||||
|
expect(hash1).toBe(hash2);
|
||||||
|
expect(hash1).toHaveLength(64);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('different addresses produce different hashes', () => {
|
||||||
|
const hash1 = hashAddressValue('123 main st');
|
||||||
|
const hash2 = hashAddressValue('456 oak ave');
|
||||||
|
expect(hash1).not.toBe(hash2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Integration: Full Pipeline', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
vi.useRealTimers();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('happy path: add property -> detect change -> create alert', async () => {
|
||||||
|
// Setup: add property to watchlist
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(PREMIUM_SUB);
|
||||||
|
mockedDb.propertyWatchlistItem.count.mockResolvedValue(0);
|
||||||
|
mockedDb.propertyWatchlistItem.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.propertyWatchlistItem.create.mockResolvedValue({
|
||||||
|
id: 'pw-1',
|
||||||
|
subscriptionId: 'sub-premium',
|
||||||
|
address: '123 main st',
|
||||||
|
parcelId: 'parcel-001',
|
||||||
|
ownerName: 'John Doe',
|
||||||
|
streetAddress: '123 main st',
|
||||||
|
city: '',
|
||||||
|
state: '',
|
||||||
|
zipCode: '',
|
||||||
|
isActive: true,
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const item = await propertyWatchlistService.addItem(
|
||||||
|
'sub-premium',
|
||||||
|
'123 Main St',
|
||||||
|
'parcel-001',
|
||||||
|
'John Doe',
|
||||||
|
);
|
||||||
|
expect(item.address).toBe('123 main st');
|
||||||
|
|
||||||
|
// Detect change: ownership transfer
|
||||||
|
const previous: PropertySnapshot = makeSnapshot({
|
||||||
|
ownerName: 'John Doe',
|
||||||
|
capturedAt: '2026-01-01T00:00:00Z',
|
||||||
|
});
|
||||||
|
const current: PropertySnapshot = makeSnapshot({
|
||||||
|
id: 'snap-2',
|
||||||
|
capturedAt: '2026-02-01T00:00:00Z',
|
||||||
|
ownerName: 'Jane Smith',
|
||||||
|
});
|
||||||
|
|
||||||
|
const changeResult = detectChanges(previous, current);
|
||||||
|
expect(changeResult.changeType).toBe('ownership_transfer');
|
||||||
|
expect(changeResult.severity).toBe('critical');
|
||||||
|
expect(changeResult.confidence).toBeGreaterThan(0.9);
|
||||||
|
|
||||||
|
// Pipeline processes the change
|
||||||
|
mockedDb.alert.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.alert.create.mockResolvedValue({
|
||||||
|
id: 'alert-001',
|
||||||
|
subscriptionId: 'sub-premium',
|
||||||
|
userId: 'user-001',
|
||||||
|
type: 'system_warning',
|
||||||
|
title: '[CRITICAL] Ownership Transfer detected',
|
||||||
|
message: 'Change detected',
|
||||||
|
severity: 'CRITICAL' as any,
|
||||||
|
channel: ['email', 'push', 'sms'],
|
||||||
|
createdAt: new Date('2026-05-14T12:00:00Z'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const pipeline = new HomeTitleAlertPipeline();
|
||||||
|
const alert = await pipeline.processChangeDetection(
|
||||||
|
changeResult,
|
||||||
|
'sub-premium',
|
||||||
|
'user-001',
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(alert).toBeDefined();
|
||||||
|
expect(alert?.changeType).toBe('ownership_transfer');
|
||||||
|
expect(alert?.severity).toBe('critical');
|
||||||
|
expect(mockedDb.alert.create).toHaveBeenCalled();
|
||||||
|
expect(mockedDb.normalizedAlert.create).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('tier gating: premium gets more watchlist items than plus', async () => {
|
||||||
|
// Plus tier: 5 items max
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(PLUS_SUB);
|
||||||
|
mockedDb.propertyWatchlistItem.count.mockResolvedValue(5);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
propertyWatchlistService.addItem('sub-plus', '50th property')
|
||||||
|
).rejects.toThrow(/limit reached/);
|
||||||
|
|
||||||
|
// Premium tier: 50 items max
|
||||||
|
mockedDb.subscription.findUnique.mockResolvedValue(PREMIUM_SUB);
|
||||||
|
mockedDb.propertyWatchlistItem.count.mockResolvedValue(49);
|
||||||
|
mockedDb.propertyWatchlistItem.findFirst.mockResolvedValue(null);
|
||||||
|
mockedDb.propertyWatchlistItem.create.mockResolvedValue({
|
||||||
|
id: 'pw-50',
|
||||||
|
subscriptionId: 'sub-premium',
|
||||||
|
address: '50th property',
|
||||||
|
parcelId: 'parcel-050',
|
||||||
|
ownerName: null,
|
||||||
|
streetAddress: '50th property',
|
||||||
|
city: '',
|
||||||
|
state: '',
|
||||||
|
zipCode: '',
|
||||||
|
isActive: true,
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const item = await propertyWatchlistService.addItem(
|
||||||
|
'sub-premium',
|
||||||
|
'50th Property',
|
||||||
|
'parcel-050',
|
||||||
|
);
|
||||||
|
expect(item).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fuzzy matching: similar names are detected as matches', async () => {
|
||||||
|
const { matchRecords } = await import('../src/matcher.service');
|
||||||
|
|
||||||
|
const addr = {
|
||||||
|
streetNumber: '123',
|
||||||
|
streetName: 'main',
|
||||||
|
streetType: 'st',
|
||||||
|
city: 'springfield',
|
||||||
|
state: 'IL',
|
||||||
|
zip: '62701',
|
||||||
|
};
|
||||||
|
|
||||||
|
// Slight typo in name
|
||||||
|
const result = matchRecords(
|
||||||
|
'John Doe',
|
||||||
|
addr,
|
||||||
|
'Jhon Doe',
|
||||||
|
addr,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result.isMatch).toBe(true);
|
||||||
|
expect(result.nameScore).toBeGreaterThan(0.7);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fuzzy matching: completely different names don\'t match', async () => {
|
||||||
|
const { matchRecords } = await import('../src/matcher.service');
|
||||||
|
|
||||||
|
const addr = {
|
||||||
|
streetNumber: '123',
|
||||||
|
streetName: 'main',
|
||||||
|
streetType: 'st',
|
||||||
|
city: 'springfield',
|
||||||
|
state: 'IL',
|
||||||
|
zip: '62701',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = matchRecords(
|
||||||
|
'John Doe',
|
||||||
|
addr,
|
||||||
|
'Robert Williams',
|
||||||
|
addr,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result.isMatch).toBe(false);
|
||||||
|
expect(result.nameScore).toBeLessThan(0.5);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('change detection: tax change is minor severity', async () => {
|
||||||
|
const previous: PropertySnapshot = makeSnapshot({
|
||||||
|
taxAmount: 2500,
|
||||||
|
});
|
||||||
|
const current: PropertySnapshot = makeSnapshot({
|
||||||
|
id: 'snap-2',
|
||||||
|
capturedAt: '2026-02-01T00:00:00Z',
|
||||||
|
taxAmount: 3500,
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = detectChanges(previous, current);
|
||||||
|
expect(result.changes.some(c => c.changeType === 'tax_change')).toBe(true);
|
||||||
|
expect(result.severity).toBe('info');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('change detection: lien filing is moderate severity', async () => {
|
||||||
|
const previous: PropertySnapshot = makeSnapshot({
|
||||||
|
lienCount: 0,
|
||||||
|
});
|
||||||
|
const current: PropertySnapshot = makeSnapshot({
|
||||||
|
id: 'snap-2',
|
||||||
|
capturedAt: '2026-02-01T00:00:00Z',
|
||||||
|
lienCount: 2,
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = detectChanges(previous, current);
|
||||||
|
expect(result.changes.some(c => c.changeType === 'lien_filing')).toBe(true);
|
||||||
|
expect(result.severity).toBe('warning');
|
||||||
|
});
|
||||||
|
});
|
||||||
272
services/hometitle/test/matcher.test.ts
Normal file
272
services/hometitle/test/matcher.test.ts
Normal file
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
335
services/hometitle/test/scheduler.service.test.ts
Normal file
335
services/hometitle/test/scheduler.service.test.ts
Normal file
@@ -0,0 +1,335 @@
|
|||||||
|
import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest';
|
||||||
|
import { HomeTitleSchedulerService } from '../src/scheduler.service';
|
||||||
|
import { PropertySnapshot } from '../src/types';
|
||||||
|
|
||||||
|
// All mocks inside vi.hoisted() to avoid vitest hoisting issues
|
||||||
|
const mocked = vi.hoisted(() => {
|
||||||
|
const mockPrisma = {
|
||||||
|
subscription: { findMany: vi.fn() },
|
||||||
|
$queryRaw: vi.fn(),
|
||||||
|
};
|
||||||
|
const mockProcessChangeDetection = vi.fn();
|
||||||
|
const mockDetectChanges = vi.fn();
|
||||||
|
const mockShouldTriggerAlert = vi.fn();
|
||||||
|
|
||||||
|
return {
|
||||||
|
mockPrisma,
|
||||||
|
mockProcessChangeDetection,
|
||||||
|
mockDetectChanges,
|
||||||
|
mockShouldTriggerAlert,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
vi.mock('@shieldai/db', () => ({
|
||||||
|
prisma: mocked.mockPrisma,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../src/alert.pipeline', () => ({
|
||||||
|
homeTitleAlertPipeline: {
|
||||||
|
processChangeDetection: mocked.mockProcessChangeDetection,
|
||||||
|
},
|
||||||
|
HomeTitleAlertPipeline: class {},
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('../src/change-detector', () => ({
|
||||||
|
detectChanges: mocked.mockDetectChanges,
|
||||||
|
shouldTriggerAlert: mocked.mockShouldTriggerAlert,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('uuid', () => ({
|
||||||
|
v4: () => 'scan-uuid-' + Date.now(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const mockSubscription = {
|
||||||
|
id: 'sub-001',
|
||||||
|
userId: 'user-001',
|
||||||
|
tier: 'premium' as const,
|
||||||
|
};
|
||||||
|
|
||||||
|
function mockLatestSnapshots(snapshots: PropertySnapshot[]) {
|
||||||
|
mocked.mockPrisma.$queryRaw.mockResolvedValue(
|
||||||
|
snapshots.map(s => ({
|
||||||
|
id: s.id,
|
||||||
|
propertyId: s.propertyId,
|
||||||
|
capturedAt: s.capturedAt,
|
||||||
|
ownerName: s.ownerName,
|
||||||
|
address: JSON.stringify(s.address),
|
||||||
|
deedDate: s.deedDate ?? null,
|
||||||
|
taxId: s.taxId ?? null,
|
||||||
|
propertyType: s.propertyType,
|
||||||
|
taxAmount: s.taxAmount ?? null,
|
||||||
|
lienCount: s.lienCount ?? null,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function mockPreviousSnapshot(snapshot: PropertySnapshot | null) {
|
||||||
|
if (!snapshot) {
|
||||||
|
mocked.mockPrisma.$queryRaw.mockResolvedValue([]);
|
||||||
|
} else {
|
||||||
|
mocked.mockPrisma.$queryRaw.mockResolvedValue([
|
||||||
|
{
|
||||||
|
id: snapshot.id,
|
||||||
|
propertyId: snapshot.propertyId,
|
||||||
|
capturedAt: snapshot.capturedAt,
|
||||||
|
ownerName: snapshot.ownerName,
|
||||||
|
address: JSON.stringify(snapshot.address),
|
||||||
|
deedDate: snapshot.deedDate ?? null,
|
||||||
|
taxId: snapshot.taxId ?? null,
|
||||||
|
propertyType: snapshot.propertyType,
|
||||||
|
taxAmount: snapshot.taxAmount ?? null,
|
||||||
|
lienCount: snapshot.lienCount ?? null,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('HomeTitleSchedulerService', () => {
|
||||||
|
let scheduler: HomeTitleSchedulerService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.useFakeTimers();
|
||||||
|
vi.clearAllMocks();
|
||||||
|
mocked.mockProcessChangeDetection.mockReset();
|
||||||
|
mocked.mockDetectChanges.mockReset();
|
||||||
|
mocked.mockShouldTriggerAlert.mockReset();
|
||||||
|
|
||||||
|
scheduler = new HomeTitleSchedulerService({
|
||||||
|
scanIntervalMinutes: 60,
|
||||||
|
maxPropertiesPerScan: 100,
|
||||||
|
enabled: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
scheduler.stop();
|
||||||
|
vi.useRealTimers();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('constructor and config', () => {
|
||||||
|
it('uses default config when none provided', () => {
|
||||||
|
const defaultScheduler = new HomeTitleSchedulerService();
|
||||||
|
const config = defaultScheduler.getConfig();
|
||||||
|
expect(config.scanIntervalMinutes).toBe(60);
|
||||||
|
expect(config.maxPropertiesPerScan).toBe(100);
|
||||||
|
expect(config.enabled).toBe(true);
|
||||||
|
defaultScheduler.stop();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('accepts custom config', () => {
|
||||||
|
scheduler = new HomeTitleSchedulerService({ scanIntervalMinutes: 30 });
|
||||||
|
const config = scheduler.getConfig();
|
||||||
|
expect(config.scanIntervalMinutes).toBe(30);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('updates config dynamically', () => {
|
||||||
|
scheduler.updateConfig({ scanIntervalMinutes: 15 });
|
||||||
|
const config = scheduler.getConfig();
|
||||||
|
expect(config.scanIntervalMinutes).toBe(15);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('start/stop', () => {
|
||||||
|
it('starts the scheduler', () => {
|
||||||
|
scheduler.start();
|
||||||
|
expect(scheduler.isRunning()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('stops the scheduler', () => {
|
||||||
|
scheduler.start();
|
||||||
|
scheduler.stop();
|
||||||
|
expect(scheduler.isRunning()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not start when disabled', () => {
|
||||||
|
scheduler = new HomeTitleSchedulerService({ enabled: false });
|
||||||
|
scheduler.start();
|
||||||
|
expect(scheduler.isRunning()).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('runScan', () => {
|
||||||
|
it('returns empty results when no subscriptions', async () => {
|
||||||
|
mocked.mockPrisma.subscription.findMany.mockResolvedValue([]);
|
||||||
|
|
||||||
|
const result = await scheduler.runScan();
|
||||||
|
|
||||||
|
expect(result.propertiesScanned).toBe(0);
|
||||||
|
expect(result.changesDetected).toBe(0);
|
||||||
|
expect(result.alertsCreated).toBe(0);
|
||||||
|
expect(result.notificationsSent).toBe(0);
|
||||||
|
expect(result.errors).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('detects changes and creates alerts', async () => {
|
||||||
|
const previousSnapshot: PropertySnapshot = {
|
||||||
|
id: 'snap-1',
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
capturedAt: '2026-01-01T00:00:00Z',
|
||||||
|
ownerName: 'John Doe',
|
||||||
|
address: { streetNumber: '123', streetName: 'main', city: 'springfield', state: 'IL', zip: '62701' },
|
||||||
|
propertyType: 'residential',
|
||||||
|
};
|
||||||
|
const currentSnapshot: PropertySnapshot = {
|
||||||
|
...previousSnapshot,
|
||||||
|
id: 'snap-2',
|
||||||
|
capturedAt: '2026-02-01T00:00:00Z',
|
||||||
|
ownerName: 'Jane Smith',
|
||||||
|
};
|
||||||
|
|
||||||
|
mocked.mockPrisma.subscription.findMany.mockResolvedValue([mockSubscription]);
|
||||||
|
mockLatestSnapshots([currentSnapshot]);
|
||||||
|
mockPreviousSnapshot(previousSnapshot);
|
||||||
|
mocked.mockDetectChanges.mockReturnValue({
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
changeType: 'ownership_transfer',
|
||||||
|
severity: 'major',
|
||||||
|
confidence: 0.95,
|
||||||
|
changes: [],
|
||||||
|
previousSnapshot,
|
||||||
|
currentSnapshot,
|
||||||
|
detectedAt: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
mocked.mockShouldTriggerAlert.mockReturnValue(true);
|
||||||
|
mocked.mockProcessChangeDetection.mockResolvedValue({
|
||||||
|
id: 'alert-001',
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
subscriptionId: 'sub-001',
|
||||||
|
userId: 'user-001',
|
||||||
|
changeType: 'ownership_transfer',
|
||||||
|
severity: 'critical',
|
||||||
|
title: '[MAJOR] Ownership Transfer detected',
|
||||||
|
message: 'Change detected',
|
||||||
|
changeDetectionResult: {} as any,
|
||||||
|
channel: ['email', 'push', 'sms'],
|
||||||
|
dedupKey: 'hometitle:user-001:prop-001:ownership_transfer',
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await scheduler.runScan();
|
||||||
|
|
||||||
|
expect(result.changesDetected).toBe(1);
|
||||||
|
expect(result.alertsCreated).toBe(1);
|
||||||
|
expect(result.notificationsSent).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('skips snapshots without previous', async () => {
|
||||||
|
mocked.mockPrisma.subscription.findMany.mockResolvedValue([mockSubscription]);
|
||||||
|
mockLatestSnapshots([{
|
||||||
|
id: 'snap-1',
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
capturedAt: '2026-01-01T00:00:00Z',
|
||||||
|
ownerName: 'John Doe',
|
||||||
|
address: { streetNumber: '123', streetName: 'main', city: 'springfield', state: 'IL', zip: '62701' },
|
||||||
|
propertyType: 'residential',
|
||||||
|
}]);
|
||||||
|
mockPreviousSnapshot(null);
|
||||||
|
|
||||||
|
const result = await scheduler.runScan();
|
||||||
|
|
||||||
|
expect(result.changesDetected).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('handles subscription scan errors gracefully', async () => {
|
||||||
|
mocked.mockPrisma.subscription.findMany.mockResolvedValue([mockSubscription]);
|
||||||
|
mockLatestSnapshots([]);
|
||||||
|
mockPreviousSnapshot(null);
|
||||||
|
mocked.mockDetectChanges.mockReturnValue({
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
changeType: 'metadata_change',
|
||||||
|
severity: 'minor',
|
||||||
|
confidence: 0.5,
|
||||||
|
changes: [],
|
||||||
|
previousSnapshot: {} as any,
|
||||||
|
currentSnapshot: {} as any,
|
||||||
|
detectedAt: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
mocked.mockShouldTriggerAlert.mockReturnValue(false);
|
||||||
|
|
||||||
|
const result = await scheduler.runScan();
|
||||||
|
|
||||||
|
expect(result.errors).toEqual([]);
|
||||||
|
expect(result.propertiesScanned).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('tracks scan metadata', async () => {
|
||||||
|
mocked.mockPrisma.subscription.findMany.mockResolvedValue([]);
|
||||||
|
|
||||||
|
const result = await scheduler.runScan();
|
||||||
|
|
||||||
|
expect(result.scanId).toBeDefined();
|
||||||
|
expect(result.startedAt).toBeDefined();
|
||||||
|
expect(result.completedAt).toBeDefined();
|
||||||
|
// completedAt should be after startedAt
|
||||||
|
expect(new Date(result.completedAt).getTime()).toBeGreaterThanOrEqual(
|
||||||
|
new Date(result.startedAt).getTime()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not send notifications for non-premium tier', async () => {
|
||||||
|
const previousSnapshot: PropertySnapshot = {
|
||||||
|
id: 'snap-1',
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
capturedAt: '2026-01-01T00:00:00Z',
|
||||||
|
ownerName: 'John Doe',
|
||||||
|
address: { streetNumber: '123', streetName: 'main', city: 'springfield', state: 'IL', zip: '62701' },
|
||||||
|
propertyType: 'residential',
|
||||||
|
};
|
||||||
|
const currentSnapshot: PropertySnapshot = {
|
||||||
|
...previousSnapshot,
|
||||||
|
id: 'snap-2',
|
||||||
|
capturedAt: '2026-02-01T00:00:00Z',
|
||||||
|
ownerName: 'Jane Smith',
|
||||||
|
};
|
||||||
|
|
||||||
|
const nonPremiumSub = { ...mockSubscription, tier: 'plus' as const };
|
||||||
|
mocked.mockPrisma.subscription.findMany.mockResolvedValue([nonPremiumSub]);
|
||||||
|
mockLatestSnapshots([currentSnapshot]);
|
||||||
|
mockPreviousSnapshot(previousSnapshot);
|
||||||
|
mocked.mockDetectChanges.mockReturnValue({
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
changeType: 'ownership_transfer',
|
||||||
|
severity: 'major',
|
||||||
|
confidence: 0.95,
|
||||||
|
changes: [],
|
||||||
|
previousSnapshot,
|
||||||
|
currentSnapshot,
|
||||||
|
detectedAt: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
mocked.mockShouldTriggerAlert.mockReturnValue(true);
|
||||||
|
mocked.mockProcessChangeDetection.mockResolvedValue({
|
||||||
|
id: 'alert-002',
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
subscriptionId: 'sub-001',
|
||||||
|
userId: 'user-001',
|
||||||
|
changeType: 'ownership_transfer',
|
||||||
|
severity: 'critical',
|
||||||
|
title: '[MAJOR] Ownership Transfer detected',
|
||||||
|
message: 'Change detected',
|
||||||
|
changeDetectionResult: {} as any,
|
||||||
|
channel: ['email', 'push'],
|
||||||
|
dedupKey: 'hometitle:user-001:prop-001:ownership_transfer',
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await scheduler.runScan();
|
||||||
|
|
||||||
|
expect(result.changesDetected).toBe(1);
|
||||||
|
expect(result.alertsCreated).toBe(1);
|
||||||
|
expect(result.notificationsSent).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getLastScanResult', () => {
|
||||||
|
it('returns null before first scan', () => {
|
||||||
|
expect(scheduler.getLastScanResult()).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns last scan result after scan', async () => {
|
||||||
|
mocked.mockPrisma.subscription.findMany.mockResolvedValue([]);
|
||||||
|
scheduler.start();
|
||||||
|
await vi.advanceTimersByTimeAsync(60 * 60 * 1000);
|
||||||
|
expect(scheduler.getLastScanResult()).not.toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
8
services/hometitle/tsconfig.json
Normal file
8
services/hometitle/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./dist",
|
||||||
|
"rootDir": "./src"
|
||||||
|
},
|
||||||
|
"include": ["src/**/*.ts"]
|
||||||
|
}
|
||||||
26
services/hometitle/vitest.config.ts
Normal file
26
services/hometitle/vitest.config.ts
Normal file
@@ -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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user