@7365admin1/core 3.120.0 → 3.122.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 +13 -0
- package/dist/index.d.ts +144 -15
- package/dist/index.js +247 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +236 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/robot-faults.e2e.test.mjs +3 -0
- package/test/e2e/robot-ounitech-company-creds.e2e.test.mjs +5 -4
- package/test/ounitech-part1.test.mjs +8 -7
- package/test/ounitech-timestamp-probe.test.mjs +64 -4
- package/test/padbot-mqtt.test.mjs +10 -4
- package/test/padbot-real-data.test.mjs +50 -0
- package/test/robot-cloud.test.mjs +4 -3
- package/test/robot-model-manifest.test.mjs +84 -0
package/package.json
CHANGED
|
@@ -190,6 +190,9 @@ describe("robot faults - stored, deduped, network-wide", { concurrency: 1 }, ()
|
|
|
190
190
|
assert.equal(demo.ok, true);
|
|
191
191
|
assert.equal(typeof demo.online, "boolean");
|
|
192
192
|
assert.ok(demo.capabilities);
|
|
193
|
+
// Model-aware manifest: the demo robot's model resolves (brand defaults + model), with its plain-words profile.
|
|
194
|
+
assert.equal(typeof demo.profile?.modelKnown, "boolean");
|
|
195
|
+
assert.ok(Array.isArray(demo.profile.makerAppOnly));
|
|
193
196
|
assert.deepEqual(res.body.items.find((i) => i.id === String(id.noInterface)), {
|
|
194
197
|
id: String(id.noInterface), ok: false, monitorable: false,
|
|
195
198
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// - requests go to OUNITECH_API_BASE + the endpoint path (Q1),
|
|
3
3
|
// - sign = sha1("appid=..,timestamp=..,url=<that path>,secret=..") (Q3),
|
|
4
4
|
// verified SERVER-SIDE by a mock that recomputes it,
|
|
5
|
-
// - timestamp is UTC+0
|
|
5
|
+
// - timestamp is Asia/Shanghai now (they said UTC+0; production proved UTC+8),
|
|
6
6
|
// - one AppID/Secret per company (Q2): entered once, discovered robots picked
|
|
7
7
|
// by serial, reused for the client's next robot without re-entry.
|
|
8
8
|
//
|
|
@@ -37,7 +37,8 @@ async function startMockOunitech() {
|
|
|
37
37
|
const sent = /^\d{14}$/.test(t)
|
|
38
38
|
? Date.UTC(+t.slice(0, 4), +t.slice(4, 6) - 1, +t.slice(6, 8), +t.slice(8, 10), +t.slice(10, 12), +t.slice(12, 14))
|
|
39
39
|
: NaN;
|
|
40
|
-
|
|
40
|
+
// Ounitech's proven zone: Asia/Shanghai (UTC+8).
|
|
41
|
+
const utcNow = Math.abs(Date.now() + 8 * 3600_000 - sent) < 30_000;
|
|
41
42
|
const signOk = body.appid === APPID && body.sign === sha1(`appid=${APPID},timestamp=${t},url=${req.url},secret=${SECRET}`);
|
|
42
43
|
calls.push({ path: req.url, signOk, utcNow, leakedSecret: raw.includes(SECRET) });
|
|
43
44
|
res.setHeader("content-type", "application/json");
|
|
@@ -58,7 +59,7 @@ async function startMockOunitech() {
|
|
|
58
59
|
return { server, calls, url: `http://127.0.0.1:${server.address().port}/` };
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
describe("Ounitech: base URL, server-verified sign,
|
|
62
|
+
describe("Ounitech: base URL, server-verified sign, Shanghai-time timestamp, one credential per company", { concurrency: 1 }, () => {
|
|
62
63
|
let h;
|
|
63
64
|
let mock;
|
|
64
65
|
let managerSid;
|
|
@@ -97,7 +98,7 @@ describe("Ounitech: base URL, server-verified sign, UTC timestamp, one credentia
|
|
|
97
98
|
assert.equal(lastCall().signOk, false);
|
|
98
99
|
});
|
|
99
100
|
|
|
100
|
-
it("typed company credentials list the company's robots; request is signed for its own path in
|
|
101
|
+
it("typed company credentials list the company's robots; request is signed for its own path in Shanghai time", async () => {
|
|
101
102
|
const res = await h.api("/robots/discover", {
|
|
102
103
|
method: "POST",
|
|
103
104
|
sid: managerSid,
|
|
@@ -17,7 +17,7 @@ import { createOunitechAdapter } from "./.build/services/ounitech.adapter.mjs";
|
|
|
17
17
|
* Q1 base URL https://app.frankfurt.robotcloud.top
|
|
18
18
|
* Q3 sign sha1("appid=..,timestamp=..,url=..,secret=..") with url = THAT
|
|
19
19
|
* endpoint's path; the document's example values are wrong
|
|
20
|
-
* Q4 timestamp UTC+0
|
|
20
|
+
* Q4 timestamp: they said UTC+0; production proved Asia/Shanghai (UTC+8), 2026-09-26
|
|
21
21
|
* Fake credentials only - nothing here reaches Ounitech.
|
|
22
22
|
* ----------------------------------------------------------------------- */
|
|
23
23
|
|
|
@@ -34,15 +34,16 @@ test("the default base URL is the one Ounitech gave (Part 1, Q1)", () => {
|
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
test("timestamp is
|
|
38
|
-
assert.equal(robotCloudTimestamp(CLOCK), "
|
|
37
|
+
test("timestamp is Asia/Shanghai wall clock (proven in production), not the server's local time", () => {
|
|
38
|
+
assert.equal(robotCloudTimestamp(CLOCK), "20260926093005");
|
|
39
|
+
assert.equal(robotCloudTimestamp(CLOCK, "yyyyMMddHHmmss", "UTC"), "20260926013005");
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
for (const [name, path] of Object.entries(ROBOT_CLOUD_PATHS)) {
|
|
42
43
|
test(`sign for ${name} hashes exactly its own path ${path}`, () => {
|
|
43
44
|
const body = robotCloudBody(APPID, SECRET, path, { robotSn: "SN1" }, CLOCK);
|
|
44
|
-
const expected = sha1(`appid=${APPID},timestamp=
|
|
45
|
-
assert.equal(body.timestamp, "
|
|
45
|
+
const expected = sha1(`appid=${APPID},timestamp=20260926093005,url=${path},secret=${SECRET}`);
|
|
46
|
+
assert.equal(body.timestamp, "20260926093005");
|
|
46
47
|
assert.equal(body.sign, expected);
|
|
47
48
|
assert.equal(body.appid, APPID);
|
|
48
49
|
assert.equal(JSON.stringify(body).includes(SECRET), false);
|
|
@@ -54,7 +55,7 @@ test("every endpoint has a different sign at the same instant (Part 1, Q3)", ()
|
|
|
54
55
|
assert.equal(new Set(signs).size, signs.length);
|
|
55
56
|
});
|
|
56
57
|
|
|
57
|
-
test("the adapter posts to base + path, signed for that path, stamped in
|
|
58
|
+
test("the adapter posts to base + path, signed for that path, stamped in Shanghai time now", async () => {
|
|
58
59
|
const seen = [];
|
|
59
60
|
const server = http.createServer((req, res) => {
|
|
60
61
|
let raw = "";
|
|
@@ -83,7 +84,7 @@ test("the adapter posts to base + path, signed for that path, stamped in UTC now
|
|
|
83
84
|
assert.match(body.timestamp, /^\d{14}$/);
|
|
84
85
|
const t = body.timestamp;
|
|
85
86
|
const sent = Date.UTC(+t.slice(0, 4), +t.slice(4, 6) - 1, +t.slice(6, 8), +t.slice(8, 10), +t.slice(10, 12), +t.slice(12, 14));
|
|
86
|
-
assert.ok(Math.abs(Date.now() - sent) < 10_000, `timestamp ${t} is not
|
|
87
|
+
assert.ok(Math.abs(Date.now() + 8 * 3600_000 - sent) < 10_000, `timestamp ${t} is not Shanghai now`);
|
|
87
88
|
}
|
|
88
89
|
} finally {
|
|
89
90
|
server.close();
|
|
@@ -6,6 +6,7 @@ import { after, before, test } from "node:test";
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
OUNITECH_TIMESTAMP_FORMAT,
|
|
9
|
+
OUNITECH_TIMESTAMP_ZONE,
|
|
9
10
|
ROBOT_CLOUD_PATHS,
|
|
10
11
|
ROBOT_CLOUD_TIMESTAMP_FORMATS,
|
|
11
12
|
robotCloudBody,
|
|
@@ -22,23 +23,24 @@ const sha1 = (s) => createHash("sha1").update(s).digest("hex");
|
|
|
22
23
|
const PATH = ROBOT_CLOUD_PATHS.robotList;
|
|
23
24
|
|
|
24
25
|
const EXPECTED = {
|
|
25
|
-
yyyyMMddHHmmss: "
|
|
26
|
+
yyyyMMddHHmmss: "20260926093005",
|
|
26
27
|
"unix-s": "1790386205",
|
|
27
28
|
"unix-ms": "1790386205123",
|
|
28
|
-
"yyyy-MM-dd HH:mm:ss": "2026-09-26
|
|
29
|
+
"yyyy-MM-dd HH:mm:ss": "2026-09-26 09:30:05",
|
|
29
30
|
iso8601: "2026-09-26T01:30:05Z",
|
|
30
31
|
"unix-s-number": "1790386205",
|
|
31
32
|
"unix-ms-number": "1790386205123",
|
|
32
33
|
};
|
|
33
34
|
|
|
34
|
-
test("
|
|
35
|
+
test("Ounitech: yyyyMMddHHmmss in Asia/Shanghai, both proven in production", () => {
|
|
35
36
|
assert.equal(OUNITECH_TIMESTAMP_FORMAT, "yyyyMMddHHmmss");
|
|
37
|
+
assert.equal(OUNITECH_TIMESTAMP_ZONE, "Asia/Shanghai");
|
|
36
38
|
assert.equal(robotCloudTimestamp(CLOCK), EXPECTED.yyyyMMddHHmmss);
|
|
37
39
|
assert.deepEqual([...ROBOT_CLOUD_TIMESTAMP_FORMATS].sort(), Object.keys(EXPECTED).sort());
|
|
38
40
|
});
|
|
39
41
|
|
|
40
42
|
for (const [format, text] of Object.entries(EXPECTED)) {
|
|
41
|
-
test(`format ${format}:
|
|
43
|
+
test(`format ${format}: brand-zone text and a sign recomputed over that exact text`, () => {
|
|
42
44
|
assert.equal(robotCloudTimestamp(CLOCK, format), text);
|
|
43
45
|
const body = robotCloudBody(APPID, SECRET, PATH, {}, CLOCK, format);
|
|
44
46
|
assert.equal(body.sign, sha1(`appid=${APPID},timestamp=${text},url=${PATH},secret=${SECRET}`));
|
|
@@ -47,6 +49,14 @@ for (const [format, text] of Object.entries(EXPECTED)) {
|
|
|
47
49
|
});
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
test("the zone is a NAMED zone: one with summer time follows it", () => {
|
|
53
|
+
assert.equal(robotCloudTimestamp(new Date("2026-07-01T00:00:00Z"), "yyyyMMddHHmmss", "Europe/Berlin"), "20260701020000");
|
|
54
|
+
assert.equal(robotCloudTimestamp(new Date("2026-01-01T00:00:00Z"), "yyyyMMddHHmmss", "Europe/Berlin"), "20260101010000");
|
|
55
|
+
// Shanghai has none: +8 in both seasons.
|
|
56
|
+
assert.equal(robotCloudTimestamp(new Date("2026-07-01T00:00:00Z")), "20260701080000");
|
|
57
|
+
assert.equal(robotCloudTimestamp(new Date("2026-01-01T00:00:00Z")), "20260101080000");
|
|
58
|
+
});
|
|
59
|
+
|
|
50
60
|
/* -------------------------------------------------------------- the probe */
|
|
51
61
|
|
|
52
62
|
// A mock Ounitech that accepts only one format, checking the sign server-side.
|
|
@@ -167,3 +177,53 @@ test("offset probe: none accepted tries all 8; its own once-a-minute limit, sepa
|
|
|
167
177
|
assert.equal(r.attempts.length, 8);
|
|
168
178
|
await assert.rejects(fleet.probeTimestampOffset(robotRow("o2")), (e) => e.statusCode === 429);
|
|
169
179
|
});
|
|
180
|
+
|
|
181
|
+
/* ------------------------------------------------------- the region probe */
|
|
182
|
+
|
|
183
|
+
// Three mock "regions": one with the robot, one empty, one refusing.
|
|
184
|
+
let regServer;
|
|
185
|
+
let regBase;
|
|
186
|
+
const regCalls = [];
|
|
187
|
+
before(async () => {
|
|
188
|
+
regServer = http.createServer((req, res) => {
|
|
189
|
+
let raw = "";
|
|
190
|
+
req.on("data", (c) => (raw += c));
|
|
191
|
+
req.on("end", () => {
|
|
192
|
+
const [, region, ...rest] = req.url.split("/");
|
|
193
|
+
const path = "/" + rest.join("/");
|
|
194
|
+
regCalls.push({ region, path });
|
|
195
|
+
res.writeHead(200, { "content-type": "application/json" });
|
|
196
|
+
if (region === "sg") return res.end(JSON.stringify({ robotList: [{ robotSn: "Q3G-001", robotName: "Lobby", ownerName: "Owner", ownerPhone: "+6599999999", statusName: "Idle", onlineFlag: true }] }));
|
|
197
|
+
if (region === "fra") return res.end(JSON.stringify({ robotList: [] }));
|
|
198
|
+
return res.end(JSON.stringify({ ok: false, msg: "invalid appid" }));
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
regServer.listen(0, "127.0.0.1");
|
|
202
|
+
await once(regServer, "listening");
|
|
203
|
+
regBase = `http://127.0.0.1:${regServer.address().port}`;
|
|
204
|
+
});
|
|
205
|
+
after(() => regServer.close());
|
|
206
|
+
|
|
207
|
+
test("region probe: asks every region's robot list, shows shape and robots, no owner phone or secret", async () => {
|
|
208
|
+
regCalls.length = 0;
|
|
209
|
+
const fleet = useRobotFleetService({
|
|
210
|
+
cloudOptions: { baseUrl: `${regBase}/fra`, timeoutMs: 1000 },
|
|
211
|
+
regionBaseUrls: [`${regBase}/fra`, `${regBase}/sg`, `${regBase}/cn`],
|
|
212
|
+
});
|
|
213
|
+
const r = await fleet.probeRegions(robotRow("r1"));
|
|
214
|
+
assert.deepEqual(r.hosts.map((h) => h.ok), [true, true, false]);
|
|
215
|
+
assert.deepEqual(r.hosts[0].replyShape, { robotList: "list of 0" });
|
|
216
|
+
assert.deepEqual(r.hosts[1].robots, [{ robotSn: "Q3G-001", robotName: "Lobby", online: true, statusName: "Idle" }]);
|
|
217
|
+
assert.equal(r.hosts[2].vendorMessage, "invalid appid");
|
|
218
|
+
assert.match(r.summary, /Robots found on .*\(1\)/);
|
|
219
|
+
assert.ok(regCalls.every((c) => c.path === PATH), "only the robot list is called");
|
|
220
|
+
const text = JSON.stringify(r);
|
|
221
|
+
assert.equal(text.includes(SECRET) || text.includes(APPID) || text.includes("+6599999999"), false);
|
|
222
|
+
await assert.rejects(fleet.probeRegions(robotRow("r1")), (e) => e.statusCode === 429);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test("region probe: every region empty says Ounitech must bind the robot", async () => {
|
|
226
|
+
const fleet = useRobotFleetService({ cloudOptions: { timeoutMs: 1000 }, regionBaseUrls: [`${regBase}/fra`] });
|
|
227
|
+
const r = await fleet.probeRegions(robotRow("r2"));
|
|
228
|
+
assert.match(r.summary, /must bind the robot/);
|
|
229
|
+
});
|
|
@@ -33,8 +33,9 @@ import {
|
|
|
33
33
|
} from "./.build/utils/padbot-mqtt.util.mjs";
|
|
34
34
|
import { floorWord, robotFaultText } from "./.build/utils/robot-fault.util.mjs";
|
|
35
35
|
import { parseRobotCommand } from "./.build/utils/robot-cloud.util.mjs";
|
|
36
|
-
import { commandSupported } from "./.build/utils/robot-adapter.util.mjs";
|
|
36
|
+
import { commandSupported, registerRobotBrand, robotManifest } from "./.build/utils/robot-adapter.util.mjs";
|
|
37
37
|
import {
|
|
38
|
+
PADBOT_BRAND_DEFINITION,
|
|
38
39
|
PADBOT_CAPABILITIES,
|
|
39
40
|
PADBOT_PATHS,
|
|
40
41
|
clearPadbotCache,
|
|
@@ -185,9 +186,12 @@ test("flags: MQTT and alarm poll default on; manual drive default OFF (only the
|
|
|
185
186
|
assert.equal(padbotManualDriveEnabled({ PADBOT_MANUAL_DRIVE: " On " }), true);
|
|
186
187
|
const env = process.env.PADBOT_MANUAL_DRIVE;
|
|
187
188
|
delete process.env.PADBOT_MANUAL_DRIVE;
|
|
188
|
-
|
|
189
|
+
registerRobotBrand(PADBOT_BRAND_DEFINITION);
|
|
190
|
+
assert.equal(robotManifest("padbot", "S2").capabilities.manualDrive, false, "the capability follows the flag");
|
|
189
191
|
process.env.PADBOT_MANUAL_DRIVE = "on";
|
|
190
|
-
assert.equal(
|
|
192
|
+
assert.equal(robotManifest("padbot", "S2").capabilities.manualDrive, true);
|
|
193
|
+
assert.equal(PADBOT_CAPABILITIES.manualDrive, false, "S2 only: the drive limits are the S2's head range");
|
|
194
|
+
assert.equal(robotManifest("padbot", "P3").capabilities.manualDrive, false, "another model: no manual control");
|
|
191
195
|
if (env === undefined) delete process.env.PADBOT_MANUAL_DRIVE;
|
|
192
196
|
else process.env.PADBOT_MANUAL_DRIVE = env;
|
|
193
197
|
});
|
|
@@ -346,7 +350,9 @@ test("go-to-point: parsed strictly; needs navigateToPoint; PadBot sends §5.7 wi
|
|
|
346
350
|
const path = new URL(url).pathname;
|
|
347
351
|
calls.push({ path, body: JSON.parse(init.body) });
|
|
348
352
|
const code = path === PADBOT_PATHS.stop ? 1009 : 0;
|
|
349
|
-
|
|
353
|
+
// The robot reports map m1 (§4.2 1007), so a point on m1 is reachable.
|
|
354
|
+
const data = path === PADBOT_PATHS.states ? [{ serialNumber: "PS1", states: [{ stateType: "1007", data: { mapId: "m1" } }] }] : null;
|
|
355
|
+
return { status: 200, text: async () => JSON.stringify({ code, message: code ? "robot busy" : "success", data }) };
|
|
350
356
|
};
|
|
351
357
|
const a = createPadbotAdapter(creds, { baseUrl: "https://pb.test", fetch });
|
|
352
358
|
await a.sendCommand("PS1", { kind: "go-to-point", mapId: "m1", targetPointId: "t2" });
|
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
clearPadbotCache,
|
|
14
14
|
createPadbotAdapter,
|
|
15
15
|
networkText,
|
|
16
|
+
PADBOT_OTHER_MAP_TEXT,
|
|
17
|
+
padbotCanReachMap,
|
|
16
18
|
padbotPatrolPlan,
|
|
17
19
|
} from "./.build/services/padbot.adapter.mjs";
|
|
18
20
|
import { normalisePatrolPlan } from "./.build/utils/robot-adapter.util.mjs";
|
|
@@ -163,3 +165,51 @@ test("live video: HD asks PadBot for quality 1, default smooth for quality 2", a
|
|
|
163
165
|
await a.getLiveVideo("PS8517");
|
|
164
166
|
assert.deepEqual(f.calls.map((c) => c.body.quality), [1, 2]);
|
|
165
167
|
});
|
|
168
|
+
|
|
169
|
+
/* ---------------------------- multi-map robots (owner report 2026-09-26: 2 maps, no choice) */
|
|
170
|
+
|
|
171
|
+
test("maps: the robot's current map comes from §4.2 1007 (and §4.3 when it names one)", async () => {
|
|
172
|
+
clearPadbotCache();
|
|
173
|
+
const f = fake({
|
|
174
|
+
[PADBOT_PATHS.states]: () => [{ serialNumber: "PS8517", states: [
|
|
175
|
+
{ stateType: "1000", data: { updatedAt: fresh } },
|
|
176
|
+
{ stateType: "1007", data: { mapId: "20260528172106098_5ecd8fa9", floor: -1, updatedAt: fresh } },
|
|
177
|
+
] }],
|
|
178
|
+
[PADBOT_PATHS.location]: () => ({ mapId: "772df9dc808b45a5_20260924185244234", worldX: 1, worldY: 1, yaw: 0 }),
|
|
179
|
+
[PADBOT_PATHS.maps]: () => [],
|
|
180
|
+
[PADBOT_PATHS.alarms]: () => ({ items: [] }),
|
|
181
|
+
});
|
|
182
|
+
const a = createPadbotAdapter(CREDS, { baseUrl: "https://pb.test", fetch: f.fetch, now: () => NOW });
|
|
183
|
+
const r = await a.getRobot("PS8517");
|
|
184
|
+
assert.equal(r.mapId, "772df9dc808b45a5_20260924185244234", "the location read's map wins (it is the newest)");
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("routes: each route keeps the id of the map it belongs to", () => {
|
|
188
|
+
const maps = [{ mapId: "mB1", floor: -1 }, { mapId: "mL3", floor: 3 }];
|
|
189
|
+
const paths = [
|
|
190
|
+
{ pathId: "p1", pathName: "B1", mapId: "mB1", isDefault: true, pointNames: ["Gate", "Lobby"] },
|
|
191
|
+
{ pathId: "p2", pathName: "Patrolling Lvl3", mapId: "mL3", pointNames: ["Lift", "Store"] },
|
|
192
|
+
];
|
|
193
|
+
const plan = normalisePatrolPlan(padbotPatrolPlan(paths, maps, {}));
|
|
194
|
+
assert.deepEqual(plan.routes.map((r) => [r.name, r.mapId, r.floorNo]), [["B1 (default)", "mB1", -1], ["Patrolling Lvl3", "mL3", 3]]);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test("go to point on another map: only inside one map group, else 'The robot must be on this map first.'", async () => {
|
|
198
|
+
assert.equal(padbotCanReachMap([], "m1", "m1"), true);
|
|
199
|
+
assert.equal(padbotCanReachMap([{ mapId: "m1", mapGroup: "" }, { mapId: "m2", mapGroup: "" }], "m1", "m2"), false);
|
|
200
|
+
assert.equal(padbotCanReachMap([{ mapId: "m1", mapGroup: "tower" }, { mapId: "m2", mapGroup: "tower" }], "m1", "m2"), true);
|
|
201
|
+
assert.equal(padbotCanReachMap([{ mapId: "m1", mapGroup: "a" }, { mapId: "m2", mapGroup: "b" }], "m1", "m2"), false);
|
|
202
|
+
assert.equal(padbotCanReachMap([], null, "m1"), false, "unknown current map: refused, never guessed");
|
|
203
|
+
|
|
204
|
+
clearPadbotCache();
|
|
205
|
+
const f = fake({
|
|
206
|
+
[PADBOT_PATHS.states]: () => [{ serialNumber: "PS8517", states: [{ stateType: "1007", data: { mapId: "m1" } }] }],
|
|
207
|
+
[PADBOT_PATHS.maps]: () => [{ mapId: "m1", mapGroup: "" }, { mapId: "m2", mapGroup: "" }],
|
|
208
|
+
[PADBOT_PATHS.navigateTarget]: () => null,
|
|
209
|
+
});
|
|
210
|
+
const a = createPadbotAdapter(CREDS, { baseUrl: "https://pb.test", fetch: f.fetch, now: () => NOW });
|
|
211
|
+
await assert.rejects(a.sendCommand("PS8517", { kind: "go-to-point", mapId: "m2", targetPointId: "t9" }), (e) => e.message === PADBOT_OTHER_MAP_TEXT);
|
|
212
|
+
assert.ok(!f.calls.some((c) => c.path === PADBOT_PATHS.navigateTarget), "nothing sent to the robot");
|
|
213
|
+
await a.sendCommand("PS8517", { kind: "go-to-point", mapId: "m1", targetPointId: "t1" });
|
|
214
|
+
assert.equal(f.calls.at(-1).path, PADBOT_PATHS.navigateTarget);
|
|
215
|
+
});
|
|
@@ -73,14 +73,15 @@ test("missing credentials throw instead of signing an empty secret", () => {
|
|
|
73
73
|
assert.throws(() => robotCloudSign("a", "20250520200000", "/p", ""), /secret/);
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
test("the timestamp is yyyyMMddHHmmss, zero-padded", () => {
|
|
76
|
+
test("the timestamp is yyyyMMddHHmmss, zero-padded, Shanghai wall clock", () => {
|
|
77
|
+
// 20:00 UTC is 04:00 the next day in Shanghai (UTC+8).
|
|
77
78
|
assert.equal(
|
|
78
79
|
robotCloudTimestamp(new Date(Date.UTC(2025, 4, 20, 20, 0, 0))),
|
|
79
|
-
"
|
|
80
|
+
"20250521040000"
|
|
80
81
|
);
|
|
81
82
|
// Single-digit month, day, hour, minute and second all pad.
|
|
82
83
|
assert.equal(
|
|
83
|
-
robotCloudTimestamp(new Date(Date.UTC(2025, 0, 2, 3, 4, 5))),
|
|
84
|
+
robotCloudTimestamp(new Date(Date.UTC(2025, 0, 2, 3, 4, 5)), "yyyyMMddHHmmss", "UTC"),
|
|
84
85
|
"20250102030405"
|
|
85
86
|
);
|
|
86
87
|
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Capabilities per brand AND model: brand defaults + the model's differences;
|
|
2
|
+
// an unknown model gets the brand's defaults, an unknown brand gets nothing.
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { test } from "node:test";
|
|
5
|
+
|
|
6
|
+
import { commandSupported, registerRobotBrand, registeredRobotBrands, robotManifest, robotTier } from "./.build/utils/robot-adapter.util.mjs";
|
|
7
|
+
import { PADBOT_BRAND_DEFINITION } from "./.build/services/padbot.adapter.mjs";
|
|
8
|
+
import { OUNITECH_BRAND_DEFINITION } from "./.build/services/ounitech.adapter.mjs";
|
|
9
|
+
import { DEMO_BRAND_DEFINITION } from "./.build/services/demo.adapter.mjs";
|
|
10
|
+
|
|
11
|
+
// Each test bundle carries its own registry: register the adapters' exact definitions here.
|
|
12
|
+
for (const b of [PADBOT_BRAND_DEFINITION, OUNITECH_BRAND_DEFINITION, DEMO_BRAND_DEFINITION]) registerRobotBrand(b);
|
|
13
|
+
|
|
14
|
+
test("PadBot S2: the full security set, heat camera, S2 alarms and maker-app list", () => {
|
|
15
|
+
for (const reported of ["PadBot S2", "S2", "padbot s2", " PADBOT-S2 "]) {
|
|
16
|
+
const m = robotManifest("padbot", reported);
|
|
17
|
+
assert.equal(m.profile.model, "PadBot S2", reported);
|
|
18
|
+
assert.equal(m.profile.modelKnown, true, reported);
|
|
19
|
+
}
|
|
20
|
+
const { capabilities: c, profile } = robotManifest("padbot", "PadBot S2");
|
|
21
|
+
for (const k of ["patrolControl", "liveVideo", "patrolHistory", "resolveAlerts", "battery", "floorReporting", "readLocation", "sendToDock", "relocalize", "navigateToPoint", "thermalCamera"]) {
|
|
22
|
+
assert.equal(c[k], true, k);
|
|
23
|
+
}
|
|
24
|
+
for (const k of ["pauseResume", "spotClean", "multiFloor", "pathAndEta"]) assert.equal(c[k], false, k);
|
|
25
|
+
assert.equal(commandSupported(c, "pause"), false, "PadBot has no pause");
|
|
26
|
+
assert.equal(commandSupported(c, "cancel"), true);
|
|
27
|
+
assert.ok(profile.alarms.includes("smoke") && profile.alarms.includes("high temperature"));
|
|
28
|
+
assert.equal(profile.makerApp, "the PadBot app");
|
|
29
|
+
assert.ok(profile.makerAppOnly.includes("patrol schedules"));
|
|
30
|
+
assert.equal(Object.getOwnPropertyDescriptor(c, "manualDrive").get, undefined, "a plain object, getters read");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("PadBot unknown model: the brand defaults (API-wide), no S2 extras", () => {
|
|
34
|
+
const { capabilities: c, profile } = robotManifest("padbot", "PadBot P3");
|
|
35
|
+
assert.equal(profile.modelKnown, false);
|
|
36
|
+
assert.equal(profile.model, "PadBot P3", "the reported name is kept");
|
|
37
|
+
assert.equal(c.patrolControl, true);
|
|
38
|
+
assert.equal(c.thermalCamera, false);
|
|
39
|
+
assert.equal(c.manualDrive, false);
|
|
40
|
+
assert.equal(profile.makerAppOnly.includes("live thermal view"), false, "heat camera is the S2's");
|
|
41
|
+
assert.ok(robotManifest("padbot", "S2").profile.makerAppOnly.includes("live thermal view"));
|
|
42
|
+
assert.equal(robotManifest("padbot").profile.model, "");
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("Ounitech: no model reported, one manifest for Q3-G and Q3-W; Basic control", () => {
|
|
46
|
+
const { capabilities: c, profile } = robotManifest("ounitech", "");
|
|
47
|
+
assert.equal(profile.modelKnown, false);
|
|
48
|
+
assert.equal(c.startProcess, true);
|
|
49
|
+
assert.equal(c.sendToDock, true);
|
|
50
|
+
for (const k of ["battery", "floorReporting", "pauseResume", "pauseProcess", "spotClean", "liveVideo", "patrolControl"]) assert.notEqual(c[k], true, k);
|
|
51
|
+
assert.equal(profile.makerApp, "the Ounitech app");
|
|
52
|
+
assert.deepEqual(profile.alarms, []);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("Demo: models differ - S1 full, CX-1 no point commands, SP-1 no spot clean", () => {
|
|
56
|
+
const s1 = robotManifest("demo", "Demo S1").capabilities;
|
|
57
|
+
const cx = robotManifest("demo", "Demo CX-1");
|
|
58
|
+
const sp = robotManifest("demo", "Demo SP-1").capabilities;
|
|
59
|
+
assert.equal(robotTier(s1), "full-control");
|
|
60
|
+
assert.equal(s1.spotClean, true);
|
|
61
|
+
assert.equal(cx.profile.modelKnown, true);
|
|
62
|
+
assert.equal(cx.capabilities.navigateToPoint, false);
|
|
63
|
+
assert.equal(commandSupported(cx.capabilities, "relocalize"), false);
|
|
64
|
+
assert.equal(commandSupported(cx.capabilities, "full"), true);
|
|
65
|
+
assert.equal(sp.spotClean, false);
|
|
66
|
+
assert.equal(sp.navigateToPoint, true);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("unknown brand: nothing claimed", () => {
|
|
70
|
+
const m = robotManifest("acme", "Z9");
|
|
71
|
+
assert.deepEqual(m.capabilities, {});
|
|
72
|
+
assert.equal(m.profile.model, "Z9");
|
|
73
|
+
assert.equal(m.profile.modelKnown, false);
|
|
74
|
+
assert.equal(robotManifest(undefined).profile.model, "");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("brand list carries each model's resolved manifest", () => {
|
|
78
|
+
const padbot = registeredRobotBrands().find((b) => b.brand === "padbot");
|
|
79
|
+
assert.deepEqual(padbot.models.map((m) => m.name), ["PadBot S2"]);
|
|
80
|
+
assert.equal(padbot.models[0].capabilities.thermalCamera, true);
|
|
81
|
+
assert.equal(padbot.capabilities.thermalCamera, false);
|
|
82
|
+
const demo = registeredRobotBrands().find((b) => b.brand === "demo");
|
|
83
|
+
assert.deepEqual(demo.models.map((m) => m.name), ["Demo CX-1", "Demo SP-1"]);
|
|
84
|
+
});
|