@7365admin1/core 3.122.4 → 3.122.5
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 +6 -0
- package/dist/index.js +50 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/padbot.e2e.test.mjs +1 -1
- package/test/padbot-patrol-start.test.mjs +105 -0
- package/test/padbot.test.mjs +5 -2
package/package.json
CHANGED
|
@@ -259,7 +259,7 @@ describe("PadBot security robots", { concurrency: 1 }, () => {
|
|
|
259
259
|
assert.deepEqual(call.body, { serialNumber: "PS0001", pathId: "p1", patrolCount: 2 });
|
|
260
260
|
const dflt = await post(`/robots/${id.robot}/command`, { kind: "full" });
|
|
261
261
|
assert.equal(dflt.status, 202, JSON.stringify(dflt.body));
|
|
262
|
-
assert.deepEqual(mock.seen.filter((c) => c.path === "/api/v1/robots/patrol/start").at(-1).body, { serialNumber: "PS0001", patrolCount: 1 });
|
|
262
|
+
assert.deepEqual(mock.seen.filter((c) => c.path === "/api/v1/robots/patrol/start").at(-1).body, { serialNumber: "PS0001", pathId: "p1", patrolCount: 1 }, "the default route, named once checked");
|
|
263
263
|
mock.state.nav = { actionType: 2, actionState: 2 };
|
|
264
264
|
});
|
|
265
265
|
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Owner, prod 2026-09-26: "start patrol also not working". Start patrol sent
|
|
2
|
+
// {kind:"full"} = §6.2 with no pathId = PadBot's DEFAULT route "B1", which lies
|
|
3
|
+
// on map B1, while the S2 stood docked on "Lvl3 Office". PadBot answered code 0
|
|
4
|
+
// and the robot stayed idle. Shapes below are the robot's recorded answers
|
|
5
|
+
// (Diagnose, 2026-09-26 12:04Z), ids shortened.
|
|
6
|
+
|
|
7
|
+
import assert from "node:assert/strict";
|
|
8
|
+
import { test } from "node:test";
|
|
9
|
+
|
|
10
|
+
import { PADBOT_PATHS, clearPadbotCache, createPadbotAdapter, padbotPatrolPlan } from "./.build/services/padbot.adapter.mjs";
|
|
11
|
+
|
|
12
|
+
const CREDS = { appid: "ak-real-id", secret: "sk-real-secret-never-shown" };
|
|
13
|
+
const NOW = Date.parse("2026-09-26T12:05:00.000Z");
|
|
14
|
+
const L3 = "40f18c40a12ee2f3c0b20b38dc7a5b0f";
|
|
15
|
+
const B1 = "24fe9c97e9160548d100dab541f1662a";
|
|
16
|
+
|
|
17
|
+
const pt = (mapId, name, id) => ({ mapId, targetPointName: name, targetPointId: id, pointIndex: Number(name.slice(1)) - 1 });
|
|
18
|
+
// Recorded §6.1: route mapId null on BOTH; each point carries its own map.
|
|
19
|
+
const ROUTES = [
|
|
20
|
+
{ pathId: "0889310e", pathName: "Patrolling Lvl3", mapId: null, isDefault: false, pointNames: ["P1", "P2", "P3", "P4"],
|
|
21
|
+
points: [pt(L3, "P1", "b35a4c"), pt(L3, "P2", "f151f7"), pt(L3, "P3", "45ad80"), pt(L3, "P4", "07828d")] },
|
|
22
|
+
{ pathId: "8e29085d", pathName: "B1", mapId: null, isDefault: true, pointNames: ["P1", "P2", "P3", "P4"],
|
|
23
|
+
points: [pt(B1, "P1", "1dc040"), pt(B1, "P2", "216e69"), pt(B1, "P3", "d1bec1"), pt(B1, "P4", "391a51")] },
|
|
24
|
+
];
|
|
25
|
+
// Both maps hold P1-P4 (name matching alone cannot tell the routes apart).
|
|
26
|
+
const tps = (mapId, ids) => ["P1", "P2", "P3", "P4"].map((n, i) => ({ targetPointId: ids[i], mapId, name: n, targetPointType: 0, worldX: i, worldY: i }));
|
|
27
|
+
const MAPS = [
|
|
28
|
+
{ mapId: B1, mapName: "B1", mapDisplayName: "B1", floor: 1, isDefault: false, mapGroup: "", targetPoints: tps(B1, ["1dc040", "216e69", "d1bec1", "391a51"]) },
|
|
29
|
+
{ mapId: L3, mapName: "Lvl3 Office", mapDisplayName: "Lvl3 Office", floor: 3, isDefault: true, mapGroup: "",
|
|
30
|
+
targetPoints: [...tps(L3, ["b35a4c", "f151f7", "45ad80", "07828d"]), { targetPointId: "chg", mapId: L3, name: "Charging Area", targetPointType: 10, worldX: -13.9, worldY: 8.75 }] },
|
|
31
|
+
];
|
|
32
|
+
const STATES = [{ serialNumber: "PS8517", states: [
|
|
33
|
+
{ stateType: "1000", data: { updatedAt: "2026-09-26T12:04:05.593Z" } },
|
|
34
|
+
{ stateType: "1002", data: { updatedAt: "2026-09-26T09:44:36.968Z", chargingState: 2 } },
|
|
35
|
+
{ stateType: "1003", data: { actionType: 0, actionState: 0 } },
|
|
36
|
+
{ stateType: "1007", data: { mapId: L3, floor: 3, mapDisplayName: "Lvl3 Office" } },
|
|
37
|
+
{ stateType: "1010", data: { workState: 0, taskType: 0 } },
|
|
38
|
+
] }];
|
|
39
|
+
|
|
40
|
+
function fake(extra = {}) {
|
|
41
|
+
const calls = [];
|
|
42
|
+
const answers = {
|
|
43
|
+
[PADBOT_PATHS.states]: () => STATES,
|
|
44
|
+
[PADBOT_PATHS.maps]: () => MAPS,
|
|
45
|
+
[PADBOT_PATHS.location]: () => ({ mapId: L3, worldX: -13.889, worldY: 8.878, yaw: -94 }),
|
|
46
|
+
[PADBOT_PATHS.patrolRoutes]: () => ROUTES,
|
|
47
|
+
[PADBOT_PATHS.patrolStart]: () => null,
|
|
48
|
+
[PADBOT_PATHS.navigateTarget]: () => null,
|
|
49
|
+
...extra,
|
|
50
|
+
};
|
|
51
|
+
const fetch = async (url, init) => {
|
|
52
|
+
const path = new URL(url).pathname;
|
|
53
|
+
calls.push({ path, body: JSON.parse(init.body) });
|
|
54
|
+
const out = answers[path]?.(JSON.parse(init.body));
|
|
55
|
+
return { status: 200, text: async () => JSON.stringify(out?.__raw ?? { code: 0, message: "success", data: out ?? null }) };
|
|
56
|
+
};
|
|
57
|
+
return { calls, adapter: createPadbotAdapter(CREDS, { baseUrl: "https://pb.test", fetch, now: () => NOW }) };
|
|
58
|
+
}
|
|
59
|
+
const starts = (calls) => calls.filter((c) => c.path === PADBOT_PATHS.patrolStart);
|
|
60
|
+
|
|
61
|
+
test("routes take their map from their points (route mapId null), and the robot's map comes first", () => {
|
|
62
|
+
const plan = padbotPatrolPlan(ROUTES, MAPS, { "1007": { mapId: L3 } });
|
|
63
|
+
assert.deepEqual(plan.routes.map((r) => [r.name, r.mapId, r.floorNo]), [["Patrolling Lvl3", L3, 3], ["B1 (default)", B1, 1]]);
|
|
64
|
+
// On B1 the default (B1) comes first.
|
|
65
|
+
assert.equal(padbotPatrolPlan(ROUTES, MAPS, { "1007": { mapId: B1 } }).routes[0].name, "B1 (default)");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("Start patrol (default route) on another map is refused in words; nothing is sent", async () => {
|
|
69
|
+
clearPadbotCache();
|
|
70
|
+
const { calls, adapter } = fake();
|
|
71
|
+
await assert.rejects(adapter.sendCommand("PS8517", { kind: "full" }), (e) =>
|
|
72
|
+
e.statusCode === 400 && e.message === '"B1" is on the B1 map, but the robot is on Lvl3 Office. Pick a route on the robot\'s map.');
|
|
73
|
+
assert.equal(starts(calls).length, 0);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("Start patrol with the Lvl3 route sends exactly that route once", async () => {
|
|
77
|
+
clearPadbotCache();
|
|
78
|
+
const { calls, adapter } = fake();
|
|
79
|
+
await adapter.sendCommand("PS8517", { kind: "area", areas: ["0889310e"] });
|
|
80
|
+
assert.deepEqual(starts(calls).map((c) => c.body), [{ serialNumber: "PS8517", pathId: "0889310e", patrolCount: 1 }]);
|
|
81
|
+
await assert.rejects(adapter.sendCommand("PS8517", { kind: "area", areas: ["8e29085d"] }), /is on the B1 map/);
|
|
82
|
+
await assert.rejects(adapter.sendCommand("PS8517", { kind: "area", areas: ["gone"] }), /no longer exists/);
|
|
83
|
+
assert.equal(starts(calls).length, 1);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("default route on the robot's map: full names it explicitly; a code != 0 inside HTTP 200 is a refusal", async () => {
|
|
87
|
+
clearPadbotCache();
|
|
88
|
+
const onB1 = [{ serialNumber: "PS8517", states: STATES[0].states.map((s) => (s.stateType === "1007" ? { ...s, data: { mapId: B1, floor: 1 } } : s)) }];
|
|
89
|
+
const { calls, adapter } = fake({ [PADBOT_PATHS.states]: () => onB1, [PADBOT_PATHS.location]: () => ({ mapId: B1, worldX: null, worldY: null }) });
|
|
90
|
+
await adapter.sendCommand("PS8517", { kind: "full" });
|
|
91
|
+
assert.deepEqual(starts(calls).at(-1).body, { serialNumber: "PS8517", pathId: "8e29085d", patrolCount: 1 });
|
|
92
|
+
|
|
93
|
+
clearPadbotCache();
|
|
94
|
+
const busy = fake({ [PADBOT_PATHS.patrolStart]: () => ({ __raw: { code: 1009, message: "robot busy", requestId: "x", data: null } }) });
|
|
95
|
+
await assert.rejects(busy.adapter.sendCommand("PS8517", { kind: "area", areas: ["0889310e"] }), (e) =>
|
|
96
|
+
e.message === "The robot is busy with something else right now." && e.vendorCode === 1009);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("go to point uses the location read's map (newer than state 1007)", async () => {
|
|
100
|
+
clearPadbotCache();
|
|
101
|
+
const stale = [{ serialNumber: "PS8517", states: STATES[0].states.map((s) => (s.stateType === "1007" ? { ...s, data: { mapId: B1, floor: 1 } } : s)) }];
|
|
102
|
+
const { calls, adapter } = fake({ [PADBOT_PATHS.states]: () => stale });
|
|
103
|
+
await adapter.sendCommand("PS8517", { kind: "go-to-point", mapId: L3, targetPointId: "b35a4c" });
|
|
104
|
+
assert.deepEqual(calls.at(-1).body, { serialNumber: "PS8517", mapId: L3, targetPointId: "b35a4c" });
|
|
105
|
+
});
|
package/test/padbot.test.mjs
CHANGED
|
@@ -486,7 +486,10 @@ test("adapter getRobot: e-stop outranks alarms; unknown serial = null; offline s
|
|
|
486
486
|
});
|
|
487
487
|
|
|
488
488
|
test("adapter commands: each of ours becomes the documented PadBot call", async () => {
|
|
489
|
-
const f = fakePadbot(
|
|
489
|
+
const f = fakePadbot({
|
|
490
|
+
...Object.fromEntries(Object.values(PADBOT_PATHS).map((p) => [p, () => null])),
|
|
491
|
+
[PADBOT_PATHS.patrolRoutes]: () => [{ pathId: "p1", pathName: "Loop", mapId: null, isDefault: false, pointNames: [] }],
|
|
492
|
+
});
|
|
490
493
|
const a = createPadbotAdapter(CREDS, { baseUrl: "https://pb.test", fetch: f.fetch, now: f.now });
|
|
491
494
|
await a.sendCommand("PS1", { kind: "full" });
|
|
492
495
|
await a.sendCommand("PS1", { kind: "area", areas: ["p1"], options: { cleanTimes: 3 } });
|
|
@@ -496,7 +499,7 @@ test("adapter commands: each of ours becomes the documented PadBot call", async
|
|
|
496
499
|
await a.sendCommand("PS1", { kind: "navigate", x: 1.5, y: 2, theta: Math.PI });
|
|
497
500
|
await a.sendCommand("PS1", { kind: "relocalize", floorNo: 1, x: 1, y: 2, theta: 0 });
|
|
498
501
|
assert.deepEqual(
|
|
499
|
-
f.calls.map((c) => [c.path, c.body]),
|
|
502
|
+
f.calls.filter((c) => ![PADBOT_PATHS.patrolRoutes, PADBOT_PATHS.states, PADBOT_PATHS.maps, PADBOT_PATHS.location].includes(c.path)).map((c) => [c.path, c.body]),
|
|
500
503
|
[
|
|
501
504
|
[PADBOT_PATHS.patrolStart, { serialNumber: "PS1", patrolCount: 1 }],
|
|
502
505
|
[PADBOT_PATHS.patrolStart, { serialNumber: "PS1", pathId: "p1", patrolCount: 3 }],
|