@voyantjs/suppliers 0.2.0 → 0.3.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.d.ts +7 -7
- package/dist/service-core.d.ts +81 -0
- package/dist/service-core.d.ts.map +1 -0
- package/dist/service-core.js +155 -0
- package/dist/service-identity.d.ts +162 -0
- package/dist/service-identity.d.ts.map +1 -0
- package/dist/service-identity.js +62 -0
- package/dist/service-operations.d.ts +1500 -0
- package/dist/service-operations.d.ts.map +1 -0
- package/dist/service-operations.js +157 -0
- package/dist/service-shared.d.ts +43 -0
- package/dist/service-shared.d.ts.map +1 -0
- package/dist/service-shared.js +212 -0
- package/dist/service.d.ts +36 -1752
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +36 -600
- package/package.json +6 -6
package/dist/routes.d.ts
CHANGED
|
@@ -270,17 +270,17 @@ export declare const supplierRoutes: import("hono/hono-base").HonoBase<Env, {
|
|
|
270
270
|
};
|
|
271
271
|
output: {
|
|
272
272
|
data: {
|
|
273
|
+
id: string;
|
|
273
274
|
name: string;
|
|
274
275
|
type: "other" | "hotel" | "restaurant" | "transfer" | "guide" | "experience" | "airline";
|
|
275
|
-
id: string;
|
|
276
|
-
createdAt: string;
|
|
277
|
-
updatedAt: string;
|
|
278
|
-
description: string | null;
|
|
279
276
|
status: "active" | "inactive" | "pending";
|
|
280
|
-
|
|
277
|
+
description: string | null;
|
|
281
278
|
defaultCurrency: string | null;
|
|
282
279
|
paymentTermsDays: number | null;
|
|
283
280
|
primaryFacilityId: string | null;
|
|
281
|
+
tags: string[] | null;
|
|
282
|
+
createdAt: string;
|
|
283
|
+
updatedAt: string;
|
|
284
284
|
email: string | null;
|
|
285
285
|
phone: string | null;
|
|
286
286
|
website: string | null;
|
|
@@ -316,8 +316,8 @@ export declare const supplierRoutes: import("hono/hono-base").HonoBase<Env, {
|
|
|
316
316
|
id: string;
|
|
317
317
|
createdAt: string;
|
|
318
318
|
updatedAt: string;
|
|
319
|
-
description: string | null;
|
|
320
319
|
status: "active" | "inactive" | "pending";
|
|
320
|
+
description: string | null;
|
|
321
321
|
tags: string[] | null;
|
|
322
322
|
defaultCurrency: string | null;
|
|
323
323
|
paymentTermsDays: number | null;
|
|
@@ -684,8 +684,8 @@ export declare const supplierRoutes: import("hono/hono-base").HonoBase<Env, {
|
|
|
684
684
|
id: string;
|
|
685
685
|
createdAt: string;
|
|
686
686
|
updatedAt: string;
|
|
687
|
-
description: string | null;
|
|
688
687
|
active: boolean;
|
|
688
|
+
description: string | null;
|
|
689
689
|
tags: string[] | null;
|
|
690
690
|
facilityId: string | null;
|
|
691
691
|
supplierId: string;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import type { CreateSupplierInput, SupplierListQuery, UpdateSupplierInput } from "./service-shared.js";
|
|
3
|
+
export declare function listSuppliers(db: PostgresJsDatabase, query: SupplierListQuery): Promise<{
|
|
4
|
+
data: ({
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
type: "other" | "hotel" | "restaurant" | "transfer" | "guide" | "experience" | "airline";
|
|
8
|
+
status: "active" | "inactive" | "pending";
|
|
9
|
+
description: string | null;
|
|
10
|
+
defaultCurrency: string | null;
|
|
11
|
+
paymentTermsDays: number | null;
|
|
12
|
+
primaryFacilityId: string | null;
|
|
13
|
+
tags: string[] | null;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
updatedAt: Date;
|
|
16
|
+
} & import("./service-shared.js").SupplierHydratedFields)[];
|
|
17
|
+
total: number;
|
|
18
|
+
limit: number;
|
|
19
|
+
offset: number;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function getSupplierById(db: PostgresJsDatabase, id: string): Promise<({
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
type: "other" | "hotel" | "restaurant" | "transfer" | "guide" | "experience" | "airline";
|
|
25
|
+
status: "active" | "inactive" | "pending";
|
|
26
|
+
description: string | null;
|
|
27
|
+
defaultCurrency: string | null;
|
|
28
|
+
paymentTermsDays: number | null;
|
|
29
|
+
primaryFacilityId: string | null;
|
|
30
|
+
tags: string[] | null;
|
|
31
|
+
createdAt: Date;
|
|
32
|
+
updatedAt: Date;
|
|
33
|
+
} & import("./service-shared.js").SupplierHydratedFields) | null>;
|
|
34
|
+
export declare function createSupplier(db: PostgresJsDatabase, data: CreateSupplierInput): Promise<{
|
|
35
|
+
email: string | null;
|
|
36
|
+
phone: string | null;
|
|
37
|
+
website: string | null;
|
|
38
|
+
address: string | null;
|
|
39
|
+
city: string | null;
|
|
40
|
+
country: string | null;
|
|
41
|
+
contactName: string | null;
|
|
42
|
+
contactEmail: string | null;
|
|
43
|
+
contactPhone: string | null;
|
|
44
|
+
name: string;
|
|
45
|
+
type: "other" | "hotel" | "restaurant" | "transfer" | "guide" | "experience" | "airline";
|
|
46
|
+
id: string;
|
|
47
|
+
createdAt: Date;
|
|
48
|
+
updatedAt: Date;
|
|
49
|
+
status: "active" | "inactive" | "pending";
|
|
50
|
+
description: string | null;
|
|
51
|
+
tags: string[] | null;
|
|
52
|
+
defaultCurrency: string | null;
|
|
53
|
+
paymentTermsDays: number | null;
|
|
54
|
+
primaryFacilityId: string | null;
|
|
55
|
+
}>;
|
|
56
|
+
export declare function updateSupplier(db: PostgresJsDatabase, id: string, data: UpdateSupplierInput): Promise<{
|
|
57
|
+
email: string | null;
|
|
58
|
+
phone: string | null;
|
|
59
|
+
website: string | null;
|
|
60
|
+
address: string | null;
|
|
61
|
+
city: string | null;
|
|
62
|
+
country: string | null;
|
|
63
|
+
contactName: string | null;
|
|
64
|
+
contactEmail: string | null;
|
|
65
|
+
contactPhone: string | null;
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
type: "other" | "hotel" | "restaurant" | "transfer" | "guide" | "experience" | "airline";
|
|
69
|
+
status: "active" | "inactive" | "pending";
|
|
70
|
+
description: string | null;
|
|
71
|
+
defaultCurrency: string | null;
|
|
72
|
+
paymentTermsDays: number | null;
|
|
73
|
+
primaryFacilityId: string | null;
|
|
74
|
+
tags: string[] | null;
|
|
75
|
+
createdAt: Date;
|
|
76
|
+
updatedAt: Date;
|
|
77
|
+
} | null>;
|
|
78
|
+
export declare function deleteSupplier(db: PostgresJsDatabase, id: string): Promise<{
|
|
79
|
+
id: string;
|
|
80
|
+
} | null>;
|
|
81
|
+
//# sourceMappingURL=service-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-core.d.ts","sourceRoot":"","sources":["../src/service-core.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,qBAAqB,CAAA;AAG5B,wBAAsB,aAAa,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,iBAAiB;;;;;;;;;;;;;;;;;GA2EnF;AAED,wBAAsB,eAAe,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;kEAQvE;AAED,wBAAsB,cAAc,CAAC,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;GA2CrF;AAED,wBAAsB,cAAc,CAClC,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;UAqD1B;AAED,wBAAsB,cAAc,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAMtE"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { identityAddresses, identityContactPoints, identityNamedContacts, } from "@voyantjs/identity/schema";
|
|
2
|
+
import { and, eq, sql } from "drizzle-orm";
|
|
3
|
+
import { suppliers } from "./schema.js";
|
|
4
|
+
import { hydrateSuppliers, supplierEntityType, syncSupplierIdentity } from "./service-shared.js";
|
|
5
|
+
export async function listSuppliers(db, query) {
|
|
6
|
+
const conditions = [];
|
|
7
|
+
if (query.type) {
|
|
8
|
+
conditions.push(eq(suppliers.type, query.type));
|
|
9
|
+
}
|
|
10
|
+
if (query.status) {
|
|
11
|
+
conditions.push(eq(suppliers.status, query.status));
|
|
12
|
+
}
|
|
13
|
+
if (query.primaryFacilityId) {
|
|
14
|
+
conditions.push(eq(suppliers.primaryFacilityId, query.primaryFacilityId));
|
|
15
|
+
}
|
|
16
|
+
if (query.search) {
|
|
17
|
+
const term = `%${query.search}%`;
|
|
18
|
+
conditions.push(sql `(
|
|
19
|
+
${suppliers.name} ilike ${term}
|
|
20
|
+
or
|
|
21
|
+
exists (
|
|
22
|
+
select 1
|
|
23
|
+
from ${identityContactPoints}
|
|
24
|
+
where ${identityContactPoints.entityType} = ${supplierEntityType}
|
|
25
|
+
and ${identityContactPoints.entityId} = ${suppliers.id}
|
|
26
|
+
and (
|
|
27
|
+
${identityContactPoints.value} ilike ${term}
|
|
28
|
+
or ${identityContactPoints.normalizedValue} ilike ${term}
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
or exists (
|
|
32
|
+
select 1
|
|
33
|
+
from ${identityNamedContacts}
|
|
34
|
+
where ${identityNamedContacts.entityType} = ${supplierEntityType}
|
|
35
|
+
and ${identityNamedContacts.entityId} = ${suppliers.id}
|
|
36
|
+
and (
|
|
37
|
+
${identityNamedContacts.name} ilike ${term}
|
|
38
|
+
or ${identityNamedContacts.email} ilike ${term}
|
|
39
|
+
or ${identityNamedContacts.phone} ilike ${term}
|
|
40
|
+
)
|
|
41
|
+
)
|
|
42
|
+
or exists (
|
|
43
|
+
select 1
|
|
44
|
+
from ${identityAddresses}
|
|
45
|
+
where ${identityAddresses.entityType} = ${supplierEntityType}
|
|
46
|
+
and ${identityAddresses.entityId} = ${suppliers.id}
|
|
47
|
+
and (
|
|
48
|
+
${identityAddresses.fullText} ilike ${term}
|
|
49
|
+
or ${identityAddresses.city} ilike ${term}
|
|
50
|
+
or ${identityAddresses.country} ilike ${term}
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
)`);
|
|
54
|
+
}
|
|
55
|
+
const where = conditions.length > 0 ? and(...conditions) : undefined;
|
|
56
|
+
const [rows, countResult] = await Promise.all([
|
|
57
|
+
db
|
|
58
|
+
.select()
|
|
59
|
+
.from(suppliers)
|
|
60
|
+
.where(where)
|
|
61
|
+
.limit(query.limit)
|
|
62
|
+
.offset(query.offset)
|
|
63
|
+
.orderBy(suppliers.createdAt),
|
|
64
|
+
db.select({ count: sql `count(*)::int` }).from(suppliers).where(where),
|
|
65
|
+
]);
|
|
66
|
+
return {
|
|
67
|
+
data: await hydrateSuppliers(db, rows),
|
|
68
|
+
total: countResult[0]?.count ?? 0,
|
|
69
|
+
limit: query.limit,
|
|
70
|
+
offset: query.offset,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export async function getSupplierById(db, id) {
|
|
74
|
+
const [row] = await db.select().from(suppliers).where(eq(suppliers.id, id)).limit(1);
|
|
75
|
+
if (!row) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const [hydrated] = await hydrateSuppliers(db, [row]);
|
|
79
|
+
return hydrated ?? null;
|
|
80
|
+
}
|
|
81
|
+
export async function createSupplier(db, data) {
|
|
82
|
+
const { email, phone, website, address, city, country, contactName, contactEmail, contactPhone, ...supplierValues } = data;
|
|
83
|
+
const [row] = await db.insert(suppliers).values(supplierValues).returning();
|
|
84
|
+
if (!row) {
|
|
85
|
+
throw new Error("Failed to create supplier");
|
|
86
|
+
}
|
|
87
|
+
await syncSupplierIdentity(db, row.id, {
|
|
88
|
+
email,
|
|
89
|
+
phone,
|
|
90
|
+
website,
|
|
91
|
+
address,
|
|
92
|
+
city,
|
|
93
|
+
country,
|
|
94
|
+
contactName,
|
|
95
|
+
contactEmail,
|
|
96
|
+
contactPhone,
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
...row,
|
|
100
|
+
email: email ?? null,
|
|
101
|
+
phone: phone ?? null,
|
|
102
|
+
website: website ?? null,
|
|
103
|
+
address: address ?? null,
|
|
104
|
+
city: city ?? null,
|
|
105
|
+
country: country ?? null,
|
|
106
|
+
contactName: contactName ?? null,
|
|
107
|
+
contactEmail: contactEmail ?? null,
|
|
108
|
+
contactPhone: contactPhone ?? null,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export async function updateSupplier(db, id, data) {
|
|
112
|
+
const existing = await getSupplierById(db, id);
|
|
113
|
+
if (!existing) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
const { email, phone, website, address, city, country, contactName, contactEmail, contactPhone, ...supplierValues } = data;
|
|
117
|
+
const [row] = await db
|
|
118
|
+
.update(suppliers)
|
|
119
|
+
.set({ ...supplierValues, updatedAt: new Date() })
|
|
120
|
+
.where(eq(suppliers.id, id))
|
|
121
|
+
.returning();
|
|
122
|
+
if (!row) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
await syncSupplierIdentity(db, id, {
|
|
126
|
+
email: email ?? existing.email,
|
|
127
|
+
phone: phone ?? existing.phone,
|
|
128
|
+
website: website ?? existing.website,
|
|
129
|
+
address: address ?? existing.address,
|
|
130
|
+
city: city ?? existing.city,
|
|
131
|
+
country: country ?? existing.country,
|
|
132
|
+
contactName: contactName ?? existing.contactName,
|
|
133
|
+
contactEmail: contactEmail ?? existing.contactEmail,
|
|
134
|
+
contactPhone: contactPhone ?? existing.contactPhone,
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
...row,
|
|
138
|
+
email: email ?? existing.email,
|
|
139
|
+
phone: phone ?? existing.phone,
|
|
140
|
+
website: website ?? existing.website,
|
|
141
|
+
address: address ?? existing.address,
|
|
142
|
+
city: city ?? existing.city,
|
|
143
|
+
country: country ?? existing.country,
|
|
144
|
+
contactName: contactName ?? existing.contactName,
|
|
145
|
+
contactEmail: contactEmail ?? existing.contactEmail,
|
|
146
|
+
contactPhone: contactPhone ?? existing.contactPhone,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
export async function deleteSupplier(db, id) {
|
|
150
|
+
const [row] = await db
|
|
151
|
+
.delete(suppliers)
|
|
152
|
+
.where(eq(suppliers.id, id))
|
|
153
|
+
.returning({ id: suppliers.id });
|
|
154
|
+
return row ?? null;
|
|
155
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { InsertAddressForEntity, InsertContactPointForEntity, InsertNamedContactForEntity, UpdateAddress as UpdateIdentityAddress, UpdateContactPoint as UpdateIdentityContactPoint, UpdateNamedContact as UpdateIdentityNamedContact } from "@voyantjs/identity/validation";
|
|
2
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
3
|
+
export declare function listContactPoints(db: PostgresJsDatabase, supplierId: string): Promise<{
|
|
4
|
+
id: string;
|
|
5
|
+
entityType: string;
|
|
6
|
+
entityId: string;
|
|
7
|
+
kind: "email" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social" | "other";
|
|
8
|
+
label: string | null;
|
|
9
|
+
value: string;
|
|
10
|
+
normalizedValue: string | null;
|
|
11
|
+
isPrimary: boolean;
|
|
12
|
+
notes: string | null;
|
|
13
|
+
metadata: Record<string, unknown> | null;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
updatedAt: Date;
|
|
16
|
+
}[]>;
|
|
17
|
+
export declare function listNamedContacts(db: PostgresJsDatabase, supplierId: string): Promise<{
|
|
18
|
+
id: string;
|
|
19
|
+
entityType: string;
|
|
20
|
+
entityId: string;
|
|
21
|
+
role: "other" | "primary" | "legal" | "general" | "reservations" | "operations" | "front_desk" | "sales" | "emergency" | "accounting";
|
|
22
|
+
name: string;
|
|
23
|
+
title: string | null;
|
|
24
|
+
email: string | null;
|
|
25
|
+
phone: string | null;
|
|
26
|
+
isPrimary: boolean;
|
|
27
|
+
notes: string | null;
|
|
28
|
+
metadata: Record<string, unknown> | null;
|
|
29
|
+
createdAt: Date;
|
|
30
|
+
updatedAt: Date;
|
|
31
|
+
}[]>;
|
|
32
|
+
export declare function createNamedContact(db: PostgresJsDatabase, supplierId: string, data: InsertNamedContactForEntity): Promise<{
|
|
33
|
+
name: string;
|
|
34
|
+
email: string | null;
|
|
35
|
+
phone: string | null;
|
|
36
|
+
entityType: string;
|
|
37
|
+
entityId: string;
|
|
38
|
+
isPrimary: boolean;
|
|
39
|
+
notes: string | null;
|
|
40
|
+
metadata: Record<string, unknown> | null;
|
|
41
|
+
role: "other" | "primary" | "legal" | "general" | "reservations" | "operations" | "front_desk" | "sales" | "emergency" | "accounting";
|
|
42
|
+
title: string | null;
|
|
43
|
+
id: string;
|
|
44
|
+
createdAt: Date;
|
|
45
|
+
updatedAt: Date;
|
|
46
|
+
} | null>;
|
|
47
|
+
export declare function updateNamedContact(db: PostgresJsDatabase, contactId: string, data: UpdateIdentityNamedContact): Promise<{
|
|
48
|
+
id: string;
|
|
49
|
+
entityType: string;
|
|
50
|
+
entityId: string;
|
|
51
|
+
role: "other" | "primary" | "legal" | "general" | "reservations" | "operations" | "front_desk" | "sales" | "emergency" | "accounting";
|
|
52
|
+
name: string;
|
|
53
|
+
title: string | null;
|
|
54
|
+
email: string | null;
|
|
55
|
+
phone: string | null;
|
|
56
|
+
isPrimary: boolean;
|
|
57
|
+
notes: string | null;
|
|
58
|
+
metadata: Record<string, unknown> | null;
|
|
59
|
+
createdAt: Date;
|
|
60
|
+
updatedAt: Date;
|
|
61
|
+
} | null>;
|
|
62
|
+
export declare function deleteNamedContact(db: PostgresJsDatabase, contactId: string): Promise<{
|
|
63
|
+
id: string;
|
|
64
|
+
} | null>;
|
|
65
|
+
export declare function createContactPoint(db: PostgresJsDatabase, supplierId: string, data: InsertContactPointForEntity): Promise<{
|
|
66
|
+
value: string;
|
|
67
|
+
kind: "email" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social" | "other";
|
|
68
|
+
entityType: string;
|
|
69
|
+
entityId: string;
|
|
70
|
+
label: string | null;
|
|
71
|
+
normalizedValue: string | null;
|
|
72
|
+
isPrimary: boolean;
|
|
73
|
+
notes: string | null;
|
|
74
|
+
metadata: Record<string, unknown> | null;
|
|
75
|
+
id: string;
|
|
76
|
+
createdAt: Date;
|
|
77
|
+
updatedAt: Date;
|
|
78
|
+
} | null>;
|
|
79
|
+
export declare function updateContactPoint(db: PostgresJsDatabase, contactPointId: string, data: UpdateIdentityContactPoint): Promise<{
|
|
80
|
+
id: string;
|
|
81
|
+
entityType: string;
|
|
82
|
+
entityId: string;
|
|
83
|
+
kind: "email" | "phone" | "mobile" | "whatsapp" | "website" | "sms" | "fax" | "social" | "other";
|
|
84
|
+
label: string | null;
|
|
85
|
+
value: string;
|
|
86
|
+
normalizedValue: string | null;
|
|
87
|
+
isPrimary: boolean;
|
|
88
|
+
notes: string | null;
|
|
89
|
+
metadata: Record<string, unknown> | null;
|
|
90
|
+
createdAt: Date;
|
|
91
|
+
updatedAt: Date;
|
|
92
|
+
} | null>;
|
|
93
|
+
export declare function deleteContactPoint(db: PostgresJsDatabase, contactPointId: string): Promise<{
|
|
94
|
+
id: string;
|
|
95
|
+
} | null>;
|
|
96
|
+
export declare function listAddresses(db: PostgresJsDatabase, supplierId: string): Promise<{
|
|
97
|
+
id: string;
|
|
98
|
+
entityType: string;
|
|
99
|
+
entityId: string;
|
|
100
|
+
label: "other" | "primary" | "billing" | "shipping" | "mailing" | "meeting" | "service" | "legal";
|
|
101
|
+
fullText: string | null;
|
|
102
|
+
line1: string | null;
|
|
103
|
+
line2: string | null;
|
|
104
|
+
city: string | null;
|
|
105
|
+
region: string | null;
|
|
106
|
+
postalCode: string | null;
|
|
107
|
+
country: string | null;
|
|
108
|
+
latitude: number | null;
|
|
109
|
+
longitude: number | null;
|
|
110
|
+
timezone: string | null;
|
|
111
|
+
isPrimary: boolean;
|
|
112
|
+
notes: string | null;
|
|
113
|
+
metadata: Record<string, unknown> | null;
|
|
114
|
+
createdAt: Date;
|
|
115
|
+
updatedAt: Date;
|
|
116
|
+
}[]>;
|
|
117
|
+
export declare function createAddress(db: PostgresJsDatabase, supplierId: string, data: InsertAddressForEntity): Promise<{
|
|
118
|
+
entityType: string;
|
|
119
|
+
entityId: string;
|
|
120
|
+
label: "other" | "primary" | "billing" | "shipping" | "mailing" | "meeting" | "service" | "legal";
|
|
121
|
+
isPrimary: boolean;
|
|
122
|
+
notes: string | null;
|
|
123
|
+
metadata: Record<string, unknown> | null;
|
|
124
|
+
fullText: string | null;
|
|
125
|
+
line1: string | null;
|
|
126
|
+
line2: string | null;
|
|
127
|
+
city: string | null;
|
|
128
|
+
region: string | null;
|
|
129
|
+
postalCode: string | null;
|
|
130
|
+
country: string | null;
|
|
131
|
+
latitude: number | null;
|
|
132
|
+
longitude: number | null;
|
|
133
|
+
timezone: string | null;
|
|
134
|
+
id: string;
|
|
135
|
+
createdAt: Date;
|
|
136
|
+
updatedAt: Date;
|
|
137
|
+
} | null>;
|
|
138
|
+
export declare function updateAddress(db: PostgresJsDatabase, addressId: string, data: UpdateIdentityAddress): Promise<{
|
|
139
|
+
id: string;
|
|
140
|
+
entityType: string;
|
|
141
|
+
entityId: string;
|
|
142
|
+
label: "other" | "primary" | "billing" | "shipping" | "mailing" | "meeting" | "service" | "legal";
|
|
143
|
+
fullText: string | null;
|
|
144
|
+
line1: string | null;
|
|
145
|
+
line2: string | null;
|
|
146
|
+
city: string | null;
|
|
147
|
+
region: string | null;
|
|
148
|
+
postalCode: string | null;
|
|
149
|
+
country: string | null;
|
|
150
|
+
latitude: number | null;
|
|
151
|
+
longitude: number | null;
|
|
152
|
+
timezone: string | null;
|
|
153
|
+
isPrimary: boolean;
|
|
154
|
+
notes: string | null;
|
|
155
|
+
metadata: Record<string, unknown> | null;
|
|
156
|
+
createdAt: Date;
|
|
157
|
+
updatedAt: Date;
|
|
158
|
+
} | null>;
|
|
159
|
+
export declare function deleteAddress(db: PostgresJsDatabase, addressId: string): Promise<{
|
|
160
|
+
id: string;
|
|
161
|
+
} | null>;
|
|
162
|
+
//# sourceMappingURL=service-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-identity.d.ts","sourceRoot":"","sources":["../src/service-identity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAC3B,aAAa,IAAI,qBAAqB,EACtC,kBAAkB,IAAI,0BAA0B,EAChD,kBAAkB,IAAI,0BAA0B,EACjD,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAIjE,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM;;;;;;;;;;;;;KAE3E;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM;;;;;;;;;;;;;;KAE3E;AAED,wBAAsB,kBAAkB,CACtC,EAAE,EAAE,kBAAkB,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,2BAA2B;;;;;;;;;;;;;;UAYlC;AAED,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,kBAAkB,EACtB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,0BAA0B;;;;;;;;;;;;;;UAGjC;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM;;UAE3E;AAED,wBAAsB,kBAAkB,CACtC,EAAE,EAAE,kBAAkB,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,2BAA2B;;;;;;;;;;;;;UAYlC;AAED,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,kBAAkB,EACtB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,0BAA0B;;;;;;;;;;;;;UAGjC;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM;;UAEhF;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;KAEvE;AAED,wBAAsB,aAAa,CACjC,EAAE,EAAE,kBAAkB,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,sBAAsB;;;;;;;;;;;;;;;;;;;;UAY7B;AAED,wBAAgB,aAAa,CAC3B,EAAE,EAAE,kBAAkB,EACtB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,qBAAqB;;;;;;;;;;;;;;;;;;;;UAG5B;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM;;UAEtE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { identityService } from "@voyantjs/identity/service";
|
|
2
|
+
import { ensureSupplierExists, supplierEntityType } from "./service-shared.js";
|
|
3
|
+
export function listContactPoints(db, supplierId) {
|
|
4
|
+
return identityService.listContactPointsForEntity(db, supplierEntityType, supplierId);
|
|
5
|
+
}
|
|
6
|
+
export function listNamedContacts(db, supplierId) {
|
|
7
|
+
return identityService.listNamedContactsForEntity(db, supplierEntityType, supplierId);
|
|
8
|
+
}
|
|
9
|
+
export async function createNamedContact(db, supplierId, data) {
|
|
10
|
+
const supplier = await ensureSupplierExists(db, supplierId);
|
|
11
|
+
if (!supplier) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return identityService.createNamedContact(db, {
|
|
15
|
+
...data,
|
|
16
|
+
entityType: supplierEntityType,
|
|
17
|
+
entityId: supplierId,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export function updateNamedContact(db, contactId, data) {
|
|
21
|
+
return identityService.updateNamedContact(db, contactId, data);
|
|
22
|
+
}
|
|
23
|
+
export function deleteNamedContact(db, contactId) {
|
|
24
|
+
return identityService.deleteNamedContact(db, contactId);
|
|
25
|
+
}
|
|
26
|
+
export async function createContactPoint(db, supplierId, data) {
|
|
27
|
+
const supplier = await ensureSupplierExists(db, supplierId);
|
|
28
|
+
if (!supplier) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return identityService.createContactPoint(db, {
|
|
32
|
+
...data,
|
|
33
|
+
entityType: supplierEntityType,
|
|
34
|
+
entityId: supplierId,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export function updateContactPoint(db, contactPointId, data) {
|
|
38
|
+
return identityService.updateContactPoint(db, contactPointId, data);
|
|
39
|
+
}
|
|
40
|
+
export function deleteContactPoint(db, contactPointId) {
|
|
41
|
+
return identityService.deleteContactPoint(db, contactPointId);
|
|
42
|
+
}
|
|
43
|
+
export function listAddresses(db, supplierId) {
|
|
44
|
+
return identityService.listAddressesForEntity(db, supplierEntityType, supplierId);
|
|
45
|
+
}
|
|
46
|
+
export async function createAddress(db, supplierId, data) {
|
|
47
|
+
const supplier = await ensureSupplierExists(db, supplierId);
|
|
48
|
+
if (!supplier) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return identityService.createAddress(db, {
|
|
52
|
+
...data,
|
|
53
|
+
entityType: supplierEntityType,
|
|
54
|
+
entityId: supplierId,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export function updateAddress(db, addressId, data) {
|
|
58
|
+
return identityService.updateAddress(db, addressId, data);
|
|
59
|
+
}
|
|
60
|
+
export function deleteAddress(db, addressId) {
|
|
61
|
+
return identityService.deleteAddress(db, addressId);
|
|
62
|
+
}
|