@7365admin1/core 3.131.1 → 3.133.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/dist/index.js CHANGED
@@ -424,6 +424,7 @@ __export(src_exports, {
424
424
  claimReadsAsStale: () => claimReadsAsStale,
425
425
  clampChassis: () => clampChassis,
426
426
  clampPtzSpeed: () => clampPtzSpeed,
427
+ clearOunitechCaches: () => clearOunitechCaches,
427
428
  clearPadbotCache: () => clearPadbotCache,
428
429
  clearRobotBrands: () => clearRobotBrands,
429
430
  clockDriftSeconds: () => clockDriftSeconds,
@@ -617,9 +618,19 @@ __export(src_exports, {
617
618
  orgQualifiesForOwnerRepair: () => orgQualifiesForOwnerRepair,
618
619
  orgRoleSets: () => orgRoleSets,
619
620
  orgSchema: () => orgSchema,
621
+ ounitechAlertRecord: () => ounitechAlertRecord,
622
+ ounitechCleaning: () => ounitechCleaning,
623
+ ounitechConsumable: () => ounitechConsumable,
624
+ ounitechCurrentMap: () => ounitechCurrentMap,
620
625
  ounitechFault: () => ounitechFault,
621
626
  ounitechJobWords: () => ounitechJobWords,
627
+ ounitechMapShare: () => ounitechMapShare,
628
+ ounitechMapView: () => ounitechMapView,
629
+ ounitechPowerPlan: () => ounitechPowerPlan,
630
+ ounitechReadings: () => ounitechReadings,
622
631
  ounitechRobotFromHomeRow: () => ounitechRobotFromHomeRow,
632
+ ounitechTaskRecord: () => ounitechTaskRecord,
633
+ ounitechTime: () => ounitechTime,
623
634
  overnight_parking_requests_namespace_collection: () => overnight_parking_requests_namespace_collection,
624
635
  padbotAccountKey: () => padbotAccountKey,
625
636
  padbotAlarmFault: () => padbotAlarmFault,
@@ -672,6 +683,7 @@ __export(src_exports, {
672
683
  platform_terms_namespace_collection: () => platform_terms_namespace_collection,
673
684
  playbackRelays: () => playbackRelays,
674
685
  playbackWindowRefusal: () => playbackWindowRefusal,
686
+ pngSize: () => pngSize,
675
687
  promoCodeRefusal: () => promoCodeRefusal,
676
688
  promoCodeSchema: () => promoCodeSchema,
677
689
  promoCodeStatusSchema: () => promoCodeStatusSchema,
@@ -3387,10 +3399,10 @@ function useOccurrenceEntryRepo() {
3387
3399
  const cacheKey = (0, import_node_server_utils10.makeCacheKey)(namespace_collection3, {
3388
3400
  dailyOccurrenceBookId
3389
3401
  });
3390
- const cached3 = await getCache(cacheKey);
3391
- if (cached3) {
3402
+ const cached4 = await getCache(cacheKey);
3403
+ if (cached4) {
3392
3404
  import_node_server_utils10.logger.info(`Cache hit for key: ${cacheKey}`);
3393
- return cached3;
3405
+ return cached4;
3394
3406
  }
3395
3407
  const bookId = typeof dailyOccurrenceBookId === "string" ? new import_mongodb9.ObjectId(dailyOccurrenceBookId) : dailyOccurrenceBookId;
3396
3408
  const data = await collection.findOne(
@@ -18938,13 +18950,13 @@ function useFileRepo() {
18938
18950
  }
18939
18951
  const cacheKey = (0, import_node_server_utils51.makeCacheKey)(namespace_collection3, { _id: String(_id) });
18940
18952
  try {
18941
- const cached3 = await getCache(cacheKey);
18942
- if (cached3) {
18953
+ const cached4 = await getCache(cacheKey);
18954
+ if (cached4) {
18943
18955
  import_node_server_utils51.logger.log({
18944
18956
  level: "info",
18945
18957
  message: `Cache hit for getById file: ${cacheKey}`
18946
18958
  });
18947
- return cached3;
18959
+ return cached4;
18948
18960
  }
18949
18961
  const result = await collection.findOne({
18950
18962
  _id
@@ -23040,9 +23052,9 @@ function useCameraViewService() {
23040
23052
  async function refreshProbe(target, channel) {
23041
23053
  if (!target?.enabled)
23042
23054
  return null;
23043
- const cached3 = await cachedProbe(target, channel);
23044
- if (cached3)
23045
- return cached3;
23055
+ const cached4 = await cachedProbe(target, channel);
23056
+ if (cached4)
23057
+ return cached4;
23046
23058
  const probe = await probeDeviceCapabilities({
23047
23059
  adapter: createDeviceHttpAdapter({ target, budget: authBudget }),
23048
23060
  channel
@@ -23413,9 +23425,9 @@ function useCameraViewService() {
23413
23425
  };
23414
23426
  }
23415
23427
  const cacheKey = `device:${resolved.device.host}:${resolved.device.port}`;
23416
- const cached3 = await getCache(cacheKey);
23417
- const reachable = typeof cached3 === "boolean" ? cached3 : await probeDevice(resolved.device);
23418
- if (typeof cached3 !== "boolean") {
23428
+ const cached4 = await getCache(cacheKey);
23429
+ const reachable = typeof cached4 === "boolean" ? cached4 : await probeDevice(resolved.device);
23430
+ if (typeof cached4 !== "boolean") {
23419
23431
  setCache(cacheKey, reachable, cacheSeconds).catch(
23420
23432
  (error) => import_node_server_utils56.logger.info(`Camera device health cache write failed: ${error?.message}`)
23421
23433
  );
@@ -23448,10 +23460,10 @@ function useCameraViewService() {
23448
23460
  const subtype = knownNoSubStream ? 0 : wanted;
23449
23461
  const fellBackFromCache = subtype !== wanted;
23450
23462
  const cacheKey = `snapshot:${params.cameraId}:${subtype}`;
23451
- const cached3 = await getCache(cacheKey);
23452
- if (cached3) {
23463
+ const cached4 = await getCache(cacheKey);
23464
+ if (cached4) {
23453
23465
  return {
23454
- buffer: Buffer.from(cached3, "base64"),
23466
+ buffer: Buffer.from(cached4, "base64"),
23455
23467
  cached: true,
23456
23468
  stream: subtype === 0 ? "main" : "sub",
23457
23469
  fellBackToMain: fellBackFromCache
@@ -23541,9 +23553,9 @@ function useCameraViewService() {
23541
23553
  };
23542
23554
  }
23543
23555
  const cacheKey = `device:${resolved.device.host}:${resolved.device.port}`;
23544
- const cached3 = await getCache(cacheKey);
23545
- const reachable = typeof cached3 === "boolean" ? cached3 : await probeDevice(resolved.device);
23546
- if (typeof cached3 !== "boolean") {
23556
+ const cached4 = await getCache(cacheKey);
23557
+ const reachable = typeof cached4 === "boolean" ? cached4 : await probeDevice(resolved.device);
23558
+ if (typeof cached4 !== "boolean") {
23547
23559
  setCache(cacheKey, reachable, DEVICE_HEALTH_CACHE_SECONDS).catch(
23548
23560
  (error) => import_node_server_utils56.logger.info(`Camera device health cache write failed: ${error?.message}`)
23549
23561
  );
@@ -26787,13 +26799,13 @@ function usePersonRepo() {
26787
26799
  _id: String(_id)
26788
26800
  });
26789
26801
  try {
26790
- const cached3 = await getCache(cacheKey);
26791
- if (cached3) {
26802
+ const cached4 = await getCache(cacheKey);
26803
+ if (cached4) {
26792
26804
  import_node_server_utils64.logger.log({
26793
26805
  level: "info",
26794
26806
  message: `Cache hit for getById person: ${cacheKey}`
26795
26807
  });
26796
- return cached3;
26808
+ return cached4;
26797
26809
  }
26798
26810
  const result = await collection.findOne({
26799
26811
  _id
@@ -27219,13 +27231,13 @@ function usePersonRepo() {
27219
27231
  user: userId
27220
27232
  });
27221
27233
  try {
27222
- const cached3 = await getCache(cacheKey);
27223
- if (cached3) {
27234
+ const cached4 = await getCache(cacheKey);
27235
+ if (cached4) {
27224
27236
  import_node_server_utils64.logger.log({
27225
27237
  level: "info",
27226
27238
  message: `Cache hit for getByUserId person: ${cacheKey}`
27227
27239
  });
27228
- return cached3;
27240
+ return cached4;
27229
27241
  }
27230
27242
  const result = await collection.findOne({
27231
27243
  user
@@ -37772,13 +37784,13 @@ function useBuildingUnitRepo() {
37772
37784
  message: `Cache key for getAll building units: ${cacheKey}`
37773
37785
  });
37774
37786
  try {
37775
- const cached3 = await getCache(cacheKey);
37776
- if (cached3) {
37787
+ const cached4 = await getCache(cacheKey);
37788
+ if (cached4) {
37777
37789
  import_node_server_utils113.logger.log({
37778
37790
  level: "info",
37779
37791
  message: `Cache hit for getAll building units: ${cacheKey}`
37780
37792
  });
37781
- return cached3;
37793
+ return cached4;
37782
37794
  }
37783
37795
  const pipeline = [
37784
37796
  { $match: query2 },
@@ -37913,13 +37925,13 @@ function useBuildingUnitRepo() {
37913
37925
  message: `Cache key for getAll building units: ${cacheKey}`
37914
37926
  });
37915
37927
  try {
37916
- const cached3 = await getCache(cacheKey);
37917
- if (cached3) {
37928
+ const cached4 = await getCache(cacheKey);
37929
+ if (cached4) {
37918
37930
  import_node_server_utils113.logger.log({
37919
37931
  level: "info",
37920
37932
  message: `Cache hit for getAll building units: ${cacheKey}`
37921
37933
  });
37922
- return cached3;
37934
+ return cached4;
37923
37935
  }
37924
37936
  const items = await collection.aggregate(
37925
37937
  [
@@ -38008,13 +38020,13 @@ function useBuildingUnitRepo() {
38008
38020
  level: level2
38009
38021
  });
38010
38022
  try {
38011
- const cached3 = await getCache(cacheKey);
38012
- if (cached3) {
38023
+ const cached4 = await getCache(cacheKey);
38024
+ if (cached4) {
38013
38025
  import_node_server_utils113.logger.log({
38014
38026
  level: "info",
38015
38027
  message: `Cache hit for getById building unit: ${cacheKey}`
38016
38028
  });
38017
- return cached3;
38029
+ return cached4;
38018
38030
  }
38019
38031
  const result = await collection.findOne({
38020
38032
  building,
@@ -38081,13 +38093,13 @@ function useBuildingUnitRepo() {
38081
38093
  building: String(building)
38082
38094
  });
38083
38095
  try {
38084
- const cached3 = await getCache(cacheKey);
38085
- if (cached3) {
38096
+ const cached4 = await getCache(cacheKey);
38097
+ if (cached4) {
38086
38098
  import_node_server_utils113.logger.log({
38087
38099
  level: "info",
38088
38100
  message: `Cache hit for getById building unit: ${cacheKey}`
38089
38101
  });
38090
- return cached3;
38102
+ return cached4;
38091
38103
  }
38092
38104
  const result = await collection.findOne({
38093
38105
  building,
@@ -38293,13 +38305,13 @@ function useBuildingUnitRepo() {
38293
38305
  cacheOptions
38294
38306
  );
38295
38307
  try {
38296
- const cached3 = await getCache(cacheKey);
38297
- if (cached3) {
38308
+ const cached4 = await getCache(cacheKey);
38309
+ if (cached4) {
38298
38310
  import_node_server_utils113.logger.log({
38299
38311
  level: "info",
38300
38312
  message: `Cache hit for getById building unit: ${cacheKey}`
38301
38313
  });
38302
- return cached3;
38314
+ return cached4;
38303
38315
  }
38304
38316
  const result = await collection.findOne(query2, {
38305
38317
  session
@@ -38339,13 +38351,13 @@ function useBuildingUnitRepo() {
38339
38351
  level: level2
38340
38352
  });
38341
38353
  try {
38342
- const cached3 = await getCache(cacheKey);
38343
- if (cached3) {
38354
+ const cached4 = await getCache(cacheKey);
38355
+ if (cached4) {
38344
38356
  import_node_server_utils113.logger.log({
38345
38357
  level: "info",
38346
38358
  message: `Cache hit for getById building unit: ${cacheKey}`
38347
38359
  });
38348
- return cached3;
38360
+ return cached4;
38349
38361
  }
38350
38362
  const query2 = {
38351
38363
  site,
@@ -38711,9 +38723,9 @@ function useVehicleService() {
38711
38723
  const siteZones = /* @__PURE__ */ new Map();
38712
38724
  async function siteTimezone(site) {
38713
38725
  const key = String(site ?? "");
38714
- const cached3 = siteZones.get(key);
38715
- if (cached3 && Date.now() - cached3.at < 5 * 6e4)
38716
- return cached3.zone;
38726
+ const cached4 = siteZones.get(key);
38727
+ if (cached4 && Date.now() - cached4.at < 5 * 6e4)
38728
+ return cached4.zone;
38717
38729
  let zone = resolveSiteTimezone(null);
38718
38730
  if (key) {
38719
38731
  try {
@@ -41586,13 +41598,13 @@ function useBuildingRepo() {
41586
41598
  message: `Cache key for getAll buildings: ${cacheKey}`
41587
41599
  });
41588
41600
  try {
41589
- const cached3 = await getCache(cacheKey);
41590
- if (cached3) {
41601
+ const cached4 = await getCache(cacheKey);
41602
+ if (cached4) {
41591
41603
  import_node_server_utils121.logger.log({
41592
41604
  level: "info",
41593
41605
  message: `Cache hit for getAll buildings: ${cacheKey}`
41594
41606
  });
41595
- return cached3;
41607
+ return cached4;
41596
41608
  }
41597
41609
  const items = await collection.aggregate(
41598
41610
  [
@@ -41721,13 +41733,13 @@ function useBuildingRepo() {
41721
41733
  _id: String(_id)
41722
41734
  });
41723
41735
  try {
41724
- const cached3 = await getCache(cacheKey);
41725
- if (cached3) {
41736
+ const cached4 = await getCache(cacheKey);
41737
+ if (cached4) {
41726
41738
  import_node_server_utils121.logger.log({
41727
41739
  level: "info",
41728
41740
  message: `Cache hit for getById building: ${cacheKey}`
41729
41741
  });
41730
- return cached3;
41742
+ return cached4;
41731
41743
  }
41732
41744
  const result = await collection.findOne({
41733
41745
  _id
@@ -41791,13 +41803,13 @@ function useBuildingRepo() {
41791
41803
  const cacheOptions = { ...query2 };
41792
41804
  const cacheKey = (0, import_node_server_utils121.makeCacheKey)(buildings_namespace_collection, cacheOptions);
41793
41805
  try {
41794
- const cached3 = await getCache(cacheKey);
41795
- if (cached3) {
41806
+ const cached4 = await getCache(cacheKey);
41807
+ if (cached4) {
41796
41808
  import_node_server_utils121.logger.log({
41797
41809
  level: "info",
41798
41810
  message: `Cache hit for getById building: ${cacheKey}`
41799
41811
  });
41800
- return cached3;
41812
+ return cached4;
41801
41813
  }
41802
41814
  const result = await collection.findOne(query2);
41803
41815
  setCache(cacheKey, result, 300).then(() => {
@@ -42280,13 +42292,13 @@ function useBuildingLevelRepo() {
42280
42292
  message: `Cache key for getAll building levels: ${cacheKey}`
42281
42293
  });
42282
42294
  try {
42283
- const cached3 = await getCache(cacheKey);
42284
- if (cached3) {
42295
+ const cached4 = await getCache(cacheKey);
42296
+ if (cached4) {
42285
42297
  import_node_server_utils124.logger.log({
42286
42298
  level: "info",
42287
42299
  message: `Cache hit for getAll building levels: ${cacheKey}`
42288
42300
  });
42289
- return cached3;
42301
+ return cached4;
42290
42302
  }
42291
42303
  const sortStage = Object.keys(sort).length > 0 ? { $sort: sort } : { $sort: { name: 1 } };
42292
42304
  const items = await collection.aggregate(
@@ -42331,13 +42343,13 @@ function useBuildingLevelRepo() {
42331
42343
  const cacheKey = (0, import_node_server_utils124.makeCacheKey)(building_level_namespace_collection, {
42332
42344
  _id
42333
42345
  });
42334
- const cached3 = await getCache(cacheKey);
42335
- if (cached3) {
42346
+ const cached4 = await getCache(cacheKey);
42347
+ if (cached4) {
42336
42348
  import_node_server_utils124.logger.log({
42337
42349
  level: "info",
42338
42350
  message: `Cache hit for getById building level: ${cacheKey}`
42339
42351
  });
42340
- return cached3;
42352
+ return cached4;
42341
42353
  }
42342
42354
  try {
42343
42355
  _id = new import_mongodb88.ObjectId(_id);
@@ -46001,7 +46013,7 @@ function useCameraViewController() {
46001
46013
  }
46002
46014
  async function snapshot2(req, res, next) {
46003
46015
  try {
46004
- const { buffer, cached: cached3, stream, fellBackToMain } = await getSnapshot({
46016
+ const { buffer, cached: cached4, stream, fellBackToMain } = await getSnapshot({
46005
46017
  cameraId: String(req.params.id ?? ""),
46006
46018
  userId: callerId5(req)
46007
46019
  });
@@ -46010,7 +46022,7 @@ function useCameraViewController() {
46010
46022
  "Cache-Control",
46011
46023
  `private, max-age=${CAMERA_SNAPSHOT_CACHE_SECONDS}`
46012
46024
  );
46013
- res.setHeader("X-Camera-Snapshot-Cached", cached3 ? "1" : "0");
46025
+ res.setHeader("X-Camera-Snapshot-Cached", cached4 ? "1" : "0");
46014
46026
  res.setHeader("X-Camera-Stream", stream);
46015
46027
  res.setHeader("X-Camera-Stream-Fallback", fellBackToMain ? "1" : "0");
46016
46028
  res.status(200).end(buffer);
@@ -63951,7 +63963,9 @@ var ROBOT_CAPABILITIES = [
63951
63963
  */
63952
63964
  "manualDrive",
63953
63965
  /** A heat camera: alarm and patrol photos carry a thermal picture and temperatures. Reporting only. */
63954
- "thermalCamera"
63966
+ "thermalCamera",
63967
+ /** A scrubber's clean/dirty water levels and whether its tanks and covers are fitted. Reporting only. */
63968
+ "waterTanks"
63955
63969
  ];
63956
63970
  var TIER_REQUIREMENTS = {
63957
63971
  "full-control": [
@@ -64245,6 +64259,9 @@ var ROBOT_CLOUD_PATHS = {
64245
64259
  taskList: "/portal/cleaning/get-task-list",
64246
64260
  alertList: "/portal/alert/get-alert-list",
64247
64261
  liftList: "/portal/lift/get-lift-list",
64262
+ workHours: "/portal/workhours/get-work-hours",
64263
+ haltPlans: "/portal/halt-plan/get",
64264
+ stationState: "/portal/detailstate/get-station-detail-state",
64248
64265
  mapList: "/portal/maps/get-map-list",
64249
64266
  fileUrl: "/portal/maps/get-file-url",
64250
64267
  tracking: "/portal/robots/tracking",
@@ -64541,6 +64558,9 @@ var STEP_NAMES = {
64541
64558
  [ROBOT_CLOUD_PATHS.filePreview]: "the map images",
64542
64559
  [ROBOT_CLOUD_PATHS.plansV2]: "the cleaning schedule",
64543
64560
  [ROBOT_CLOUD_PATHS.taskList]: "the cleaning records",
64561
+ [ROBOT_CLOUD_PATHS.workHours]: "the consumable hours",
64562
+ [ROBOT_CLOUD_PATHS.haltPlans]: "the power schedule",
64563
+ [ROBOT_CLOUD_PATHS.stationState]: "the base station state",
64544
64564
  [ROBOT_CLOUD_PATHS.alertList]: "the alert history",
64545
64565
  [ROBOT_CLOUD_PATHS.liftList]: "the lift list"
64546
64566
  };
@@ -64745,6 +64765,23 @@ function useRobotCloudService(credentials, options = {}) {
64745
64765
  async function getLiftList(sceneId) {
64746
64766
  return post(ROBOT_CLOUD_PATHS.liftList, { sceneid: sceneId }, "liftlist");
64747
64767
  }
64768
+ async function getWorkHours(robotId) {
64769
+ return post(ROBOT_CLOUD_PATHS.workHours, { robotId }, "unitlist");
64770
+ }
64771
+ async function getHaltPlans(robotId) {
64772
+ return post(
64773
+ ROBOT_CLOUD_PATHS.haltPlans,
64774
+ { planId: 0, robotId, pageNo: 1, pageSize: 20 },
64775
+ "planList"
64776
+ );
64777
+ }
64778
+ async function getStationState(robotId) {
64779
+ const data = await post(
64780
+ ROBOT_CLOUD_PATHS.stationState,
64781
+ { robotId, options: "state" }
64782
+ );
64783
+ return data.state ?? null;
64784
+ }
64748
64785
  async function getMaps(robotSn) {
64749
64786
  const data = await post(
64750
64787
  ROBOT_CLOUD_PATHS.mapList,
@@ -64826,6 +64863,9 @@ function useRobotCloudService(credentials, options = {}) {
64826
64863
  getPlansV2,
64827
64864
  getTaskList,
64828
64865
  getAlerts,
64866
+ getWorkHours,
64867
+ getHaltPlans,
64868
+ getStationState,
64829
64869
  getLiftList,
64830
64870
  getMaps,
64831
64871
  getFileUrls,
@@ -64839,6 +64879,7 @@ function useRobotCloudService(credentials, options = {}) {
64839
64879
  }
64840
64880
 
64841
64881
  // src/services/ounitech.adapter.ts
64882
+ var import_axios4 = __toESM(require("axios"));
64842
64883
  var OUNITECH_BRAND = "ounitech";
64843
64884
  var OUNITECH_CAPABILITIES = {
64844
64885
  // Pose in the chapter-6 robot list (metres) and the tracking stream.
@@ -64851,6 +64892,8 @@ var OUNITECH_CAPABILITIES = {
64851
64892
  battery: true,
64852
64893
  // The chapter-6 robot list: `floorNo` (the robot's floor).
64853
64894
  floorReporting: true,
64895
+ // robotState readings: clean-water / dirty-water (%), top-cover / tank / dust-box fitted.
64896
+ waterTanks: true,
64854
64897
  // FALSE on purpose - each one is a question for the vendor.
64855
64898
  navigateToPoint: false,
64856
64899
  // app: "Move to Target Point"; API: robot-control actionNo not documented
@@ -64926,6 +64969,39 @@ function ounitechJobWords(st) {
64926
64969
  const v = reading(st, "job");
64927
64970
  return v ? JOB_WORDS[v] ?? null : null;
64928
64971
  }
64972
+ var levelOf = (pct) => pct < 25 ? "low" : pct >= 75 ? "high" : "medium";
64973
+ var LEVEL_WORDS = { \u4F4E: "low", \u4E2D: "medium", \u9AD8: "high" };
64974
+ var PARTS = [
64975
+ ["top-cover", "top cover"],
64976
+ ["clean-water-tank", "clean-water tank"],
64977
+ ["waste-water-tank", "dirty-water tank"],
64978
+ ["dust-box", "dust box"]
64979
+ ];
64980
+ function ounitechCleaning(st, working, taskPercent) {
64981
+ const water = (pctKey, levelKey) => {
64982
+ const pct2 = num(reading(st, pctKey));
64983
+ if (pct2 !== void 0 && pct2 >= 0 && pct2 <= 100)
64984
+ return { level: levelOf(pct2), percent: Math.round(pct2) };
64985
+ const word = LEVEL_WORDS[reading(st, levelKey) ?? ""];
64986
+ return word ? { level: word, percent: null } : null;
64987
+ };
64988
+ const cleanWater = water("clean-water", "clean-water-level");
64989
+ const dirtyWater = water("dirty-water", "dirty-water-level");
64990
+ const parts = PARTS.flatMap(([key, part]) => {
64991
+ const v = reading(st, key)?.toLowerCase();
64992
+ return v === "true" || v === "1" ? [{ part, ok: true }] : v === "false" || v === "0" ? [{ part, ok: false }] : [];
64993
+ });
64994
+ const area = (k) => {
64995
+ const n = num(reading(st, k));
64996
+ return n !== void 0 && n > 0 ? Math.round(n * 10) / 10 : null;
64997
+ };
64998
+ const pct = num(reading(st, "acc-percent")) ?? (finite(taskPercent) ? taskPercent : void 0);
64999
+ const job = working ? { percent: pct !== void 0 && pct >= 0 && pct <= 100 ? Math.round(pct) : null, areaDone: area("acc-area"), areaPlanned: area("count-area") } : null;
65000
+ const hasJob = !!job && (job.percent !== null || job.areaDone !== null);
65001
+ if (!cleanWater && !dirtyWater && !parts.length && !hasJob)
65002
+ return null;
65003
+ return { cleanWater, dirtyWater, parts, job: hasJob ? job : null };
65004
+ }
64929
65005
  function updatedAt(v) {
64930
65006
  const n = num(v);
64931
65007
  if (n !== void 0)
@@ -64961,6 +65037,9 @@ function ounitechRobotFromHomeRow(row, live2, now = Date.now()) {
64961
65037
  floorKnown: Number.isInteger(row.floorNo),
64962
65038
  position: online && x !== void 0 && y !== void 0 ? { x, y, theta: num(st.theta) ?? 0 } : null
64963
65039
  };
65040
+ if (online) {
65041
+ robot.cleaning = ounitechCleaning(st, mode === "WORKING", task && String(task.statusFlag) === "1" ? task.accPercent : null);
65042
+ }
64964
65043
  if (online && (flag === 7 || Array.isArray(st.rtFaultList) && st.rtFaultList.length)) {
64965
65044
  robot.fault = ounitechFault(st.rtFaultList);
64966
65045
  }
@@ -64982,12 +65061,319 @@ function ounitechFault(list) {
64982
65061
  return { code: "error", message: String(list[0]).slice(0, 200) };
64983
65062
  return { code: "error", message: "The robot reports an error" };
64984
65063
  }
65064
+ function ounitechMapShare(map, x, y) {
65065
+ const w = map?.width, h = map?.height, r = map?.resolution;
65066
+ const wx = num(x), wy = num(y);
65067
+ if (!finite(w) || !finite(h) || !finite(r) || w <= 0 || h <= 0 || r <= 0 || wx === void 0 || wy === void 0)
65068
+ return null;
65069
+ const sx = (wx - (num(map?.originX) ?? 0)) / r / w * 100;
65070
+ const sy = 100 - (wy - (num(map?.originY) ?? 0)) / r / h * 100;
65071
+ if (sx < 0 || sx > 100 || sy < 0 || sy > 100)
65072
+ return null;
65073
+ return { x: Math.round(sx * 100) / 100, y: Math.round(sy * 100) / 100 };
65074
+ }
65075
+ function ounitechMapView(m, imageUrl, partitionImageUrl, size) {
65076
+ const floorNo2 = Number.isInteger(m.floorNo) ? m.floorNo : null;
65077
+ const width = size?.width ?? null;
65078
+ const height = size?.height ?? null;
65079
+ const frame2 = { width, height, resolution: m.resolution, originX: m.originX, originY: m.originY };
65080
+ const areas = (Array.isArray(m.areaList) ? m.areaList : []).filter((a) => typeof a?.areaName === "string" && a.areaName.trim()).map((a) => {
65081
+ const px = num(a.x), py = num(a.y);
65082
+ const at2 = width && height && px !== void 0 && py !== void 0 && (px > 0 || py > 0) && px <= width && py <= height ? { x: Math.round(px / width * 1e4) / 100, y: Math.round(py / height * 1e4) / 100 } : null;
65083
+ return { ...a.areaId != null ? { areaId: a.areaId } : {}, areaName: a.areaName.trim(), rgba: a.rgba, x: a.x, y: a.y, at: at2 };
65084
+ });
65085
+ return {
65086
+ mapId: String(m.mapId ?? `floor-${floorNo2 ?? 0}`),
65087
+ floor: floorNo2,
65088
+ floorNo: floorNo2,
65089
+ mapDisplayName: String(m.mapName ?? "").trim(),
65090
+ mapName: m.mapName,
65091
+ imageUrl,
65092
+ partitionImageUrl,
65093
+ width,
65094
+ height,
65095
+ resolution: m.resolution,
65096
+ originX: m.originX,
65097
+ originY: m.originY,
65098
+ backgroundFileKey: m.backgroundFileKey,
65099
+ partitionFileKey: m.partitionFileKey,
65100
+ totalArea: m.totalArea,
65101
+ baseX: m.baseX,
65102
+ baseY: m.baseY,
65103
+ baseTheta: m.baseTheta,
65104
+ createTime: m.createTime,
65105
+ dock: ounitechMapShare(frame2, m.baseX ?? 0, m.baseY ?? 0),
65106
+ positionApproximate: true,
65107
+ // The raw areas, kept for older screens.
65108
+ areaList: areas.map(({ at: _at, ...a }) => a),
65109
+ areas: areas.map((a) => ({ name: a.areaName, at: a.at }))
65110
+ };
65111
+ }
65112
+ function ounitechCurrentMap(maps, taskMapId, floorNo2) {
65113
+ const byTask = taskMapId != null ? maps.find((m) => m.mapId === String(taskMapId)) : void 0;
65114
+ if (byTask)
65115
+ return byTask;
65116
+ if (Number.isInteger(floorNo2))
65117
+ return maps.find((m) => m.floorNo === floorNo2) ?? null;
65118
+ return maps.length === 1 ? maps[0] : null;
65119
+ }
65120
+ function pngSize(bytes) {
65121
+ if (!bytes || bytes.length < 24)
65122
+ return null;
65123
+ const ihdr = String.fromCharCode(bytes[12], bytes[13], bytes[14], bytes[15]);
65124
+ if (bytes[1] !== 80 || ihdr !== "IHDR")
65125
+ return null;
65126
+ const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
65127
+ const width = dv.getUint32(16), height = dv.getUint32(20);
65128
+ return width > 0 && height > 0 && width < 2e4 && height < 2e4 ? { width, height } : null;
65129
+ }
65130
+ async function fetchPngSize(url2) {
65131
+ try {
65132
+ const res = await import_axios4.default.get(url2, { responseType: "arraybuffer", headers: { Range: "bytes=0-63" }, timeout: 8e3 });
65133
+ return pngSize(new Uint8Array(res.data));
65134
+ } catch {
65135
+ return null;
65136
+ }
65137
+ }
65138
+ function ounitechTime(v, tzMinutes = 480) {
65139
+ const m = typeof v === "string" ? /^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2}(?::\d{2})?)/.exec(v.trim()) : null;
65140
+ if (!m)
65141
+ return null;
65142
+ const t = Date.parse(`${m[1]}T${m[2].length === 5 ? `${m[2]}:00` : m[2]}Z`) - tzMinutes * 6e4;
65143
+ return Number.isFinite(t) ? new Date(t).toISOString() : null;
65144
+ }
65145
+ var MODE_WORDS = { \u5438\u5C18: "Vacuum", \u6D17\u5730: "Wash floor", \u5C18\u63A8: "Dust mop", \u62D6\u5730: "Mop" };
65146
+ var TYPE_WORDS = {
65147
+ \u51C6\u5907\u6E05\u6D01: "Getting ready",
65148
+ \u8131\u79BB\u57FA\u7AD9\u4E2D: "Leaving the charger",
65149
+ \u5168\u5C40\u6E05\u626B: "Clean all",
65150
+ \u5206\u533A\u6E05\u626B: "Area clean",
65151
+ \u5B9A\u70B9\u6E05\u626B: "Spot clean",
65152
+ \u56DE\u5145: "Returning to charge",
65153
+ \u6CBF\u8FB9\u6E05\u626B: "Edge clean"
65154
+ };
65155
+ var SOURCE_WORDS = { plan: "Schedule", app: "Ounitech app", btn: "Button on the robot" };
65156
+ var round1 = (v) => v !== void 0 ? Math.round(v * 10) / 10 : null;
65157
+ function ounitechTaskRecord(t, maps = [], tz = 480) {
65158
+ const map = maps.find((m) => m.mapId === String(t.mapId));
65159
+ const kind = String(t.typeName ?? "").trim();
65160
+ const mode = String(t.subTypeName ?? "").trim();
65161
+ const src = String(t.source ?? "").split(",")[0].trim();
65162
+ const mileage = num(t.cleanedMileage);
65163
+ return {
65164
+ id: String(t.taskId ?? ""),
65165
+ start: ounitechTime(t.timeFrom, tz),
65166
+ end: ounitechTime(t.timeTo, tz),
65167
+ durationSec: num(t.durationSeconds) ?? num(t.accTime) ?? null,
65168
+ areaM2: round1(num(t.cleanedArea) ?? num(t.accArea)),
65169
+ plannedM2: round1(num(t.countArea)),
65170
+ percent: num(t.accPercent) ?? null,
65171
+ distanceM: mileage !== void 0 ? Math.round(mileage) : null,
65172
+ result: String(t.statusName ?? "").trim() || null,
65173
+ job: TYPE_WORDS[kind] ?? (kind || null),
65174
+ mode: MODE_WORDS[mode] ?? (mode || null),
65175
+ source: SOURCE_WORDS[src] ?? (src || null),
65176
+ map: map ? map.mapDisplayName || (map.floorNo !== null ? `Floor ${map.floorNo}` : null) : null,
65177
+ floorNo: Number.isInteger(t.floorNo) ? t.floorNo : map?.floorNo ?? null
65178
+ };
65179
+ }
65180
+ var ALERT_WORDS = {
65181
+ "540": "Floor check: cliff sensor switched on",
65182
+ "601": "Left wheel driver reset",
65183
+ "620": "Right wheel driver offline",
65184
+ "621": "Right wheel driver reset",
65185
+ "734": "IMU zero offset too large",
65186
+ "785": "Localisation ready"
65187
+ };
65188
+ var ALERT_LEVEL_WORDS = { \u63D0\u793A: "Notice", \u8B66\u544A: "Warning", \u6545\u969C: "Fault", \u9519\u8BEF: "Error", \u4E25\u91CD: "Critical" };
65189
+ function ounitechAlertRecord(a, tz = 480) {
65190
+ const raw = String(a.errMsg ?? a.errCode ?? "").trim();
65191
+ const m = /^\s*(\d+)\s*-\s*(.*)$/.exec(raw);
65192
+ const code = m?.[1] ?? "";
65193
+ let rest = (m?.[2] ?? raw).trim();
65194
+ const resolved = /\(Resolved\)\s*$/i.test(rest);
65195
+ rest = rest.replace(/\(Resolved\)\s*$/i, "").replace(/\(\s*\d+\s*\)\s*$/, "").trim();
65196
+ const lv = /^\(([^)]*)\)/.exec(rest);
65197
+ if (lv)
65198
+ rest = rest.slice(lv[0].length).trim();
65199
+ return {
65200
+ code,
65201
+ level: lv ? ALERT_LEVEL_WORDS[lv[1].trim()] ?? lv[1].trim() : null,
65202
+ message: ALERT_WORDS[code] ?? (rest || raw),
65203
+ vendorText: rest || raw,
65204
+ resolved,
65205
+ at: ounitechTime(a.createTime, tz)
65206
+ };
65207
+ }
65208
+ var READINGS = {
65209
+ "battery-percent": { group: "Battery", label: "Battery", unit: "%" },
65210
+ "left-battery-percent": { group: "Battery", label: "Left battery", unit: "%" },
65211
+ "right-battery-percent": { group: "Battery", label: "Right battery", unit: "%" },
65212
+ "bat-vol-left": { group: "Battery", label: "Left battery voltage", unit: "V" },
65213
+ "bat-vol-right": { group: "Battery", label: "Right battery voltage", unit: "V" },
65214
+ BatteryOffline: { group: "Battery", label: "Battery disconnected", bad: "true" },
65215
+ BatteryClosed: { group: "Battery", label: "Battery switched off", bad: "true" },
65216
+ "clean-water": { group: "Water", label: "Clean water", unit: "%" },
65217
+ "dirty-water": { group: "Water", label: "Dirty water", unit: "%" },
65218
+ "clean-water-level": { group: "Water", label: "Clean water level" },
65219
+ "dirty-water-level": { group: "Water", label: "Dirty water level" },
65220
+ "ctank-full": { group: "Water", label: "Clean water tank full" },
65221
+ "cmop-pump-low": { group: "Water", label: "Mop water running low", bad: "true" },
65222
+ "top-cover": { group: "Parts in place", label: "Top cover closed", bad: "false" },
65223
+ "hand-push-rod": { group: "Parts in place", label: "Push handle in place", bad: "false" },
65224
+ "clean-water-tank": { group: "Parts in place", label: "Clean water tank fitted", bad: "false" },
65225
+ "waste-water-tank": { group: "Parts in place", label: "Dirty water tank fitted", bad: "false" },
65226
+ "dust-box": { group: "Parts in place", label: "Dust box fitted", bad: "false" },
65227
+ "collision-left": { group: "Sensors", label: "Left bumper pressed", bad: "true" },
65228
+ "collision-right": { group: "Sensors", label: "Right bumper pressed", bad: "true" },
65229
+ "wfan-brake-flag": { group: "Sensors", label: "Water suction fan blocked", bad: "true" },
65230
+ "sfan-brake-flag": { group: "Sensors", label: "Dust suction fan blocked", bad: "true" },
65231
+ "wfan-brake-percent": { group: "Sensors", label: "Water suction fan blockage", unit: "%" },
65232
+ "sfan-brake-percent": { group: "Sensors", label: "Dust suction fan blockage", unit: "%" },
65233
+ job: { group: "Current job", label: "Job" },
65234
+ status: { group: "Current job", label: "Work status" },
65235
+ "acc-percent": { group: "Current job", label: "Job done", unit: "%" },
65236
+ "acc-area": { group: "Current job", label: "Area cleaned", unit: "m\xB2" },
65237
+ "count-area": { group: "Current job", label: "Area planned", unit: "m\xB2" },
65238
+ "acc-mile": { group: "Current job", label: "Distance driven", unit: "m" },
65239
+ "acc-time": { group: "Current job", label: "Cleaning time" },
65240
+ "acc-task": { group: "Current job", label: "Jobs counted" },
65241
+ "avg-speed": { group: "Current job", label: "Average speed", unit: "m\xB2/s" },
65242
+ x: { group: "Position", label: "Position x", unit: "m" },
65243
+ y: { group: "Position", label: "Position y", unit: "m" },
65244
+ theta: { group: "Position", label: "Heading", unit: "rad" },
65245
+ "mcu-state": { group: "Connection", label: "Main board connected", bad: "false" },
65246
+ bslink: { group: "Connection", label: "Linked to the base station" },
65247
+ RouterSignalStrength: { group: "Connection", label: "Mobile signal" },
65248
+ IsOfflineMode: { group: "Connection", label: "Offline mode", bad: "true" },
65249
+ OfflineVersion: { group: "Software", label: "Offline map version" },
65250
+ McuSW: { group: "Software", label: "Main board software" },
65251
+ FaceH7SW: { group: "Software", label: "Front panel software" },
65252
+ SlamType: { group: "Software", label: "Mapping type" },
65253
+ LockType: { group: "Software", label: "Lock type" }
65254
+ };
65255
+ var STATION_READINGS = {
65256
+ "clean-water": { group: "Base station", label: "Station clean water", unit: "L" },
65257
+ "dirty-water": { group: "Base station", label: "Station dirty water", unit: "L" },
65258
+ "clean-percent": { group: "Base station", label: "Station clean water", unit: "%" },
65259
+ "dirty-percent": { group: "Base station", label: "Station dirty water", unit: "%" },
65260
+ temperature: { group: "Base station", label: "Station temperature", unit: "\xB0C" },
65261
+ "bluetooth-err": { group: "Base station", label: "Bluetooth fault", bad: "true" },
65262
+ "charge-err": { group: "Base station", label: "Charging fault", bad: "true" },
65263
+ "clean-box-err": { group: "Base station", label: "Clean water box fault", bad: "true" },
65264
+ "clean-pump-err": { group: "Base station", label: "Clean water pump fault", bad: "true" },
65265
+ "dirty-box-err": { group: "Base station", label: "Dirty water box fault", bad: "true" },
65266
+ "dirty-pump-err": { group: "Base station", label: "Dirty water pump fault", bad: "true" },
65267
+ "dust-box-err": { group: "Base station", label: "Dust box fault", bad: "true" },
65268
+ "dust-fan-err": { group: "Base station", label: "Dust fan fault", bad: "true" },
65269
+ "ir-err": { group: "Base station", label: "Docking sensor fault", bad: "true" },
65270
+ "solenoid-err": { group: "Base station", label: "Water valve fault", bad: "true" },
65271
+ "temperature-err": { group: "Base station", label: "Temperature fault", bad: "true" },
65272
+ "water-sensor-err": { group: "Base station", label: "Water sensor fault", bad: "true" }
65273
+ };
65274
+ var HIDDEN_READINGS = /* @__PURE__ */ new Set(["RobotIP", "RouterIccid"]);
65275
+ var LEVEL_READING = { \u4F4E: "Low", \u4E2D: "Medium", \u9AD8: "High", \u7A7A: "Empty", \u6EE1: "Full" };
65276
+ function ounitechReadings(props, station = false) {
65277
+ const defs = station ? STATION_READINGS : READINGS;
65278
+ const out = [];
65279
+ for (const p of Array.isArray(props) ? props : []) {
65280
+ const key = String(p?.key ?? "").trim();
65281
+ if (!key || HIDDEN_READINGS.has(key))
65282
+ continue;
65283
+ const raw = p?.value == null ? "" : String(p.value).trim();
65284
+ if (raw === "" || raw === "-")
65285
+ continue;
65286
+ const d = defs[key] ?? { group: station ? "Base station" : "Other readings", label: key };
65287
+ let value;
65288
+ if (raw === "true" || raw === "false")
65289
+ value = raw === "true" ? "Yes" : "No";
65290
+ else if (key === "job")
65291
+ value = JOB_WORDS[raw] ?? raw;
65292
+ else if (key === "status")
65293
+ value = ROBOT_STATUS_NAMES[STATUS_CODE_BY_READING[raw] ?? -1] ?? raw;
65294
+ else if (LEVEL_READING[raw])
65295
+ value = LEVEL_READING[raw];
65296
+ else if (key === "acc-time" && num(raw) !== void 0)
65297
+ value = `${Math.round(num(raw) / 60)} min`;
65298
+ else
65299
+ value = d.unit === "%" ? `${raw}%` : d.unit ? `${raw} ${d.unit}` : raw;
65300
+ out.push({ key, group: d.group, label: d.label, value, attention: !!d.bad && raw === d.bad });
65301
+ }
65302
+ return out;
65303
+ }
65304
+ var PART_WORDS = {
65305
+ left_side_brush_plastic: "Left side brush",
65306
+ right_side_brush_plastic: "Right side brush",
65307
+ dust_bag: "Dust bag",
65308
+ single_suction_mouth_rubber: "Suction rubber",
65309
+ floor_brush_double_roller_structure: "Floor brush rollers",
65310
+ floor_mop_double_roller_structure: "Mop rollers"
65311
+ };
65312
+ function ounitechConsumable(u) {
65313
+ const code = String(u.unitcode ?? "").trim();
65314
+ const minutes = num(u.workminutes);
65315
+ return {
65316
+ part: PART_WORDS[code] ?? (code.replace(/_/g, " ") || String(u.unitname ?? "").trim() || "Part"),
65317
+ hours: minutes !== void 0 ? Math.round(minutes / 6) / 10 : null,
65318
+ days: num(u.workdays) ?? null
65319
+ };
65320
+ }
65321
+ function ounitechPowerPlan(p) {
65322
+ return {
65323
+ days: (Array.isArray(p.dateList) ? p.dateList : []).map(Number).filter((d) => d >= 1 && d <= 7),
65324
+ time: String(p.actionTime ?? "").trim(),
65325
+ action: Number(p.actionFlag) === 1 ? "on" : "off",
65326
+ enabled: p.enableFlag !== false
65327
+ };
65328
+ }
65329
+ var MAP_TTL_MS = 10 * 6e4;
65330
+ var RECORDS_TTL_MS = 2 * 6e4;
65331
+ var mapCache = /* @__PURE__ */ new Map();
65332
+ var recordsCache = /* @__PURE__ */ new Map();
65333
+ function cached2(cache3, field, key, ttl, load) {
65334
+ const hit = cache3.get(key);
65335
+ if (hit && Date.now() - hit.at < ttl)
65336
+ return hit[field];
65337
+ const p = load();
65338
+ cache3.set(key, { at: Date.now(), [field]: p });
65339
+ p.catch(() => cache3.delete(key));
65340
+ return p;
65341
+ }
65342
+ function clearOunitechCaches() {
65343
+ mapCache.clear();
65344
+ recordsCache.clear();
65345
+ }
64985
65346
  var robotTime = (d) => robotCloudTimestamp(d, "yyyy-MM-dd HH:mm:ss", "Asia/Shanghai");
64986
65347
  function createOunitechAdapter(credentials, options) {
64987
65348
  const cloud = useRobotCloudService(credentials, options);
64988
65349
  async function liveFor(row) {
64989
65350
  return needsLiveState(row) ? cloud.getRobotState(row.robotId).catch(() => null) : null;
64990
65351
  }
65352
+ function floorMaps(sceneId) {
65353
+ return cached2(mapCache, "maps", `${options?.baseUrl ?? ""}|${credentials.appid}|${sceneId}`, MAP_TTL_MS, async () => {
65354
+ const list = (await cloud.getFloorMaps(sceneId)).filter((m) => m.latestFlag !== false);
65355
+ const keys = list.flatMap((m) => [m.backgroundFileKey, m.partitionFileKey]).filter((k) => typeof k === "string" && !!k);
65356
+ const files = keys.length ? await cloud.previewFiles(keys).catch(() => []) : [];
65357
+ const url2 = (k) => files.find((f) => f.fileKey === k)?.url || null;
65358
+ return Promise.all(
65359
+ list.map(async (m) => {
65360
+ const imageUrl = url2(m.backgroundFileKey);
65361
+ return ounitechMapView(m, imageUrl, url2(m.partitionFileKey), imageUrl ? await fetchPngSize(imageUrl) : null);
65362
+ })
65363
+ );
65364
+ });
65365
+ }
65366
+ async function placed(row, robot) {
65367
+ if (!robot.online || !finite(row.sceneId))
65368
+ return robot;
65369
+ const maps = await floorMaps(row.sceneId).catch(() => []);
65370
+ const map = ounitechCurrentMap(maps, row.taskState?.mapId, robot.floorNo);
65371
+ if (!map)
65372
+ return robot;
65373
+ robot.mapId = map.mapId;
65374
+ robot.planPosition = robot.position ? ounitechMapShare(map, robot.position.x, robot.position.y) : null;
65375
+ return robot;
65376
+ }
64991
65377
  async function rowFor(robotSn) {
64992
65378
  return (await cloud.getHomeRobots()).find((r) => r.robotSn === robotSn) ?? null;
64993
65379
  }
@@ -64996,7 +65382,9 @@ function createOunitechAdapter(credentials, options) {
64996
65382
  displayName: "Ounitech (Q3-G / Q3-W)",
64997
65383
  capabilities: OUNITECH_CAPABILITIES,
64998
65384
  async listRobots() {
64999
- return Promise.all((await cloud.getHomeRobots()).map(async (row) => ounitechRobotFromHomeRow(row, await liveFor(row))));
65385
+ return Promise.all(
65386
+ (await cloud.getHomeRobots()).map(async (row) => placed(row, ounitechRobotFromHomeRow(row, await liveFor(row))))
65387
+ );
65000
65388
  },
65001
65389
  async getRobot(robotSn) {
65002
65390
  const row = await rowFor(robotSn);
@@ -65012,7 +65400,7 @@ function createOunitechAdapter(credentials, options) {
65012
65400
  position: null
65013
65401
  };
65014
65402
  }
65015
- return ounitechRobotFromHomeRow(row, await liveFor(row));
65403
+ return placed(row, ounitechRobotFromHomeRow(row, await liveFor(row)));
65016
65404
  },
65017
65405
  async sendCommand(robotSn, command) {
65018
65406
  const options2 = {
@@ -65040,31 +65428,16 @@ function createOunitechAdapter(credentials, options) {
65040
65428
  );
65041
65429
  }
65042
65430
  },
65043
- /** Chapter 6 floor maps, in the chapter-2 shape the screens read (walls left out - they are large). */
65431
+ /**
65432
+ * Chapter 6 floor maps (walls left out - they are large): the chapter-2
65433
+ * fields plus `mapId`, `imageUrl`, `width` / `height` (from the PNG) and
65434
+ * the areas' centres, so robot detail draws the real map with the robot on it.
65435
+ */
65044
65436
  async getMaps(robotSn) {
65045
65437
  const row = await rowFor(robotSn);
65046
65438
  if (!row || !finite(row.sceneId))
65047
65439
  return [];
65048
- return (await cloud.getFloorMaps(row.sceneId)).filter((m) => m.latestFlag !== false).map((m) => ({
65049
- floorNo: m.floorNo,
65050
- mapName: m.mapName,
65051
- backgroundFileKey: m.backgroundFileKey,
65052
- partitionFileKey: m.partitionFileKey,
65053
- originX: m.originX,
65054
- originY: m.originY,
65055
- resolution: m.resolution,
65056
- totalArea: m.totalArea,
65057
- baseX: m.baseX,
65058
- baseY: m.baseY,
65059
- baseTheta: m.baseTheta,
65060
- createTime: m.createTime,
65061
- areaList: (Array.isArray(m.areaList) ? m.areaList : []).map((a) => ({
65062
- areaName: a.areaName,
65063
- rgba: a.rgba,
65064
- x: a.x,
65065
- y: a.y
65066
- }))
65067
- }));
65440
+ return floorMaps(row.sceneId);
65068
65441
  },
65069
65442
  async getMapImages(_robotSn, fileKeys) {
65070
65443
  return cloud.previewFiles(fileKeys);
@@ -65083,6 +65456,53 @@ function createOunitechAdapter(credentials, options) {
65083
65456
  jobList: p.cleanList ?? p.jobList ?? []
65084
65457
  }));
65085
65458
  },
65459
+ /**
65460
+ * Robot detail's records (read-only, cached 2 min - the vendor rate-limits):
65461
+ * cleaning jobs (14 days), alert history (30 days), consumable hours, power
65462
+ * schedule, lifts, every live reading and the base station. Reads run one
65463
+ * after another (gentler on the rate limit); each part carries its own error.
65464
+ */
65465
+ async getRecords(robotSn) {
65466
+ return cached2(recordsCache, "value", `${options?.baseUrl ?? ""}|${credentials.appid}|${robotSn}`, RECORDS_TTL_MS, async () => {
65467
+ const row = await rowFor(robotSn);
65468
+ if (!row || !finite(row.robotId))
65469
+ return { supported: true, error: `Serial ${robotSn} is not on this Ounitech account.` };
65470
+ const robotId = row.robotId;
65471
+ const tz = finite(row.timezone) ? row.timezone : 480;
65472
+ const now = /* @__PURE__ */ new Date();
65473
+ const since = (days) => robotTime(new Date(now.getTime() - days * 864e5));
65474
+ const part = async (read2) => {
65475
+ try {
65476
+ return { items: await read2() };
65477
+ } catch (e) {
65478
+ return { items: [], error: String(e?.message ?? e).slice(0, 300) };
65479
+ }
65480
+ };
65481
+ const maps = finite(row.sceneId) ? await floorMaps(row.sceneId).catch(() => []) : [];
65482
+ const tasks = await part(
65483
+ async () => ((await cloud.getTaskList(robotId, since(14), robotTime(now))).taskList ?? []).map((t) => ounitechTaskRecord(t, maps, tz)).sort((a, b) => String(b.start ?? "").localeCompare(String(a.start ?? ""))).slice(0, 50)
65484
+ );
65485
+ const alerts = await part(
65486
+ async () => ((await cloud.getAlerts(robotId, since(30), robotTime(now))).alertList ?? []).map((a) => ounitechAlertRecord(a, tz))
65487
+ );
65488
+ const consumables = await part(async () => ((await cloud.getWorkHours(robotId)).unitlist ?? []).map(ounitechConsumable));
65489
+ const power = await part(async () => ((await cloud.getHaltPlans(robotId)).planList ?? []).map(ounitechPowerPlan));
65490
+ const lifts = finite(row.sceneId) ? await part(
65491
+ async () => ((await cloud.getLiftList(row.sceneId)).liftlist ?? []).map((l) => ({
65492
+ name: String(l.liftname ?? "").trim() || `Lift ${l.liftno ?? ""}`.trim(),
65493
+ floorNo: Number.isInteger(l.floorno) ? l.floorno : null,
65494
+ online: Number(l.onlineflag) === 1,
65495
+ enabled: l.enableflag !== false
65496
+ }))
65497
+ ) : { items: [] };
65498
+ const readings = await part(async () => ounitechReadings((await cloud.getRobotState(robotId)).properties));
65499
+ const station = await part(async () => {
65500
+ const st = await cloud.getStationState(robotId);
65501
+ return st ? [{ status: String(st.statusName ?? "").trim() || null, readings: ounitechReadings(st.properties, true) }] : [];
65502
+ });
65503
+ return { supported: true, readAt: now.toISOString(), tasks, alerts, consumables, power, lifts, readings, station };
65504
+ });
65505
+ },
65086
65506
  /**
65087
65507
  * Staff Diagnose: every other read-only chapter-6 call, with the vendor's
65088
65508
  * answer (lists cut to 3). Never a command, never the signed envelope.
@@ -65156,6 +65576,9 @@ function createOunitechAdapter(credentials, options) {
65156
65576
  const r = await cloud.getAlerts(robotId, window.timeFrom, window.timeTo);
65157
65577
  return { total: r.total ?? r.alertList?.length ?? 0, latest: cut(r.alertList ?? []) };
65158
65578
  });
65579
+ await run("consumable hours (get-work-hours)", ROBOT_CLOUD_PATHS.workHours, { robotId }, async () => cut((await cloud.getWorkHours(robotId)).unitlist ?? []));
65580
+ await run("power schedule (halt-plan/get)", ROBOT_CLOUD_PATHS.haltPlans, { robotId }, async () => cut((await cloud.getHaltPlans(robotId)).planList ?? []));
65581
+ await run("base station (get-station-detail-state)", ROBOT_CLOUD_PATHS.stationState, { robotId, options: "state" }, async () => cloud.getStationState(robotId));
65159
65582
  if (finite(row.sceneId)) {
65160
65583
  const sceneId = row.sceneId;
65161
65584
  await run("lifts (get-lift-list)", ROBOT_CLOUD_PATHS.liftList, { sceneid: sceneId }, async () => {
@@ -65189,7 +65612,7 @@ var OUNITECH_BRAND_DEFINITION = {
65189
65612
  { name: "Q3-G", codes: ["Q3G", "Q3-G"] },
65190
65613
  { name: "Q3-W", codes: ["Q3W", "Q3-W"] }
65191
65614
  ],
65192
- info: { makerApp: "the Ounitech app", makerAppOnly: ["pausing or stopping a job", "cleaning across floors"] },
65615
+ info: { makerApp: "the Ounitech app", makerAppOnly: ["pausing or stopping a job", "cleaning across floors", "changing maps, areas and schedules"] },
65193
65616
  create: (credentials) => createOunitechAdapter(credentials)
65194
65617
  };
65195
65618
  function registerOunitechBrand() {
@@ -65988,7 +66411,7 @@ function createOpenRmfClient(config2, deps) {
65988
66411
  throw new OpenRmfError("The fleet server sent a reply that is not JSON.");
65989
66412
  }
65990
66413
  }
65991
- function cached3(key, ttlMs, load) {
66414
+ function cached4(key, ttlMs, load) {
65992
66415
  const k = `${config2?.baseUrl}|${key}`;
65993
66416
  const hit = cache.get(k);
65994
66417
  if (hit && now() - hit.at < ttlMs)
@@ -66000,8 +66423,8 @@ function createOpenRmfClient(config2, deps) {
66000
66423
  }
66001
66424
  const enc2 = encodeURIComponent;
66002
66425
  return {
66003
- fleets: () => cached3("fleets", 1500, () => call("GET", "/fleets")),
66004
- buildingMap: () => cached3("building_map", 6e4, () => call("GET", "/building_map")),
66426
+ fleets: () => cached4("fleets", 1500, () => call("GET", "/fleets")),
66427
+ buildingMap: () => cached4("building_map", 6e4, () => call("GET", "/building_map")),
66005
66428
  doors: () => call("GET", "/doors"),
66006
66429
  doorState: (name) => call("GET", `/doors/${enc2(name)}/state`),
66007
66430
  doorRequest: (name, mode) => call("POST", `/doors/${enc2(name)}/request`, { mode }),
@@ -67445,7 +67868,7 @@ function mapSummary(m) {
67445
67868
  }
67446
67869
  var CACHE_TTL_MS = 5 * 6e4;
67447
67870
  var cache2 = /* @__PURE__ */ new Map();
67448
- function cached2(key, load) {
67871
+ function cached3(key, load) {
67449
67872
  const hit = cache2.get(key);
67450
67873
  if (hit && Date.now() - hit.at < CACHE_TTL_MS)
67451
67874
  return hit.value;
@@ -67531,8 +67954,8 @@ function createPadbotAdapter(credentials, options = {}) {
67531
67954
  const ns = `${credentials.appid}@${options.baseUrl ?? padbotBaseUrl()}`;
67532
67955
  const account = padbotAccountKey(credentials);
67533
67956
  const callRaw = call;
67534
- const roster = () => cached2(`${ns}:robots`, () => call(PADBOT_PATHS.robots, { robotTypes: ["PATROL"] }));
67535
- const maps = (sn) => cached2(`${ns}:maps:${sn}`, () => call(PADBOT_PATHS.maps, { serialNumber: sn }).then(asList));
67957
+ const roster = () => cached3(`${ns}:robots`, () => call(PADBOT_PATHS.robots, { robotTypes: ["PATROL"] }));
67958
+ const maps = (sn) => cached3(`${ns}:maps:${sn}`, () => call(PADBOT_PATHS.maps, { serialNumber: sn }).then(asList));
67536
67959
  const states = async (sn) => {
67537
67960
  const list = await call(PADBOT_PATHS.states, { serialNumbers: [sn] });
67538
67961
  const entry = (list ?? []).find((e) => e?.serialNumber === sn);
@@ -67955,6 +68378,7 @@ function fleetStateItem(id, s, lastSeenAt) {
67955
68378
  fault: s.fault,
67956
68379
  capabilities: s.capabilities,
67957
68380
  profile: s.profile,
68381
+ cleaning: s.cleaning ?? null,
67958
68382
  lastSeenAt: lastSeenAt ? new Date(lastSeenAt) : null
67959
68383
  };
67960
68384
  }
@@ -68083,7 +68507,8 @@ function useRobotFleetService(deps) {
68083
68507
  planPosition: found.planPosition ?? null,
68084
68508
  fault,
68085
68509
  capabilities: manifest.capabilities,
68086
- profile: manifest.profile
68510
+ profile: manifest.profile,
68511
+ cleaning: manifest.capabilities.waterTanks === true && found.online ? found.cleaning ?? null : null
68087
68512
  };
68088
68513
  }
68089
68514
  async function getMaps(robot) {
@@ -68098,6 +68523,12 @@ function useRobotFleetService(deps) {
68098
68523
  return [];
68099
68524
  return adapter.getMapImages(await resolveRobotSn(robot), fileKeys);
68100
68525
  }
68526
+ async function getRecords(robot) {
68527
+ const adapter = adapterFor(robot);
68528
+ if (!adapter.getRecords)
68529
+ return null;
68530
+ return adapter.getRecords(await resolveRobotSn(robot));
68531
+ }
68101
68532
  async function getPlans(robot) {
68102
68533
  const adapter = adapterFor(robot);
68103
68534
  if (!adapter.getPlans)
@@ -68467,6 +68898,7 @@ function useRobotFleetService(deps) {
68467
68898
  getMaps,
68468
68899
  getMapImages,
68469
68900
  getPlans,
68901
+ getRecords,
68470
68902
  getPatrolRoutes,
68471
68903
  dispatch: dispatch2
68472
68904
  };
@@ -71060,9 +71492,9 @@ function rmfSummary(rmf) {
71060
71492
  }
71061
71493
 
71062
71494
  // src/services/robot-tracking.service.ts
71063
- var import_axios4 = __toESM(require("axios"));
71495
+ var import_axios5 = __toESM(require("axios"));
71064
71496
  async function openWithAxios(url2, body) {
71065
- const response = await import_axios4.default.post(url2, body, {
71497
+ const response = await import_axios5.default.post(url2, body, {
71066
71498
  responseType: "stream",
71067
71499
  // No read timeout: this connection is SUPPOSED to stay open and mostly
71068
71500
  // silent. A request timeout here would sever a healthy stream on a quiet
@@ -71275,6 +71707,14 @@ function useRobotFleetController(deps) {
71275
71707
  fail(next, error);
71276
71708
  }
71277
71709
  }
71710
+ async function getRecords(req, res, next) {
71711
+ try {
71712
+ const robot = await entitleRobot(req, req.params.id);
71713
+ res.json(await getFleet2().getRecords(robot) ?? { supported: false });
71714
+ } catch (error) {
71715
+ fail(next, error);
71716
+ }
71717
+ }
71278
71718
  async function getPatrolRoutes(req, res, next) {
71279
71719
  try {
71280
71720
  const robot = await entitleRobot(req, req.params.id);
@@ -71568,6 +72008,7 @@ function useRobotFleetController(deps) {
71568
72008
  getMaps,
71569
72009
  getMapImages,
71570
72010
  getPlans,
72011
+ getRecords,
71571
72012
  getPatrolRoutes,
71572
72013
  sendCommand: sendCommand2,
71573
72014
  trackRobot,
@@ -80206,13 +80647,13 @@ function useSiteBillingItemRepo() {
80206
80647
  }
80207
80648
  const cacheKey = (0, import_node_server_utils209.makeCacheKey)(namespace_collection3, { _id: String(_id) });
80208
80649
  try {
80209
- const cached3 = await getCache(cacheKey);
80210
- if (cached3) {
80650
+ const cached4 = await getCache(cacheKey);
80651
+ if (cached4) {
80211
80652
  import_node_server_utils209.logger.log({
80212
80653
  level: "info",
80213
80654
  message: `Cache hit for getById site billing items: ${cacheKey}`
80214
80655
  });
80215
- return cached3;
80656
+ return cached4;
80216
80657
  }
80217
80658
  const result = await collection.findOne({
80218
80659
  _id
@@ -80566,13 +81007,13 @@ function useSiteBillingConfigurationRepo() {
80566
81007
  }
80567
81008
  const cacheKey = (0, import_node_server_utils211.makeCacheKey)(namespace_collection3, { _id: String(_id) });
80568
81009
  try {
80569
- const cached3 = await getCache(cacheKey);
80570
- if (cached3) {
81010
+ const cached4 = await getCache(cacheKey);
81011
+ if (cached4) {
80571
81012
  import_node_server_utils211.logger.log({
80572
81013
  level: "info",
80573
81014
  message: `Cache hit for getById site billing configuration: ${cacheKey}`
80574
81015
  });
80575
- return cached3;
81016
+ return cached4;
80576
81017
  }
80577
81018
  const result = await collection.findOne({
80578
81019
  _id
@@ -82217,13 +82658,13 @@ function useSiteUnitBillingRepo() {
82217
82658
  }
82218
82659
  const cacheKey = (0, import_node_server_utils220.makeCacheKey)(namespace_collection3, { _id: String(_id) });
82219
82660
  try {
82220
- const cached3 = await getCache(cacheKey);
82221
- if (cached3) {
82661
+ const cached4 = await getCache(cacheKey);
82662
+ if (cached4) {
82222
82663
  import_node_server_utils220.logger.log({
82223
82664
  level: "info",
82224
82665
  message: `Cache hit for getById site unit billing: ${cacheKey}`
82225
82666
  });
82226
- return cached3;
82667
+ return cached4;
82227
82668
  }
82228
82669
  const result = await collection.findOne({
82229
82670
  _id
@@ -85026,13 +85467,13 @@ function useNfcPatrolRouteRepo() {
85026
85467
  }
85027
85468
  const cacheKey = (0, import_node_server_utils227.makeCacheKey)(namespace_collection3, cacheParams);
85028
85469
  try {
85029
- const cached3 = await getCache(cacheKey);
85030
- if (cached3) {
85470
+ const cached4 = await getCache(cacheKey);
85471
+ if (cached4) {
85031
85472
  import_node_server_utils227.logger.log({
85032
85473
  level: "info",
85033
85474
  message: `Cache hit for getById ${namespace_collection3}: ${cacheKey}`
85034
85475
  });
85035
- return cached3;
85476
+ return cached4;
85036
85477
  }
85037
85478
  let result;
85038
85479
  if (isStart === true) {
@@ -86480,13 +86921,13 @@ function useStatementOfAccountRepo() {
86480
86921
  }
86481
86922
  const cacheKey = (0, import_node_server_utils235.makeCacheKey)(namespace_collection3, { _id: String(_id) });
86482
86923
  try {
86483
- const cached3 = await getCache(cacheKey);
86484
- if (cached3) {
86924
+ const cached4 = await getCache(cacheKey);
86925
+ if (cached4) {
86485
86926
  import_node_server_utils235.logger.log({
86486
86927
  level: "info",
86487
86928
  message: `Cache hit for getById soa: ${cacheKey}`
86488
86929
  });
86489
- return cached3;
86930
+ return cached4;
86490
86931
  }
86491
86932
  const result = await collection.findOne({
86492
86933
  _id
@@ -93558,7 +93999,7 @@ var MManpowerMonitoring = class {
93558
93999
  var import_node_server_utils265 = require("@7365admin1/node-server-utils");
93559
94000
 
93560
94001
  // src/utils/hrmlabs-attendance.util.ts
93561
- var import_axios5 = __toESM(require("axios"));
94002
+ var import_axios6 = __toESM(require("axios"));
93562
94003
  var import_moment_timezone7 = __toESM(require("moment-timezone"));
93563
94004
  var default_early_checkIn = 4;
93564
94005
  async function hrmLabsAuthentication({
@@ -93567,7 +94008,7 @@ async function hrmLabsAuthentication({
93567
94008
  password,
93568
94009
  domain
93569
94010
  }) {
93570
- const res = await import_axios5.default.post(
94011
+ const res = await import_axios6.default.post(
93571
94012
  authUrl,
93572
94013
  {
93573
94014
  grant_type: "password",
@@ -93597,7 +94038,7 @@ async function fetchAttendanceData({
93597
94038
  search
93598
94039
  }) {
93599
94040
  try {
93600
- const res = await import_axios5.default.post(
94041
+ const res = await import_axios6.default.post(
93601
94042
  attendanceUrl,
93602
94043
  {
93603
94044
  start: startDate,
@@ -93797,7 +94238,7 @@ async function fetchSites({ siteUrl, token }) {
93797
94238
  do {
93798
94239
  try {
93799
94240
  attempt++;
93800
- const res = await import_axios5.default.get(siteUrl, {
94241
+ const res = await import_axios6.default.get(siteUrl, {
93801
94242
  headers: { Authorization: `Bearer ${token}` },
93802
94243
  timeout: 15e3
93803
94244
  });
@@ -97348,7 +97789,7 @@ async function manpowerEvents(io) {
97348
97789
  }
97349
97790
 
97350
97791
  // src/services/reddot-payment.service.ts
97351
- var import_axios6 = __toESM(require("axios"));
97792
+ var import_axios7 = __toESM(require("axios"));
97352
97793
 
97353
97794
  // src/utils/payment-signature.util.ts
97354
97795
  var crypto11 = __toESM(require("crypto"));
@@ -97982,7 +98423,7 @@ var useRedDotPaymentSvc = () => {
97982
98423
  );
97983
98424
  }
97984
98425
  const url2 = process.env.MERCHANT_PAYMENT;
97985
- const response = await import_axios6.default.post(url2, dataString, { headers });
98426
+ const response = await import_axios7.default.post(url2, dataString, { headers });
97986
98427
  const result = response.data;
97987
98428
  return result;
97988
98429
  } catch (error) {
@@ -98016,7 +98457,7 @@ var useRedDotPaymentSvc = () => {
98016
98457
  );
98017
98458
  }
98018
98459
  const url2 = process.env.MERCHANT_ENQUIRY;
98019
- const response = await import_axios6.default.post(url2, dataString, { headers });
98460
+ const response = await import_axios7.default.post(url2, dataString, { headers });
98020
98461
  const result = response.data;
98021
98462
  const transactionId = result.transaction_id;
98022
98463
  const amount = result.request_amount || 0;
@@ -107181,6 +107622,7 @@ function usePersonalEmergencyChainController() {
107181
107622
  claimReadsAsStale,
107182
107623
  clampChassis,
107183
107624
  clampPtzSpeed,
107625
+ clearOunitechCaches,
107184
107626
  clearPadbotCache,
107185
107627
  clearRobotBrands,
107186
107628
  clockDriftSeconds,
@@ -107374,9 +107816,19 @@ function usePersonalEmergencyChainController() {
107374
107816
  orgQualifiesForOwnerRepair,
107375
107817
  orgRoleSets,
107376
107818
  orgSchema,
107819
+ ounitechAlertRecord,
107820
+ ounitechCleaning,
107821
+ ounitechConsumable,
107822
+ ounitechCurrentMap,
107377
107823
  ounitechFault,
107378
107824
  ounitechJobWords,
107825
+ ounitechMapShare,
107826
+ ounitechMapView,
107827
+ ounitechPowerPlan,
107828
+ ounitechReadings,
107379
107829
  ounitechRobotFromHomeRow,
107830
+ ounitechTaskRecord,
107831
+ ounitechTime,
107380
107832
  overnight_parking_requests_namespace_collection,
107381
107833
  padbotAccountKey,
107382
107834
  padbotAlarmFault,
@@ -107429,6 +107881,7 @@ function usePersonalEmergencyChainController() {
107429
107881
  platform_terms_namespace_collection,
107430
107882
  playbackRelays,
107431
107883
  playbackWindowRefusal,
107884
+ pngSize,
107432
107885
  promoCodeRefusal,
107433
107886
  promoCodeSchema,
107434
107887
  promoCodeStatusSchema,