@7365admin1/core 3.99.1-staging.394 → 3.99.1-staging.395

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.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Robots: a still-open OFFLINE ("Not reporting") record now takes the reason of the latest failed read instead of keeping the first one forever (same record, same `since`, no second alert). Tests prove the Ounitech base URL defaults to https://app.frankfurt.robotcloud.top with OUNITECH_API_BASE / ROBOT_CLOUD_BASE_URL unset or blank, and that an empty base URL is a handled 502.
package/dist/index.d.ts CHANGED
@@ -10564,6 +10564,7 @@ declare function useRobotFaultRepo(): {
10564
10564
  findNotifiedOccurrence: (robotId: unknown, code: string, since: Date | null, after: Date) => Promise<mongodb.WithId<TRobotFaultRecord> | null>;
10565
10565
  markNotified: (id: unknown, at: Date) => Promise<void>;
10566
10566
  clearFault: (id: unknown) => Promise<void>;
10567
+ setFaultMessage: (id: unknown, message: string) => Promise<void>;
10567
10568
  listNetworkFaults: (q: TNetworkFaultQuery) => Promise<{
10568
10569
  items: any;
10569
10570
  page: number;
package/dist/index.js CHANGED
@@ -10994,12 +10994,16 @@ function planFaultChanges(open, reading) {
10994
10994
  want.push({ code: fault.code, message: fault.message || fault.code, since: fault.since });
10995
10995
  const clear = [];
10996
10996
  const toOpen = [];
10997
+ const refresh = [];
10997
10998
  for (const w of want) {
10998
10999
  const existing = byCode.get(w.code);
10999
11000
  if (!existing) {
11000
11001
  toOpen.push(w);
11001
11002
  continue;
11002
11003
  }
11004
+ if (w.code === OFFLINE_FAULT_CODE && typeof existing.message === "string" && existing.message !== w.message) {
11005
+ refresh.push({ id: existing._id, message: w.message });
11006
+ }
11003
11007
  const newOccurrence = typeof w.since === "number" && Math.abs(new Date(existing.since).getTime() - w.since) > SAME_OCCURRENCE_MS;
11004
11008
  if (newOccurrence) {
11005
11009
  clear.push(existing._id);
@@ -11014,7 +11018,7 @@ function planFaultChanges(open, reading) {
11014
11018
  continue;
11015
11019
  clear.push(r._id);
11016
11020
  }
11017
- return { open: toOpen, clear };
11021
+ return { open: toOpen, clear, refresh };
11018
11022
  }
11019
11023
  function robotFaultSweepConfig(env2 = process.env) {
11020
11024
  const num3 = (v, def, min, max) => {
@@ -68911,7 +68915,7 @@ function useRobotFaultRepo() {
68911
68915
  }
68912
68916
  }
68913
68917
  async function getOpenFaults() {
68914
- return collection.find({ clearedAt: null }, { projection: { robotId: 1, code: 1, since: 1 } }).toArray();
68918
+ return collection.find({ clearedAt: null }, { projection: { robotId: 1, code: 1, since: 1, message: 1 } }).toArray();
68915
68919
  }
68916
68920
  async function getOpenFault(robotId, code) {
68917
68921
  return collection.findOne({ robotId: toId3(robotId), code, clearedAt: null });
@@ -68972,6 +68976,9 @@ function useRobotFaultRepo() {
68972
68976
  async function markNotified(id, at2) {
68973
68977
  await collection.updateOne({ _id: toId3(id), notifiedAt: null }, { $set: { notifiedAt: at2 } });
68974
68978
  }
68979
+ async function setFaultMessage(id, message) {
68980
+ await collection.updateOne({ _id: toId3(id), clearedAt: null }, { $set: { message } });
68981
+ }
68975
68982
  async function clearFault(id) {
68976
68983
  await collection.updateOne(
68977
68984
  { _id: toId3(id), clearedAt: null },
@@ -69001,6 +69008,7 @@ function useRobotFaultRepo() {
69001
69008
  findNotifiedOccurrence,
69002
69009
  markNotified,
69003
69010
  clearFault,
69011
+ setFaultMessage,
69004
69012
  listNetworkFaults,
69005
69013
  countNetworkFaults
69006
69014
  };
@@ -69155,6 +69163,8 @@ function useRobotFaultSweep(deps) {
69155
69163
  await repo.clearFault(id);
69156
69164
  out.cleared++;
69157
69165
  }
69166
+ for (const r of plan.refresh)
69167
+ await repo.setFaultMessage(r.id, r.message);
69158
69168
  if (offlineRec) {
69159
69169
  const online = plan.clear.includes(offlineRec._id);
69160
69170
  if (await alertConnection(robot, offlineRec._id, online, cfg.offlineAlertMinutes, deps?.connectionNotifyFn))