@7365admin1/core 3.117.0 → 3.117.1
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.d.ts +1 -0
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/padbot.test.mjs +2 -2
- package/test/robot-fault.test.mjs +26 -5
- package/test/robot-vendor-errors.test.mjs +34 -0
package/package.json
CHANGED
package/test/padbot.test.mjs
CHANGED
|
@@ -282,13 +282,13 @@ test("alarm dedupe: the same alarm on every read opens once; a new occurrence re
|
|
|
282
282
|
assert.equal(first.open.length, 1);
|
|
283
283
|
const rec = { _id: "r1", code: f.code, since: new Date(f.since) };
|
|
284
284
|
const again = planFaultChanges([rec], { ok: true, online: true, fault: padbotAlarmFault(alarm) });
|
|
285
|
-
assert.deepEqual(again, { open: [], clear: [] });
|
|
285
|
+
assert.deepEqual(again, { open: [], clear: [], refresh: [] });
|
|
286
286
|
const later = padbotAlarmFault({ alarmType: "3", occurredAt: "2026-07-25T09:04:17.010Z" });
|
|
287
287
|
const second = planFaultChanges([rec], { ok: true, online: true, fault: later });
|
|
288
288
|
assert.deepEqual(second.clear, ["r1"]);
|
|
289
289
|
assert.equal(second.open.length, 1);
|
|
290
290
|
const resolved = planFaultChanges([rec], { ok: true, online: true, fault: null });
|
|
291
|
-
assert.deepEqual(resolved, { open: [], clear: ["r1"] });
|
|
291
|
+
assert.deepEqual(resolved, { open: [], clear: ["r1"], refresh: [] });
|
|
292
292
|
});
|
|
293
293
|
|
|
294
294
|
/* ------------------------------------------------------ patrol */
|
|
@@ -50,14 +50,14 @@ const rec = (code, since = 1000, _id = code) => ({ _id, code, since: new Date(si
|
|
|
50
50
|
|
|
51
51
|
test("plan: a new fault opens; the same fault on every read changes nothing", () => {
|
|
52
52
|
const fault = { code: "JAM", message: "Brush jammed", since: 1000 };
|
|
53
|
-
assert.deepEqual(planFaultChanges([], { ok: true, online: true, fault }), { open: [fault], clear: [] });
|
|
54
|
-
assert.deepEqual(planFaultChanges([rec("JAM")], { ok: true, online: true, fault }), { open: [], clear: [] });
|
|
53
|
+
assert.deepEqual(planFaultChanges([], { ok: true, online: true, fault }), { open: [fault], clear: [], refresh: [] });
|
|
54
|
+
assert.deepEqual(planFaultChanges([rec("JAM")], { ok: true, online: true, fault }), { open: [], clear: [], refresh: [] });
|
|
55
55
|
// a brand that cannot say when it started: the open record stands
|
|
56
|
-
assert.deepEqual(planFaultChanges([rec("JAM")], { ok: true, online: true, fault: { code: "JAM" } }), { open: [], clear: [] });
|
|
56
|
+
assert.deepEqual(planFaultChanges([rec("JAM")], { ok: true, online: true, fault: { code: "JAM" } }), { open: [], clear: [], refresh: [] });
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
test("plan: a fault that goes away is cleared; coming back later is a new occurrence", () => {
|
|
60
|
-
assert.deepEqual(planFaultChanges([rec("JAM")], { ok: true, online: true, fault: null }), { open: [], clear: ["JAM"] });
|
|
60
|
+
assert.deepEqual(planFaultChanges([rec("JAM")], { ok: true, online: true, fault: null }), { open: [], clear: ["JAM"], refresh: [] });
|
|
61
61
|
const again = planFaultChanges([rec("JAM", 1000)], { ok: true, online: true, fault: { code: "JAM", message: "m", since: 90000 } });
|
|
62
62
|
assert.deepEqual(again.clear, ["JAM"]);
|
|
63
63
|
assert.equal(again.open[0].code, "JAM");
|
|
@@ -74,7 +74,7 @@ test("plan: offline / not reporting is an OFFLINE record; a failed read cannot c
|
|
|
74
74
|
const back = planFaultChanges([rec(OFFLINE_FAULT_CODE), rec("JAM")], { ok: true, online: true, fault: null });
|
|
75
75
|
assert.deepEqual(back.clear.sort(), ["JAM", OFFLINE_FAULT_CODE].sort());
|
|
76
76
|
// still offline: nothing new
|
|
77
|
-
assert.deepEqual(planFaultChanges([rec(OFFLINE_FAULT_CODE)], { ok: true, online: false }), { open: [], clear: [] });
|
|
77
|
+
assert.deepEqual(planFaultChanges([rec(OFFLINE_FAULT_CODE)], { ok: true, online: false }), { open: [], clear: [], refresh: [] });
|
|
78
78
|
// going offline does NOT clear the robot's own fault (it would re-notify on return)
|
|
79
79
|
const wentOff = planFaultChanges([rec("JAM")], { ok: true, online: false, fault: null });
|
|
80
80
|
assert.deepEqual(wentOff.clear, []);
|
|
@@ -117,3 +117,24 @@ test("bounded: never more than the limit in flight, one failure does not stop th
|
|
|
117
117
|
await assert.rejects(withTimeout(new Promise(() => {}), 20, "slow"), /slow after 20 ms/);
|
|
118
118
|
assert.equal(await withTimeout(Promise.resolve(7), 20), 7);
|
|
119
119
|
});
|
|
120
|
+
|
|
121
|
+
test("plan: a still-open OFFLINE record takes the LATEST failed read's reason, without re-opening", () => {
|
|
122
|
+
// HERO-OTH: the record opened with "ROBOT_CLOUD_BASE_URL is not configured"
|
|
123
|
+
// and kept saying so after the base URL was fixed and the robot failed for a
|
|
124
|
+
// different reason.
|
|
125
|
+
const stale = { ...rec(OFFLINE_FAULT_CODE), message: "Not reporting: Robot cloud: ROBOT_CLOUD_BASE_URL is not configured." };
|
|
126
|
+
const plan = planFaultChanges([stale], { ok: false, error: "Ounitech rejected the robot list (sign-in) (sign error)." });
|
|
127
|
+
assert.deepEqual(plan.open, [], "no second record, so no second alert and the same since");
|
|
128
|
+
assert.deepEqual(plan.clear, []);
|
|
129
|
+
assert.deepEqual(plan.refresh, [
|
|
130
|
+
{ id: OFFLINE_FAULT_CODE, message: "Not reporting: Ounitech rejected the robot list (sign-in) (sign error)." },
|
|
131
|
+
]);
|
|
132
|
+
|
|
133
|
+
// Same reason: nothing to rewrite. A record read without its message: nothing either.
|
|
134
|
+
const same = { ...stale, message: plan.refresh[0].message };
|
|
135
|
+
assert.deepEqual(planFaultChanges([same], { ok: false, error: "Ounitech rejected the robot list (sign-in) (sign error)." }).refresh, []);
|
|
136
|
+
assert.deepEqual(planFaultChanges([rec(OFFLINE_FAULT_CODE)], { ok: false, error: "x" }).refresh, []);
|
|
137
|
+
// A machine fault's message is the robot's own and is never rewritten here.
|
|
138
|
+
const jam = { ...rec("JAM"), message: "old" };
|
|
139
|
+
assert.deepEqual(planFaultChanges([jam], { ok: true, online: true, fault: { code: "JAM", message: "new", since: 1000 } }).refresh, []);
|
|
140
|
+
});
|
|
@@ -287,3 +287,37 @@ test("diagnose: an unknown brand is named, not thrown", async () => {
|
|
|
287
287
|
const d = await fleetFor("ok").diagnose(robotRow({ brand: "nobody" }));
|
|
288
288
|
assert.equal(d.failedStep, "brand");
|
|
289
289
|
});
|
|
290
|
+
|
|
291
|
+
/* ------------------------------------------- base URL with the env unset */
|
|
292
|
+
|
|
293
|
+
import { execFileSync } from "node:child_process";
|
|
294
|
+
|
|
295
|
+
test("with OUNITECH_API_BASE and ROBOT_CLOUD_BASE_URL unset (or blank), the Ounitech host is the default and nothing throws", () => {
|
|
296
|
+
const script = `
|
|
297
|
+
const { ROBOT_CLOUD_BASE_URL } = await import("./test/.build/config.mjs");
|
|
298
|
+
const { useRobotCloudService } = await import("./test/.build/services/robot-cloud.service.mjs");
|
|
299
|
+
useRobotCloudService({ appid: "a", secret: "s" }); // threw "not configured" when the base was empty
|
|
300
|
+
console.log(ROBOT_CLOUD_BASE_URL);`;
|
|
301
|
+
for (const extra of [{}, { OUNITECH_API_BASE: "", ROBOT_CLOUD_BASE_URL: "" }]) {
|
|
302
|
+
const env = { ...process.env, ...extra };
|
|
303
|
+
if (!("OUNITECH_API_BASE" in extra)) {
|
|
304
|
+
delete env.OUNITECH_API_BASE;
|
|
305
|
+
delete env.ROBOT_CLOUD_BASE_URL;
|
|
306
|
+
}
|
|
307
|
+
const out = execFileSync(process.execPath, ["--input-type=module", "-e", script], { env, encoding: "utf8" }).trim();
|
|
308
|
+
assert.equal(out.split("\n").pop(), "https://app.frankfurt.robotcloud.top", JSON.stringify(extra));
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
test("a missing base URL (only reachable by passing an empty one) is a handled 502, never a 500", () => {
|
|
313
|
+
let e;
|
|
314
|
+
try {
|
|
315
|
+
useRobotCloudService(CREDS, { baseUrl: "" });
|
|
316
|
+
} catch (err) {
|
|
317
|
+
e = err;
|
|
318
|
+
}
|
|
319
|
+
assert.ok(e instanceof RobotCloudError);
|
|
320
|
+
const answer = apiAnswer(e);
|
|
321
|
+
assert.equal(answer.status, 502);
|
|
322
|
+
assert.match(answer.body.message, /not configured/);
|
|
323
|
+
});
|