@voyantjs/crm 0.105.1 → 0.106.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/routes/accounts.d.ts +105 -0
- package/dist/routes/accounts.d.ts.map +1 -1
- package/dist/routes/accounts.js +28 -1
- package/dist/routes/index.d.ts +105 -0
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/service/accounts-merge.d.ts +63 -0
- package/dist/service/accounts-merge.d.ts.map +1 -0
- package/dist/service/accounts-merge.js +366 -0
- package/dist/service/accounts-people.js +1 -1
- package/dist/service/accounts-shared.d.ts +4 -1
- package/dist/service/accounts-shared.d.ts.map +1 -1
- package/dist/service/accounts-shared.js +20 -6
- package/dist/service/accounts.d.ts +56 -0
- package/dist/service/accounts.d.ts.map +1 -1
- package/dist/service/accounts.js +3 -0
- package/dist/service/index.d.ts +55 -0
- package/dist/service/index.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -162,6 +162,52 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
|
|
|
162
162
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
163
163
|
};
|
|
164
164
|
};
|
|
165
|
+
} & {
|
|
166
|
+
"/organizations/:id/merge": {
|
|
167
|
+
$post: {
|
|
168
|
+
input: {
|
|
169
|
+
param: {
|
|
170
|
+
id: string;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
output: {
|
|
174
|
+
error: string;
|
|
175
|
+
};
|
|
176
|
+
outputFormat: "json";
|
|
177
|
+
status: 400 | 404;
|
|
178
|
+
} | {
|
|
179
|
+
input: {
|
|
180
|
+
param: {
|
|
181
|
+
id: string;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
output: {
|
|
185
|
+
data: {
|
|
186
|
+
id: string;
|
|
187
|
+
name: string;
|
|
188
|
+
legalName: string | null;
|
|
189
|
+
website: string | null;
|
|
190
|
+
taxId: string | null;
|
|
191
|
+
industry: string | null;
|
|
192
|
+
relation: "partner" | "supplier" | "other" | "client" | null;
|
|
193
|
+
ownerId: string | null;
|
|
194
|
+
defaultCurrency: string | null;
|
|
195
|
+
preferredLanguage: string | null;
|
|
196
|
+
paymentTerms: number | null;
|
|
197
|
+
status: "active" | "inactive" | "archived";
|
|
198
|
+
source: string | null;
|
|
199
|
+
sourceRef: string | null;
|
|
200
|
+
tags: string[];
|
|
201
|
+
notes: string | null;
|
|
202
|
+
createdAt: string;
|
|
203
|
+
updatedAt: string;
|
|
204
|
+
archivedAt: string | null;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
outputFormat: "json";
|
|
208
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
209
|
+
};
|
|
210
|
+
};
|
|
165
211
|
} & {
|
|
166
212
|
"/organizations/:id": {
|
|
167
213
|
$delete: {
|
|
@@ -654,6 +700,65 @@ export declare const accountRoutes: import("hono/hono-base").HonoBase<Env, {
|
|
|
654
700
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
655
701
|
};
|
|
656
702
|
};
|
|
703
|
+
} & {
|
|
704
|
+
"/people/:id/merge": {
|
|
705
|
+
$post: {
|
|
706
|
+
input: {
|
|
707
|
+
param: {
|
|
708
|
+
id: string;
|
|
709
|
+
};
|
|
710
|
+
};
|
|
711
|
+
output: {
|
|
712
|
+
error: string;
|
|
713
|
+
};
|
|
714
|
+
outputFormat: "json";
|
|
715
|
+
status: 400 | 404;
|
|
716
|
+
} | {
|
|
717
|
+
input: {
|
|
718
|
+
param: {
|
|
719
|
+
id: string;
|
|
720
|
+
};
|
|
721
|
+
};
|
|
722
|
+
output: {
|
|
723
|
+
data: {
|
|
724
|
+
id: string;
|
|
725
|
+
organizationId: string | null;
|
|
726
|
+
firstName: string;
|
|
727
|
+
middleName: string | null;
|
|
728
|
+
lastName: string;
|
|
729
|
+
gender: string | null;
|
|
730
|
+
jobTitle: string | null;
|
|
731
|
+
relation: "partner" | "supplier" | "other" | "client" | null;
|
|
732
|
+
preferredLanguage: string | null;
|
|
733
|
+
preferredCurrency: string | null;
|
|
734
|
+
ownerId: string | null;
|
|
735
|
+
status: "active" | "inactive" | "archived";
|
|
736
|
+
source: string | null;
|
|
737
|
+
sourceRef: string | null;
|
|
738
|
+
tags: string[];
|
|
739
|
+
dateOfBirth: string | null;
|
|
740
|
+
notes: string | null;
|
|
741
|
+
accessibilityEncrypted: {
|
|
742
|
+
enc: string;
|
|
743
|
+
} | null;
|
|
744
|
+
dietaryEncrypted: {
|
|
745
|
+
enc: string;
|
|
746
|
+
} | null;
|
|
747
|
+
loyaltyEncrypted: {
|
|
748
|
+
enc: string;
|
|
749
|
+
} | null;
|
|
750
|
+
insuranceEncrypted: {
|
|
751
|
+
enc: string;
|
|
752
|
+
} | null;
|
|
753
|
+
createdAt: string;
|
|
754
|
+
updatedAt: string;
|
|
755
|
+
archivedAt: string | null;
|
|
756
|
+
};
|
|
757
|
+
};
|
|
758
|
+
outputFormat: "json";
|
|
759
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
760
|
+
};
|
|
761
|
+
};
|
|
657
762
|
} & {
|
|
658
763
|
"/people/:id": {
|
|
659
764
|
$delete: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/routes/accounts.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/routes/accounts.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AA0BjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAYD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAgVtB,CAAA"}
|
package/dist/routes/accounts.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { idempotencyKey, parseJsonBody, parseQuery, requireUserId } from "@voyantjs/hono";
|
|
2
2
|
import { insertAddressSchema, insertContactPointSchema, updateAddressSchema, updateContactPointSchema, } from "@voyantjs/identity/validation";
|
|
3
3
|
import { Hono } from "hono";
|
|
4
|
+
import { CrmMergeError } from "../service/accounts-merge.js";
|
|
4
5
|
import { crmService } from "../service/index.js";
|
|
5
|
-
import { communicationListQuerySchema, insertCommunicationLogSchema, insertOrganizationNoteSchema, insertOrganizationSchema, insertPersonNoteSchema, insertPersonPaymentMethodSchema, insertPersonSchema, insertSegmentSchema, organizationListQuerySchema, personListQuerySchema, updateOrganizationNoteSchema, updateOrganizationSchema, updatePersonNoteSchema, updatePersonPaymentMethodSchema, updatePersonSchema, } from "../validation.js";
|
|
6
|
+
import { communicationListQuerySchema, insertCommunicationLogSchema, insertOrganizationNoteSchema, insertOrganizationSchema, insertPersonNoteSchema, insertPersonPaymentMethodSchema, insertPersonSchema, insertSegmentSchema, mergeOrganizationSchema, mergePersonSchema, organizationListQuerySchema, personListQuerySchema, updateOrganizationNoteSchema, updateOrganizationSchema, updatePersonNoteSchema, updatePersonPaymentMethodSchema, updatePersonSchema, } from "../validation.js";
|
|
6
7
|
const organizationEntity = "organization";
|
|
7
8
|
const personEntity = "person";
|
|
9
|
+
function mergeErrorResponse(c, error) {
|
|
10
|
+
if (error instanceof CrmMergeError) {
|
|
11
|
+
return c.json({ error: error.message }, error.status);
|
|
12
|
+
}
|
|
13
|
+
throw error;
|
|
14
|
+
}
|
|
8
15
|
export const accountRoutes = new Hono()
|
|
9
16
|
// Organizations
|
|
10
17
|
.get("/organizations", async (c) => {
|
|
@@ -27,6 +34,16 @@ export const accountRoutes = new Hono()
|
|
|
27
34
|
if (!row)
|
|
28
35
|
return c.json({ error: "Organization not found" }, 404);
|
|
29
36
|
return c.json({ data: row });
|
|
37
|
+
})
|
|
38
|
+
.post("/organizations/:id/merge", async (c) => {
|
|
39
|
+
try {
|
|
40
|
+
const body = await parseJsonBody(c, mergeOrganizationSchema);
|
|
41
|
+
const row = await crmService.mergeOrganization(c.get("db"), c.req.param("id"), body.mergeId);
|
|
42
|
+
return c.json({ data: row });
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return mergeErrorResponse(c, error);
|
|
46
|
+
}
|
|
30
47
|
})
|
|
31
48
|
.delete("/organizations/:id", async (c) => {
|
|
32
49
|
const row = await crmService.deleteOrganization(c.get("db"), c.req.param("id"));
|
|
@@ -100,6 +117,16 @@ export const accountRoutes = new Hono()
|
|
|
100
117
|
if (!row)
|
|
101
118
|
return c.json({ error: "Person not found" }, 404);
|
|
102
119
|
return c.json({ data: row });
|
|
120
|
+
})
|
|
121
|
+
.post("/people/:id/merge", async (c) => {
|
|
122
|
+
try {
|
|
123
|
+
const body = await parseJsonBody(c, mergePersonSchema);
|
|
124
|
+
const row = await crmService.mergePerson(c.get("db"), c.req.param("id"), body.mergeId);
|
|
125
|
+
return c.json({ data: row });
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
return mergeErrorResponse(c, error);
|
|
129
|
+
}
|
|
103
130
|
})
|
|
104
131
|
.delete("/people/:id", async (c) => {
|
|
105
132
|
const row = await crmService.deletePerson(c.get("db"), c.req.param("id"));
|
package/dist/routes/index.d.ts
CHANGED
|
@@ -162,6 +162,52 @@ export declare const crmRoutes: import("hono/hono-base").HonoBase<Env, import("h
|
|
|
162
162
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
163
163
|
};
|
|
164
164
|
};
|
|
165
|
+
} & {
|
|
166
|
+
"/organizations/:id/merge": {
|
|
167
|
+
$post: {
|
|
168
|
+
input: {
|
|
169
|
+
param: {
|
|
170
|
+
id: string;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
output: {
|
|
174
|
+
error: string;
|
|
175
|
+
};
|
|
176
|
+
outputFormat: "json";
|
|
177
|
+
status: 400 | 404;
|
|
178
|
+
} | {
|
|
179
|
+
input: {
|
|
180
|
+
param: {
|
|
181
|
+
id: string;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
output: {
|
|
185
|
+
data: {
|
|
186
|
+
id: string;
|
|
187
|
+
name: string;
|
|
188
|
+
legalName: string | null;
|
|
189
|
+
website: string | null;
|
|
190
|
+
taxId: string | null;
|
|
191
|
+
industry: string | null;
|
|
192
|
+
relation: "partner" | "supplier" | "other" | "client" | null;
|
|
193
|
+
ownerId: string | null;
|
|
194
|
+
defaultCurrency: string | null;
|
|
195
|
+
preferredLanguage: string | null;
|
|
196
|
+
paymentTerms: number | null;
|
|
197
|
+
status: "active" | "inactive" | "archived";
|
|
198
|
+
source: string | null;
|
|
199
|
+
sourceRef: string | null;
|
|
200
|
+
tags: string[];
|
|
201
|
+
notes: string | null;
|
|
202
|
+
createdAt: string;
|
|
203
|
+
updatedAt: string;
|
|
204
|
+
archivedAt: string | null;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
outputFormat: "json";
|
|
208
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
209
|
+
};
|
|
210
|
+
};
|
|
165
211
|
} & {
|
|
166
212
|
"/organizations/:id": {
|
|
167
213
|
$delete: {
|
|
@@ -654,6 +700,65 @@ export declare const crmRoutes: import("hono/hono-base").HonoBase<Env, import("h
|
|
|
654
700
|
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
655
701
|
};
|
|
656
702
|
};
|
|
703
|
+
} & {
|
|
704
|
+
"/people/:id/merge": {
|
|
705
|
+
$post: {
|
|
706
|
+
input: {
|
|
707
|
+
param: {
|
|
708
|
+
id: string;
|
|
709
|
+
};
|
|
710
|
+
};
|
|
711
|
+
output: {
|
|
712
|
+
error: string;
|
|
713
|
+
};
|
|
714
|
+
outputFormat: "json";
|
|
715
|
+
status: 400 | 404;
|
|
716
|
+
} | {
|
|
717
|
+
input: {
|
|
718
|
+
param: {
|
|
719
|
+
id: string;
|
|
720
|
+
};
|
|
721
|
+
};
|
|
722
|
+
output: {
|
|
723
|
+
data: {
|
|
724
|
+
id: string;
|
|
725
|
+
organizationId: string | null;
|
|
726
|
+
firstName: string;
|
|
727
|
+
middleName: string | null;
|
|
728
|
+
lastName: string;
|
|
729
|
+
gender: string | null;
|
|
730
|
+
jobTitle: string | null;
|
|
731
|
+
relation: "partner" | "supplier" | "other" | "client" | null;
|
|
732
|
+
preferredLanguage: string | null;
|
|
733
|
+
preferredCurrency: string | null;
|
|
734
|
+
ownerId: string | null;
|
|
735
|
+
status: "active" | "inactive" | "archived";
|
|
736
|
+
source: string | null;
|
|
737
|
+
sourceRef: string | null;
|
|
738
|
+
tags: string[];
|
|
739
|
+
dateOfBirth: string | null;
|
|
740
|
+
notes: string | null;
|
|
741
|
+
accessibilityEncrypted: {
|
|
742
|
+
enc: string;
|
|
743
|
+
} | null;
|
|
744
|
+
dietaryEncrypted: {
|
|
745
|
+
enc: string;
|
|
746
|
+
} | null;
|
|
747
|
+
loyaltyEncrypted: {
|
|
748
|
+
enc: string;
|
|
749
|
+
} | null;
|
|
750
|
+
insuranceEncrypted: {
|
|
751
|
+
enc: string;
|
|
752
|
+
} | null;
|
|
753
|
+
createdAt: string;
|
|
754
|
+
updatedAt: string;
|
|
755
|
+
archivedAt: string | null;
|
|
756
|
+
};
|
|
757
|
+
};
|
|
758
|
+
outputFormat: "json";
|
|
759
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
760
|
+
};
|
|
761
|
+
};
|
|
657
762
|
} & {
|
|
658
763
|
"/people/:id": {
|
|
659
764
|
$delete: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAajE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAajE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBASU,CAAA;AAEhC,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
export declare class CrmMergeError extends Error {
|
|
3
|
+
readonly status: 400 | 404;
|
|
4
|
+
constructor(message: string, status: 400 | 404);
|
|
5
|
+
}
|
|
6
|
+
export declare const accountMergeService: {
|
|
7
|
+
mergePerson(db: PostgresJsDatabase, keepId: string, mergeId: string): Promise<{
|
|
8
|
+
id: string;
|
|
9
|
+
organizationId: string | null;
|
|
10
|
+
firstName: string;
|
|
11
|
+
middleName: string | null;
|
|
12
|
+
lastName: string;
|
|
13
|
+
gender: string | null;
|
|
14
|
+
jobTitle: string | null;
|
|
15
|
+
relation: "partner" | "supplier" | "other" | "client" | null;
|
|
16
|
+
preferredLanguage: string | null;
|
|
17
|
+
preferredCurrency: string | null;
|
|
18
|
+
ownerId: string | null;
|
|
19
|
+
status: "active" | "inactive" | "archived";
|
|
20
|
+
source: string | null;
|
|
21
|
+
sourceRef: string | null;
|
|
22
|
+
tags: string[];
|
|
23
|
+
dateOfBirth: string | null;
|
|
24
|
+
notes: string | null;
|
|
25
|
+
accessibilityEncrypted: {
|
|
26
|
+
enc: string;
|
|
27
|
+
} | null;
|
|
28
|
+
dietaryEncrypted: {
|
|
29
|
+
enc: string;
|
|
30
|
+
} | null;
|
|
31
|
+
loyaltyEncrypted: {
|
|
32
|
+
enc: string;
|
|
33
|
+
} | null;
|
|
34
|
+
insuranceEncrypted: {
|
|
35
|
+
enc: string;
|
|
36
|
+
} | null;
|
|
37
|
+
createdAt: Date;
|
|
38
|
+
updatedAt: Date;
|
|
39
|
+
archivedAt: Date | null;
|
|
40
|
+
}>;
|
|
41
|
+
mergeOrganization(db: PostgresJsDatabase, keepId: string, mergeId: string): Promise<{
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
legalName: string | null;
|
|
45
|
+
website: string | null;
|
|
46
|
+
taxId: string | null;
|
|
47
|
+
industry: string | null;
|
|
48
|
+
relation: "partner" | "supplier" | "other" | "client" | null;
|
|
49
|
+
ownerId: string | null;
|
|
50
|
+
defaultCurrency: string | null;
|
|
51
|
+
preferredLanguage: string | null;
|
|
52
|
+
paymentTerms: number | null;
|
|
53
|
+
status: "active" | "inactive" | "archived";
|
|
54
|
+
source: string | null;
|
|
55
|
+
sourceRef: string | null;
|
|
56
|
+
tags: string[];
|
|
57
|
+
notes: string | null;
|
|
58
|
+
createdAt: Date;
|
|
59
|
+
updatedAt: Date;
|
|
60
|
+
archivedAt: Date | null;
|
|
61
|
+
}>;
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=accounts-merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts-merge.d.ts","sourceRoot":"","sources":["../../src/service/accounts-merge.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAqBjE,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAA;gBAEd,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,GAAG;CAK/C;AA4TD,eAAO,MAAM,mBAAmB;oBACR,kBAAkB,UAAU,MAAM,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAmI7C,kBAAkB,UAAU,MAAM,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;CAoFhF,CAAA"}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { identityAddresses, identityContactPoints, identityNamedContacts, } from "@voyantjs/identity/schema";
|
|
2
|
+
import { and, eq, inArray, ne, or, sql } from "drizzle-orm";
|
|
3
|
+
import { activityLinks, activityParticipants, communicationLog, customerSignals, customFieldValues, opportunities, opportunityParticipants, organizationNotes, organizations, people, personDocuments, personNotes, personPaymentMethods, personRelationships, segmentMembers, } from "../schema.js";
|
|
4
|
+
import { hydratePeople, organizationEntityType, personEntityType } from "./accounts-shared.js";
|
|
5
|
+
export class CrmMergeError extends Error {
|
|
6
|
+
status;
|
|
7
|
+
constructor(message, status) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "CrmMergeError";
|
|
10
|
+
this.status = status;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const OPTIONAL_PERSON_REFERENCES = [
|
|
14
|
+
{ table: "bookings", column: "person_id" },
|
|
15
|
+
{ table: "booking_travelers", column: "person_id" },
|
|
16
|
+
{ table: "booking_staff_assignments", column: "person_id" },
|
|
17
|
+
{ table: "offers", column: "person_id" },
|
|
18
|
+
{ table: "offer_participants", column: "person_id" },
|
|
19
|
+
{ table: "offer_contact_assignments", column: "person_id" },
|
|
20
|
+
{ table: "offer_staff_assignments", column: "person_id" },
|
|
21
|
+
{ table: "orders", column: "person_id" },
|
|
22
|
+
{ table: "order_participants", column: "person_id" },
|
|
23
|
+
{ table: "order_contact_assignments", column: "person_id" },
|
|
24
|
+
{ table: "order_staff_assignments", column: "person_id" },
|
|
25
|
+
{ table: "order_terms", column: "accepted_by" },
|
|
26
|
+
{ table: "invoices", column: "person_id" },
|
|
27
|
+
{ table: "vouchers", column: "issued_to_person_id" },
|
|
28
|
+
{ table: "payment_instruments", column: "person_id" },
|
|
29
|
+
{ table: "payment_sessions", column: "payer_person_id" },
|
|
30
|
+
{ table: "contracts", column: "person_id" },
|
|
31
|
+
{ table: "contract_signatures", column: "person_id" },
|
|
32
|
+
{ table: "policy_acceptances", column: "person_id" },
|
|
33
|
+
{ table: "policy_acceptances", column: "accepted_by" },
|
|
34
|
+
{ table: "notification_deliveries", column: "person_id" },
|
|
35
|
+
{ table: "notification_reminder_runs", column: "person_id" },
|
|
36
|
+
];
|
|
37
|
+
const OPTIONAL_ORGANIZATION_REFERENCES = [
|
|
38
|
+
{ table: "bookings", column: "organization_id" },
|
|
39
|
+
{ table: "offers", column: "organization_id" },
|
|
40
|
+
{ table: "orders", column: "organization_id" },
|
|
41
|
+
{ table: "invoices", column: "organization_id" },
|
|
42
|
+
{ table: "vouchers", column: "issued_to_organization_id" },
|
|
43
|
+
{ table: "payment_instruments", column: "organization_id" },
|
|
44
|
+
{ table: "payment_sessions", column: "payer_organization_id" },
|
|
45
|
+
{ table: "contracts", column: "organization_id" },
|
|
46
|
+
{ table: "policy_assignments", column: "organization_id" },
|
|
47
|
+
{ table: "notification_deliveries", column: "organization_id" },
|
|
48
|
+
{ table: "notification_reminder_runs", column: "organization_id" },
|
|
49
|
+
];
|
|
50
|
+
const OPTIONAL_PERSON_ENTITY_TARGET_REFERENCES = [
|
|
51
|
+
{ table: "notification_deliveries", entityType: "person" },
|
|
52
|
+
];
|
|
53
|
+
const OPTIONAL_ORGANIZATION_ENTITY_TARGET_REFERENCES = [
|
|
54
|
+
{ table: "notification_deliveries", entityType: "organization" },
|
|
55
|
+
];
|
|
56
|
+
function quoteIdentifier(identifier) {
|
|
57
|
+
return `"${identifier.replaceAll('"', '""')}"`;
|
|
58
|
+
}
|
|
59
|
+
function mergeTags(keepTags, mergeTags) {
|
|
60
|
+
return [...new Set([...(keepTags ?? []), ...(mergeTags ?? [])])];
|
|
61
|
+
}
|
|
62
|
+
function backfill(keep, merge, keys) {
|
|
63
|
+
const patch = {};
|
|
64
|
+
for (const key of keys) {
|
|
65
|
+
const keepValue = keep[key];
|
|
66
|
+
const mergeValue = merge[key];
|
|
67
|
+
if ((keepValue === null || keepValue === undefined || keepValue === "") &&
|
|
68
|
+
mergeValue !== null &&
|
|
69
|
+
mergeValue !== undefined &&
|
|
70
|
+
mergeValue !== "") {
|
|
71
|
+
patch[key] = mergeValue;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return patch;
|
|
75
|
+
}
|
|
76
|
+
async function tableHasColumn(db, table, column) {
|
|
77
|
+
const rows = await db.execute(sql `
|
|
78
|
+
SELECT EXISTS (
|
|
79
|
+
SELECT 1
|
|
80
|
+
FROM information_schema.columns
|
|
81
|
+
WHERE table_schema = 'public'
|
|
82
|
+
AND table_name = ${table}
|
|
83
|
+
AND column_name = ${column}
|
|
84
|
+
) AS "exists"
|
|
85
|
+
`);
|
|
86
|
+
return Boolean(rows[0]?.exists);
|
|
87
|
+
}
|
|
88
|
+
async function updateOptionalReference(db, reference, keepId, mergeId) {
|
|
89
|
+
if (!(await tableHasColumn(db, reference.table, reference.column)))
|
|
90
|
+
return;
|
|
91
|
+
await db.execute(sql `
|
|
92
|
+
UPDATE ${sql.raw(quoteIdentifier(reference.table))}
|
|
93
|
+
SET ${sql.raw(quoteIdentifier(reference.column))} = ${keepId}
|
|
94
|
+
WHERE ${sql.raw(quoteIdentifier(reference.column))} = ${mergeId}
|
|
95
|
+
`);
|
|
96
|
+
}
|
|
97
|
+
async function updateOptionalReferences(db, references, keepId, mergeId) {
|
|
98
|
+
for (const reference of references) {
|
|
99
|
+
await updateOptionalReference(db, reference, keepId, mergeId);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async function updateOptionalEntityTargetReference(db, reference, keepId, mergeId) {
|
|
103
|
+
const hasTargetType = await tableHasColumn(db, reference.table, "target_type");
|
|
104
|
+
const hasTargetId = await tableHasColumn(db, reference.table, "target_id");
|
|
105
|
+
if (!hasTargetType || !hasTargetId)
|
|
106
|
+
return;
|
|
107
|
+
await db.execute(sql `
|
|
108
|
+
UPDATE ${sql.raw(quoteIdentifier(reference.table))}
|
|
109
|
+
SET target_id = ${keepId}
|
|
110
|
+
WHERE target_type = ${reference.entityType}
|
|
111
|
+
AND target_id = ${mergeId}
|
|
112
|
+
`);
|
|
113
|
+
}
|
|
114
|
+
async function updateOptionalEntityTargetReferences(db, references, keepId, mergeId) {
|
|
115
|
+
for (const reference of references) {
|
|
116
|
+
await updateOptionalEntityTargetReference(db, reference, keepId, mergeId);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function mergeIdentityRows(db, entityType, keepId, mergeId) {
|
|
120
|
+
await db.delete(identityContactPoints).where(and(eq(identityContactPoints.entityType, entityType), eq(identityContactPoints.entityId, mergeId), sql `EXISTS (
|
|
121
|
+
SELECT 1
|
|
122
|
+
FROM identity_contact_points keep_point
|
|
123
|
+
WHERE keep_point.entity_type = ${entityType}
|
|
124
|
+
AND keep_point.entity_id = ${keepId}
|
|
125
|
+
AND keep_point.kind = ${identityContactPoints.kind}
|
|
126
|
+
AND keep_point.value = ${identityContactPoints.value}
|
|
127
|
+
)`));
|
|
128
|
+
await db
|
|
129
|
+
.update(identityContactPoints)
|
|
130
|
+
.set({ entityId: keepId, updatedAt: new Date() })
|
|
131
|
+
.where(and(eq(identityContactPoints.entityType, entityType), eq(identityContactPoints.entityId, mergeId)));
|
|
132
|
+
await db
|
|
133
|
+
.update(identityAddresses)
|
|
134
|
+
.set({ entityId: keepId, updatedAt: new Date() })
|
|
135
|
+
.where(and(eq(identityAddresses.entityType, entityType), eq(identityAddresses.entityId, mergeId)));
|
|
136
|
+
await db
|
|
137
|
+
.update(identityNamedContacts)
|
|
138
|
+
.set({ entityId: keepId, updatedAt: new Date() })
|
|
139
|
+
.where(and(eq(identityNamedContacts.entityType, entityType), eq(identityNamedContacts.entityId, mergeId)));
|
|
140
|
+
}
|
|
141
|
+
async function mergeEntityLinks(db, entityType, keepId, mergeId) {
|
|
142
|
+
await db
|
|
143
|
+
.update(activityLinks)
|
|
144
|
+
.set({ entityId: keepId })
|
|
145
|
+
.where(and(eq(activityLinks.entityType, entityType), eq(activityLinks.entityId, mergeId)));
|
|
146
|
+
await db.delete(customFieldValues).where(and(eq(customFieldValues.entityType, entityType), eq(customFieldValues.entityId, mergeId), sql `EXISTS (
|
|
147
|
+
SELECT 1
|
|
148
|
+
FROM custom_field_values keep_value
|
|
149
|
+
WHERE keep_value.definition_id = ${customFieldValues.definitionId}
|
|
150
|
+
AND keep_value.entity_type = ${entityType}
|
|
151
|
+
AND keep_value.entity_id = ${keepId}
|
|
152
|
+
)`));
|
|
153
|
+
await db
|
|
154
|
+
.update(customFieldValues)
|
|
155
|
+
.set({ entityId: keepId, updatedAt: new Date() })
|
|
156
|
+
.where(and(eq(customFieldValues.entityType, entityType), eq(customFieldValues.entityId, mergeId)));
|
|
157
|
+
}
|
|
158
|
+
async function dedupePersonJoinTables(db, keepId, mergeId) {
|
|
159
|
+
await db.delete(opportunityParticipants).where(and(eq(opportunityParticipants.personId, mergeId), sql `EXISTS (
|
|
160
|
+
SELECT 1
|
|
161
|
+
FROM opportunity_participants keep_participant
|
|
162
|
+
WHERE keep_participant.opportunity_id = ${opportunityParticipants.opportunityId}
|
|
163
|
+
AND keep_participant.person_id = ${keepId}
|
|
164
|
+
)`));
|
|
165
|
+
await db.delete(activityParticipants).where(and(eq(activityParticipants.personId, mergeId), sql `EXISTS (
|
|
166
|
+
SELECT 1
|
|
167
|
+
FROM activity_participants keep_participant
|
|
168
|
+
WHERE keep_participant.activity_id = ${activityParticipants.activityId}
|
|
169
|
+
AND keep_participant.person_id = ${keepId}
|
|
170
|
+
)`));
|
|
171
|
+
await db
|
|
172
|
+
.delete(personRelationships)
|
|
173
|
+
.where(or(and(eq(personRelationships.fromPersonId, mergeId), eq(personRelationships.toPersonId, keepId)), and(eq(personRelationships.fromPersonId, keepId), eq(personRelationships.toPersonId, mergeId)), and(eq(personRelationships.fromPersonId, mergeId), eq(personRelationships.toPersonId, mergeId))));
|
|
174
|
+
await db.delete(personRelationships).where(and(eq(personRelationships.fromPersonId, mergeId), ne(personRelationships.toPersonId, mergeId), sql `EXISTS (
|
|
175
|
+
SELECT 1
|
|
176
|
+
FROM person_relationships keep_relationship
|
|
177
|
+
WHERE keep_relationship.from_person_id = ${keepId}
|
|
178
|
+
AND keep_relationship.to_person_id = ${personRelationships.toPersonId}
|
|
179
|
+
AND keep_relationship.kind = ${personRelationships.kind}
|
|
180
|
+
)`));
|
|
181
|
+
await db.delete(personRelationships).where(and(eq(personRelationships.toPersonId, mergeId), ne(personRelationships.fromPersonId, mergeId), sql `EXISTS (
|
|
182
|
+
SELECT 1
|
|
183
|
+
FROM person_relationships keep_relationship
|
|
184
|
+
WHERE keep_relationship.from_person_id = ${personRelationships.fromPersonId}
|
|
185
|
+
AND keep_relationship.to_person_id = ${keepId}
|
|
186
|
+
AND keep_relationship.kind = ${personRelationships.kind}
|
|
187
|
+
)`));
|
|
188
|
+
}
|
|
189
|
+
export const accountMergeService = {
|
|
190
|
+
async mergePerson(db, keepId, mergeId) {
|
|
191
|
+
if (keepId === mergeId) {
|
|
192
|
+
throw new CrmMergeError("Cannot merge a person into itself", 400);
|
|
193
|
+
}
|
|
194
|
+
return db.transaction(async (tx) => {
|
|
195
|
+
const [keep, merge] = await tx
|
|
196
|
+
.select()
|
|
197
|
+
.from(people)
|
|
198
|
+
.where(inArray(people.id, [keepId, mergeId]))
|
|
199
|
+
.for("update");
|
|
200
|
+
const keepPerson = keep?.id === keepId ? keep : merge?.id === keepId ? merge : null;
|
|
201
|
+
const mergePerson = keep?.id === mergeId ? keep : merge?.id === mergeId ? merge : null;
|
|
202
|
+
if (!keepPerson)
|
|
203
|
+
throw new CrmMergeError("Person to keep not found", 404);
|
|
204
|
+
if (!mergePerson)
|
|
205
|
+
throw new CrmMergeError("Person to merge not found", 404);
|
|
206
|
+
await tx
|
|
207
|
+
.update(people)
|
|
208
|
+
.set({
|
|
209
|
+
...backfill(keepPerson, mergePerson, [
|
|
210
|
+
"organizationId",
|
|
211
|
+
"middleName",
|
|
212
|
+
"gender",
|
|
213
|
+
"jobTitle",
|
|
214
|
+
"relation",
|
|
215
|
+
"preferredLanguage",
|
|
216
|
+
"preferredCurrency",
|
|
217
|
+
"ownerId",
|
|
218
|
+
"source",
|
|
219
|
+
"sourceRef",
|
|
220
|
+
"dateOfBirth",
|
|
221
|
+
"notes",
|
|
222
|
+
"accessibilityEncrypted",
|
|
223
|
+
"dietaryEncrypted",
|
|
224
|
+
"loyaltyEncrypted",
|
|
225
|
+
"insuranceEncrypted",
|
|
226
|
+
]),
|
|
227
|
+
tags: mergeTags(keepPerson.tags, mergePerson.tags),
|
|
228
|
+
updatedAt: new Date(),
|
|
229
|
+
})
|
|
230
|
+
.where(eq(people.id, keepId));
|
|
231
|
+
await dedupePersonJoinTables(tx, keepId, mergeId);
|
|
232
|
+
await mergeIdentityRows(tx, personEntityType, keepId, mergeId);
|
|
233
|
+
await mergeEntityLinks(tx, "person", keepId, mergeId);
|
|
234
|
+
await tx
|
|
235
|
+
.update(personNotes)
|
|
236
|
+
.set({ personId: keepId })
|
|
237
|
+
.where(eq(personNotes.personId, mergeId));
|
|
238
|
+
await tx
|
|
239
|
+
.update(personDocuments)
|
|
240
|
+
.set({ isPrimary: false, updatedAt: new Date() })
|
|
241
|
+
.where(and(eq(personDocuments.personId, mergeId), eq(personDocuments.isPrimary, true), sql `EXISTS (
|
|
242
|
+
SELECT 1
|
|
243
|
+
FROM person_documents keep_document
|
|
244
|
+
WHERE keep_document.person_id = ${keepId}
|
|
245
|
+
AND keep_document.type = ${personDocuments.type}
|
|
246
|
+
AND keep_document.is_primary = true
|
|
247
|
+
)`));
|
|
248
|
+
await tx
|
|
249
|
+
.update(personDocuments)
|
|
250
|
+
.set({ personId: keepId, updatedAt: new Date() })
|
|
251
|
+
.where(eq(personDocuments.personId, mergeId));
|
|
252
|
+
await tx
|
|
253
|
+
.update(personPaymentMethods)
|
|
254
|
+
.set({ personId: keepId })
|
|
255
|
+
.where(eq(personPaymentMethods.personId, mergeId));
|
|
256
|
+
await tx
|
|
257
|
+
.update(communicationLog)
|
|
258
|
+
.set({ personId: keepId })
|
|
259
|
+
.where(eq(communicationLog.personId, mergeId));
|
|
260
|
+
await tx
|
|
261
|
+
.update(opportunities)
|
|
262
|
+
.set({ personId: keepId, updatedAt: new Date() })
|
|
263
|
+
.where(eq(opportunities.personId, mergeId));
|
|
264
|
+
await tx
|
|
265
|
+
.update(opportunityParticipants)
|
|
266
|
+
.set({ personId: keepId })
|
|
267
|
+
.where(eq(opportunityParticipants.personId, mergeId));
|
|
268
|
+
await tx
|
|
269
|
+
.update(activityParticipants)
|
|
270
|
+
.set({ personId: keepId })
|
|
271
|
+
.where(eq(activityParticipants.personId, mergeId));
|
|
272
|
+
await tx
|
|
273
|
+
.update(personRelationships)
|
|
274
|
+
.set({ fromPersonId: keepId, updatedAt: new Date() })
|
|
275
|
+
.where(eq(personRelationships.fromPersonId, mergeId));
|
|
276
|
+
await tx
|
|
277
|
+
.update(personRelationships)
|
|
278
|
+
.set({ toPersonId: keepId, updatedAt: new Date() })
|
|
279
|
+
.where(eq(personRelationships.toPersonId, mergeId));
|
|
280
|
+
await tx
|
|
281
|
+
.update(segmentMembers)
|
|
282
|
+
.set({ personId: keepId })
|
|
283
|
+
.where(eq(segmentMembers.personId, mergeId));
|
|
284
|
+
await tx
|
|
285
|
+
.update(customerSignals)
|
|
286
|
+
.set({ personId: keepId, updatedAt: new Date() })
|
|
287
|
+
.where(eq(customerSignals.personId, mergeId));
|
|
288
|
+
await updateOptionalReferences(tx, OPTIONAL_PERSON_REFERENCES, keepId, mergeId);
|
|
289
|
+
await updateOptionalEntityTargetReferences(tx, OPTIONAL_PERSON_ENTITY_TARGET_REFERENCES, keepId, mergeId);
|
|
290
|
+
await tx.delete(people).where(eq(people.id, mergeId));
|
|
291
|
+
const [row] = await tx.select().from(people).where(eq(people.id, keepId)).limit(1);
|
|
292
|
+
if (!row)
|
|
293
|
+
throw new Error("Merged person disappeared");
|
|
294
|
+
const [hydrated] = await hydratePeople(tx, [row]);
|
|
295
|
+
return hydrated ?? row;
|
|
296
|
+
});
|
|
297
|
+
},
|
|
298
|
+
async mergeOrganization(db, keepId, mergeId) {
|
|
299
|
+
if (keepId === mergeId) {
|
|
300
|
+
throw new CrmMergeError("Cannot merge an organization into itself", 400);
|
|
301
|
+
}
|
|
302
|
+
return db.transaction(async (tx) => {
|
|
303
|
+
const [keep, merge] = await tx
|
|
304
|
+
.select()
|
|
305
|
+
.from(organizations)
|
|
306
|
+
.where(inArray(organizations.id, [keepId, mergeId]))
|
|
307
|
+
.for("update");
|
|
308
|
+
const keepOrganization = keep?.id === keepId ? keep : merge?.id === keepId ? merge : null;
|
|
309
|
+
const mergeOrganization = keep?.id === mergeId ? keep : merge?.id === mergeId ? merge : null;
|
|
310
|
+
if (!keepOrganization)
|
|
311
|
+
throw new CrmMergeError("Organization to keep not found", 404);
|
|
312
|
+
if (!mergeOrganization)
|
|
313
|
+
throw new CrmMergeError("Organization to merge not found", 404);
|
|
314
|
+
await tx
|
|
315
|
+
.update(organizations)
|
|
316
|
+
.set({
|
|
317
|
+
...backfill(keepOrganization, mergeOrganization, [
|
|
318
|
+
"legalName",
|
|
319
|
+
"website",
|
|
320
|
+
"taxId",
|
|
321
|
+
"industry",
|
|
322
|
+
"relation",
|
|
323
|
+
"ownerId",
|
|
324
|
+
"defaultCurrency",
|
|
325
|
+
"preferredLanguage",
|
|
326
|
+
"paymentTerms",
|
|
327
|
+
"source",
|
|
328
|
+
"sourceRef",
|
|
329
|
+
"notes",
|
|
330
|
+
]),
|
|
331
|
+
tags: mergeTags(keepOrganization.tags, mergeOrganization.tags),
|
|
332
|
+
updatedAt: new Date(),
|
|
333
|
+
})
|
|
334
|
+
.where(eq(organizations.id, keepId));
|
|
335
|
+
await mergeIdentityRows(tx, organizationEntityType, keepId, mergeId);
|
|
336
|
+
await mergeEntityLinks(tx, "organization", keepId, mergeId);
|
|
337
|
+
await tx
|
|
338
|
+
.update(people)
|
|
339
|
+
.set({ organizationId: keepId, updatedAt: new Date() })
|
|
340
|
+
.where(eq(people.organizationId, mergeId));
|
|
341
|
+
await tx
|
|
342
|
+
.update(organizationNotes)
|
|
343
|
+
.set({ organizationId: keepId })
|
|
344
|
+
.where(eq(organizationNotes.organizationId, mergeId));
|
|
345
|
+
await tx
|
|
346
|
+
.update(communicationLog)
|
|
347
|
+
.set({ organizationId: keepId })
|
|
348
|
+
.where(eq(communicationLog.organizationId, mergeId));
|
|
349
|
+
await tx
|
|
350
|
+
.update(opportunities)
|
|
351
|
+
.set({ organizationId: keepId, updatedAt: new Date() })
|
|
352
|
+
.where(eq(opportunities.organizationId, mergeId));
|
|
353
|
+
await updateOptionalReferences(tx, OPTIONAL_ORGANIZATION_REFERENCES, keepId, mergeId);
|
|
354
|
+
await updateOptionalEntityTargetReferences(tx, OPTIONAL_ORGANIZATION_ENTITY_TARGET_REFERENCES, keepId, mergeId);
|
|
355
|
+
await tx.delete(organizations).where(eq(organizations.id, mergeId));
|
|
356
|
+
const [row] = await tx
|
|
357
|
+
.select()
|
|
358
|
+
.from(organizations)
|
|
359
|
+
.where(eq(organizations.id, keepId))
|
|
360
|
+
.limit(1);
|
|
361
|
+
if (!row)
|
|
362
|
+
throw new Error("Merged organization disappeared");
|
|
363
|
+
return row;
|
|
364
|
+
});
|
|
365
|
+
},
|
|
366
|
+
};
|
|
@@ -78,7 +78,7 @@ export const peopleAccountsService = {
|
|
|
78
78
|
.orderBy(...orderBy), db.select({ count: sql `count(*)::int` }).from(people).where(where), query.limit, query.offset);
|
|
79
79
|
return {
|
|
80
80
|
...result,
|
|
81
|
-
data: await hydratePeople(db, result.data),
|
|
81
|
+
data: await hydratePeople(db, result.data, { fallbackOnError: true }),
|
|
82
82
|
};
|
|
83
83
|
},
|
|
84
84
|
async getPersonById(db, id) {
|
|
@@ -26,6 +26,9 @@ export type PersonHydratedFields = {
|
|
|
26
26
|
phone: string | null;
|
|
27
27
|
website: string | null;
|
|
28
28
|
};
|
|
29
|
+
type HydratePeopleOptions = {
|
|
30
|
+
fallbackOnError?: boolean;
|
|
31
|
+
};
|
|
29
32
|
export declare function personBaseFields(data: CreatePersonInput | UpdatePersonInput): {
|
|
30
33
|
organizationId: string | null | undefined;
|
|
31
34
|
firstName: string | undefined;
|
|
@@ -60,6 +63,6 @@ export declare function syncPersonIdentity(db: PostgresJsDatabase, personId: str
|
|
|
60
63
|
export declare function deletePersonIdentity(db: PostgresJsDatabase, personId: string): Promise<void>;
|
|
61
64
|
export declare function hydratePeople<T extends {
|
|
62
65
|
id: string;
|
|
63
|
-
}>(db: PostgresJsDatabase, rows: T[]): Promise<Array<T & PersonHydratedFields>>;
|
|
66
|
+
}>(db: PostgresJsDatabase, rows: T[], options?: HydratePeopleOptions): Promise<Array<T & PersonHydratedFields>>;
|
|
64
67
|
export {};
|
|
65
68
|
//# sourceMappingURL=accounts-shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts-shared.d.ts","sourceRoot":"","sources":["../../src/service/accounts-shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,KAAK,EACV,4BAA4B,EAC5B,4BAA4B,EAC5B,4BAA4B,EAC5B,wBAAwB,EACxB,sBAAsB,EACtB,k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gC1C"}
|
|
@@ -117,15 +117,29 @@ export async function deletePersonIdentity(db, personId) {
|
|
|
117
117
|
...addresses.map((address) => identityService.deleteAddress(db, address.id)),
|
|
118
118
|
]);
|
|
119
119
|
}
|
|
120
|
-
export async function hydratePeople(db, rows) {
|
|
120
|
+
export async function hydratePeople(db, rows, options = {}) {
|
|
121
|
+
const emptyHydratedRows = () => rows.map((row) => ({
|
|
122
|
+
...row,
|
|
123
|
+
...emptyPersonHydratedFields(),
|
|
124
|
+
}));
|
|
121
125
|
if (rows.length === 0) {
|
|
122
|
-
return
|
|
123
|
-
...row,
|
|
124
|
-
...emptyPersonHydratedFields(),
|
|
125
|
-
}));
|
|
126
|
+
return emptyHydratedRows();
|
|
126
127
|
}
|
|
127
128
|
const ids = rows.map((row) => row.id);
|
|
128
|
-
|
|
129
|
+
let directoryMap;
|
|
130
|
+
try {
|
|
131
|
+
directoryMap = await loadPersonDirectoryMap(db, ids);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
if (!options.fallbackOnError) {
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
console.warn("[crm] person identity hydration failed; returning base people rows", {
|
|
138
|
+
error,
|
|
139
|
+
personCount: rows.length,
|
|
140
|
+
});
|
|
141
|
+
return emptyHydratedRows();
|
|
142
|
+
}
|
|
129
143
|
return rows.map((row) => {
|
|
130
144
|
return {
|
|
131
145
|
...row,
|
|
@@ -2,6 +2,61 @@ import { findPersonByContactPoint, personNameFromContact, upsertPersonFromContac
|
|
|
2
2
|
export declare const accountsService: {
|
|
3
3
|
findPersonByContactPoint: typeof findPersonByContactPoint;
|
|
4
4
|
upsertPersonFromContact: typeof upsertPersonFromContact;
|
|
5
|
+
mergePerson(db: import("drizzle-orm/postgres-js").PostgresJsDatabase, keepId: string, mergeId: string): Promise<{
|
|
6
|
+
id: string;
|
|
7
|
+
organizationId: string | null;
|
|
8
|
+
firstName: string;
|
|
9
|
+
middleName: string | null;
|
|
10
|
+
lastName: string;
|
|
11
|
+
gender: string | null;
|
|
12
|
+
jobTitle: string | null;
|
|
13
|
+
relation: "partner" | "supplier" | "other" | "client" | null;
|
|
14
|
+
preferredLanguage: string | null;
|
|
15
|
+
preferredCurrency: string | null;
|
|
16
|
+
ownerId: string | null;
|
|
17
|
+
status: "active" | "inactive" | "archived";
|
|
18
|
+
source: string | null;
|
|
19
|
+
sourceRef: string | null;
|
|
20
|
+
tags: string[];
|
|
21
|
+
dateOfBirth: string | null;
|
|
22
|
+
notes: string | null;
|
|
23
|
+
accessibilityEncrypted: {
|
|
24
|
+
enc: string;
|
|
25
|
+
} | null;
|
|
26
|
+
dietaryEncrypted: {
|
|
27
|
+
enc: string;
|
|
28
|
+
} | null;
|
|
29
|
+
loyaltyEncrypted: {
|
|
30
|
+
enc: string;
|
|
31
|
+
} | null;
|
|
32
|
+
insuranceEncrypted: {
|
|
33
|
+
enc: string;
|
|
34
|
+
} | null;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
archivedAt: Date | null;
|
|
38
|
+
}>;
|
|
39
|
+
mergeOrganization(db: import("drizzle-orm/postgres-js").PostgresJsDatabase, keepId: string, mergeId: string): Promise<{
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
legalName: string | null;
|
|
43
|
+
website: string | null;
|
|
44
|
+
taxId: string | null;
|
|
45
|
+
industry: string | null;
|
|
46
|
+
relation: "partner" | "supplier" | "other" | "client" | null;
|
|
47
|
+
ownerId: string | null;
|
|
48
|
+
defaultCurrency: string | null;
|
|
49
|
+
preferredLanguage: string | null;
|
|
50
|
+
paymentTerms: number | null;
|
|
51
|
+
status: "active" | "inactive" | "archived";
|
|
52
|
+
source: string | null;
|
|
53
|
+
sourceRef: string | null;
|
|
54
|
+
tags: string[];
|
|
55
|
+
notes: string | null;
|
|
56
|
+
createdAt: Date;
|
|
57
|
+
updatedAt: Date;
|
|
58
|
+
archivedAt: Date | null;
|
|
59
|
+
}>;
|
|
5
60
|
listPeople(db: import("drizzle-orm/postgres-js").PostgresJsDatabase, query: import("./accounts-shared.js").PersonListQuery): Promise<{
|
|
6
61
|
data: ({
|
|
7
62
|
id: string;
|
|
@@ -1404,6 +1459,7 @@ export declare const accountsService: {
|
|
|
1404
1459
|
id: string;
|
|
1405
1460
|
} | null>;
|
|
1406
1461
|
};
|
|
1462
|
+
export { accountMergeService, CrmMergeError } from "./accounts-merge.js";
|
|
1407
1463
|
export type { PersonContactInput, UpsertPersonFromContactOptions, } from "./accounts-resolve.js";
|
|
1408
1464
|
export { findPersonByContactPoint, personNameFromContact, upsertPersonFromContact };
|
|
1409
1465
|
//# sourceMappingURL=accounts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/service/accounts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/service/accounts.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,uBAAuB,CAAA;AAE9B,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;CAM3B,CAAA;AAED,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxE,YAAY,EACV,kBAAkB,EAClB,8BAA8B,GAC/B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,CAAA"}
|
package/dist/service/accounts.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { accountMergeService } from "./accounts-merge.js";
|
|
1
2
|
import { organizationAccountsService } from "./accounts-organizations.js";
|
|
2
3
|
import { peopleAccountsService } from "./accounts-people.js";
|
|
3
4
|
import { findPersonByContactPoint, personNameFromContact, upsertPersonFromContact, } from "./accounts-resolve.js";
|
|
4
5
|
export const accountsService = {
|
|
5
6
|
...organizationAccountsService,
|
|
6
7
|
...peopleAccountsService,
|
|
8
|
+
...accountMergeService,
|
|
7
9
|
findPersonByContactPoint,
|
|
8
10
|
upsertPersonFromContact,
|
|
9
11
|
};
|
|
12
|
+
export { accountMergeService, CrmMergeError } from "./accounts-merge.js";
|
|
10
13
|
export { findPersonByContactPoint, personNameFromContact, upsertPersonFromContact };
|
package/dist/service/index.d.ts
CHANGED
|
@@ -4496,6 +4496,61 @@ export declare const crmService: {
|
|
|
4496
4496
|
} | null>;
|
|
4497
4497
|
findPersonByContactPoint: typeof import("./accounts-resolve.js").findPersonByContactPoint;
|
|
4498
4498
|
upsertPersonFromContact: typeof import("./accounts-resolve.js").upsertPersonFromContact;
|
|
4499
|
+
mergePerson(db: import("drizzle-orm/postgres-js").PostgresJsDatabase, keepId: string, mergeId: string): Promise<{
|
|
4500
|
+
id: string;
|
|
4501
|
+
organizationId: string | null;
|
|
4502
|
+
firstName: string;
|
|
4503
|
+
middleName: string | null;
|
|
4504
|
+
lastName: string;
|
|
4505
|
+
gender: string | null;
|
|
4506
|
+
jobTitle: string | null;
|
|
4507
|
+
relation: "partner" | "supplier" | "other" | "client" | null;
|
|
4508
|
+
preferredLanguage: string | null;
|
|
4509
|
+
preferredCurrency: string | null;
|
|
4510
|
+
ownerId: string | null;
|
|
4511
|
+
status: "active" | "inactive" | "archived";
|
|
4512
|
+
source: string | null;
|
|
4513
|
+
sourceRef: string | null;
|
|
4514
|
+
tags: string[];
|
|
4515
|
+
dateOfBirth: string | null;
|
|
4516
|
+
notes: string | null;
|
|
4517
|
+
accessibilityEncrypted: {
|
|
4518
|
+
enc: string;
|
|
4519
|
+
} | null;
|
|
4520
|
+
dietaryEncrypted: {
|
|
4521
|
+
enc: string;
|
|
4522
|
+
} | null;
|
|
4523
|
+
loyaltyEncrypted: {
|
|
4524
|
+
enc: string;
|
|
4525
|
+
} | null;
|
|
4526
|
+
insuranceEncrypted: {
|
|
4527
|
+
enc: string;
|
|
4528
|
+
} | null;
|
|
4529
|
+
createdAt: Date;
|
|
4530
|
+
updatedAt: Date;
|
|
4531
|
+
archivedAt: Date | null;
|
|
4532
|
+
}>;
|
|
4533
|
+
mergeOrganization(db: import("drizzle-orm/postgres-js").PostgresJsDatabase, keepId: string, mergeId: string): Promise<{
|
|
4534
|
+
id: string;
|
|
4535
|
+
name: string;
|
|
4536
|
+
legalName: string | null;
|
|
4537
|
+
website: string | null;
|
|
4538
|
+
taxId: string | null;
|
|
4539
|
+
industry: string | null;
|
|
4540
|
+
relation: "partner" | "supplier" | "other" | "client" | null;
|
|
4541
|
+
ownerId: string | null;
|
|
4542
|
+
defaultCurrency: string | null;
|
|
4543
|
+
preferredLanguage: string | null;
|
|
4544
|
+
paymentTerms: number | null;
|
|
4545
|
+
status: "active" | "inactive" | "archived";
|
|
4546
|
+
source: string | null;
|
|
4547
|
+
sourceRef: string | null;
|
|
4548
|
+
tags: string[];
|
|
4549
|
+
notes: string | null;
|
|
4550
|
+
createdAt: Date;
|
|
4551
|
+
updatedAt: Date;
|
|
4552
|
+
archivedAt: Date | null;
|
|
4553
|
+
}>;
|
|
4499
4554
|
listPeople(db: import("drizzle-orm/postgres-js").PostgresJsDatabase, query: import("./accounts-shared.js").PersonListQuery): Promise<{
|
|
4500
4555
|
data: ({
|
|
4501
4556
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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EACzB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,mCAAmC,EACnC,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EACV,6BAA6B,EAC7B,sBAAsB,EACtB,2BAA2B,EAC3B,6BAA6B,GAC9B,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyantjs/crm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.106.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"drizzle-orm": "^0.45.2",
|
|
40
40
|
"hono": "^4.12.10",
|
|
41
41
|
"zod": "^4.3.6",
|
|
42
|
-
"@voyantjs/action-ledger": "^0.104.1",
|
|
43
42
|
"@voyantjs/core": "^0.104.1",
|
|
44
|
-
"@voyantjs/
|
|
43
|
+
"@voyantjs/action-ledger": "^0.104.1",
|
|
44
|
+
"@voyantjs/crm-contracts": "^0.105.0",
|
|
45
45
|
"@voyantjs/db": "^0.104.2",
|
|
46
46
|
"@voyantjs/hono": "^0.104.1",
|
|
47
|
-
"@voyantjs/identity": "^0.
|
|
47
|
+
"@voyantjs/identity": "^0.106.0",
|
|
48
48
|
"@voyantjs/utils": "^0.104.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|