hvp-shared 6.95.0 → 6.97.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,83 @@
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, name similarity, and shared pets.
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
+ /** Pet names for quick visual comparison */
28
+ petNames: string[];
29
+ }
30
+ /**
31
+ * A pair of clients detected as potential duplicates.
32
+ *
33
+ * Scoring:
34
+ * - Same phone (last 7 digits): 60 pts
35
+ * - Same email: 60 pts
36
+ * - Same pet name: 40 pts
37
+ * - Exact name match: +30 pts
38
+ * - Name contained: +25 pts
39
+ * - Name similarity >= 50%: +1 to +25 pts
40
+ * - Same branch: +5 pts
41
+ * - Name-only match (no other signal): 40 pts
42
+ *
43
+ * Confidence: HIGH >= 80, MEDIUM 60-79, LOW < 60
44
+ */
45
+ export interface DuplicateClientPair {
46
+ score: number;
47
+ confidence: DuplicateClientConfidence;
48
+ reasons: string[];
49
+ clientA: DuplicateClientInfo;
50
+ clientB: DuplicateClientInfo;
51
+ /** Groups pairs sharing clients (e.g., A-B, A-C, B-C all get same groupId) */
52
+ groupId: number;
53
+ }
54
+ /**
55
+ * Summary statistics for duplicate detection results.
56
+ */
57
+ export interface DuplicateClientsSummary {
58
+ totalPairs: number;
59
+ totalGroups: number;
60
+ highConfidence: number;
61
+ mediumConfidence: number;
62
+ lowConfidence: number;
63
+ uniqueClientsInvolved: number;
64
+ }
65
+ /**
66
+ * Full response for duplicate client detection endpoint.
67
+ *
68
+ * @example GET /api/qvet/clients/duplicates
69
+ */
70
+ export interface DuplicateClientsResponse {
71
+ summary: DuplicateClientsSummary;
72
+ pairs: DuplicateClientPair[];
73
+ }
74
+ /**
75
+ * Query parameters for filtering duplicate detection results.
76
+ */
77
+ export interface DuplicateClientsQueryParams {
78
+ branch?: string;
79
+ minScore?: number;
80
+ confidence?: DuplicateClientConfidence;
81
+ /** Include inactive clients in detection (default: false, only active) */
82
+ includeInactive?: boolean;
83
+ }
@@ -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, name similarity, and shared pets.
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.97.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",