hvp-shared 6.95.0 → 6.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,75 @@
1
+ /**
2
+ * QVET Client Duplicate Detection Contracts
3
+ *
4
+ * Types for the duplicate client detection and audit system.
5
+ * Detects potential duplicate client records using scoring-based matching
6
+ * on phone, email, and name similarity.
7
+ *
8
+ * @example GET /api/qvet/clients/duplicates?branch=MAT&confidence=HIGH
9
+ */
10
+ export type DuplicateClientConfidence = 'HIGH' | 'MEDIUM' | 'LOW';
11
+ /**
12
+ * Information about a single client within a duplicate pair.
13
+ * Includes enrichment data (pets, visits, sales) to help decide which to keep.
14
+ */
15
+ export interface DuplicateClientInfo {
16
+ qvetClientId: number;
17
+ name: string;
18
+ branch: string;
19
+ isActive: boolean;
20
+ phone1: string;
21
+ phone2: string;
22
+ email: string;
23
+ lastActivityAt: string | null;
24
+ petCount: number;
25
+ visitCount: number;
26
+ salesTotalAmount: number;
27
+ }
28
+ /**
29
+ * A pair of clients detected as potential duplicates.
30
+ *
31
+ * Scoring:
32
+ * - Same phone (last 7 digits): 60 pts
33
+ * - Same email: 60 pts
34
+ * - Exact name match: +30 pts
35
+ * - Name contained: +25 pts
36
+ * - Name similarity >= 50%: +1 to +25 pts
37
+ * - Same branch: +5 pts
38
+ * - Name-only match (no phone/email): 40 pts
39
+ *
40
+ * Confidence: HIGH >= 80, MEDIUM 60-79, LOW < 60
41
+ */
42
+ export interface DuplicateClientPair {
43
+ score: number;
44
+ confidence: DuplicateClientConfidence;
45
+ reasons: string[];
46
+ clientA: DuplicateClientInfo;
47
+ clientB: DuplicateClientInfo;
48
+ }
49
+ /**
50
+ * Summary statistics for duplicate detection results.
51
+ */
52
+ export interface DuplicateClientsSummary {
53
+ totalPairs: number;
54
+ highConfidence: number;
55
+ mediumConfidence: number;
56
+ lowConfidence: number;
57
+ uniqueClientsInvolved: number;
58
+ }
59
+ /**
60
+ * Full response for duplicate client detection endpoint.
61
+ *
62
+ * @example GET /api/qvet/clients/duplicates
63
+ */
64
+ export interface DuplicateClientsResponse {
65
+ summary: DuplicateClientsSummary;
66
+ pairs: DuplicateClientPair[];
67
+ }
68
+ /**
69
+ * Query parameters for filtering duplicate detection results.
70
+ */
71
+ export interface DuplicateClientsQueryParams {
72
+ branch?: string;
73
+ minScore?: number;
74
+ confidence?: DuplicateClientConfidence;
75
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ /**
3
+ * QVET Client Duplicate Detection Contracts
4
+ *
5
+ * Types for the duplicate client detection and audit system.
6
+ * Detects potential duplicate client records using scoring-based matching
7
+ * on phone, email, and name similarity.
8
+ *
9
+ * @example GET /api/qvet/clients/duplicates?branch=MAT&confidence=HIGH
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -9,3 +9,4 @@ export * from './payables';
9
9
  export * from './staff';
10
10
  export * from './pets';
11
11
  export * from './visits';
12
+ export * from './client-duplicates';
@@ -25,3 +25,4 @@ __exportStar(require("./payables"), exports);
25
25
  __exportStar(require("./staff"), exports);
26
26
  __exportStar(require("./pets"), exports);
27
27
  __exportStar(require("./visits"), exports);
28
+ __exportStar(require("./client-duplicates"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hvp-shared",
3
- "version": "6.95.0",
3
+ "version": "6.96.0",
4
4
  "description": "Shared types and utilities for HVP backend and frontend",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",