@voyantjs/suppliers 0.6.3 → 0.6.5
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/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/schema.d.ts +200 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +32 -6
- package/dist/service-identity.d.ts.map +1 -1
- package/dist/service-identity.js +55 -16
- package/dist/service-shared.d.ts +2 -0
- package/dist/service-shared.d.ts.map +1 -1
- package/dist/service-shared.js +144 -62
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { suppliersService } from "./service.js";
|
|
|
4
4
|
export type { SupplierRoutes } from "./routes.js";
|
|
5
5
|
export declare const suppliersModule: Module;
|
|
6
6
|
export declare const suppliersHonoModule: HonoModule;
|
|
7
|
-
export type { NewSupplier, NewSupplierAvailabilityEntry, NewSupplierContract, NewSupplierNote, NewSupplierRate, NewSupplierService, Supplier, SupplierAvailabilityEntry, SupplierContract, SupplierNote, SupplierRate, SupplierService, } from "./schema.js";
|
|
8
|
-
export { supplierAvailability, supplierContracts, supplierNotes, supplierRates, supplierServices, suppliers, } from "./schema.js";
|
|
7
|
+
export type { NewSupplier, NewSupplierAvailabilityEntry, NewSupplierContract, NewSupplierDirectoryProjection, NewSupplierNote, NewSupplierRate, NewSupplierService, Supplier, SupplierAvailabilityEntry, SupplierContract, SupplierDirectoryProjection, SupplierNote, SupplierRate, SupplierService, } from "./schema.js";
|
|
8
|
+
export { supplierAvailability, supplierContracts, supplierDirectoryProjections, supplierNotes, supplierRates, supplierServices, suppliers, } from "./schema.js";
|
|
9
9
|
export { availabilityQuerySchema, insertAvailabilitySchema, insertContractSchema, insertRateSchema, insertServiceSchema, insertSupplierNoteSchema, insertSupplierSchema, selectSupplierSchema, supplierListQuerySchema, updateContractSchema, updateRateSchema, updateServiceSchema, updateSupplierSchema, } from "./validation.js";
|
|
10
10
|
export { suppliersService };
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAGvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,eAAO,MAAM,eAAe,EAAE,MAE7B,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,UAGjC,CAAA;AAED,YAAY,EACV,WAAW,EACX,4BAA4B,EAC5B,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,yBAAyB,EACzB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,eAAe,GAChB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,SAAS,GACV,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAGvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,eAAO,MAAM,eAAe,EAAE,MAE7B,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,UAGjC,CAAA;AAED,YAAY,EACV,WAAW,EACX,4BAA4B,EAC5B,mBAAmB,EACnB,8BAA8B,EAC9B,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,yBAAyB,EACzB,gBAAgB,EAChB,2BAA2B,EAC3B,YAAY,EACZ,YAAY,EACZ,eAAe,GAChB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,4BAA4B,EAC5B,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,SAAS,GACV,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,6 @@ export const suppliersHonoModule = {
|
|
|
7
7
|
module: suppliersModule,
|
|
8
8
|
routes: supplierRoutes,
|
|
9
9
|
};
|
|
10
|
-
export { supplierAvailability, supplierContracts, supplierNotes, supplierRates, supplierServices, suppliers, } from "./schema.js";
|
|
10
|
+
export { supplierAvailability, supplierContracts, supplierDirectoryProjections, supplierNotes, supplierRates, supplierServices, suppliers, } from "./schema.js";
|
|
11
11
|
export { availabilityQuerySchema, insertAvailabilitySchema, insertContractSchema, insertRateSchema, insertServiceSchema, insertSupplierNoteSchema, insertSupplierSchema, selectSupplierSchema, supplierListQuerySchema, updateContractSchema, updateRateSchema, updateServiceSchema, updateSupplierSchema, } from "./validation.js";
|
|
12
12
|
export { suppliersService };
|
package/dist/schema.d.ts
CHANGED
|
@@ -201,6 +201,202 @@ export declare const suppliers: import("drizzle-orm/pg-core").PgTableWithColumns
|
|
|
201
201
|
}>;
|
|
202
202
|
export type Supplier = typeof suppliers.$inferSelect;
|
|
203
203
|
export type NewSupplier = typeof suppliers.$inferInsert;
|
|
204
|
+
export declare const supplierDirectoryProjections: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
205
|
+
name: "supplier_directory_projections";
|
|
206
|
+
schema: undefined;
|
|
207
|
+
columns: {
|
|
208
|
+
supplierId: import("drizzle-orm/pg-core").PgColumn<{
|
|
209
|
+
name: string;
|
|
210
|
+
tableName: "supplier_directory_projections";
|
|
211
|
+
dataType: "string";
|
|
212
|
+
columnType: "PgText";
|
|
213
|
+
data: string;
|
|
214
|
+
driverParam: string;
|
|
215
|
+
notNull: true;
|
|
216
|
+
hasDefault: false;
|
|
217
|
+
isPrimaryKey: false;
|
|
218
|
+
isAutoincrement: false;
|
|
219
|
+
hasRuntimeDefault: false;
|
|
220
|
+
enumValues: [string, ...string[]];
|
|
221
|
+
baseColumn: never;
|
|
222
|
+
identity: undefined;
|
|
223
|
+
generated: undefined;
|
|
224
|
+
}, {}, {}>;
|
|
225
|
+
email: import("drizzle-orm/pg-core").PgColumn<{
|
|
226
|
+
name: "email";
|
|
227
|
+
tableName: "supplier_directory_projections";
|
|
228
|
+
dataType: "string";
|
|
229
|
+
columnType: "PgText";
|
|
230
|
+
data: string;
|
|
231
|
+
driverParam: string;
|
|
232
|
+
notNull: false;
|
|
233
|
+
hasDefault: false;
|
|
234
|
+
isPrimaryKey: false;
|
|
235
|
+
isAutoincrement: false;
|
|
236
|
+
hasRuntimeDefault: false;
|
|
237
|
+
enumValues: [string, ...string[]];
|
|
238
|
+
baseColumn: never;
|
|
239
|
+
identity: undefined;
|
|
240
|
+
generated: undefined;
|
|
241
|
+
}, {}, {}>;
|
|
242
|
+
phone: import("drizzle-orm/pg-core").PgColumn<{
|
|
243
|
+
name: "phone";
|
|
244
|
+
tableName: "supplier_directory_projections";
|
|
245
|
+
dataType: "string";
|
|
246
|
+
columnType: "PgText";
|
|
247
|
+
data: string;
|
|
248
|
+
driverParam: string;
|
|
249
|
+
notNull: false;
|
|
250
|
+
hasDefault: false;
|
|
251
|
+
isPrimaryKey: false;
|
|
252
|
+
isAutoincrement: false;
|
|
253
|
+
hasRuntimeDefault: false;
|
|
254
|
+
enumValues: [string, ...string[]];
|
|
255
|
+
baseColumn: never;
|
|
256
|
+
identity: undefined;
|
|
257
|
+
generated: undefined;
|
|
258
|
+
}, {}, {}>;
|
|
259
|
+
website: import("drizzle-orm/pg-core").PgColumn<{
|
|
260
|
+
name: "website";
|
|
261
|
+
tableName: "supplier_directory_projections";
|
|
262
|
+
dataType: "string";
|
|
263
|
+
columnType: "PgText";
|
|
264
|
+
data: string;
|
|
265
|
+
driverParam: string;
|
|
266
|
+
notNull: false;
|
|
267
|
+
hasDefault: false;
|
|
268
|
+
isPrimaryKey: false;
|
|
269
|
+
isAutoincrement: false;
|
|
270
|
+
hasRuntimeDefault: false;
|
|
271
|
+
enumValues: [string, ...string[]];
|
|
272
|
+
baseColumn: never;
|
|
273
|
+
identity: undefined;
|
|
274
|
+
generated: undefined;
|
|
275
|
+
}, {}, {}>;
|
|
276
|
+
address: import("drizzle-orm/pg-core").PgColumn<{
|
|
277
|
+
name: "address";
|
|
278
|
+
tableName: "supplier_directory_projections";
|
|
279
|
+
dataType: "string";
|
|
280
|
+
columnType: "PgText";
|
|
281
|
+
data: string;
|
|
282
|
+
driverParam: string;
|
|
283
|
+
notNull: false;
|
|
284
|
+
hasDefault: false;
|
|
285
|
+
isPrimaryKey: false;
|
|
286
|
+
isAutoincrement: false;
|
|
287
|
+
hasRuntimeDefault: false;
|
|
288
|
+
enumValues: [string, ...string[]];
|
|
289
|
+
baseColumn: never;
|
|
290
|
+
identity: undefined;
|
|
291
|
+
generated: undefined;
|
|
292
|
+
}, {}, {}>;
|
|
293
|
+
city: import("drizzle-orm/pg-core").PgColumn<{
|
|
294
|
+
name: "city";
|
|
295
|
+
tableName: "supplier_directory_projections";
|
|
296
|
+
dataType: "string";
|
|
297
|
+
columnType: "PgText";
|
|
298
|
+
data: string;
|
|
299
|
+
driverParam: string;
|
|
300
|
+
notNull: false;
|
|
301
|
+
hasDefault: false;
|
|
302
|
+
isPrimaryKey: false;
|
|
303
|
+
isAutoincrement: false;
|
|
304
|
+
hasRuntimeDefault: false;
|
|
305
|
+
enumValues: [string, ...string[]];
|
|
306
|
+
baseColumn: never;
|
|
307
|
+
identity: undefined;
|
|
308
|
+
generated: undefined;
|
|
309
|
+
}, {}, {}>;
|
|
310
|
+
country: import("drizzle-orm/pg-core").PgColumn<{
|
|
311
|
+
name: "country";
|
|
312
|
+
tableName: "supplier_directory_projections";
|
|
313
|
+
dataType: "string";
|
|
314
|
+
columnType: "PgText";
|
|
315
|
+
data: string;
|
|
316
|
+
driverParam: string;
|
|
317
|
+
notNull: false;
|
|
318
|
+
hasDefault: false;
|
|
319
|
+
isPrimaryKey: false;
|
|
320
|
+
isAutoincrement: false;
|
|
321
|
+
hasRuntimeDefault: false;
|
|
322
|
+
enumValues: [string, ...string[]];
|
|
323
|
+
baseColumn: never;
|
|
324
|
+
identity: undefined;
|
|
325
|
+
generated: undefined;
|
|
326
|
+
}, {}, {}>;
|
|
327
|
+
contactName: import("drizzle-orm/pg-core").PgColumn<{
|
|
328
|
+
name: "contact_name";
|
|
329
|
+
tableName: "supplier_directory_projections";
|
|
330
|
+
dataType: "string";
|
|
331
|
+
columnType: "PgText";
|
|
332
|
+
data: string;
|
|
333
|
+
driverParam: string;
|
|
334
|
+
notNull: false;
|
|
335
|
+
hasDefault: false;
|
|
336
|
+
isPrimaryKey: false;
|
|
337
|
+
isAutoincrement: false;
|
|
338
|
+
hasRuntimeDefault: false;
|
|
339
|
+
enumValues: [string, ...string[]];
|
|
340
|
+
baseColumn: never;
|
|
341
|
+
identity: undefined;
|
|
342
|
+
generated: undefined;
|
|
343
|
+
}, {}, {}>;
|
|
344
|
+
contactEmail: import("drizzle-orm/pg-core").PgColumn<{
|
|
345
|
+
name: "contact_email";
|
|
346
|
+
tableName: "supplier_directory_projections";
|
|
347
|
+
dataType: "string";
|
|
348
|
+
columnType: "PgText";
|
|
349
|
+
data: string;
|
|
350
|
+
driverParam: string;
|
|
351
|
+
notNull: false;
|
|
352
|
+
hasDefault: false;
|
|
353
|
+
isPrimaryKey: false;
|
|
354
|
+
isAutoincrement: false;
|
|
355
|
+
hasRuntimeDefault: false;
|
|
356
|
+
enumValues: [string, ...string[]];
|
|
357
|
+
baseColumn: never;
|
|
358
|
+
identity: undefined;
|
|
359
|
+
generated: undefined;
|
|
360
|
+
}, {}, {}>;
|
|
361
|
+
contactPhone: import("drizzle-orm/pg-core").PgColumn<{
|
|
362
|
+
name: "contact_phone";
|
|
363
|
+
tableName: "supplier_directory_projections";
|
|
364
|
+
dataType: "string";
|
|
365
|
+
columnType: "PgText";
|
|
366
|
+
data: string;
|
|
367
|
+
driverParam: string;
|
|
368
|
+
notNull: false;
|
|
369
|
+
hasDefault: false;
|
|
370
|
+
isPrimaryKey: false;
|
|
371
|
+
isAutoincrement: false;
|
|
372
|
+
hasRuntimeDefault: false;
|
|
373
|
+
enumValues: [string, ...string[]];
|
|
374
|
+
baseColumn: never;
|
|
375
|
+
identity: undefined;
|
|
376
|
+
generated: undefined;
|
|
377
|
+
}, {}, {}>;
|
|
378
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
379
|
+
name: "updated_at";
|
|
380
|
+
tableName: "supplier_directory_projections";
|
|
381
|
+
dataType: "date";
|
|
382
|
+
columnType: "PgTimestamp";
|
|
383
|
+
data: Date;
|
|
384
|
+
driverParam: string;
|
|
385
|
+
notNull: true;
|
|
386
|
+
hasDefault: true;
|
|
387
|
+
isPrimaryKey: false;
|
|
388
|
+
isAutoincrement: false;
|
|
389
|
+
hasRuntimeDefault: false;
|
|
390
|
+
enumValues: undefined;
|
|
391
|
+
baseColumn: never;
|
|
392
|
+
identity: undefined;
|
|
393
|
+
generated: undefined;
|
|
394
|
+
}, {}, {}>;
|
|
395
|
+
};
|
|
396
|
+
dialect: "pg";
|
|
397
|
+
}>;
|
|
398
|
+
export type SupplierDirectoryProjection = typeof supplierDirectoryProjections.$inferSelect;
|
|
399
|
+
export type NewSupplierDirectoryProjection = typeof supplierDirectoryProjections.$inferInsert;
|
|
204
400
|
export declare const supplierServices: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
205
401
|
name: "supplier_services";
|
|
206
402
|
schema: undefined;
|
|
@@ -1015,11 +1211,15 @@ export type SupplierContract = typeof supplierContracts.$inferSelect;
|
|
|
1015
1211
|
export type NewSupplierContract = typeof supplierContracts.$inferInsert;
|
|
1016
1212
|
export declare const suppliersRelations: import("drizzle-orm").Relations<"suppliers", {
|
|
1017
1213
|
primaryFacility: import("drizzle-orm").One<"facilities", false>;
|
|
1214
|
+
directoryProjection: import("drizzle-orm").One<"supplier_directory_projections", true>;
|
|
1018
1215
|
services: import("drizzle-orm").Many<"supplier_services">;
|
|
1019
1216
|
notes: import("drizzle-orm").Many<"supplier_notes">;
|
|
1020
1217
|
availability: import("drizzle-orm").Many<"supplier_availability">;
|
|
1021
1218
|
contracts: import("drizzle-orm").Many<"supplier_contracts">;
|
|
1022
1219
|
}>;
|
|
1220
|
+
export declare const supplierDirectoryProjectionsRelations: import("drizzle-orm").Relations<"supplier_directory_projections", {
|
|
1221
|
+
supplier: import("drizzle-orm").One<"suppliers", true>;
|
|
1222
|
+
}>;
|
|
1023
1223
|
export declare const supplierServicesRelations: import("drizzle-orm").Relations<"supplier_services", {
|
|
1024
1224
|
supplier: import("drizzle-orm").One<"suppliers", true>;
|
|
1025
1225
|
facility: import("drizzle-orm").One<"facilities", false>;
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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ChF,MAAM,MAAM,4BAA4B,GAAG,OAAO,oBAAoB,CAAC,YAAY,CAAA;AAInF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoB7B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,iBAAiB,CAAC,YAAY,CAAA;AACpE,MAAM,MAAM,mBAAmB,GAAG,OAAO,iBAAiB,CAAC,YAAY,CAAA;AAIvE,eAAO,MAAM,kBAAkB;;;;;;;EAa5B,CAAA;AAEH,eAAO,MAAM,qCAAqC;;EAQjD,CAAA;AAED,eAAO,MAAM,yBAAyB;;;;EAOnC,CAAA;AAEH,eAAO,MAAM,sBAAsB;;EAKhC,CAAA;AAEH,eAAO,MAAM,sBAAsB;;EAEhC,CAAA;AAEH,eAAO,MAAM,6BAA6B;;EAKvC,CAAA;AAEH,eAAO,MAAM,0BAA0B;;EAKpC,CAAA"}
|
package/dist/schema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { typeId, typeIdRef } from "@voyantjs/db/lib/typeid-column";
|
|
2
2
|
import { facilities } from "@voyantjs/facilities/schema";
|
|
3
3
|
import { relations } from "drizzle-orm";
|
|
4
|
-
import { boolean, date, index, integer, jsonb, pgEnum, pgTable, text, timestamp, } from "drizzle-orm/pg-core";
|
|
4
|
+
import { boolean, date, index, integer, jsonb, pgEnum, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
|
|
5
5
|
export const supplierTypeEnum = pgEnum("supplier_type", [
|
|
6
6
|
"hotel",
|
|
7
7
|
"transfer",
|
|
@@ -56,6 +56,22 @@ export const suppliers = pgTable("suppliers", {
|
|
|
56
56
|
index("idx_suppliers_status").on(table.status),
|
|
57
57
|
index("idx_suppliers_primary_facility").on(table.primaryFacilityId),
|
|
58
58
|
]);
|
|
59
|
+
// ---------- supplier_directory_projections ----------
|
|
60
|
+
export const supplierDirectoryProjections = pgTable("supplier_directory_projections", {
|
|
61
|
+
supplierId: typeIdRef("supplier_id")
|
|
62
|
+
.notNull()
|
|
63
|
+
.references(() => suppliers.id, { onDelete: "cascade" }),
|
|
64
|
+
email: text("email"),
|
|
65
|
+
phone: text("phone"),
|
|
66
|
+
website: text("website"),
|
|
67
|
+
address: text("address"),
|
|
68
|
+
city: text("city"),
|
|
69
|
+
country: text("country"),
|
|
70
|
+
contactName: text("contact_name"),
|
|
71
|
+
contactEmail: text("contact_email"),
|
|
72
|
+
contactPhone: text("contact_phone"),
|
|
73
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
74
|
+
}, (table) => [uniqueIndex("uq_supplier_directory_projections_supplier").on(table.supplierId)]);
|
|
59
75
|
// ---------- supplier_services ----------
|
|
60
76
|
export const supplierServices = pgTable("supplier_services", {
|
|
61
77
|
id: typeId("supplier_services"),
|
|
@@ -75,7 +91,7 @@ export const supplierServices = pgTable("supplier_services", {
|
|
|
75
91
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
76
92
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
77
93
|
}, (table) => [
|
|
78
|
-
index("
|
|
94
|
+
index("idx_supplier_services_supplier_created").on(table.supplierId, table.createdAt),
|
|
79
95
|
index("idx_supplier_services_type").on(table.serviceType),
|
|
80
96
|
index("idx_supplier_services_facility").on(table.facilityId),
|
|
81
97
|
]);
|
|
@@ -99,7 +115,7 @@ export const supplierRates = pgTable("supplier_rates", {
|
|
|
99
115
|
// Timestamps
|
|
100
116
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
101
117
|
}, (table) => [
|
|
102
|
-
index("
|
|
118
|
+
index("idx_supplier_rates_service_created").on(table.serviceId, table.createdAt),
|
|
103
119
|
index("idx_supplier_rates_validity").on(table.validFrom, table.validTo),
|
|
104
120
|
]);
|
|
105
121
|
// ---------- supplier_notes ----------
|
|
@@ -111,7 +127,7 @@ export const supplierNotes = pgTable("supplier_notes", {
|
|
|
111
127
|
authorId: text("author_id").notNull(),
|
|
112
128
|
content: text("content").notNull(),
|
|
113
129
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
114
|
-
}, (table) => [index("
|
|
130
|
+
}, (table) => [index("idx_supplier_notes_supplier_created").on(table.supplierId, table.createdAt)]);
|
|
115
131
|
// ---------- supplier_availability ----------
|
|
116
132
|
export const supplierAvailability = pgTable("supplier_availability", {
|
|
117
133
|
id: typeId("supplier_availability"),
|
|
@@ -123,7 +139,7 @@ export const supplierAvailability = pgTable("supplier_availability", {
|
|
|
123
139
|
notes: text("notes"),
|
|
124
140
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
125
141
|
}, (table) => [
|
|
126
|
-
index("
|
|
142
|
+
index("idx_supplier_availability_supplier_date").on(table.supplierId, table.date),
|
|
127
143
|
index("idx_supplier_availability_date").on(table.date),
|
|
128
144
|
]);
|
|
129
145
|
// ---------- supplier_contracts ----------
|
|
@@ -141,7 +157,7 @@ export const supplierContracts = pgTable("supplier_contracts", {
|
|
|
141
157
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
142
158
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
143
159
|
}, (table) => [
|
|
144
|
-
index("
|
|
160
|
+
index("idx_supplier_contracts_supplier_created").on(table.supplierId, table.createdAt),
|
|
145
161
|
index("idx_supplier_contracts_status").on(table.status),
|
|
146
162
|
]);
|
|
147
163
|
// ---------- relations ----------
|
|
@@ -150,11 +166,21 @@ export const suppliersRelations = relations(suppliers, ({ one, many }) => ({
|
|
|
150
166
|
fields: [suppliers.primaryFacilityId],
|
|
151
167
|
references: [facilities.id],
|
|
152
168
|
}),
|
|
169
|
+
directoryProjection: one(supplierDirectoryProjections, {
|
|
170
|
+
fields: [suppliers.id],
|
|
171
|
+
references: [supplierDirectoryProjections.supplierId],
|
|
172
|
+
}),
|
|
153
173
|
services: many(supplierServices),
|
|
154
174
|
notes: many(supplierNotes),
|
|
155
175
|
availability: many(supplierAvailability),
|
|
156
176
|
contracts: many(supplierContracts),
|
|
157
177
|
}));
|
|
178
|
+
export const supplierDirectoryProjectionsRelations = relations(supplierDirectoryProjections, ({ one }) => ({
|
|
179
|
+
supplier: one(suppliers, {
|
|
180
|
+
fields: [supplierDirectoryProjections.supplierId],
|
|
181
|
+
references: [suppliers.id],
|
|
182
|
+
}),
|
|
183
|
+
}));
|
|
158
184
|
export const supplierServicesRelations = relations(supplierServices, ({ one, many }) => ({
|
|
159
185
|
supplier: one(suppliers, { fields: [supplierServices.supplierId], references: [suppliers.id] }),
|
|
160
186
|
facility: one(facilities, {
|
|
@@ -1 +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;
|
|
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,yB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AE,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM;;UAO5E"}
|
package/dist/service-identity.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { identityService } from "@voyantjs/identity/service";
|
|
2
|
-
import { ensureSupplierExists, supplierEntityType } from "./service-shared.js";
|
|
2
|
+
import { ensureSupplierExists, rebuildSupplierDirectoryProjection, supplierEntityType, } from "./service-shared.js";
|
|
3
3
|
export function listContactPoints(db, supplierId) {
|
|
4
4
|
return identityService.listContactPointsForEntity(db, supplierEntityType, supplierId);
|
|
5
5
|
}
|
|
@@ -11,34 +11,60 @@ export async function createNamedContact(db, supplierId, data) {
|
|
|
11
11
|
if (!supplier) {
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
const row = await identityService.createNamedContact(db, {
|
|
15
15
|
...data,
|
|
16
16
|
entityType: supplierEntityType,
|
|
17
17
|
entityId: supplierId,
|
|
18
18
|
});
|
|
19
|
+
if (row) {
|
|
20
|
+
await rebuildSupplierDirectoryProjection(db, supplierId);
|
|
21
|
+
}
|
|
22
|
+
return row;
|
|
19
23
|
}
|
|
20
|
-
export function updateNamedContact(db, contactId, data) {
|
|
21
|
-
|
|
24
|
+
export async function updateNamedContact(db, contactId, data) {
|
|
25
|
+
const row = await identityService.updateNamedContact(db, contactId, data);
|
|
26
|
+
if (row?.entityType === supplierEntityType) {
|
|
27
|
+
await rebuildSupplierDirectoryProjection(db, row.entityId);
|
|
28
|
+
}
|
|
29
|
+
return row;
|
|
22
30
|
}
|
|
23
|
-
export function deleteNamedContact(db, contactId) {
|
|
24
|
-
|
|
31
|
+
export async function deleteNamedContact(db, contactId) {
|
|
32
|
+
const existing = await identityService.getNamedContactById(db, contactId);
|
|
33
|
+
const row = await identityService.deleteNamedContact(db, contactId);
|
|
34
|
+
if (row && existing?.entityType === supplierEntityType) {
|
|
35
|
+
await rebuildSupplierDirectoryProjection(db, existing.entityId);
|
|
36
|
+
}
|
|
37
|
+
return row;
|
|
25
38
|
}
|
|
26
39
|
export async function createContactPoint(db, supplierId, data) {
|
|
27
40
|
const supplier = await ensureSupplierExists(db, supplierId);
|
|
28
41
|
if (!supplier) {
|
|
29
42
|
return null;
|
|
30
43
|
}
|
|
31
|
-
|
|
44
|
+
const row = await identityService.createContactPoint(db, {
|
|
32
45
|
...data,
|
|
33
46
|
entityType: supplierEntityType,
|
|
34
47
|
entityId: supplierId,
|
|
35
48
|
});
|
|
49
|
+
if (row) {
|
|
50
|
+
await rebuildSupplierDirectoryProjection(db, supplierId);
|
|
51
|
+
}
|
|
52
|
+
return row;
|
|
36
53
|
}
|
|
37
|
-
export function updateContactPoint(db, contactPointId, data) {
|
|
38
|
-
|
|
54
|
+
export async function updateContactPoint(db, contactPointId, data) {
|
|
55
|
+
const row = await identityService.updateContactPoint(db, contactPointId, data);
|
|
56
|
+
if (row?.entityType === supplierEntityType) {
|
|
57
|
+
await rebuildSupplierDirectoryProjection(db, row.entityId);
|
|
58
|
+
}
|
|
59
|
+
return row;
|
|
39
60
|
}
|
|
40
|
-
export function deleteContactPoint(db, contactPointId) {
|
|
41
|
-
|
|
61
|
+
export async function deleteContactPoint(db, contactPointId) {
|
|
62
|
+
const existing = await identityService.getContactPointById(db, contactPointId);
|
|
63
|
+
const row = await identityService.deleteContactPoint(db, contactPointId);
|
|
64
|
+
if (row && existing?.entityType === supplierEntityType) {
|
|
65
|
+
await rebuildSupplierDirectoryProjection(db, existing.entityId);
|
|
66
|
+
}
|
|
67
|
+
return row;
|
|
42
68
|
}
|
|
43
69
|
export function listAddresses(db, supplierId) {
|
|
44
70
|
return identityService.listAddressesForEntity(db, supplierEntityType, supplierId);
|
|
@@ -48,15 +74,28 @@ export async function createAddress(db, supplierId, data) {
|
|
|
48
74
|
if (!supplier) {
|
|
49
75
|
return null;
|
|
50
76
|
}
|
|
51
|
-
|
|
77
|
+
const row = await identityService.createAddress(db, {
|
|
52
78
|
...data,
|
|
53
79
|
entityType: supplierEntityType,
|
|
54
80
|
entityId: supplierId,
|
|
55
81
|
});
|
|
82
|
+
if (row) {
|
|
83
|
+
await rebuildSupplierDirectoryProjection(db, supplierId);
|
|
84
|
+
}
|
|
85
|
+
return row;
|
|
56
86
|
}
|
|
57
|
-
export function updateAddress(db, addressId, data) {
|
|
58
|
-
|
|
87
|
+
export async function updateAddress(db, addressId, data) {
|
|
88
|
+
const row = await identityService.updateAddress(db, addressId, data);
|
|
89
|
+
if (row?.entityType === supplierEntityType) {
|
|
90
|
+
await rebuildSupplierDirectoryProjection(db, row.entityId);
|
|
91
|
+
}
|
|
92
|
+
return row;
|
|
59
93
|
}
|
|
60
|
-
export function deleteAddress(db, addressId) {
|
|
61
|
-
|
|
94
|
+
export async function deleteAddress(db, addressId) {
|
|
95
|
+
const existing = await identityService.getAddressById(db, addressId);
|
|
96
|
+
const row = await identityService.deleteAddress(db, addressId);
|
|
97
|
+
if (row && existing?.entityType === supplierEntityType) {
|
|
98
|
+
await rebuildSupplierDirectoryProjection(db, existing.entityId);
|
|
99
|
+
}
|
|
100
|
+
return row;
|
|
62
101
|
}
|
package/dist/service-shared.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ export type HydratedSupplier = Supplier & SupplierHydratedFields;
|
|
|
33
33
|
export declare function ensureSupplierExists(db: PostgresJsDatabase, supplierId: string): Promise<{
|
|
34
34
|
id: string;
|
|
35
35
|
} | null>;
|
|
36
|
+
export declare function rebuildSupplierDirectoryProjection(db: PostgresJsDatabase, supplierId: string): Promise<void>;
|
|
37
|
+
export declare function rebuildSupplierDirectoryProjections(db: PostgresJsDatabase, supplierIds: string[]): Promise<void>;
|
|
36
38
|
export declare function syncSupplierIdentity(db: PostgresJsDatabase, supplierId: string, data: SupplierIdentityInput): Promise<void>;
|
|
37
39
|
export declare function hydrateSuppliers<T extends {
|
|
38
40
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-shared.d.ts","sourceRoot":"","sources":["../src/service-shared.ts"],"names":[],"mappings":"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5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B,EACD,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAc/E"}
|
package/dist/service-shared.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { identityAddresses, identityContactPoints, identityNamedContacts, } from "@voyantjs/identity/schema";
|
|
2
2
|
import { identityService } from "@voyantjs/identity/service";
|
|
3
3
|
import { and, eq, inArray } from "drizzle-orm";
|
|
4
|
-
import { suppliers } from "./schema.js";
|
|
4
|
+
import { supplierDirectoryProjections, suppliers } from "./schema.js";
|
|
5
5
|
export const supplierEntityType = "supplier";
|
|
6
6
|
export const supplierBaseIdentitySource = "suppliers.base";
|
|
7
7
|
export const supplierPrimaryNamedContactSource = "suppliers.primary_contact";
|
|
@@ -40,6 +40,144 @@ export async function ensureSupplierExists(db, supplierId) {
|
|
|
40
40
|
.limit(1);
|
|
41
41
|
return supplier ?? null;
|
|
42
42
|
}
|
|
43
|
+
function emptySupplierHydratedFields() {
|
|
44
|
+
return {
|
|
45
|
+
email: null,
|
|
46
|
+
phone: null,
|
|
47
|
+
website: null,
|
|
48
|
+
address: null,
|
|
49
|
+
city: null,
|
|
50
|
+
country: null,
|
|
51
|
+
contactName: null,
|
|
52
|
+
contactEmail: null,
|
|
53
|
+
contactPhone: null,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async function buildSupplierDirectoryProjectionRows(db, supplierIds) {
|
|
57
|
+
if (supplierIds.length === 0) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
const ids = [...new Set(supplierIds)];
|
|
61
|
+
const [contactPoints, addresses, namedContacts] = await Promise.all([
|
|
62
|
+
db
|
|
63
|
+
.select()
|
|
64
|
+
.from(identityContactPoints)
|
|
65
|
+
.where(and(eq(identityContactPoints.entityType, supplierEntityType), inArray(identityContactPoints.entityId, ids))),
|
|
66
|
+
db
|
|
67
|
+
.select()
|
|
68
|
+
.from(identityAddresses)
|
|
69
|
+
.where(and(eq(identityAddresses.entityType, supplierEntityType), inArray(identityAddresses.entityId, ids))),
|
|
70
|
+
db
|
|
71
|
+
.select()
|
|
72
|
+
.from(identityNamedContacts)
|
|
73
|
+
.where(and(eq(identityNamedContacts.entityType, supplierEntityType), inArray(identityNamedContacts.entityId, ids))),
|
|
74
|
+
]);
|
|
75
|
+
const contactPointMap = new Map();
|
|
76
|
+
const addressMap = new Map();
|
|
77
|
+
const namedContactMap = new Map();
|
|
78
|
+
for (const point of contactPoints) {
|
|
79
|
+
const bucket = contactPointMap.get(point.entityId) ?? [];
|
|
80
|
+
bucket.push(point);
|
|
81
|
+
contactPointMap.set(point.entityId, bucket);
|
|
82
|
+
}
|
|
83
|
+
for (const address of addresses) {
|
|
84
|
+
const bucket = addressMap.get(address.entityId) ?? [];
|
|
85
|
+
bucket.push(address);
|
|
86
|
+
addressMap.set(address.entityId, bucket);
|
|
87
|
+
}
|
|
88
|
+
for (const contact of namedContacts) {
|
|
89
|
+
const bucket = namedContactMap.get(contact.entityId) ?? [];
|
|
90
|
+
bucket.push(contact);
|
|
91
|
+
namedContactMap.set(contact.entityId, bucket);
|
|
92
|
+
}
|
|
93
|
+
return ids.map((supplierId) => {
|
|
94
|
+
const entityContactPoints = contactPointMap.get(supplierId) ?? [];
|
|
95
|
+
const entityAddresses = addressMap.get(supplierId) ?? [];
|
|
96
|
+
const entityNamedContacts = namedContactMap.get(supplierId) ?? [];
|
|
97
|
+
const pickContactValue = (kind) => entityContactPoints.find((point) => point.kind === kind && point.isPrimary)?.value ??
|
|
98
|
+
entityContactPoints.find((point) => point.kind === kind)?.value ??
|
|
99
|
+
null;
|
|
100
|
+
const primaryAddress = entityAddresses.find((address) => address.isPrimary) ?? entityAddresses[0] ?? null;
|
|
101
|
+
const primaryContact = entityNamedContacts.find((contact) => contact.isPrimary) ?? entityNamedContacts[0] ?? null;
|
|
102
|
+
return {
|
|
103
|
+
supplierId,
|
|
104
|
+
email: pickContactValue("email"),
|
|
105
|
+
phone: pickContactValue("phone"),
|
|
106
|
+
website: pickContactValue("website"),
|
|
107
|
+
address: primaryAddress ? formatAddress(primaryAddress) : null,
|
|
108
|
+
city: primaryAddress?.city ?? null,
|
|
109
|
+
country: primaryAddress?.country ?? null,
|
|
110
|
+
contactName: primaryContact?.name ?? null,
|
|
111
|
+
contactEmail: primaryContact?.email ?? null,
|
|
112
|
+
contactPhone: primaryContact?.phone ?? null,
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
export async function rebuildSupplierDirectoryProjection(db, supplierId) {
|
|
117
|
+
return rebuildSupplierDirectoryProjections(db, [supplierId]);
|
|
118
|
+
}
|
|
119
|
+
export async function rebuildSupplierDirectoryProjections(db, supplierIds) {
|
|
120
|
+
const ids = [...new Set(supplierIds)];
|
|
121
|
+
if (ids.length === 0) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const rows = await buildSupplierDirectoryProjectionRows(db, ids);
|
|
125
|
+
await db
|
|
126
|
+
.delete(supplierDirectoryProjections)
|
|
127
|
+
.where(inArray(supplierDirectoryProjections.supplierId, ids));
|
|
128
|
+
await db.insert(supplierDirectoryProjections).values(rows);
|
|
129
|
+
}
|
|
130
|
+
async function ensureSupplierDirectoryProjectionMap(db, supplierIds) {
|
|
131
|
+
const ids = [...new Set(supplierIds)];
|
|
132
|
+
if (ids.length === 0) {
|
|
133
|
+
return new Map();
|
|
134
|
+
}
|
|
135
|
+
const existing = await db
|
|
136
|
+
.select()
|
|
137
|
+
.from(supplierDirectoryProjections)
|
|
138
|
+
.where(inArray(supplierDirectoryProjections.supplierId, ids));
|
|
139
|
+
const map = new Map();
|
|
140
|
+
for (const projection of existing) {
|
|
141
|
+
map.set(projection.supplierId, {
|
|
142
|
+
email: projection.email,
|
|
143
|
+
phone: projection.phone,
|
|
144
|
+
website: projection.website,
|
|
145
|
+
address: projection.address,
|
|
146
|
+
city: projection.city,
|
|
147
|
+
country: projection.country,
|
|
148
|
+
contactName: projection.contactName,
|
|
149
|
+
contactEmail: projection.contactEmail,
|
|
150
|
+
contactPhone: projection.contactPhone,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const missingIds = ids.filter((id) => !map.has(id));
|
|
154
|
+
if (missingIds.length > 0) {
|
|
155
|
+
await rebuildSupplierDirectoryProjections(db, missingIds);
|
|
156
|
+
const rebuilt = await db
|
|
157
|
+
.select()
|
|
158
|
+
.from(supplierDirectoryProjections)
|
|
159
|
+
.where(inArray(supplierDirectoryProjections.supplierId, missingIds));
|
|
160
|
+
for (const projection of rebuilt) {
|
|
161
|
+
map.set(projection.supplierId, {
|
|
162
|
+
email: projection.email,
|
|
163
|
+
phone: projection.phone,
|
|
164
|
+
website: projection.website,
|
|
165
|
+
address: projection.address,
|
|
166
|
+
city: projection.city,
|
|
167
|
+
country: projection.country,
|
|
168
|
+
contactName: projection.contactName,
|
|
169
|
+
contactEmail: projection.contactEmail,
|
|
170
|
+
contactPhone: projection.contactPhone,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
for (const id of ids) {
|
|
175
|
+
if (!map.has(id)) {
|
|
176
|
+
map.set(id, emptySupplierHydratedFields());
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return map;
|
|
180
|
+
}
|
|
43
181
|
export async function syncSupplierIdentity(db, supplierId, data) {
|
|
44
182
|
const existingContactPoints = await identityService.listContactPointsForEntity(db, supplierEntityType, supplierId);
|
|
45
183
|
const existingAddresses = await identityService.listAddressesForEntity(db, supplierEntityType, supplierId);
|
|
@@ -118,6 +256,7 @@ export async function syncSupplierIdentity(db, supplierId, data) {
|
|
|
118
256
|
if (managedPrimaryContact) {
|
|
119
257
|
await identityService.deleteNamedContact(db, managedPrimaryContact.id);
|
|
120
258
|
}
|
|
259
|
+
await rebuildSupplierDirectoryProjection(db, supplierId);
|
|
121
260
|
return;
|
|
122
261
|
}
|
|
123
262
|
const namedContactPayload = {
|
|
@@ -138,75 +277,18 @@ export async function syncSupplierIdentity(db, supplierId, data) {
|
|
|
138
277
|
else {
|
|
139
278
|
await identityService.createNamedContact(db, namedContactPayload);
|
|
140
279
|
}
|
|
280
|
+
await rebuildSupplierDirectoryProjection(db, supplierId);
|
|
141
281
|
}
|
|
142
282
|
export async function hydrateSuppliers(db, rows) {
|
|
143
283
|
if (rows.length === 0) {
|
|
144
|
-
return rows.map((row) => ({
|
|
145
|
-
...row,
|
|
146
|
-
email: null,
|
|
147
|
-
phone: null,
|
|
148
|
-
website: null,
|
|
149
|
-
address: null,
|
|
150
|
-
city: null,
|
|
151
|
-
country: null,
|
|
152
|
-
contactName: null,
|
|
153
|
-
contactEmail: null,
|
|
154
|
-
contactPhone: null,
|
|
155
|
-
}));
|
|
284
|
+
return rows.map((row) => ({ ...row, ...emptySupplierHydratedFields() }));
|
|
156
285
|
}
|
|
157
286
|
const ids = rows.map((row) => row.id);
|
|
158
|
-
const
|
|
159
|
-
db
|
|
160
|
-
.select()
|
|
161
|
-
.from(identityContactPoints)
|
|
162
|
-
.where(and(eq(identityContactPoints.entityType, supplierEntityType), inArray(identityContactPoints.entityId, ids))),
|
|
163
|
-
db
|
|
164
|
-
.select()
|
|
165
|
-
.from(identityAddresses)
|
|
166
|
-
.where(and(eq(identityAddresses.entityType, supplierEntityType), inArray(identityAddresses.entityId, ids))),
|
|
167
|
-
db
|
|
168
|
-
.select()
|
|
169
|
-
.from(identityNamedContacts)
|
|
170
|
-
.where(and(eq(identityNamedContacts.entityType, supplierEntityType), inArray(identityNamedContacts.entityId, ids))),
|
|
171
|
-
]);
|
|
172
|
-
const contactPointMap = new Map();
|
|
173
|
-
const addressMap = new Map();
|
|
174
|
-
const namedContactMap = new Map();
|
|
175
|
-
for (const point of contactPoints) {
|
|
176
|
-
const bucket = contactPointMap.get(point.entityId) ?? [];
|
|
177
|
-
bucket.push(point);
|
|
178
|
-
contactPointMap.set(point.entityId, bucket);
|
|
179
|
-
}
|
|
180
|
-
for (const address of addresses) {
|
|
181
|
-
const bucket = addressMap.get(address.entityId) ?? [];
|
|
182
|
-
bucket.push(address);
|
|
183
|
-
addressMap.set(address.entityId, bucket);
|
|
184
|
-
}
|
|
185
|
-
for (const contact of namedContacts) {
|
|
186
|
-
const bucket = namedContactMap.get(contact.entityId) ?? [];
|
|
187
|
-
bucket.push(contact);
|
|
188
|
-
namedContactMap.set(contact.entityId, bucket);
|
|
189
|
-
}
|
|
287
|
+
const projectionMap = await ensureSupplierDirectoryProjectionMap(db, ids);
|
|
190
288
|
return rows.map((row) => {
|
|
191
|
-
const entityContactPoints = contactPointMap.get(row.id) ?? [];
|
|
192
|
-
const entityAddresses = addressMap.get(row.id) ?? [];
|
|
193
|
-
const entityNamedContacts = namedContactMap.get(row.id) ?? [];
|
|
194
|
-
const pickContactValue = (kind) => entityContactPoints.find((point) => point.kind === kind && point.isPrimary)?.value ??
|
|
195
|
-
entityContactPoints.find((point) => point.kind === kind)?.value ??
|
|
196
|
-
null;
|
|
197
|
-
const primaryAddress = entityAddresses.find((address) => address.isPrimary) ?? entityAddresses[0] ?? null;
|
|
198
|
-
const primaryContact = entityNamedContacts.find((contact) => contact.isPrimary) ?? entityNamedContacts[0] ?? null;
|
|
199
289
|
return {
|
|
200
290
|
...row,
|
|
201
|
-
|
|
202
|
-
phone: pickContactValue("phone"),
|
|
203
|
-
website: pickContactValue("website"),
|
|
204
|
-
address: primaryAddress ? formatAddress(primaryAddress) : null,
|
|
205
|
-
city: primaryAddress?.city ?? null,
|
|
206
|
-
country: primaryAddress?.country ?? null,
|
|
207
|
-
contactName: primaryContact?.name ?? null,
|
|
208
|
-
contactEmail: primaryContact?.email ?? null,
|
|
209
|
-
contactPhone: primaryContact?.phone ?? null,
|
|
291
|
+
...(projectionMap.get(row.id) ?? emptySupplierHydratedFields()),
|
|
210
292
|
};
|
|
211
293
|
});
|
|
212
294
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyantjs/suppliers",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"license": "FSL-1.1-Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"drizzle-orm": "^0.45.2",
|
|
26
26
|
"hono": "^4.12.10",
|
|
27
27
|
"zod": "^4.3.6",
|
|
28
|
-
"@voyantjs/core": "0.6.
|
|
29
|
-
"@voyantjs/db": "0.6.
|
|
30
|
-
"@voyantjs/facilities": "0.6.
|
|
31
|
-
"@voyantjs/hono": "0.6.
|
|
32
|
-
"@voyantjs/identity": "0.6.
|
|
28
|
+
"@voyantjs/core": "0.6.5",
|
|
29
|
+
"@voyantjs/db": "0.6.5",
|
|
30
|
+
"@voyantjs/facilities": "0.6.5",
|
|
31
|
+
"@voyantjs/hono": "0.6.5",
|
|
32
|
+
"@voyantjs/identity": "0.6.5"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"typescript": "^6.0.2",
|