@voyantjs/facilities 0.6.5 → 0.6.8
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 +251 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +49 -13
- package/dist/service-core.d.ts.map +1 -1
- package/dist/service-core.js +11 -14
- package/dist/service-identity.d.ts.map +1 -1
- package/dist/service-identity.js +20 -6
- package/dist/service-shared.d.ts +14 -11
- package/dist/service-shared.d.ts.map +1 -1
- package/dist/service-shared.js +56 -35
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { facilitiesService } from "./service.js";
|
|
|
4
4
|
export type { FacilitiesRoutes } from "./routes.js";
|
|
5
5
|
export declare const facilitiesModule: Module;
|
|
6
6
|
export declare const facilitiesHonoModule: HonoModule;
|
|
7
|
-
export type { Facility, FacilityContact, FacilityFeature, FacilityOperationSchedule, NewFacility, NewFacilityContact, NewFacilityFeature, NewFacilityOperationSchedule, NewProperty, NewPropertyGroup, NewPropertyGroupMember, Property, PropertyGroup, PropertyGroupMember, } from "./schema.js";
|
|
8
|
-
export { facilities, facilityFeatures, facilityOperationSchedules, properties, propertyGroupMembers, propertyGroups, } from "./schema.js";
|
|
7
|
+
export type { Facility, FacilityAddressProjection, FacilityContact, FacilityFeature, FacilityOperationSchedule, NewFacility, NewFacilityAddressProjection, NewFacilityContact, NewFacilityFeature, NewFacilityOperationSchedule, NewProperty, NewPropertyGroup, NewPropertyGroupMember, Property, PropertyGroup, PropertyGroupMember, } from "./schema.js";
|
|
8
|
+
export { facilities, facilityAddressProjections, facilityFeatures, facilityOperationSchedules, properties, propertyGroupMembers, propertyGroups, } from "./schema.js";
|
|
9
9
|
export { facilityContactListQuerySchema, facilityFeatureListQuerySchema, facilityListQuerySchema, facilityOperationScheduleListQuerySchema, insertFacilityContactSchema, insertFacilityFeatureSchema, insertFacilityOperationScheduleSchema, insertFacilitySchema, insertPropertyGroupMemberSchema, insertPropertyGroupSchema, insertPropertySchema, propertyGroupListQuerySchema, propertyGroupMemberListQuerySchema, propertyListQuerySchema, updateFacilityContactSchema, updateFacilityFeatureSchema, updateFacilityOperationScheduleSchema, updateFacilitySchema, updatePropertyGroupMemberSchema, updatePropertyGroupSchema, updatePropertySchema, } from "./validation.js";
|
|
10
10
|
export { facilitiesService };
|
|
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,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD,eAAO,MAAM,gBAAgB,EAAE,MAE9B,CAAA;AAED,eAAO,MAAM,oBAAoB,EAAE,UAGlC,CAAA;AAED,YAAY,EACV,QAAQ,EACR,eAAe,EACf,eAAe,EACf,yBAAyB,EACzB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,4BAA4B,EAC5B,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,QAAQ,EACR,aAAa,EACb,mBAAmB,GACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,0BAA0B,EAC1B,UAAU,EACV,oBAAoB,EACpB,cAAc,GACf,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC9B,uBAAuB,EACvB,wCAAwC,EACxC,2BAA2B,EAC3B,2BAA2B,EAC3B,qCAAqC,EACrC,oBAAoB,EACpB,+BAA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AA2B,EAC3B,2BAA2B,EAC3B,qCAAqC,EACrC,oBAAoB,EACpB,+BAA+B,EAC/B,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,6 @@ export const facilitiesHonoModule = {
|
|
|
7
7
|
module: facilitiesModule,
|
|
8
8
|
routes: facilitiesRoutes,
|
|
9
9
|
};
|
|
10
|
-
export { facilities, facilityFeatures, facilityOperationSchedules, properties, propertyGroupMembers, propertyGroups, } from "./schema.js";
|
|
10
|
+
export { facilities, facilityAddressProjections, facilityFeatures, facilityOperationSchedules, properties, propertyGroupMembers, propertyGroups, } from "./schema.js";
|
|
11
11
|
export { facilityContactListQuerySchema, facilityFeatureListQuerySchema, facilityListQuerySchema, facilityOperationScheduleListQuerySchema, insertFacilityContactSchema, insertFacilityFeatureSchema, insertFacilityOperationScheduleSchema, insertFacilitySchema, insertPropertyGroupMemberSchema, insertPropertyGroupSchema, insertPropertySchema, propertyGroupListQuerySchema, propertyGroupMemberListQuerySchema, propertyListQuerySchema, updateFacilityContactSchema, updateFacilityFeatureSchema, updateFacilityOperationScheduleSchema, updateFacilitySchema, updatePropertyGroupMemberSchema, updatePropertyGroupSchema, updatePropertySchema, } from "./validation.js";
|
|
12
12
|
export { facilitiesService };
|
package/dist/schema.d.ts
CHANGED
|
@@ -238,6 +238,251 @@ export declare const facilities: import("drizzle-orm/pg-core").PgTableWithColumn
|
|
|
238
238
|
};
|
|
239
239
|
dialect: "pg";
|
|
240
240
|
}>;
|
|
241
|
+
export declare const facilityAddressProjections: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
242
|
+
name: "facility_address_projections";
|
|
243
|
+
schema: undefined;
|
|
244
|
+
columns: {
|
|
245
|
+
facilityId: import("drizzle-orm/pg-core").PgColumn<{
|
|
246
|
+
name: string;
|
|
247
|
+
tableName: "facility_address_projections";
|
|
248
|
+
dataType: "string";
|
|
249
|
+
columnType: "PgText";
|
|
250
|
+
data: string;
|
|
251
|
+
driverParam: string;
|
|
252
|
+
notNull: true;
|
|
253
|
+
hasDefault: false;
|
|
254
|
+
isPrimaryKey: true;
|
|
255
|
+
isAutoincrement: false;
|
|
256
|
+
hasRuntimeDefault: false;
|
|
257
|
+
enumValues: [string, ...string[]];
|
|
258
|
+
baseColumn: never;
|
|
259
|
+
identity: undefined;
|
|
260
|
+
generated: undefined;
|
|
261
|
+
}, {}, {}>;
|
|
262
|
+
addressId: import("drizzle-orm/pg-core").PgColumn<{
|
|
263
|
+
name: "address_id";
|
|
264
|
+
tableName: "facility_address_projections";
|
|
265
|
+
dataType: "string";
|
|
266
|
+
columnType: "PgText";
|
|
267
|
+
data: string;
|
|
268
|
+
driverParam: string;
|
|
269
|
+
notNull: false;
|
|
270
|
+
hasDefault: false;
|
|
271
|
+
isPrimaryKey: false;
|
|
272
|
+
isAutoincrement: false;
|
|
273
|
+
hasRuntimeDefault: false;
|
|
274
|
+
enumValues: [string, ...string[]];
|
|
275
|
+
baseColumn: never;
|
|
276
|
+
identity: undefined;
|
|
277
|
+
generated: undefined;
|
|
278
|
+
}, {}, {}>;
|
|
279
|
+
fullText: import("drizzle-orm/pg-core").PgColumn<{
|
|
280
|
+
name: "full_text";
|
|
281
|
+
tableName: "facility_address_projections";
|
|
282
|
+
dataType: "string";
|
|
283
|
+
columnType: "PgText";
|
|
284
|
+
data: string;
|
|
285
|
+
driverParam: string;
|
|
286
|
+
notNull: false;
|
|
287
|
+
hasDefault: false;
|
|
288
|
+
isPrimaryKey: false;
|
|
289
|
+
isAutoincrement: false;
|
|
290
|
+
hasRuntimeDefault: false;
|
|
291
|
+
enumValues: [string, ...string[]];
|
|
292
|
+
baseColumn: never;
|
|
293
|
+
identity: undefined;
|
|
294
|
+
generated: undefined;
|
|
295
|
+
}, {}, {}>;
|
|
296
|
+
line1: import("drizzle-orm/pg-core").PgColumn<{
|
|
297
|
+
name: "line1";
|
|
298
|
+
tableName: "facility_address_projections";
|
|
299
|
+
dataType: "string";
|
|
300
|
+
columnType: "PgText";
|
|
301
|
+
data: string;
|
|
302
|
+
driverParam: string;
|
|
303
|
+
notNull: false;
|
|
304
|
+
hasDefault: false;
|
|
305
|
+
isPrimaryKey: false;
|
|
306
|
+
isAutoincrement: false;
|
|
307
|
+
hasRuntimeDefault: false;
|
|
308
|
+
enumValues: [string, ...string[]];
|
|
309
|
+
baseColumn: never;
|
|
310
|
+
identity: undefined;
|
|
311
|
+
generated: undefined;
|
|
312
|
+
}, {}, {}>;
|
|
313
|
+
line2: import("drizzle-orm/pg-core").PgColumn<{
|
|
314
|
+
name: "line2";
|
|
315
|
+
tableName: "facility_address_projections";
|
|
316
|
+
dataType: "string";
|
|
317
|
+
columnType: "PgText";
|
|
318
|
+
data: string;
|
|
319
|
+
driverParam: string;
|
|
320
|
+
notNull: false;
|
|
321
|
+
hasDefault: false;
|
|
322
|
+
isPrimaryKey: false;
|
|
323
|
+
isAutoincrement: false;
|
|
324
|
+
hasRuntimeDefault: false;
|
|
325
|
+
enumValues: [string, ...string[]];
|
|
326
|
+
baseColumn: never;
|
|
327
|
+
identity: undefined;
|
|
328
|
+
generated: undefined;
|
|
329
|
+
}, {}, {}>;
|
|
330
|
+
city: import("drizzle-orm/pg-core").PgColumn<{
|
|
331
|
+
name: "city";
|
|
332
|
+
tableName: "facility_address_projections";
|
|
333
|
+
dataType: "string";
|
|
334
|
+
columnType: "PgText";
|
|
335
|
+
data: string;
|
|
336
|
+
driverParam: string;
|
|
337
|
+
notNull: false;
|
|
338
|
+
hasDefault: false;
|
|
339
|
+
isPrimaryKey: false;
|
|
340
|
+
isAutoincrement: false;
|
|
341
|
+
hasRuntimeDefault: false;
|
|
342
|
+
enumValues: [string, ...string[]];
|
|
343
|
+
baseColumn: never;
|
|
344
|
+
identity: undefined;
|
|
345
|
+
generated: undefined;
|
|
346
|
+
}, {}, {}>;
|
|
347
|
+
region: import("drizzle-orm/pg-core").PgColumn<{
|
|
348
|
+
name: "region";
|
|
349
|
+
tableName: "facility_address_projections";
|
|
350
|
+
dataType: "string";
|
|
351
|
+
columnType: "PgText";
|
|
352
|
+
data: string;
|
|
353
|
+
driverParam: string;
|
|
354
|
+
notNull: false;
|
|
355
|
+
hasDefault: false;
|
|
356
|
+
isPrimaryKey: false;
|
|
357
|
+
isAutoincrement: false;
|
|
358
|
+
hasRuntimeDefault: false;
|
|
359
|
+
enumValues: [string, ...string[]];
|
|
360
|
+
baseColumn: never;
|
|
361
|
+
identity: undefined;
|
|
362
|
+
generated: undefined;
|
|
363
|
+
}, {}, {}>;
|
|
364
|
+
postalCode: import("drizzle-orm/pg-core").PgColumn<{
|
|
365
|
+
name: "postal_code";
|
|
366
|
+
tableName: "facility_address_projections";
|
|
367
|
+
dataType: "string";
|
|
368
|
+
columnType: "PgText";
|
|
369
|
+
data: string;
|
|
370
|
+
driverParam: string;
|
|
371
|
+
notNull: false;
|
|
372
|
+
hasDefault: false;
|
|
373
|
+
isPrimaryKey: false;
|
|
374
|
+
isAutoincrement: false;
|
|
375
|
+
hasRuntimeDefault: false;
|
|
376
|
+
enumValues: [string, ...string[]];
|
|
377
|
+
baseColumn: never;
|
|
378
|
+
identity: undefined;
|
|
379
|
+
generated: undefined;
|
|
380
|
+
}, {}, {}>;
|
|
381
|
+
country: import("drizzle-orm/pg-core").PgColumn<{
|
|
382
|
+
name: "country";
|
|
383
|
+
tableName: "facility_address_projections";
|
|
384
|
+
dataType: "string";
|
|
385
|
+
columnType: "PgText";
|
|
386
|
+
data: string;
|
|
387
|
+
driverParam: string;
|
|
388
|
+
notNull: false;
|
|
389
|
+
hasDefault: false;
|
|
390
|
+
isPrimaryKey: false;
|
|
391
|
+
isAutoincrement: false;
|
|
392
|
+
hasRuntimeDefault: false;
|
|
393
|
+
enumValues: [string, ...string[]];
|
|
394
|
+
baseColumn: never;
|
|
395
|
+
identity: undefined;
|
|
396
|
+
generated: undefined;
|
|
397
|
+
}, {}, {}>;
|
|
398
|
+
latitude: import("drizzle-orm/pg-core").PgColumn<{
|
|
399
|
+
name: "latitude";
|
|
400
|
+
tableName: "facility_address_projections";
|
|
401
|
+
dataType: "number";
|
|
402
|
+
columnType: "PgDoublePrecision";
|
|
403
|
+
data: number;
|
|
404
|
+
driverParam: string | number;
|
|
405
|
+
notNull: false;
|
|
406
|
+
hasDefault: false;
|
|
407
|
+
isPrimaryKey: false;
|
|
408
|
+
isAutoincrement: false;
|
|
409
|
+
hasRuntimeDefault: false;
|
|
410
|
+
enumValues: undefined;
|
|
411
|
+
baseColumn: never;
|
|
412
|
+
identity: undefined;
|
|
413
|
+
generated: undefined;
|
|
414
|
+
}, {}, {}>;
|
|
415
|
+
longitude: import("drizzle-orm/pg-core").PgColumn<{
|
|
416
|
+
name: "longitude";
|
|
417
|
+
tableName: "facility_address_projections";
|
|
418
|
+
dataType: "number";
|
|
419
|
+
columnType: "PgDoublePrecision";
|
|
420
|
+
data: number;
|
|
421
|
+
driverParam: string | number;
|
|
422
|
+
notNull: false;
|
|
423
|
+
hasDefault: false;
|
|
424
|
+
isPrimaryKey: false;
|
|
425
|
+
isAutoincrement: false;
|
|
426
|
+
hasRuntimeDefault: false;
|
|
427
|
+
enumValues: undefined;
|
|
428
|
+
baseColumn: never;
|
|
429
|
+
identity: undefined;
|
|
430
|
+
generated: undefined;
|
|
431
|
+
}, {}, {}>;
|
|
432
|
+
address: import("drizzle-orm/pg-core").PgColumn<{
|
|
433
|
+
name: "address";
|
|
434
|
+
tableName: "facility_address_projections";
|
|
435
|
+
dataType: "string";
|
|
436
|
+
columnType: "PgText";
|
|
437
|
+
data: string;
|
|
438
|
+
driverParam: string;
|
|
439
|
+
notNull: false;
|
|
440
|
+
hasDefault: false;
|
|
441
|
+
isPrimaryKey: false;
|
|
442
|
+
isAutoincrement: false;
|
|
443
|
+
hasRuntimeDefault: false;
|
|
444
|
+
enumValues: [string, ...string[]];
|
|
445
|
+
baseColumn: never;
|
|
446
|
+
identity: undefined;
|
|
447
|
+
generated: undefined;
|
|
448
|
+
}, {}, {}>;
|
|
449
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
450
|
+
name: "created_at";
|
|
451
|
+
tableName: "facility_address_projections";
|
|
452
|
+
dataType: "date";
|
|
453
|
+
columnType: "PgTimestamp";
|
|
454
|
+
data: Date;
|
|
455
|
+
driverParam: string;
|
|
456
|
+
notNull: true;
|
|
457
|
+
hasDefault: true;
|
|
458
|
+
isPrimaryKey: false;
|
|
459
|
+
isAutoincrement: false;
|
|
460
|
+
hasRuntimeDefault: false;
|
|
461
|
+
enumValues: undefined;
|
|
462
|
+
baseColumn: never;
|
|
463
|
+
identity: undefined;
|
|
464
|
+
generated: undefined;
|
|
465
|
+
}, {}, {}>;
|
|
466
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
467
|
+
name: "updated_at";
|
|
468
|
+
tableName: "facility_address_projections";
|
|
469
|
+
dataType: "date";
|
|
470
|
+
columnType: "PgTimestamp";
|
|
471
|
+
data: Date;
|
|
472
|
+
driverParam: string;
|
|
473
|
+
notNull: true;
|
|
474
|
+
hasDefault: true;
|
|
475
|
+
isPrimaryKey: false;
|
|
476
|
+
isAutoincrement: false;
|
|
477
|
+
hasRuntimeDefault: false;
|
|
478
|
+
enumValues: undefined;
|
|
479
|
+
baseColumn: never;
|
|
480
|
+
identity: undefined;
|
|
481
|
+
generated: undefined;
|
|
482
|
+
}, {}, {}>;
|
|
483
|
+
};
|
|
484
|
+
dialect: "pg";
|
|
485
|
+
}>;
|
|
241
486
|
export declare const facilityFeatures: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
242
487
|
name: "facility_features";
|
|
243
488
|
schema: undefined;
|
|
@@ -1263,6 +1508,8 @@ export declare const propertyGroupMembers: import("drizzle-orm/pg-core").PgTable
|
|
|
1263
1508
|
}>;
|
|
1264
1509
|
export type Facility = typeof facilities.$inferSelect;
|
|
1265
1510
|
export type NewFacility = typeof facilities.$inferInsert;
|
|
1511
|
+
export type FacilityAddressProjection = typeof facilityAddressProjections.$inferSelect;
|
|
1512
|
+
export type NewFacilityAddressProjection = typeof facilityAddressProjections.$inferInsert;
|
|
1266
1513
|
export type FacilityContact = IdentityNamedContact;
|
|
1267
1514
|
export type NewFacilityContact = NewIdentityNamedContact;
|
|
1268
1515
|
export type FacilityFeature = typeof facilityFeatures.$inferSelect;
|
|
@@ -1280,8 +1527,12 @@ export declare const facilitiesRelations: import("drizzle-orm").Relations<"facil
|
|
|
1280
1527
|
childFacilities: import("drizzle-orm").Many<"facilities">;
|
|
1281
1528
|
features: import("drizzle-orm").Many<"facility_features">;
|
|
1282
1529
|
operationSchedules: import("drizzle-orm").Many<"facility_operation_schedules">;
|
|
1530
|
+
addressProjection: import("drizzle-orm").One<"facility_address_projections", true>;
|
|
1283
1531
|
property: import("drizzle-orm").One<"properties", true>;
|
|
1284
1532
|
}>;
|
|
1533
|
+
export declare const facilityAddressProjectionsRelations: import("drizzle-orm").Relations<"facility_address_projections", {
|
|
1534
|
+
facility: import("drizzle-orm").One<"facilities", true>;
|
|
1535
|
+
}>;
|
|
1285
1536
|
export declare const facilityFeaturesRelations: import("drizzle-orm").Relations<"facility_features", {
|
|
1286
1537
|
facility: import("drizzle-orm").One<"facilities", true>;
|
|
1287
1538
|
}>;
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAiB9F,eAAO,MAAM,gBAAgB,iNAgB3B,CAAA;AAEF,eAAO,MAAM,kBAAkB,0EAAgE,CAAA;AA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yantjs/db/lib/typeid-column";
|
|
2
2
|
import { relations } from "drizzle-orm";
|
|
3
|
-
import { boolean, date, index, integer, jsonb, pgEnum, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
|
|
3
|
+
import { boolean, date, doublePrecision, index, integer, jsonb, pgEnum, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
|
|
4
4
|
export const facilityKindEnum = pgEnum("facility_kind", [
|
|
5
5
|
"property",
|
|
6
6
|
"hotel",
|
|
@@ -90,12 +90,34 @@ export const facilities = pgTable("facilities", {
|
|
|
90
90
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
91
91
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
92
92
|
}, (table) => [
|
|
93
|
-
index("
|
|
94
|
-
index("
|
|
95
|
-
index("
|
|
96
|
-
index("
|
|
93
|
+
index("idx_facilities_parent_updated").on(table.parentFacilityId, table.updatedAt),
|
|
94
|
+
index("idx_facilities_owner_updated").on(table.ownerType, table.ownerId, table.updatedAt),
|
|
95
|
+
index("idx_facilities_owner_id_updated").on(table.ownerId, table.updatedAt),
|
|
96
|
+
index("idx_facilities_kind_updated").on(table.kind, table.updatedAt),
|
|
97
|
+
index("idx_facilities_status_updated").on(table.status, table.updatedAt),
|
|
97
98
|
uniqueIndex("uidx_facilities_code").on(table.code),
|
|
98
99
|
]);
|
|
100
|
+
export const facilityAddressProjections = pgTable("facility_address_projections", {
|
|
101
|
+
facilityId: typeIdRef("facility_id")
|
|
102
|
+
.primaryKey()
|
|
103
|
+
.references(() => facilities.id, { onDelete: "cascade" }),
|
|
104
|
+
addressId: text("address_id"),
|
|
105
|
+
fullText: text("full_text"),
|
|
106
|
+
line1: text("line1"),
|
|
107
|
+
line2: text("line2"),
|
|
108
|
+
city: text("city"),
|
|
109
|
+
region: text("region"),
|
|
110
|
+
postalCode: text("postal_code"),
|
|
111
|
+
country: text("country"),
|
|
112
|
+
latitude: doublePrecision("latitude"),
|
|
113
|
+
longitude: doublePrecision("longitude"),
|
|
114
|
+
address: text("address"),
|
|
115
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
116
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
117
|
+
}, (table) => [
|
|
118
|
+
index("idx_facility_address_projections_country").on(table.country),
|
|
119
|
+
index("idx_facility_address_projections_city_country").on(table.city, table.country),
|
|
120
|
+
]);
|
|
99
121
|
export const facilityFeatures = pgTable("facility_features", {
|
|
100
122
|
id: typeId("facility_features"),
|
|
101
123
|
facilityId: typeIdRef("facility_id")
|
|
@@ -112,7 +134,8 @@ export const facilityFeatures = pgTable("facility_features", {
|
|
|
112
134
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
113
135
|
}, (table) => [
|
|
114
136
|
index("idx_facility_features_facility_sort_name").on(table.facilityId, table.sortOrder, table.name),
|
|
115
|
-
index("
|
|
137
|
+
index("idx_facility_features_category_sort_name").on(table.category, table.sortOrder, table.name),
|
|
138
|
+
index("idx_facility_features_facility_category_sort_name").on(table.facilityId, table.category, table.sortOrder, table.name),
|
|
116
139
|
]);
|
|
117
140
|
export const facilityOperationSchedules = pgTable("facility_operation_schedules", {
|
|
118
141
|
id: typeId("facility_operation_schedules"),
|
|
@@ -130,7 +153,7 @@ export const facilityOperationSchedules = pgTable("facility_operation_schedules"
|
|
|
130
153
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
131
154
|
}, (table) => [
|
|
132
155
|
index("idx_facility_operation_schedules_facility_day_valid").on(table.facilityId, table.dayOfWeek, table.validFrom),
|
|
133
|
-
index("
|
|
156
|
+
index("idx_facility_operation_schedules_day_valid").on(table.dayOfWeek, table.validFrom),
|
|
134
157
|
]);
|
|
135
158
|
export const properties = pgTable("properties", {
|
|
136
159
|
id: typeId("properties"),
|
|
@@ -150,8 +173,9 @@ export const properties = pgTable("properties", {
|
|
|
150
173
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
151
174
|
}, (table) => [
|
|
152
175
|
uniqueIndex("uidx_properties_facility").on(table.facilityId),
|
|
153
|
-
index("
|
|
154
|
-
index("
|
|
176
|
+
index("idx_properties_updated").on(table.updatedAt),
|
|
177
|
+
index("idx_properties_type_updated").on(table.propertyType, table.updatedAt),
|
|
178
|
+
index("idx_properties_group_updated").on(table.groupName, table.updatedAt),
|
|
155
179
|
]);
|
|
156
180
|
export const propertyGroups = pgTable("property_groups", {
|
|
157
181
|
id: typeId("property_groups"),
|
|
@@ -171,8 +195,9 @@ export const propertyGroups = pgTable("property_groups", {
|
|
|
171
195
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
172
196
|
}, (table) => [
|
|
173
197
|
index("idx_property_groups_parent_updated").on(table.parentGroupId, table.updatedAt),
|
|
174
|
-
index("
|
|
175
|
-
index("
|
|
198
|
+
index("idx_property_groups_updated").on(table.updatedAt),
|
|
199
|
+
index("idx_property_groups_type_updated").on(table.groupType, table.updatedAt),
|
|
200
|
+
index("idx_property_groups_status_updated").on(table.status, table.updatedAt),
|
|
176
201
|
uniqueIndex("uidx_property_groups_code").on(table.code),
|
|
177
202
|
]);
|
|
178
203
|
export const propertyGroupMembers = pgTable("property_group_members", {
|
|
@@ -192,8 +217,9 @@ export const propertyGroupMembers = pgTable("property_group_members", {
|
|
|
192
217
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
|
193
218
|
}, (table) => [
|
|
194
219
|
index("idx_property_group_members_group_updated").on(table.groupId, table.updatedAt),
|
|
195
|
-
index("
|
|
196
|
-
index("
|
|
220
|
+
index("idx_property_group_members_updated").on(table.updatedAt),
|
|
221
|
+
index("idx_property_group_members_property_updated").on(table.propertyId, table.updatedAt),
|
|
222
|
+
index("idx_property_group_members_role_updated").on(table.membershipRole, table.updatedAt),
|
|
197
223
|
uniqueIndex("uidx_property_group_members_pair").on(table.groupId, table.propertyId),
|
|
198
224
|
]);
|
|
199
225
|
export const facilitiesRelations = relations(facilities, ({ one, many }) => ({
|
|
@@ -205,11 +231,21 @@ export const facilitiesRelations = relations(facilities, ({ one, many }) => ({
|
|
|
205
231
|
childFacilities: many(facilities, { relationName: "facility_parent" }),
|
|
206
232
|
features: many(facilityFeatures),
|
|
207
233
|
operationSchedules: many(facilityOperationSchedules),
|
|
234
|
+
addressProjection: one(facilityAddressProjections, {
|
|
235
|
+
fields: [facilities.id],
|
|
236
|
+
references: [facilityAddressProjections.facilityId],
|
|
237
|
+
}),
|
|
208
238
|
property: one(properties, {
|
|
209
239
|
fields: [facilities.id],
|
|
210
240
|
references: [properties.facilityId],
|
|
211
241
|
}),
|
|
212
242
|
}));
|
|
243
|
+
export const facilityAddressProjectionsRelations = relations(facilityAddressProjections, ({ one }) => ({
|
|
244
|
+
facility: one(facilities, {
|
|
245
|
+
fields: [facilityAddressProjections.facilityId],
|
|
246
|
+
references: [facilities.id],
|
|
247
|
+
}),
|
|
248
|
+
}));
|
|
213
249
|
export const facilityFeaturesRelations = relations(facilityFeatures, ({ one }) => ({
|
|
214
250
|
facility: one(facilities, {
|
|
215
251
|
fields: [facilityFeatures.facilityId],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-core.d.ts","sourceRoot":"","sources":["../src/service-core.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service-core.d.ts","sourceRoot":"","sources":["../src/service-core.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,qBAAqB,CAAA;AAQ5B,wBAAsB,cAAc,CAAC,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DpF;AAED,wBAAsB,eAAe,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;WAMvE;AAED,wBAAsB,cAAc,CAAC,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;GAiDrF;AAED,wBAAsB,cAAc,CAClC,EAAE,EAAE,kBAAkB,EACtB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;UAuD1B;AAED,wBAAsB,cAAc,CAAC,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM;;UAMtE"}
|
package/dist/service-core.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { identityAddresses } from "@voyantjs/identity/schema";
|
|
2
1
|
import { and, desc, eq, sql } from "drizzle-orm";
|
|
3
|
-
import { facilities } from "./schema.js";
|
|
4
|
-
import {
|
|
2
|
+
import { facilities, facilityAddressProjections } from "./schema.js";
|
|
3
|
+
import { formatAddress, hydrateFacilities, paginate, syncFacilityAddress, } from "./service-shared.js";
|
|
5
4
|
export async function listFacilities(db, query) {
|
|
6
5
|
const conditions = [];
|
|
7
6
|
if (query.kind)
|
|
@@ -17,10 +16,9 @@ export async function listFacilities(db, query) {
|
|
|
17
16
|
if (query.country) {
|
|
18
17
|
conditions.push(sql `exists (
|
|
19
18
|
select 1
|
|
20
|
-
from ${
|
|
21
|
-
where ${
|
|
22
|
-
and ${
|
|
23
|
-
and ${identityAddresses.country} = ${query.country}
|
|
19
|
+
from ${facilityAddressProjections}
|
|
20
|
+
where ${facilityAddressProjections.facilityId} = ${facilities.id}
|
|
21
|
+
and ${facilityAddressProjections.country} = ${query.country}
|
|
24
22
|
)`);
|
|
25
23
|
}
|
|
26
24
|
if (query.search) {
|
|
@@ -31,14 +29,13 @@ export async function listFacilities(db, query) {
|
|
|
31
29
|
or ${facilities.description} ilike ${term}
|
|
32
30
|
or exists (
|
|
33
31
|
select 1
|
|
34
|
-
from ${
|
|
35
|
-
where ${
|
|
36
|
-
and ${identityAddresses.entityId} = ${facilities.id}
|
|
32
|
+
from ${facilityAddressProjections}
|
|
33
|
+
where ${facilityAddressProjections.facilityId} = ${facilities.id}
|
|
37
34
|
and (
|
|
38
|
-
${
|
|
39
|
-
or ${
|
|
40
|
-
or ${
|
|
41
|
-
or ${
|
|
35
|
+
${facilityAddressProjections.fullText} ilike ${term}
|
|
36
|
+
or ${facilityAddressProjections.line1} ilike ${term}
|
|
37
|
+
or ${facilityAddressProjections.city} ilike ${term}
|
|
38
|
+
or ${facilityAddressProjections.country} ilike ${term}
|
|
42
39
|
)
|
|
43
40
|
)
|
|
44
41
|
)`);
|
|
@@ -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,aAAa,IAAI,qBAAqB,EACtC,kBAAkB,IAAI,0BAA0B,EACjD,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,qBAAqB,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,aAAa,IAAI,qBAAqB,EACtC,kBAAkB,IAAI,0BAA0B,EACjD,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,KAAK,EACV,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,qBAAqB,CAAA;AAQ5B,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,kBAAkB,EAAE,UA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GED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { identityService } from "@voyantjs/identity/service";
|
|
2
|
-
import { ensureFacilityExists, facilityContactIdentitySource, facilityEntityType, } from "./service-shared.js";
|
|
2
|
+
import { ensureFacilityExists, facilityContactIdentitySource, facilityEntityType, rebuildFacilityAddressProjection, } from "./service-shared.js";
|
|
3
3
|
export function listContactPoints(db, facilityId) {
|
|
4
4
|
return identityService.listContactPointsForEntity(db, facilityEntityType, facilityId);
|
|
5
5
|
}
|
|
@@ -26,17 +26,31 @@ export async function createAddress(db, facilityId, data) {
|
|
|
26
26
|
const facility = await ensureFacilityExists(db, facilityId);
|
|
27
27
|
if (!facility)
|
|
28
28
|
return null;
|
|
29
|
-
|
|
29
|
+
const row = await identityService.createAddress(db, {
|
|
30
30
|
...data,
|
|
31
31
|
entityType: facilityEntityType,
|
|
32
32
|
entityId: facilityId,
|
|
33
33
|
});
|
|
34
|
+
await rebuildFacilityAddressProjection(db, facilityId);
|
|
35
|
+
return row;
|
|
34
36
|
}
|
|
35
|
-
export function updateAddress(db, id, data) {
|
|
36
|
-
|
|
37
|
+
export async function updateAddress(db, id, data) {
|
|
38
|
+
const existing = await identityService.getAddressById(db, id);
|
|
39
|
+
if (!existing)
|
|
40
|
+
return null;
|
|
41
|
+
const row = await identityService.updateAddress(db, id, data);
|
|
42
|
+
if (row) {
|
|
43
|
+
await rebuildFacilityAddressProjection(db, row.entityId);
|
|
44
|
+
}
|
|
45
|
+
return row;
|
|
37
46
|
}
|
|
38
|
-
export function deleteAddress(db, id) {
|
|
39
|
-
|
|
47
|
+
export async function deleteAddress(db, id) {
|
|
48
|
+
const existing = await identityService.getAddressById(db, id);
|
|
49
|
+
const row = await identityService.deleteAddress(db, id);
|
|
50
|
+
if (row && existing?.entityType === facilityEntityType) {
|
|
51
|
+
await rebuildFacilityAddressProjection(db, existing.entityId);
|
|
52
|
+
}
|
|
53
|
+
return row;
|
|
40
54
|
}
|
|
41
55
|
export async function listFacilityContacts(db, query) {
|
|
42
56
|
return identityService.listNamedContacts(db, {
|
package/dist/service-shared.d.ts
CHANGED
|
@@ -25,6 +25,17 @@ export type UpdatePropertyGroupMemberInput = z.infer<typeof updatePropertyGroupM
|
|
|
25
25
|
export declare const facilityEntityType = "facility";
|
|
26
26
|
export declare const facilityBaseIdentitySource = "facilities.base";
|
|
27
27
|
export declare const facilityContactIdentitySource = "facilities.contacts";
|
|
28
|
+
type FacilityAddressFields = {
|
|
29
|
+
addressLine1: string | null;
|
|
30
|
+
addressLine2: string | null;
|
|
31
|
+
city: string | null;
|
|
32
|
+
region: string | null;
|
|
33
|
+
country: string | null;
|
|
34
|
+
postalCode: string | null;
|
|
35
|
+
latitude: number | null;
|
|
36
|
+
longitude: number | null;
|
|
37
|
+
address: string | null;
|
|
38
|
+
};
|
|
28
39
|
export declare function paginate<T extends object>(rowsQuery: Promise<T[]>, countQuery: Promise<Array<{
|
|
29
40
|
count: number;
|
|
30
41
|
}>>, limit: number, offset: number): Promise<{
|
|
@@ -47,17 +58,9 @@ export declare function ensureFacilityExists(db: PostgresJsDatabase, facilityId:
|
|
|
47
58
|
id: string;
|
|
48
59
|
} | null>;
|
|
49
60
|
export declare function syncFacilityAddress(db: PostgresJsDatabase, facilityId: string, data: FacilityAddressInput): Promise<void>;
|
|
61
|
+
export declare function rebuildFacilityAddressProjection(db: PostgresJsDatabase, facilityId: string): Promise<void>;
|
|
50
62
|
export declare function hydrateFacilities<T extends {
|
|
51
63
|
id: string;
|
|
52
|
-
}>(db: PostgresJsDatabase, rows: T[]): Promise<(T &
|
|
53
|
-
|
|
54
|
-
addressLine2: string | null;
|
|
55
|
-
city: string | null;
|
|
56
|
-
region: string | null;
|
|
57
|
-
country: string | null;
|
|
58
|
-
postalCode: string | null;
|
|
59
|
-
latitude: number | null;
|
|
60
|
-
longitude: number | null;
|
|
61
|
-
address: string | null;
|
|
62
|
-
})[]>;
|
|
64
|
+
}>(db: PostgresJsDatabase, rows: T[]): Promise<(T & FacilityAddressFields)[]>;
|
|
65
|
+
export {};
|
|
63
66
|
//# sourceMappingURL=service-shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-shared.d.ts","sourceRoot":"","sources":["../src/service-shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service-shared.d.ts","sourceRoot":"","sources":["../src/service-shared.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAG5B,OAAO,KAAK,EACV,8BAA8B,EAC9B,8BAA8B,EAC9B,uBAAuB,EACvB,wCAAwC,EACxC,2BAA2B,EAC3B,2BAA2B,EAC3B,qCAAqC,EACrC,oBAAoB,EACpB,+BAA+B,EAC/B,yBAAyB,EACzB,oBAAoB,EACpB,4BAA4B,EAC5B,kCAAkC,EAClC,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,qCAAqC,EACrC,oBAAoB,EACpB,+BAA+B,EAC/B,yBAAyB,EACzB,oBAAoB,EACrB,MAAM,iBAAiB,CAAA;AAExB,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AACvE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACtE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACtE,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AACrF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AACpF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AACpF,MAAM,MA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AQ,GACR,YAAY,GACZ,SAAS,GACT,UAAU,GACV,WAAW,CACd,CAAA;AAED,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM;;UAOpF;AAED,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,kBAAkB,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,oBAAoB,iBAiE3B;AAED,wBAAsB,gCAAgC,CAAC,EAAE,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,iBA+BhG;AAED,wBAAsB,iBAAiB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAC9D,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,CAAC,EAAE,0CAgCV"}
|
package/dist/service-shared.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { identityAddresses } from "@voyantjs/identity/schema";
|
|
2
1
|
import { identityService } from "@voyantjs/identity/service";
|
|
3
|
-
import {
|
|
4
|
-
import { facilities } from "./schema.js";
|
|
2
|
+
import { eq, inArray } from "drizzle-orm";
|
|
3
|
+
import { facilities, facilityAddressProjections } from "./schema.js";
|
|
5
4
|
export const facilityEntityType = "facility";
|
|
6
5
|
export const facilityBaseIdentitySource = "facilities.base";
|
|
7
6
|
export const facilityContactIdentitySource = "facilities.contacts";
|
|
@@ -35,6 +34,19 @@ export function formatAddress(address) {
|
|
|
35
34
|
].filter(Boolean);
|
|
36
35
|
return parts.length > 0 ? parts.join(", ") : null;
|
|
37
36
|
}
|
|
37
|
+
function emptyFacilityAddressFields() {
|
|
38
|
+
return {
|
|
39
|
+
addressLine1: null,
|
|
40
|
+
addressLine2: null,
|
|
41
|
+
city: null,
|
|
42
|
+
region: null,
|
|
43
|
+
country: null,
|
|
44
|
+
postalCode: null,
|
|
45
|
+
latitude: null,
|
|
46
|
+
longitude: null,
|
|
47
|
+
address: null,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
38
50
|
export async function ensureFacilityExists(db, facilityId) {
|
|
39
51
|
const [facility] = await db
|
|
40
52
|
.select({ id: facilities.id })
|
|
@@ -64,6 +76,7 @@ export async function syncFacilityAddress(db, facilityId, data) {
|
|
|
64
76
|
if (managedAddress) {
|
|
65
77
|
await identityService.deleteAddress(db, managedAddress.id);
|
|
66
78
|
}
|
|
79
|
+
await rebuildFacilityAddressProjection(db, facilityId);
|
|
67
80
|
return;
|
|
68
81
|
}
|
|
69
82
|
const payload = {
|
|
@@ -90,47 +103,55 @@ export async function syncFacilityAddress(db, facilityId, data) {
|
|
|
90
103
|
else {
|
|
91
104
|
await identityService.createAddress(db, payload);
|
|
92
105
|
}
|
|
106
|
+
await rebuildFacilityAddressProjection(db, facilityId);
|
|
107
|
+
}
|
|
108
|
+
export async function rebuildFacilityAddressProjection(db, facilityId) {
|
|
109
|
+
const entityAddresses = await identityService.listAddressesForEntity(db, facilityEntityType, facilityId);
|
|
110
|
+
const primaryAddress = entityAddresses.find((address) => address.isPrimary) ?? entityAddresses[0] ?? null;
|
|
111
|
+
await db
|
|
112
|
+
.delete(facilityAddressProjections)
|
|
113
|
+
.where(eq(facilityAddressProjections.facilityId, facilityId));
|
|
114
|
+
if (!primaryAddress) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
await db.insert(facilityAddressProjections).values({
|
|
118
|
+
facilityId,
|
|
119
|
+
addressId: primaryAddress.id,
|
|
120
|
+
fullText: primaryAddress.fullText,
|
|
121
|
+
line1: primaryAddress.line1,
|
|
122
|
+
line2: primaryAddress.line2,
|
|
123
|
+
city: primaryAddress.city,
|
|
124
|
+
region: primaryAddress.region,
|
|
125
|
+
postalCode: primaryAddress.postalCode,
|
|
126
|
+
country: primaryAddress.country,
|
|
127
|
+
latitude: primaryAddress.latitude,
|
|
128
|
+
longitude: primaryAddress.longitude,
|
|
129
|
+
address: formatAddress(primaryAddress),
|
|
130
|
+
});
|
|
93
131
|
}
|
|
94
132
|
export async function hydrateFacilities(db, rows) {
|
|
95
133
|
if (rows.length === 0) {
|
|
96
|
-
return rows.map((row) => ({
|
|
97
|
-
...row,
|
|
98
|
-
addressLine1: null,
|
|
99
|
-
addressLine2: null,
|
|
100
|
-
city: null,
|
|
101
|
-
region: null,
|
|
102
|
-
country: null,
|
|
103
|
-
postalCode: null,
|
|
104
|
-
latitude: null,
|
|
105
|
-
longitude: null,
|
|
106
|
-
address: null,
|
|
107
|
-
}));
|
|
134
|
+
return rows.map((row) => ({ ...row, ...emptyFacilityAddressFields() }));
|
|
108
135
|
}
|
|
109
136
|
const ids = rows.map((row) => row.id);
|
|
110
|
-
const
|
|
137
|
+
const projections = await db
|
|
111
138
|
.select()
|
|
112
|
-
.from(
|
|
113
|
-
.where(
|
|
114
|
-
const
|
|
115
|
-
for (const address of addresses) {
|
|
116
|
-
const bucket = addressMap.get(address.entityId) ?? [];
|
|
117
|
-
bucket.push(address);
|
|
118
|
-
addressMap.set(address.entityId, bucket);
|
|
119
|
-
}
|
|
139
|
+
.from(facilityAddressProjections)
|
|
140
|
+
.where(inArray(facilityAddressProjections.facilityId, ids));
|
|
141
|
+
const projectionMap = new Map(projections.map((projection) => [projection.facilityId, projection]));
|
|
120
142
|
return rows.map((row) => {
|
|
121
|
-
const
|
|
122
|
-
const primaryAddress = entityAddresses.find((address) => address.isPrimary) ?? entityAddresses[0] ?? null;
|
|
143
|
+
const projection = projectionMap.get(row.id);
|
|
123
144
|
return {
|
|
124
145
|
...row,
|
|
125
|
-
addressLine1:
|
|
126
|
-
addressLine2:
|
|
127
|
-
city:
|
|
128
|
-
region:
|
|
129
|
-
country:
|
|
130
|
-
postalCode:
|
|
131
|
-
latitude:
|
|
132
|
-
longitude:
|
|
133
|
-
address:
|
|
146
|
+
addressLine1: projection?.line1 ?? null,
|
|
147
|
+
addressLine2: projection?.line2 ?? null,
|
|
148
|
+
city: projection?.city ?? null,
|
|
149
|
+
region: projection?.region ?? null,
|
|
150
|
+
country: projection?.country ?? null,
|
|
151
|
+
postalCode: projection?.postalCode ?? null,
|
|
152
|
+
latitude: projection?.latitude ?? null,
|
|
153
|
+
longitude: projection?.longitude ?? null,
|
|
154
|
+
address: projection?.address ?? null,
|
|
134
155
|
};
|
|
135
156
|
});
|
|
136
157
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyantjs/facilities",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"license": "FSL-1.1-Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -25,10 +25,10 @@
|
|
|
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/hono": "0.6.
|
|
31
|
-
"@voyantjs/identity": "0.6.
|
|
28
|
+
"@voyantjs/core": "0.6.8",
|
|
29
|
+
"@voyantjs/db": "0.6.8",
|
|
30
|
+
"@voyantjs/hono": "0.6.8",
|
|
31
|
+
"@voyantjs/identity": "0.6.8"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"typescript": "^6.0.2",
|