@7365admin1/core 3.122.1 → 3.122.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@7365admin1/core",
3
3
  "license": "MIT",
4
- "version": "3.122.1",
4
+ "version": "3.122.3",
5
5
  "author": "7365admin1",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -23,6 +23,9 @@ import {
23
23
  padbotPatrolRecord,
24
24
  padbotCheckpointVisit,
25
25
  padbotPlanShare,
26
+ padbotCurrentMap,
27
+ padbotAccountKey,
28
+ recordPadbotLive,
26
29
  statesByType,
27
30
  } from "./.build/services/padbot.adapter.mjs";
28
31
  import { commandSupported, normalisePatrolPlan, robotTier } from "./.build/utils/robot-adapter.util.mjs";
@@ -578,3 +581,76 @@ test("adapter listRobots: the account's patrol robots with one batched state rea
578
581
  assert.deepEqual(f.calls.find((c) => c.path === PADBOT_PATHS.states).body.serialNumbers, ["PS0001", "PS0002"]);
579
582
  assert.equal(f.calls.filter((c) => c.path === PADBOT_PATHS.states).length, 1);
580
583
  });
584
+
585
+ /* ---- real S2 reply shapes (prod Diagnose 2026-09-26, map ids kept, no credentials) ---- */
586
+
587
+ const S2_LVL3 = "40f18c40a12ee2f3c0b20b38dc7a5b0f";
588
+ const S2_MAPS = [
589
+ { mapId: "24fe9c97e9160548d100dab541f1662a", mapName: "20260528172106098_5ecd8fa9", mapDisplayName: "B1", building: "", floor: 1, isDefault: false, width: 1092, height: 1865, resolution: 0.05, originX: -27.55, originY: -80, mapGroup: "" },
590
+ { mapId: S2_LVL3, mapName: "772df9dc808b45a5_20260924185244234", mapDisplayName: "Lvl3 Office", building: "", floor: 3, isDefault: true, width: 255, height: 244, resolution: 0.05, originX: -24.7, originY: -2.3, mapGroup: "" },
591
+ ];
592
+ const s2States = (mapId = S2_LVL3) => [
593
+ {
594
+ serialNumber: "PS8517",
595
+ states: [
596
+ { stateType: "1000", data: { updatedAt: fresh } },
597
+ { stateType: "1001", data: { updatedAt: fresh, batteryPercent: 100 } },
598
+ { stateType: "1002", data: { updatedAt: fresh, chargingState: 2 } },
599
+ { stateType: "1003", data: { updatedAt: fresh, mapName: null, nextTargetPointName: null, finalTargetPointName: null, actionType: 0, actionState: 0, message: null } },
600
+ { stateType: "1007", data: { updatedAt: "2026-09-24T10:52:45.143Z", mapId, floor: 3, mapDisplayName: "Lvl3 Office", width: 255, height: 244 } },
601
+ { stateType: "1010", data: { updatedAt: fresh, workState: 0, taskType: 0, taskInfo: null } },
602
+ ],
603
+ },
604
+ ];
605
+ const s2Robot = (location, mapId, heardPose) => {
606
+ clearPadbotCache();
607
+ if (heardPose) recordPadbotLive(padbotAccountKey(CREDS), "PS8517", { pose: heardPose });
608
+ const f = fakePadbot({
609
+ [PADBOT_PATHS.states]: () => s2States(mapId),
610
+ [PADBOT_PATHS.robots]: () => [{ serialNumber: "PS8517", robotName: "HERO-OTH-SECURITY", robotType: "PATROL", robotModel: "S2" }],
611
+ [PADBOT_PATHS.location]: () => location,
612
+ [PADBOT_PATHS.maps]: () => S2_MAPS,
613
+ [PADBOT_PATHS.alarms]: () => ({ items: [], totalItems: 0, totalPages: 0 }),
614
+ });
615
+ return createPadbotAdapter(CREDS, { baseUrl: "https://pb.test", fetch: f.fetch, now: f.now }).getRobot("PS8517");
616
+ };
617
+
618
+ test("real S2: coordinates on Lvl3 -> pin on Lvl3, mapId reported", async () => {
619
+ const r = await s2Robot({ mapId: S2_LVL3, worldX: -13.9, worldY: 8.79, yaw: -94 });
620
+ assert.equal(r.mapId, S2_LVL3);
621
+ assert.deepEqual(r.planPosition, padbotPlanShare(S2_MAPS[1], -13.9, 8.79));
622
+ assert.ok(r.planPosition, "inside the Lvl3 image");
623
+ });
624
+
625
+ test("real S2: PadBot's null worldX/worldY -> no pin, but the map is still known", async () => {
626
+ const r = await s2Robot({ mapId: S2_LVL3, worldX: null, worldY: null, yaw: -94 });
627
+ assert.equal(r.position, null);
628
+ assert.equal(r.mapId, S2_LVL3, "the map selector can still say 'Robot is here'");
629
+ assert.match(r.statusName, /Position not reported$/);
630
+ });
631
+
632
+ test("real S2: an unlisted or missing map id falls back to the robot's floor map, the pin is kept", async () => {
633
+ const r = await s2Robot({ worldX: -13.9, worldY: 8.79, yaw: -94 }, "not-in-the-list");
634
+ assert.equal(r.mapId, S2_LVL3);
635
+ assert.ok(r.planPosition);
636
+ assert.equal(padbotCurrentMap(S2_MAPS, [null, "x"], 1).mapId, S2_MAPS[0].mapId);
637
+ assert.equal(padbotCurrentMap([...S2_MAPS, { ...S2_MAPS[1], mapId: "other-l3" }], ["x"], 3), null, "two maps on one floor: no guess");
638
+ });
639
+
640
+ test("/robots/states row carries mapId (the map screens draw the pin only on the robot's map)", async () => {
641
+ const { fleetStateItem } = await import("./.build/services/robot-fleet.service.mjs");
642
+ const row = fleetStateItem("r1", { online: true, mode: "IDLE", statusName: "Standing by", model: "PadBot S2", batteryPercent: 100, floorNo: 3, floorKnown: true, mapId: S2_LVL3, position: null, planPosition: null, fault: null, capabilities: {}, profile: {} });
643
+ assert.equal(row.mapId, S2_LVL3);
644
+ assert.equal(fleetStateItem("r2", { mapId: undefined }).mapId, null);
645
+ });
646
+
647
+ test("real S2: PadBot's REST gives null coordinates while standing still -> its last MQTT position on this map, with its age", async () => {
648
+ const r = await s2Robot({ mapId: S2_LVL3, worldX: null, worldY: null, yaw: -94 }, undefined, { mapId: S2_LVL3, x: -13.89, y: 8.83, yawDeg: -94, at: NOW - 125_000 });
649
+ assert.deepEqual(r.planPosition, padbotPlanShare(S2_MAPS[1], -13.89, 8.83));
650
+ assert.match(r.statusName, /Last reported position \(2 min ago\)$/);
651
+ // a pose heard on ANOTHER map is not used
652
+ const other = await s2Robot({ mapId: S2_LVL3, worldX: null, worldY: null, yaw: -94 }, undefined, { mapId: S2_MAPS[0].mapId, x: 1, y: 1, yawDeg: 0, at: NOW - 125_000 });
653
+ assert.equal(other.position, null);
654
+ assert.match(other.statusName, /Position not reported$/);
655
+ clearPadbotCache();
656
+ });