@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/dist/index.mjs CHANGED
@@ -9970,12 +9970,16 @@ function planFaultChanges(open, reading) {
9970
9970
  want.push({ code: fault.code, message: fault.message || fault.code, since: fault.since });
9971
9971
  const clear = [];
9972
9972
  const toOpen = [];
9973
+ const refresh = [];
9973
9974
  for (const w of want) {
9974
9975
  const existing = byCode.get(w.code);
9975
9976
  if (!existing) {
9976
9977
  toOpen.push(w);
9977
9978
  continue;
9978
9979
  }
9980
+ if (w.code === OFFLINE_FAULT_CODE && typeof existing.message === "string" && existing.message !== w.message) {
9981
+ refresh.push({ id: existing._id, message: w.message });
9982
+ }
9979
9983
  const newOccurrence = typeof w.since === "number" && Math.abs(new Date(existing.since).getTime() - w.since) > SAME_OCCURRENCE_MS;
9980
9984
  if (newOccurrence) {
9981
9985
  clear.push(existing._id);
@@ -9990,7 +9994,7 @@ function planFaultChanges(open, reading) {
9990
9994
  continue;
9991
9995
  clear.push(r._id);
9992
9996
  }
9993
- return { open: toOpen, clear };
9997
+ return { open: toOpen, clear, refresh };
9994
9998
  }
9995
9999
  function robotFaultSweepConfig(env2 = process.env) {
9996
10000
  const num3 = (v, def, min, max) => {
@@ -66667,7 +66671,7 @@ function useRobotFaultRepo() {
66667
66671
  }
66668
66672
  }
66669
66673
  async function getOpenFaults() {
66670
- return collection.find({ clearedAt: null }, { projection: { robotId: 1, code: 1, since: 1 } }).toArray();
66674
+ return collection.find({ clearedAt: null }, { projection: { robotId: 1, code: 1, since: 1, message: 1 } }).toArray();
66671
66675
  }
66672
66676
  async function getOpenFault(robotId, code) {
66673
66677
  return collection.findOne({ robotId: toId3(robotId), code, clearedAt: null });
@@ -66728,6 +66732,9 @@ function useRobotFaultRepo() {
66728
66732
  async function markNotified(id, at2) {
66729
66733
  await collection.updateOne({ _id: toId3(id), notifiedAt: null }, { $set: { notifiedAt: at2 } });
66730
66734
  }
66735
+ async function setFaultMessage(id, message) {
66736
+ await collection.updateOne({ _id: toId3(id), clearedAt: null }, { $set: { message } });
66737
+ }
66731
66738
  async function clearFault(id) {
66732
66739
  await collection.updateOne(
66733
66740
  { _id: toId3(id), clearedAt: null },
@@ -66757,6 +66764,7 @@ function useRobotFaultRepo() {
66757
66764
  findNotifiedOccurrence,
66758
66765
  markNotified,
66759
66766
  clearFault,
66767
+ setFaultMessage,
66760
66768
  listNetworkFaults,
66761
66769
  countNetworkFaults
66762
66770
  };
@@ -66911,6 +66919,8 @@ function useRobotFaultSweep(deps) {
66911
66919
  await repo.clearFault(id);
66912
66920
  out.cleared++;
66913
66921
  }
66922
+ for (const r of plan.refresh)
66923
+ await repo.setFaultMessage(r.id, r.message);
66914
66924
  if (offlineRec) {
66915
66925
  const online = plan.clear.includes(offlineRec._id);
66916
66926
  if (await alertConnection(robot, offlineRec._id, online, cfg.offlineAlertMinutes, deps?.connectionNotifyFn))