@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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +100 -2
- package/dist/index.js +42 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/console-audit.test.mjs +8 -0
- package/test/e2e/dashboard-inventory-low-stock.e2e.test.mjs +40 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @iservice365/core
|
|
2
2
|
|
|
3
|
+
## 3.124.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 18bf151: Console audit: new action `inventory.store-type-repaired` (target `inventory-store`, keeps only `ownerType` and `name`) for the Super Admin inventory store-type repair in API-core.
|
|
8
|
+
|
|
9
|
+
## 3.123.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 028e4ad: Dashboard Low Stock: each app's tile now lists only its own kind of organisation's inventory store at the site (a cleaning company no longer sees the security company's store, and the other way round), and the Property Management and Security dashboards gain the Low Stock tile (`supplyAlert`, basis `below-alert-level`) wherever their store serves the site. Sites without such a store are unchanged.
|
|
14
|
+
|
|
3
15
|
## 3.122.6
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -806,7 +806,13 @@ declare enum ConsoleAuditAction {
|
|
|
806
806
|
ROBOT_MAP_UPDATED = "robot.map-updated",
|
|
807
807
|
ROBOT_MAP_REMOVED = "robot.map-removed",
|
|
808
808
|
ROBOT_LIFT_REQUESTED = "robot.lift-requested",
|
|
809
|
-
ROBOT_LIFT_RELEASED = "robot.lift-released"
|
|
809
|
+
ROBOT_LIFT_RELEASED = "robot.lift-released",
|
|
810
|
+
/**
|
|
811
|
+
* Seven365 staff correcting the kind of an inventory store (property store
|
|
812
|
+
* vs a service provider's own store) that was saved wrong. One row per store
|
|
813
|
+
* changed, recorded by API-core's inventory repair endpoint.
|
|
814
|
+
*/
|
|
815
|
+
INVENTORY_STORE_TYPE_REPAIRED = "inventory.store-type-repaired"
|
|
810
816
|
}
|
|
811
817
|
/**
|
|
812
818
|
* The three actions that live in `organization.controller.ts`.
|
|
@@ -830,7 +836,8 @@ declare enum ConsoleAuditTarget {
|
|
|
830
836
|
CAMERA = "camera",
|
|
831
837
|
SITE = "site",
|
|
832
838
|
ROBOT = "robot",
|
|
833
|
-
ROBOT_MAP = "robot-map"
|
|
839
|
+
ROBOT_MAP = "robot-map",
|
|
840
|
+
INVENTORY_STORE = "inventory-store"
|
|
834
841
|
}
|
|
835
842
|
/** A stored value is a primitive or it is not stored. */
|
|
836
843
|
declare const AUDIT_VALUE_MAX_LENGTH = 120;
|
|
@@ -15466,6 +15473,47 @@ declare function useNewDashboardRepo(): {
|
|
|
15466
15473
|
period?: Period | undefined;
|
|
15467
15474
|
type?: string | undefined;
|
|
15468
15475
|
}) => Promise<{
|
|
15476
|
+
supplyAlert: {
|
|
15477
|
+
items: {
|
|
15478
|
+
name: any;
|
|
15479
|
+
qty: any;
|
|
15480
|
+
}[];
|
|
15481
|
+
basis: "below-alert-level";
|
|
15482
|
+
};
|
|
15483
|
+
openWorkOrder: {
|
|
15484
|
+
count: any;
|
|
15485
|
+
inProgress: any;
|
|
15486
|
+
percentage: number | null;
|
|
15487
|
+
};
|
|
15488
|
+
openIncidents: {
|
|
15489
|
+
count: any;
|
|
15490
|
+
highSeverity: number | null;
|
|
15491
|
+
highSeverityUnavailableReason: string;
|
|
15492
|
+
percentage: number | null;
|
|
15493
|
+
};
|
|
15494
|
+
visitors: {
|
|
15495
|
+
count: any;
|
|
15496
|
+
currentlyOnSite: number;
|
|
15497
|
+
percentage: number | null;
|
|
15498
|
+
};
|
|
15499
|
+
patrolCompliance: {
|
|
15500
|
+
count: number | null;
|
|
15501
|
+
checkpointsDue: any;
|
|
15502
|
+
unavailableReason: string | null;
|
|
15503
|
+
missedCheckpoints: any;
|
|
15504
|
+
missed: any;
|
|
15505
|
+
percentage: number | null;
|
|
15506
|
+
};
|
|
15507
|
+
activePatrolItems: {
|
|
15508
|
+
id: string;
|
|
15509
|
+
title: any;
|
|
15510
|
+
subtitle: string;
|
|
15511
|
+
person: any;
|
|
15512
|
+
status: any;
|
|
15513
|
+
time: string;
|
|
15514
|
+
}[];
|
|
15515
|
+
} | {
|
|
15516
|
+
supplyAlert?: undefined;
|
|
15469
15517
|
openWorkOrder: {
|
|
15470
15518
|
count: any;
|
|
15471
15519
|
inProgress: any;
|
|
@@ -15500,6 +15548,56 @@ declare function useNewDashboardRepo(): {
|
|
|
15500
15548
|
}[];
|
|
15501
15549
|
}>;
|
|
15502
15550
|
getPropertyManagementDashboard: (siteId: string, period?: Period, type?: string, facility?: string) => Promise<{
|
|
15551
|
+
supplyAlert: {
|
|
15552
|
+
items: {
|
|
15553
|
+
name: any;
|
|
15554
|
+
qty: any;
|
|
15555
|
+
}[];
|
|
15556
|
+
basis: "below-alert-level";
|
|
15557
|
+
};
|
|
15558
|
+
openWorkOrder: {
|
|
15559
|
+
count: any;
|
|
15560
|
+
inProgress: any;
|
|
15561
|
+
percentage: number | null;
|
|
15562
|
+
};
|
|
15563
|
+
openIncidents: {
|
|
15564
|
+
count: any;
|
|
15565
|
+
highSeverity: number | null;
|
|
15566
|
+
highSeverityUnavailableReason: string;
|
|
15567
|
+
percentage: number | null;
|
|
15568
|
+
};
|
|
15569
|
+
visitors: {
|
|
15570
|
+
count: any;
|
|
15571
|
+
currentlyOnSite: number;
|
|
15572
|
+
percentage: number | null;
|
|
15573
|
+
};
|
|
15574
|
+
facilityBooking: {
|
|
15575
|
+
count: any;
|
|
15576
|
+
ongoing: any;
|
|
15577
|
+
waitingApproval: any;
|
|
15578
|
+
byStatus: {
|
|
15579
|
+
Pending: number;
|
|
15580
|
+
Approved: number;
|
|
15581
|
+
Ongoing: number;
|
|
15582
|
+
"For Review": number;
|
|
15583
|
+
"With Balance": number;
|
|
15584
|
+
"With Refund": number;
|
|
15585
|
+
Completed: number;
|
|
15586
|
+
Rejected: number;
|
|
15587
|
+
Cancelled: number;
|
|
15588
|
+
};
|
|
15589
|
+
percentage: number | null;
|
|
15590
|
+
};
|
|
15591
|
+
workOrderStatus: {
|
|
15592
|
+
pending: number;
|
|
15593
|
+
inProgress: number;
|
|
15594
|
+
completed: number;
|
|
15595
|
+
};
|
|
15596
|
+
upcomingEvents: mongodb.WithId<bson.Document>[];
|
|
15597
|
+
todayReminders: mongodb.WithId<bson.Document>[];
|
|
15598
|
+
todayAttentions: any[];
|
|
15599
|
+
} | {
|
|
15600
|
+
supplyAlert?: undefined;
|
|
15503
15601
|
openWorkOrder: {
|
|
15504
15602
|
count: any;
|
|
15505
15603
|
inProgress: any;
|
package/dist/index.js
CHANGED
|
@@ -11336,6 +11336,7 @@ var ConsoleAuditAction = /* @__PURE__ */ ((ConsoleAuditAction3) => {
|
|
|
11336
11336
|
ConsoleAuditAction3["ROBOT_MAP_REMOVED"] = "robot.map-removed";
|
|
11337
11337
|
ConsoleAuditAction3["ROBOT_LIFT_REQUESTED"] = "robot.lift-requested";
|
|
11338
11338
|
ConsoleAuditAction3["ROBOT_LIFT_RELEASED"] = "robot.lift-released";
|
|
11339
|
+
ConsoleAuditAction3["INVENTORY_STORE_TYPE_REPAIRED"] = "inventory.store-type-repaired";
|
|
11339
11340
|
return ConsoleAuditAction3;
|
|
11340
11341
|
})(ConsoleAuditAction || {});
|
|
11341
11342
|
var CLIENT_ACTIONS = [
|
|
@@ -11373,7 +11374,8 @@ var CONSOLE_AUDIT_LABELS = {
|
|
|
11373
11374
|
["robot.map-updated" /* ROBOT_MAP_UPDATED */]: "Building map edited",
|
|
11374
11375
|
["robot.map-removed" /* ROBOT_MAP_REMOVED */]: "Building map removed",
|
|
11375
11376
|
["robot.lift-requested" /* ROBOT_LIFT_REQUESTED */]: "Robot asked for a lift",
|
|
11376
|
-
["robot.lift-released" /* ROBOT_LIFT_RELEASED */]: "Robot lift request released"
|
|
11377
|
+
["robot.lift-released" /* ROBOT_LIFT_RELEASED */]: "Robot lift request released",
|
|
11378
|
+
["inventory.store-type-repaired" /* INVENTORY_STORE_TYPE_REPAIRED */]: "Inventory store type corrected"
|
|
11377
11379
|
};
|
|
11378
11380
|
var ConsoleAuditTarget = /* @__PURE__ */ ((ConsoleAuditTarget2) => {
|
|
11379
11381
|
ConsoleAuditTarget2["ORGANIZATION"] = "organization";
|
|
@@ -11385,6 +11387,7 @@ var ConsoleAuditTarget = /* @__PURE__ */ ((ConsoleAuditTarget2) => {
|
|
|
11385
11387
|
ConsoleAuditTarget2["SITE"] = "site";
|
|
11386
11388
|
ConsoleAuditTarget2["ROBOT"] = "robot";
|
|
11387
11389
|
ConsoleAuditTarget2["ROBOT_MAP"] = "robot-map";
|
|
11390
|
+
ConsoleAuditTarget2["INVENTORY_STORE"] = "inventory-store";
|
|
11388
11391
|
return ConsoleAuditTarget2;
|
|
11389
11392
|
})(ConsoleAuditTarget || {});
|
|
11390
11393
|
var CAMERA_AUDIT_FIELDS = [
|
|
@@ -11432,6 +11435,7 @@ var ROBOT_MAP_AUDIT_FIELDS = [
|
|
|
11432
11435
|
];
|
|
11433
11436
|
var ROBOT_LIFT_AUDIT_FIELDS = ["name", "liftName", "fromFloor", "toFloor"];
|
|
11434
11437
|
var AUDIT_FIELDS = {
|
|
11438
|
+
["inventory.store-type-repaired" /* INVENTORY_STORE_TYPE_REPAIRED */]: ["ownerType", "name"],
|
|
11435
11439
|
["robot.map-saved" /* ROBOT_MAP_SAVED */]: ROBOT_MAP_AUDIT_FIELDS,
|
|
11436
11440
|
["robot.map-updated" /* ROBOT_MAP_UPDATED */]: ROBOT_MAP_AUDIT_FIELDS,
|
|
11437
11441
|
["robot.map-removed" /* ROBOT_MAP_REMOVED */]: ROBOT_MAP_AUDIT_FIELDS,
|
|
@@ -90264,7 +90268,7 @@ function useNewDashboardRepo() {
|
|
|
90264
90268
|
},
|
|
90265
90269
|
activePatrolItems
|
|
90266
90270
|
};
|
|
90267
|
-
return data;
|
|
90271
|
+
return { ...data, ...await inventorySupplyTile(siteIdObj, "security_agency") };
|
|
90268
90272
|
}
|
|
90269
90273
|
async function getPropertyManagementDashboard(siteId, period = "today" /* TODAY */, type, facility) {
|
|
90270
90274
|
const siteIdObj = (0, import_node_server_utils261.toObjectId)(siteId);
|
|
@@ -90703,7 +90707,7 @@ function useNewDashboardRepo() {
|
|
|
90703
90707
|
todayReminders,
|
|
90704
90708
|
todayAttentions
|
|
90705
90709
|
};
|
|
90706
|
-
return data;
|
|
90710
|
+
return { ...data, ...await inventorySupplyTile(siteIdObj, "property_management_agency") };
|
|
90707
90711
|
}
|
|
90708
90712
|
function areaChecklistScheduleLookup(site, serviceType, createdAtRange) {
|
|
90709
90713
|
return [
|
|
@@ -90728,24 +90732,38 @@ function useNewDashboardRepo() {
|
|
|
90728
90732
|
{ $unwind: { path: "$scheduleDoc", preserveNullAndEmptyArrays: false } }
|
|
90729
90733
|
];
|
|
90730
90734
|
}
|
|
90735
|
+
async function inventoryLowStock(site, serviceType) {
|
|
90736
|
+
const natures = serviceType === "property_management_agency" ? ["property_management_agency", "real_estate_developer"] : [serviceType];
|
|
90737
|
+
const siteStores = await db2.collection("inventory.stores").find({ sites: site, status: "active" }, { projection: { _id: 1, org: 1 } }).toArray();
|
|
90738
|
+
if (!siteStores.length)
|
|
90739
|
+
return null;
|
|
90740
|
+
const ownOrgs = new Set(
|
|
90741
|
+
(await db2.collection("organizations").find(
|
|
90742
|
+
{ _id: { $in: siteStores.map((store) => store.org) }, nature: { $in: natures } },
|
|
90743
|
+
{ projection: { _id: 1 } }
|
|
90744
|
+
).toArray()).map((org) => org._id.toString())
|
|
90745
|
+
);
|
|
90746
|
+
const stores = siteStores.filter((store) => ownOrgs.has(String(store.org)));
|
|
90747
|
+
if (!stores.length)
|
|
90748
|
+
return null;
|
|
90749
|
+
return db2.collection("inventory.items").aggregate([
|
|
90750
|
+
{
|
|
90751
|
+
$match: {
|
|
90752
|
+
store: { $in: stores.map((store) => store._id) },
|
|
90753
|
+
status: "active",
|
|
90754
|
+
reorderLevel: { $gt: 0 },
|
|
90755
|
+
$expr: { $lte: ["$onHand", "$reorderLevel"] }
|
|
90756
|
+
}
|
|
90757
|
+
},
|
|
90758
|
+
{ $sort: { onHand: 1 } },
|
|
90759
|
+
{ $limit: 5 },
|
|
90760
|
+
{ $project: { _id: 1, name: 1, qty: "$onHand" } }
|
|
90761
|
+
]).toArray();
|
|
90762
|
+
}
|
|
90731
90763
|
async function lowStockItems(site, serviceType) {
|
|
90732
|
-
const
|
|
90733
|
-
if (
|
|
90734
|
-
|
|
90735
|
-
{
|
|
90736
|
-
$match: {
|
|
90737
|
-
store: { $in: stores.map((store) => store._id) },
|
|
90738
|
-
status: "active",
|
|
90739
|
-
reorderLevel: { $gt: 0 },
|
|
90740
|
-
$expr: { $lte: ["$onHand", "$reorderLevel"] }
|
|
90741
|
-
}
|
|
90742
|
-
},
|
|
90743
|
-
{ $sort: { onHand: 1 } },
|
|
90744
|
-
{ $limit: 5 },
|
|
90745
|
-
{ $project: { _id: 1, name: 1, qty: "$onHand" } }
|
|
90746
|
-
]).toArray();
|
|
90747
|
-
return { items: items2, basis: SUPPLY_BASIS_BELOW_ALERT_LEVEL };
|
|
90748
|
-
}
|
|
90764
|
+
const inventory = await inventoryLowStock(site, serviceType);
|
|
90765
|
+
if (inventory)
|
|
90766
|
+
return { items: inventory, basis: SUPPLY_BASIS_BELOW_ALERT_LEVEL };
|
|
90749
90767
|
const items = await supplyCollection.aggregate([
|
|
90750
90768
|
{ $match: { site, serviceType, status: "active" } },
|
|
90751
90769
|
{ $sort: { qty: 1 } },
|
|
@@ -90754,6 +90772,10 @@ function useNewDashboardRepo() {
|
|
|
90754
90772
|
]).toArray();
|
|
90755
90773
|
return { items, basis: SUPPLY_BASIS_LOWEST_QUANTITY };
|
|
90756
90774
|
}
|
|
90775
|
+
async function inventorySupplyTile(site, serviceType) {
|
|
90776
|
+
const items = await inventoryLowStock(site, serviceType);
|
|
90777
|
+
return items ? { supplyAlert: { items: items.map((item) => ({ name: item.name, qty: item.qty })), basis: SUPPLY_BASIS_BELOW_ALERT_LEVEL } } : {};
|
|
90778
|
+
}
|
|
90757
90779
|
async function getServiceDashboard({
|
|
90758
90780
|
site,
|
|
90759
90781
|
serviceType,
|