@7365admin1/core 3.122.2 → 3.122.4

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.2",
4
+ "version": "3.122.4",
5
5
  "author": "7365admin1",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -24,6 +24,9 @@ import {
24
24
  padbotCheckpointVisit,
25
25
  padbotPlanShare,
26
26
  padbotCurrentMap,
27
+ padbotChargingPoint,
28
+ padbotAccountKey,
29
+ recordPadbotLive,
27
30
  statesByType,
28
31
  } from "./.build/services/padbot.adapter.mjs";
29
32
  import { commandSupported, normalisePatrolPlan, robotTier } from "./.build/utils/robot-adapter.util.mjs";
@@ -585,25 +588,33 @@ test("adapter listRobots: the account's patrol robots with one batched state rea
585
588
  const S2_LVL3 = "40f18c40a12ee2f3c0b20b38dc7a5b0f";
586
589
  const S2_MAPS = [
587
590
  { 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: "" },
588
- { 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
+ { 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: "",
592
+ targetPoints: [
593
+ { name: "P4", targetPointType: 0, worldX: -22.3, worldY: 4.1, yaw: 188 },
594
+ { name: "P3", targetPointType: 0, worldX: -18.75, worldY: 6.4, yaw: 170 },
595
+ { name: "Charging Area", targetPointType: 10, worldX: -13.9, worldY: 8.75, yaw: 266 },
596
+ { name: "P1", targetPointType: 0, worldX: -13.7, worldY: 5.15, yaw: 258 },
597
+ { name: "P2", targetPointType: 0, worldX: -15.55, worldY: 7.1, yaw: 29 },
598
+ ] },
589
599
  ];
590
- const s2States = (mapId = S2_LVL3) => [
600
+ const s2States = (mapId = S2_LVL3, chargingState = 2) => [
591
601
  {
592
602
  serialNumber: "PS8517",
593
603
  states: [
594
604
  { stateType: "1000", data: { updatedAt: fresh } },
595
605
  { stateType: "1001", data: { updatedAt: fresh, batteryPercent: 100 } },
596
- { stateType: "1002", data: { updatedAt: fresh, chargingState: 2 } },
606
+ { stateType: "1002", data: { updatedAt: fresh, chargingState } },
597
607
  { stateType: "1003", data: { updatedAt: fresh, mapName: null, nextTargetPointName: null, finalTargetPointName: null, actionType: 0, actionState: 0, message: null } },
598
608
  { stateType: "1007", data: { updatedAt: "2026-09-24T10:52:45.143Z", mapId, floor: 3, mapDisplayName: "Lvl3 Office", width: 255, height: 244 } },
599
609
  { stateType: "1010", data: { updatedAt: fresh, workState: 0, taskType: 0, taskInfo: null } },
600
610
  ],
601
611
  },
602
612
  ];
603
- const s2Robot = (location, mapId) => {
613
+ const s2Robot = (location, mapId, heardPose, chargingState = 0) => {
604
614
  clearPadbotCache();
615
+ if (heardPose) recordPadbotLive(padbotAccountKey(CREDS), "PS8517", { pose: heardPose });
605
616
  const f = fakePadbot({
606
- [PADBOT_PATHS.states]: () => s2States(mapId),
617
+ [PADBOT_PATHS.states]: () => s2States(mapId, chargingState),
607
618
  [PADBOT_PATHS.robots]: () => [{ serialNumber: "PS8517", robotName: "HERO-OTH-SECURITY", robotType: "PATROL", robotModel: "S2" }],
608
619
  [PADBOT_PATHS.location]: () => location,
609
620
  [PADBOT_PATHS.maps]: () => S2_MAPS,
@@ -640,3 +651,37 @@ test("/robots/states row carries mapId (the map screens draw the pin only on the
640
651
  assert.equal(row.mapId, S2_LVL3);
641
652
  assert.equal(fleetStateItem("r2", { mapId: undefined }).mapId, null);
642
653
  });
654
+
655
+ test("real S2: PadBot's REST gives null coordinates while standing still -> its last MQTT position on this map, with its age", async () => {
656
+ 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 });
657
+ assert.deepEqual(r.planPosition, padbotPlanShare(S2_MAPS[1], -13.89, 8.83));
658
+ assert.match(r.statusName, /Last reported position \(2 min ago\)$/);
659
+ // a pose heard on ANOTHER map is not used
660
+ 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 });
661
+ assert.equal(other.position, null);
662
+ assert.match(other.statusName, /Position not reported$/);
663
+ clearPadbotCache();
664
+ });
665
+
666
+ test("real S2 docked (1002 chargingState 2, REST null, no MQTT pose) -> pin at Lvl3's Charging Area, 'At charger'", async () => {
667
+ const r = await s2Robot({ mapId: S2_LVL3, worldX: null, worldY: null, yaw: -94 }, undefined, undefined, 2);
668
+ assert.deepEqual(r.planPosition, padbotPlanShare(S2_MAPS[1], -13.9, 8.75));
669
+ assert.match(r.statusName, /At charger$/);
670
+ const off = await s2Robot({ mapId: S2_LVL3, worldX: null, worldY: null, yaw: -94 }, undefined, undefined, 0);
671
+ assert.equal(off.position, null, "not on the charger: no pin");
672
+ assert.equal(padbotChargingPoint({ targetPoints: [{ targetPointType: 10, worldX: 1, worldY: 1 }, { targetPointType: 10, worldX: 2, worldY: 2 }] }), null, "two piles: no guess");
673
+ });
674
+
675
+ test("real S2 routes with mapId null -> each on the map holding all its stops (names repeat across maps)", () => {
676
+ const b1 = { ...S2_MAPS[0], targetPoints: ["P1", "P2", "P3", "P4", "P5"].map((name, i) => ({ name, targetPointType: 0, worldX: -20 + i, worldY: -70 + i })) };
677
+ const maps = [b1, S2_MAPS[1]];
678
+ const paths = [
679
+ { pathId: "a", pathName: "B1", mapId: null, isDefault: true, pointNames: ["P1", "P2", "P3", "P4", "P5"] },
680
+ { pathId: "b", pathName: "Patrolling Lvl3", mapId: null, isDefault: false, pointNames: ["P1", "P2", "P3", "P4"] },
681
+ ];
682
+ const plan = padbotPatrolPlan(paths, maps, { "1007": { mapId: S2_LVL3, floor: 3 } });
683
+ const byId = Object.fromEntries(plan.routes.map((r) => [r.id, r]));
684
+ assert.equal(byId.a.mapId, b1.mapId);
685
+ assert.equal(byId.b.mapId, S2_LVL3, "on both maps -> the robot's current map");
686
+ assert.deepEqual(byId.b.checkpoints[0], { name: "P1", ...padbotPlanShare(S2_MAPS[1], -13.7, 5.15) }, "placed with Lvl3's P1, not B1's");
687
+ });