@7365admin1/core 3.122.6 → 3.124.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -10312,6 +10312,7 @@ var ConsoleAuditAction = /* @__PURE__ */ ((ConsoleAuditAction3) => {
10312
10312
  ConsoleAuditAction3["ROBOT_MAP_REMOVED"] = "robot.map-removed";
10313
10313
  ConsoleAuditAction3["ROBOT_LIFT_REQUESTED"] = "robot.lift-requested";
10314
10314
  ConsoleAuditAction3["ROBOT_LIFT_RELEASED"] = "robot.lift-released";
10315
+ ConsoleAuditAction3["INVENTORY_STORE_TYPE_REPAIRED"] = "inventory.store-type-repaired";
10315
10316
  return ConsoleAuditAction3;
10316
10317
  })(ConsoleAuditAction || {});
10317
10318
  var CLIENT_ACTIONS = [
@@ -10349,7 +10350,8 @@ var CONSOLE_AUDIT_LABELS = {
10349
10350
  ["robot.map-updated" /* ROBOT_MAP_UPDATED */]: "Building map edited",
10350
10351
  ["robot.map-removed" /* ROBOT_MAP_REMOVED */]: "Building map removed",
10351
10352
  ["robot.lift-requested" /* ROBOT_LIFT_REQUESTED */]: "Robot asked for a lift",
10352
- ["robot.lift-released" /* ROBOT_LIFT_RELEASED */]: "Robot lift request released"
10353
+ ["robot.lift-released" /* ROBOT_LIFT_RELEASED */]: "Robot lift request released",
10354
+ ["inventory.store-type-repaired" /* INVENTORY_STORE_TYPE_REPAIRED */]: "Inventory store type corrected"
10353
10355
  };
10354
10356
  var ConsoleAuditTarget = /* @__PURE__ */ ((ConsoleAuditTarget2) => {
10355
10357
  ConsoleAuditTarget2["ORGANIZATION"] = "organization";
@@ -10361,6 +10363,7 @@ var ConsoleAuditTarget = /* @__PURE__ */ ((ConsoleAuditTarget2) => {
10361
10363
  ConsoleAuditTarget2["SITE"] = "site";
10362
10364
  ConsoleAuditTarget2["ROBOT"] = "robot";
10363
10365
  ConsoleAuditTarget2["ROBOT_MAP"] = "robot-map";
10366
+ ConsoleAuditTarget2["INVENTORY_STORE"] = "inventory-store";
10364
10367
  return ConsoleAuditTarget2;
10365
10368
  })(ConsoleAuditTarget || {});
10366
10369
  var CAMERA_AUDIT_FIELDS = [
@@ -10408,6 +10411,7 @@ var ROBOT_MAP_AUDIT_FIELDS = [
10408
10411
  ];
10409
10412
  var ROBOT_LIFT_AUDIT_FIELDS = ["name", "liftName", "fromFloor", "toFloor"];
10410
10413
  var AUDIT_FIELDS = {
10414
+ ["inventory.store-type-repaired" /* INVENTORY_STORE_TYPE_REPAIRED */]: ["ownerType", "name"],
10411
10415
  ["robot.map-saved" /* ROBOT_MAP_SAVED */]: ROBOT_MAP_AUDIT_FIELDS,
10412
10416
  ["robot.map-updated" /* ROBOT_MAP_UPDATED */]: ROBOT_MAP_AUDIT_FIELDS,
10413
10417
  ["robot.map-removed" /* ROBOT_MAP_REMOVED */]: ROBOT_MAP_AUDIT_FIELDS,
@@ -89914,7 +89918,7 @@ function useNewDashboardRepo() {
89914
89918
  },
89915
89919
  activePatrolItems
89916
89920
  };
89917
- return data;
89921
+ return { ...data, ...await inventorySupplyTile(siteIdObj, "security_agency") };
89918
89922
  }
89919
89923
  async function getPropertyManagementDashboard(siteId, period = "today" /* TODAY */, type, facility) {
89920
89924
  const siteIdObj = toObjectId19(siteId);
@@ -90353,7 +90357,7 @@ function useNewDashboardRepo() {
90353
90357
  todayReminders,
90354
90358
  todayAttentions
90355
90359
  };
90356
- return data;
90360
+ return { ...data, ...await inventorySupplyTile(siteIdObj, "property_management_agency") };
90357
90361
  }
90358
90362
  function areaChecklistScheduleLookup(site, serviceType, createdAtRange) {
90359
90363
  return [
@@ -90378,24 +90382,38 @@ function useNewDashboardRepo() {
90378
90382
  { $unwind: { path: "$scheduleDoc", preserveNullAndEmptyArrays: false } }
90379
90383
  ];
90380
90384
  }
90385
+ async function inventoryLowStock(site, serviceType) {
90386
+ const natures = serviceType === "property_management_agency" ? ["property_management_agency", "real_estate_developer"] : [serviceType];
90387
+ const siteStores = await db2.collection("inventory.stores").find({ sites: site, status: "active" }, { projection: { _id: 1, org: 1 } }).toArray();
90388
+ if (!siteStores.length)
90389
+ return null;
90390
+ const ownOrgs = new Set(
90391
+ (await db2.collection("organizations").find(
90392
+ { _id: { $in: siteStores.map((store) => store.org) }, nature: { $in: natures } },
90393
+ { projection: { _id: 1 } }
90394
+ ).toArray()).map((org) => org._id.toString())
90395
+ );
90396
+ const stores = siteStores.filter((store) => ownOrgs.has(String(store.org)));
90397
+ if (!stores.length)
90398
+ return null;
90399
+ return db2.collection("inventory.items").aggregate([
90400
+ {
90401
+ $match: {
90402
+ store: { $in: stores.map((store) => store._id) },
90403
+ status: "active",
90404
+ reorderLevel: { $gt: 0 },
90405
+ $expr: { $lte: ["$onHand", "$reorderLevel"] }
90406
+ }
90407
+ },
90408
+ { $sort: { onHand: 1 } },
90409
+ { $limit: 5 },
90410
+ { $project: { _id: 1, name: 1, qty: "$onHand" } }
90411
+ ]).toArray();
90412
+ }
90381
90413
  async function lowStockItems(site, serviceType) {
90382
- const stores = await db2.collection("inventory.stores").find({ sites: site, status: "active" }, { projection: { _id: 1 } }).toArray();
90383
- if (stores.length) {
90384
- const items2 = await db2.collection("inventory.items").aggregate([
90385
- {
90386
- $match: {
90387
- store: { $in: stores.map((store) => store._id) },
90388
- status: "active",
90389
- reorderLevel: { $gt: 0 },
90390
- $expr: { $lte: ["$onHand", "$reorderLevel"] }
90391
- }
90392
- },
90393
- { $sort: { onHand: 1 } },
90394
- { $limit: 5 },
90395
- { $project: { _id: 1, name: 1, qty: "$onHand" } }
90396
- ]).toArray();
90397
- return { items: items2, basis: SUPPLY_BASIS_BELOW_ALERT_LEVEL };
90398
- }
90414
+ const inventory = await inventoryLowStock(site, serviceType);
90415
+ if (inventory)
90416
+ return { items: inventory, basis: SUPPLY_BASIS_BELOW_ALERT_LEVEL };
90399
90417
  const items = await supplyCollection.aggregate([
90400
90418
  { $match: { site, serviceType, status: "active" } },
90401
90419
  { $sort: { qty: 1 } },
@@ -90404,6 +90422,10 @@ function useNewDashboardRepo() {
90404
90422
  ]).toArray();
90405
90423
  return { items, basis: SUPPLY_BASIS_LOWEST_QUANTITY };
90406
90424
  }
90425
+ async function inventorySupplyTile(site, serviceType) {
90426
+ const items = await inventoryLowStock(site, serviceType);
90427
+ return items ? { supplyAlert: { items: items.map((item) => ({ name: item.name, qty: item.qty })), basis: SUPPLY_BASIS_BELOW_ALERT_LEVEL } } : {};
90428
+ }
90407
90429
  async function getServiceDashboard({
90408
90430
  site,
90409
90431
  serviceType,