@7365admin1/core 3.118.0 → 3.120.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 +12 -0
- package/dist/index.d.ts +81 -11
- package/dist/index.js +145 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +193 -58
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/ounitech-timestamp-probe.test.mjs +169 -0
package/dist/index.mjs
CHANGED
|
@@ -61990,7 +61990,7 @@ function clearRobotBrands() {
|
|
|
61990
61990
|
}
|
|
61991
61991
|
|
|
61992
61992
|
// src/services/robot-fleet.service.ts
|
|
61993
|
-
import { BadRequestError as BadRequestError136, NotFoundError as NotFoundError43 } from "@7365admin1/node-server-utils";
|
|
61993
|
+
import { AppError as AppError25, BadRequestError as BadRequestError136, NotFoundError as NotFoundError43 } from "@7365admin1/node-server-utils";
|
|
61994
61994
|
|
|
61995
61995
|
// src/services/robot-cloud.service.ts
|
|
61996
61996
|
import axios3 from "axios";
|
|
@@ -62001,9 +62001,36 @@ import * as crypto10 from "crypto";
|
|
|
62001
62001
|
function robotCloudSigningString(appid, timestamp, path5, secret) {
|
|
62002
62002
|
return `appid=${appid},timestamp=${timestamp},url=${path5},secret=${secret}`;
|
|
62003
62003
|
}
|
|
62004
|
-
|
|
62004
|
+
var ROBOT_CLOUD_TIMESTAMP_FORMATS = [
|
|
62005
|
+
"yyyyMMddHHmmss",
|
|
62006
|
+
"unix-s",
|
|
62007
|
+
"unix-ms",
|
|
62008
|
+
"yyyy-MM-dd HH:mm:ss",
|
|
62009
|
+
"iso8601",
|
|
62010
|
+
"unix-s-number",
|
|
62011
|
+
"unix-ms-number"
|
|
62012
|
+
];
|
|
62013
|
+
var OUNITECH_TIMESTAMP_FORMAT = "yyyyMMddHHmmss";
|
|
62014
|
+
function robotCloudTimestamp(now = /* @__PURE__ */ new Date(), format2 = OUNITECH_TIMESTAMP_FORMAT) {
|
|
62005
62015
|
const p = (n, w = 2) => String(n).padStart(w, "0");
|
|
62006
|
-
|
|
62016
|
+
const date = `${p(now.getUTCFullYear(), 4)}-${p(now.getUTCMonth() + 1)}-${p(now.getUTCDate())}`;
|
|
62017
|
+
const time = `${p(now.getUTCHours())}:${p(now.getUTCMinutes())}:${p(now.getUTCSeconds())}`;
|
|
62018
|
+
switch (format2) {
|
|
62019
|
+
case "unix-s":
|
|
62020
|
+
case "unix-s-number":
|
|
62021
|
+
return String(Math.floor(now.getTime() / 1e3));
|
|
62022
|
+
case "unix-ms":
|
|
62023
|
+
case "unix-ms-number":
|
|
62024
|
+
return String(now.getTime());
|
|
62025
|
+
case "yyyy-MM-dd HH:mm:ss":
|
|
62026
|
+
return `${date} ${time}`;
|
|
62027
|
+
case "iso8601":
|
|
62028
|
+
return `${date}T${time}Z`;
|
|
62029
|
+
case "yyyyMMddHHmmss":
|
|
62030
|
+
return `${date}${time}`.replace(/[-:]/g, "");
|
|
62031
|
+
default:
|
|
62032
|
+
throw new Error(`Robot cloud: unknown timestamp format "${format2}".`);
|
|
62033
|
+
}
|
|
62007
62034
|
}
|
|
62008
62035
|
function robotCloudSign(appid, timestamp, path5, secret) {
|
|
62009
62036
|
if (!appid)
|
|
@@ -62015,11 +62042,11 @@ function robotCloudSign(appid, timestamp, path5, secret) {
|
|
|
62015
62042
|
}
|
|
62016
62043
|
return crypto10.createHash("sha1").update(robotCloudSigningString(appid, timestamp, path5, secret)).digest("hex");
|
|
62017
62044
|
}
|
|
62018
|
-
function robotCloudBody(appid, secret, path5, params = {}, now) {
|
|
62019
|
-
const timestamp = robotCloudTimestamp(now);
|
|
62045
|
+
function robotCloudBody(appid, secret, path5, params = {}, now, format2 = OUNITECH_TIMESTAMP_FORMAT) {
|
|
62046
|
+
const timestamp = robotCloudTimestamp(now, format2);
|
|
62020
62047
|
return {
|
|
62021
62048
|
appid,
|
|
62022
|
-
timestamp,
|
|
62049
|
+
timestamp: format2.endsWith("-number") ? Number(timestamp) : timestamp,
|
|
62023
62050
|
sign: robotCloudSign(appid, timestamp, path5, secret),
|
|
62024
62051
|
...params
|
|
62025
62052
|
};
|
|
@@ -62376,7 +62403,9 @@ function useRobotCloudService(credentials, options = {}) {
|
|
|
62376
62403
|
credentials.appid,
|
|
62377
62404
|
credentials.secret,
|
|
62378
62405
|
path5,
|
|
62379
|
-
params
|
|
62406
|
+
params,
|
|
62407
|
+
options.now?.(),
|
|
62408
|
+
options.timestampFormat
|
|
62380
62409
|
);
|
|
62381
62410
|
const step = robotCloudStepName(path5);
|
|
62382
62411
|
let data;
|
|
@@ -65040,6 +65069,17 @@ function registerPadbotBrand() {
|
|
|
65040
65069
|
registerPadbotBrand();
|
|
65041
65070
|
|
|
65042
65071
|
// src/services/robot-fleet.service.ts
|
|
65072
|
+
var TIMESTAMP_OFFSET_CANDIDATES = [
|
|
65073
|
+
{ offsetMinutes: 120, label: "UTC+2 (Frankfurt summer time)" },
|
|
65074
|
+
{ offsetMinutes: 60, label: "UTC+1 (Frankfurt winter time)" },
|
|
65075
|
+
{ offsetMinutes: 480, label: "UTC+8 (China / Singapore)" },
|
|
65076
|
+
{ offsetMinutes: -480, label: "UTC-8" },
|
|
65077
|
+
{ offsetMinutes: 540, label: "UTC+9" },
|
|
65078
|
+
{ offsetMinutes: 1, label: "UTC +1 min drift" },
|
|
65079
|
+
{ offsetMinutes: -1, label: "UTC -1 min drift" }
|
|
65080
|
+
];
|
|
65081
|
+
var lastTimestampProbe = /* @__PURE__ */ new Map();
|
|
65082
|
+
var TIMESTAMP_PROBE_INTERVAL_MS = 6e4;
|
|
65043
65083
|
function cloudHost(baseUrl) {
|
|
65044
65084
|
try {
|
|
65045
65085
|
return new URL(baseUrl).host;
|
|
@@ -65383,8 +65423,93 @@ function useRobotFleetService(deps) {
|
|
|
65383
65423
|
}
|
|
65384
65424
|
return out(null, "Every step worked.");
|
|
65385
65425
|
}
|
|
65426
|
+
function probeGate(robot, kind) {
|
|
65427
|
+
if (String(robot.brand ?? "").trim() !== OUNITECH_BRAND) {
|
|
65428
|
+
throw new BadRequestError136("The timestamp probe is for Ounitech robots only.");
|
|
65429
|
+
}
|
|
65430
|
+
const id = robot._id ? String(robot._id) : "";
|
|
65431
|
+
const key = `${id}:${kind}`;
|
|
65432
|
+
const last = lastTimestampProbe.get(key);
|
|
65433
|
+
if (last && Date.now() - last < TIMESTAMP_PROBE_INTERVAL_MS) {
|
|
65434
|
+
const wait = Math.ceil((TIMESTAMP_PROBE_INTERVAL_MS - (Date.now() - last)) / 1e3);
|
|
65435
|
+
throw new AppError25(`The timestamp probe ran for this robot less than a minute ago - try again in ${wait} s.`, 429);
|
|
65436
|
+
}
|
|
65437
|
+
const pair = robotCloudCredentials(robot);
|
|
65438
|
+
if (!pair.appid || !pair.secret) {
|
|
65439
|
+
throw new BadRequestError136("No AppID and Secret saved on this robot - run Diagnose first.");
|
|
65440
|
+
}
|
|
65441
|
+
lastTimestampProbe.set(key, Date.now());
|
|
65442
|
+
return { id, pair };
|
|
65443
|
+
}
|
|
65444
|
+
async function probeTimestampOffset(robot) {
|
|
65445
|
+
const { id, pair } = probeGate(robot, "offset");
|
|
65446
|
+
const baseUrl = deps?.cloudOptions?.baseUrl ?? ROBOT_CLOUD_BASE_URL;
|
|
65447
|
+
let skewMs = null;
|
|
65448
|
+
const onReply = ({ date }) => {
|
|
65449
|
+
const t = date ? Date.parse(date) : NaN;
|
|
65450
|
+
if (skewMs === null && !Number.isNaN(t))
|
|
65451
|
+
skewMs = t - Date.now();
|
|
65452
|
+
};
|
|
65453
|
+
const attempts = [];
|
|
65454
|
+
let accepted = null;
|
|
65455
|
+
for (const c of [{ offsetMinutes: 0, label: "UTC (current)" }, ...TIMESTAMP_OFFSET_CANDIDATES]) {
|
|
65456
|
+
const now = () => new Date(Date.now() + (skewMs ?? 0) + c.offsetMinutes * 6e4);
|
|
65457
|
+
const sent = robotCloudTimestamp(now(), "yyyyMMddHHmmss");
|
|
65458
|
+
try {
|
|
65459
|
+
const robots = await useRobotCloudService(pair, { ...deps?.cloudOptions, timestampFormat: "yyyyMMddHHmmss", now, onReply }).getRobots();
|
|
65460
|
+
attempts.push({ ...c, sent, ok: true, detail: `Accepted. The account lists ${robots.length} robot${robots.length === 1 ? "" : "s"}.` });
|
|
65461
|
+
accepted = c.offsetMinutes;
|
|
65462
|
+
break;
|
|
65463
|
+
} catch (e) {
|
|
65464
|
+
attempts.push({ ...c, sent, ok: false, ...describeFailure(e) });
|
|
65465
|
+
if (e instanceof RobotCloudError && (e.kind === "unreachable" || e.kind === "timeout"))
|
|
65466
|
+
break;
|
|
65467
|
+
}
|
|
65468
|
+
}
|
|
65469
|
+
const skew = skewMs;
|
|
65470
|
+
const winner = attempts[attempts.length - 1];
|
|
65471
|
+
return {
|
|
65472
|
+
robotId: id,
|
|
65473
|
+
cloudHost: cloudHost(baseUrl),
|
|
65474
|
+
vendorSkewSeconds: skew === null ? null : Math.round(skew / 1e3),
|
|
65475
|
+
acceptedOffsetMinutes: accepted,
|
|
65476
|
+
attempts,
|
|
65477
|
+
summary: accepted === null ? "Ounitech accepted none of the offsets tried - ask Ounitech for an exact example timestamp." : accepted === 0 ? "Ounitech accepts plain UTC now - the earlier refusal was not the offset." : `Ounitech accepts yyyyMMddHHmmss at ${winner.label} (${accepted > 0 ? "+" : ""}${accepted} min from UTC).`,
|
|
65478
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
65479
|
+
};
|
|
65480
|
+
}
|
|
65481
|
+
async function probeTimestampFormat(robot) {
|
|
65482
|
+
const { id, pair } = probeGate(robot, "format");
|
|
65483
|
+
const baseUrl = deps?.cloudOptions?.baseUrl ?? ROBOT_CLOUD_BASE_URL;
|
|
65484
|
+
const attempts = [];
|
|
65485
|
+
let accepted = null;
|
|
65486
|
+
for (const format2 of ROBOT_CLOUD_TIMESTAMP_FORMATS) {
|
|
65487
|
+
const sent = robotCloudTimestamp(/* @__PURE__ */ new Date(), format2);
|
|
65488
|
+
try {
|
|
65489
|
+
const robots = await useRobotCloudService(pair, { ...deps?.cloudOptions, timestampFormat: format2 }).getRobots();
|
|
65490
|
+
attempts.push({ format: format2, sent, ok: true, detail: `Accepted. The account lists ${robots.length} robot${robots.length === 1 ? "" : "s"}.` });
|
|
65491
|
+
accepted = format2;
|
|
65492
|
+
break;
|
|
65493
|
+
} catch (e) {
|
|
65494
|
+
attempts.push({ format: format2, sent, ok: false, ...describeFailure(e) });
|
|
65495
|
+
if (e instanceof RobotCloudError && (e.kind === "unreachable" || e.kind === "timeout"))
|
|
65496
|
+
break;
|
|
65497
|
+
}
|
|
65498
|
+
}
|
|
65499
|
+
return {
|
|
65500
|
+
robotId: id,
|
|
65501
|
+
cloudHost: cloudHost(baseUrl),
|
|
65502
|
+
currentFormat: OUNITECH_TIMESTAMP_FORMAT,
|
|
65503
|
+
accepted,
|
|
65504
|
+
attempts,
|
|
65505
|
+
summary: accepted ? accepted === OUNITECH_TIMESTAMP_FORMAT ? `Ounitech accepts "${accepted}", the format already in use - the refusal is not the timestamp format.` : `Ounitech accepts "${accepted}". Switch OUNITECH_TIMESTAMP_FORMAT to it.` : "Ounitech accepted none of the formats tried - ask Ounitech for the exact format with an example.",
|
|
65506
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
65507
|
+
};
|
|
65508
|
+
}
|
|
65386
65509
|
return {
|
|
65387
65510
|
diagnose,
|
|
65511
|
+
probeTimestampFormat,
|
|
65512
|
+
probeTimestampOffset,
|
|
65388
65513
|
getLiveVideo,
|
|
65389
65514
|
resolveAlerts,
|
|
65390
65515
|
getPatrolHistory,
|
|
@@ -66763,7 +66888,7 @@ function startPadbotLiveFeed(deps = {}) {
|
|
|
66763
66888
|
|
|
66764
66889
|
// src/services/padbot-drive.service.ts
|
|
66765
66890
|
import { randomBytes as randomBytes3, randomUUID as randomUUID2 } from "crypto";
|
|
66766
|
-
import { AppError as
|
|
66891
|
+
import { AppError as AppError26, BadRequestError as BadRequestError138, logger as logger111 } from "@7365admin1/node-server-utils";
|
|
66767
66892
|
var sessions = /* @__PURE__ */ new Map();
|
|
66768
66893
|
var byRobot = /* @__PURE__ */ new Map();
|
|
66769
66894
|
var endedWhy = /* @__PURE__ */ new Map();
|
|
@@ -66804,7 +66929,7 @@ async function startPadbotDrive(robot, userId, deps = {}) {
|
|
|
66804
66929
|
if (current) {
|
|
66805
66930
|
const s = sessions.get(current);
|
|
66806
66931
|
if (s && s.userId !== userId)
|
|
66807
|
-
throw new
|
|
66932
|
+
throw new AppError26("Someone else is controlling this robot right now.", 409);
|
|
66808
66933
|
s?.watchdog.end("replaced");
|
|
66809
66934
|
}
|
|
66810
66935
|
if (!(deps.linkUp ?? padbotLinkUp)(robotId)) {
|
|
@@ -66881,7 +67006,7 @@ function padbotDriveSignal(robotId, sessionId, userId, signal) {
|
|
|
66881
67006
|
const s = sessions.get(sessionId);
|
|
66882
67007
|
if (!s || s.robotId !== robotId || s.userId !== userId) {
|
|
66883
67008
|
const why = endedWhy.get(sessionId);
|
|
66884
|
-
throw new
|
|
67009
|
+
throw new AppError26(DRIVE_END_TEXT[why?.reason ?? ""] ?? "Manual control has ended.", 410);
|
|
66885
67010
|
}
|
|
66886
67011
|
if (signal.seq <= s.seq)
|
|
66887
67012
|
return { ok: true, moving: s.watchdog.moving };
|
|
@@ -66905,7 +67030,7 @@ function padbotDriveSignal(robotId, sessionId, userId, signal) {
|
|
|
66905
67030
|
}
|
|
66906
67031
|
if (s.watchdog.ended) {
|
|
66907
67032
|
const why = endedWhy.get(sessionId);
|
|
66908
|
-
throw new
|
|
67033
|
+
throw new AppError26(DRIVE_END_TEXT[why?.reason ?? ""] ?? "Manual control has ended.", 410);
|
|
66909
67034
|
}
|
|
66910
67035
|
return { ok: true, moving: s.watchdog.moving };
|
|
66911
67036
|
}
|
|
@@ -68129,7 +68254,7 @@ function startRobotTracking(options) {
|
|
|
68129
68254
|
|
|
68130
68255
|
// src/controllers/robot-fleet.controller.ts
|
|
68131
68256
|
import Joi76 from "joi";
|
|
68132
|
-
import { AppError as
|
|
68257
|
+
import { AppError as AppError27, BadRequestError as BadRequestError139, logger as logger112 } from "@7365admin1/node-server-utils";
|
|
68133
68258
|
function useRobotFleetController(deps) {
|
|
68134
68259
|
let repo = null;
|
|
68135
68260
|
const getRepo = () => repo ?? (repo = useRobotRepo());
|
|
@@ -68159,7 +68284,7 @@ function useRobotFleetController(deps) {
|
|
|
68159
68284
|
if (error?.isOperational)
|
|
68160
68285
|
return next(error);
|
|
68161
68286
|
next(
|
|
68162
|
-
new
|
|
68287
|
+
new AppError27(
|
|
68163
68288
|
"Couldn't read this robot from its cloud (unexpected error). Seven365 staff can run Diagnose on the robot to see the failing step.",
|
|
68164
68289
|
502
|
|
68165
68290
|
)
|
|
@@ -68445,9 +68570,16 @@ function useRobotFleetController(deps) {
|
|
|
68445
68570
|
async function diagnoseRobot(req, res, next) {
|
|
68446
68571
|
try {
|
|
68447
68572
|
await requirePlatformStaff(req, CROSS_CLIENT_GRANT);
|
|
68573
|
+
const probe = req.query.probe;
|
|
68574
|
+
if (probe !== void 0 && probe !== "timestamp" && probe !== "timestamp-offset") {
|
|
68575
|
+
return fail(next, new BadRequestError139('probe must be "timestamp" or "timestamp-offset".'));
|
|
68576
|
+
}
|
|
68448
68577
|
const robot = await entitleRobot(req, req.params.id);
|
|
68449
68578
|
res.set("Cache-Control", "no-store");
|
|
68450
|
-
|
|
68579
|
+
const fleet2 = getFleet2();
|
|
68580
|
+
res.json(
|
|
68581
|
+
probe === "timestamp" ? await fleet2.probeTimestampFormat(robot) : probe === "timestamp-offset" ? await fleet2.probeTimestampOffset(robot) : await fleet2.diagnose(robot)
|
|
68582
|
+
);
|
|
68451
68583
|
} catch (error) {
|
|
68452
68584
|
fail(next, error);
|
|
68453
68585
|
}
|
|
@@ -68722,7 +68854,7 @@ import {
|
|
|
68722
68854
|
paginate as paginate35,
|
|
68723
68855
|
BadRequestError as BadRequestError140,
|
|
68724
68856
|
NotFoundError as NotFoundError44,
|
|
68725
|
-
AppError as
|
|
68857
|
+
AppError as AppError28
|
|
68726
68858
|
} from "@7365admin1/node-server-utils";
|
|
68727
68859
|
var NOT_DELETED2 = { deletedAt: { $in: ["", null] } };
|
|
68728
68860
|
function toObjectId16(id, what) {
|
|
@@ -68863,7 +68995,7 @@ function useRobotBuildingMapRepo() {
|
|
|
68863
68995
|
}
|
|
68864
68996
|
);
|
|
68865
68997
|
if (!res.matchedCount) {
|
|
68866
|
-
throw new
|
|
68998
|
+
throw new AppError28(
|
|
68867
68999
|
"This map was changed by someone else since you opened it. Reload it and make your change again.",
|
|
68868
69000
|
409
|
|
68869
69001
|
);
|
|
@@ -68891,7 +69023,7 @@ function useRobotBuildingMapRepo() {
|
|
|
68891
69023
|
const exists = await collection.countDocuments({ _id: id, ...NOT_DELETED2, "floorPlans.floorNo": floorNo2 });
|
|
68892
69024
|
if (!exists)
|
|
68893
69025
|
throw new NotFoundError44("This floor has no plan.");
|
|
68894
|
-
throw new
|
|
69026
|
+
throw new AppError28("This map was changed by someone else since you opened it. Reload it and make your change again.", 409);
|
|
68895
69027
|
}
|
|
68896
69028
|
return version + 1;
|
|
68897
69029
|
}
|
|
@@ -68912,7 +69044,7 @@ function useRobotBuildingMapRepo() {
|
|
|
68912
69044
|
}
|
|
68913
69045
|
);
|
|
68914
69046
|
if (!res.matchedCount) {
|
|
68915
|
-
throw new
|
|
69047
|
+
throw new AppError28(
|
|
68916
69048
|
"This map was changed by someone else since you opened it. Reload it and make your change again.",
|
|
68917
69049
|
409
|
|
68918
69050
|
);
|
|
@@ -69033,7 +69165,7 @@ function useRobotLiftSessionRepo() {
|
|
|
69033
69165
|
insertedId = res.insertedId;
|
|
69034
69166
|
} catch (error) {
|
|
69035
69167
|
if (isDuplicateKey(error)) {
|
|
69036
|
-
throw new
|
|
69168
|
+
throw new AppError28("This robot already has a lift request open. Release it first.", 409);
|
|
69037
69169
|
}
|
|
69038
69170
|
throw error;
|
|
69039
69171
|
}
|
|
@@ -69071,7 +69203,7 @@ function useRobotLiftSessionRepo() {
|
|
|
69071
69203
|
{ $set: { expiresAt: new Date(now.getTime() + LIFT_LEASE_MS), updatedAt: now } }
|
|
69072
69204
|
);
|
|
69073
69205
|
if (!res.matchedCount) {
|
|
69074
|
-
throw new
|
|
69206
|
+
throw new AppError28("This lift session is no longer active.", 409);
|
|
69075
69207
|
}
|
|
69076
69208
|
}
|
|
69077
69209
|
async function release(session, reason = "released") {
|
|
@@ -69129,7 +69261,7 @@ function useRobotLiftSessionRepo() {
|
|
|
69129
69261
|
|
|
69130
69262
|
// src/controllers/robot-map.controller.ts
|
|
69131
69263
|
import Joi78 from "joi";
|
|
69132
|
-
import { AppError as
|
|
69264
|
+
import { AppError as AppError29, BadRequestError as BadRequestError141, NotFoundError as NotFoundError45, logger as logger113 } from "@7365admin1/node-server-utils";
|
|
69133
69265
|
import { load as loadYaml, CORE_SCHEMA as YAML_CORE_SCHEMA } from "js-yaml";
|
|
69134
69266
|
function useRobotMapController(deps) {
|
|
69135
69267
|
const now = () => deps?.now?.() ?? Date.now();
|
|
@@ -69577,7 +69709,7 @@ function useRobotMapController(deps) {
|
|
|
69577
69709
|
try {
|
|
69578
69710
|
const session = await entitleSession(req);
|
|
69579
69711
|
if (!session.open)
|
|
69580
|
-
throw new
|
|
69712
|
+
throw new AppError29("This lift session is already closed.", 409);
|
|
69581
69713
|
await lifts().release(session);
|
|
69582
69714
|
await audit2(
|
|
69583
69715
|
req,
|
|
@@ -69643,7 +69775,7 @@ function useRobotMapController(deps) {
|
|
|
69643
69775
|
liftStates: liftStates.filter(Boolean)
|
|
69644
69776
|
});
|
|
69645
69777
|
} catch (e) {
|
|
69646
|
-
fail(next, e instanceof OpenRmfError ? new
|
|
69778
|
+
fail(next, e instanceof OpenRmfError ? new AppError29(e.message, 502) : e);
|
|
69647
69779
|
}
|
|
69648
69780
|
}
|
|
69649
69781
|
return {
|
|
@@ -70136,7 +70268,7 @@ function MPatrolQuestion(value) {
|
|
|
70136
70268
|
|
|
70137
70269
|
// src/repositories/patrol-question.repo.ts
|
|
70138
70270
|
import {
|
|
70139
|
-
AppError as
|
|
70271
|
+
AppError as AppError30,
|
|
70140
70272
|
BadRequestError as BadRequestError145,
|
|
70141
70273
|
InternalServerError as InternalServerError52,
|
|
70142
70274
|
logger as logger117,
|
|
@@ -70200,7 +70332,7 @@ function usePatrolQuestionRepo() {
|
|
|
70200
70332
|
if (isDuplicated) {
|
|
70201
70333
|
throw new BadRequestError145("Question already exist.");
|
|
70202
70334
|
}
|
|
70203
|
-
if (error instanceof
|
|
70335
|
+
if (error instanceof AppError30) {
|
|
70204
70336
|
throw error;
|
|
70205
70337
|
} else {
|
|
70206
70338
|
throw new Error("Failed to create Patrol Question.");
|
|
@@ -70601,7 +70733,7 @@ function MPatrolRoute(value) {
|
|
|
70601
70733
|
|
|
70602
70734
|
// src/repositories/patrol-route.repo.ts
|
|
70603
70735
|
import {
|
|
70604
|
-
AppError as
|
|
70736
|
+
AppError as AppError31,
|
|
70605
70737
|
BadRequestError as BadRequestError148,
|
|
70606
70738
|
InternalServerError as InternalServerError53,
|
|
70607
70739
|
logger as logger120,
|
|
@@ -70679,7 +70811,7 @@ function usePatrolRouteRepo() {
|
|
|
70679
70811
|
if (isDuplicated) {
|
|
70680
70812
|
throw new BadRequestError148("Route already exist.");
|
|
70681
70813
|
}
|
|
70682
|
-
if (error instanceof
|
|
70814
|
+
if (error instanceof AppError31) {
|
|
70683
70815
|
throw error;
|
|
70684
70816
|
} else {
|
|
70685
70817
|
throw new Error("Failed to create Patrol Route.");
|
|
@@ -71381,7 +71513,7 @@ function MPatrolLog(value) {
|
|
|
71381
71513
|
|
|
71382
71514
|
// src/repositories/patrol-log.repo.ts
|
|
71383
71515
|
import {
|
|
71384
|
-
AppError as
|
|
71516
|
+
AppError as AppError32,
|
|
71385
71517
|
BadRequestError as BadRequestError151,
|
|
71386
71518
|
InternalServerError as InternalServerError54,
|
|
71387
71519
|
logger as logger123,
|
|
@@ -71447,7 +71579,7 @@ function usePatrolLogRepo() {
|
|
|
71447
71579
|
if (isDuplicated) {
|
|
71448
71580
|
throw new BadRequestError151("Log already exist.");
|
|
71449
71581
|
}
|
|
71450
|
-
if (error instanceof
|
|
71582
|
+
if (error instanceof AppError32) {
|
|
71451
71583
|
throw error;
|
|
71452
71584
|
} else {
|
|
71453
71585
|
throw new Error("Failed to create Patrol Log.");
|
|
@@ -72179,7 +72311,7 @@ function MPatrolEmail(value) {
|
|
|
72179
72311
|
|
|
72180
72312
|
// src/repositories/patrol-email.repo.ts
|
|
72181
72313
|
import {
|
|
72182
|
-
AppError as
|
|
72314
|
+
AppError as AppError33,
|
|
72183
72315
|
BadRequestError as BadRequestError155,
|
|
72184
72316
|
InternalServerError as InternalServerError55,
|
|
72185
72317
|
logger as logger126,
|
|
@@ -72232,7 +72364,7 @@ function usePatrolEmailRepo() {
|
|
|
72232
72364
|
return { ...document2, _id: res.insertedId };
|
|
72233
72365
|
} catch (error) {
|
|
72234
72366
|
logger126.log({ level: "error", message: error.message });
|
|
72235
|
-
if (error instanceof
|
|
72367
|
+
if (error instanceof AppError33) {
|
|
72236
72368
|
throw error;
|
|
72237
72369
|
}
|
|
72238
72370
|
throw new InternalServerError55("Failed to record the patrol email.");
|
|
@@ -72392,7 +72524,7 @@ function usePatrolEmailRepo() {
|
|
|
72392
72524
|
}
|
|
72393
72525
|
return result;
|
|
72394
72526
|
} catch (error) {
|
|
72395
|
-
if (error instanceof
|
|
72527
|
+
if (error instanceof AppError33) {
|
|
72396
72528
|
throw error;
|
|
72397
72529
|
}
|
|
72398
72530
|
logger126.log({ level: "error", message: error.message });
|
|
@@ -77139,7 +77271,7 @@ function MBillingItem(value) {
|
|
|
77139
77271
|
|
|
77140
77272
|
// src/repositories/site-billing-item.repo.ts
|
|
77141
77273
|
import {
|
|
77142
|
-
AppError as
|
|
77274
|
+
AppError as AppError34,
|
|
77143
77275
|
BadRequestError as BadRequestError172,
|
|
77144
77276
|
InternalServerError as InternalServerError61,
|
|
77145
77277
|
logger as logger142,
|
|
@@ -77195,7 +77327,7 @@ function useSiteBillingItemRepo() {
|
|
|
77195
77327
|
if (isDuplicated) {
|
|
77196
77328
|
throw new BadRequestError172("Site Billing Item already exist.");
|
|
77197
77329
|
}
|
|
77198
|
-
if (error instanceof
|
|
77330
|
+
if (error instanceof AppError34) {
|
|
77199
77331
|
throw error;
|
|
77200
77332
|
} else {
|
|
77201
77333
|
throw new Error("Failed to create Site Site Billing Item.");
|
|
@@ -77298,7 +77430,7 @@ function useSiteBillingItemRepo() {
|
|
|
77298
77430
|
});
|
|
77299
77431
|
return result;
|
|
77300
77432
|
} catch (error) {
|
|
77301
|
-
if (error instanceof
|
|
77433
|
+
if (error instanceof AppError34) {
|
|
77302
77434
|
throw error;
|
|
77303
77435
|
} else {
|
|
77304
77436
|
throw new InternalServerError61("Failed to get site billing item by id.");
|
|
@@ -77400,7 +77532,7 @@ import {
|
|
|
77400
77532
|
|
|
77401
77533
|
// src/repositories/site-billing-configuration.repo.ts
|
|
77402
77534
|
import {
|
|
77403
|
-
AppError as
|
|
77535
|
+
AppError as AppError35,
|
|
77404
77536
|
BadRequestError as BadRequestError174,
|
|
77405
77537
|
InternalServerError as InternalServerError62,
|
|
77406
77538
|
logger as logger144,
|
|
@@ -77583,7 +77715,7 @@ function useSiteBillingConfigurationRepo() {
|
|
|
77583
77715
|
if (isDuplicated) {
|
|
77584
77716
|
throw new BadRequestError174("Site Billing Configuration already exist.");
|
|
77585
77717
|
}
|
|
77586
|
-
if (error instanceof
|
|
77718
|
+
if (error instanceof AppError35) {
|
|
77587
77719
|
throw error;
|
|
77588
77720
|
} else {
|
|
77589
77721
|
throw new Error("Failed to create Site Site Billing Configuration.");
|
|
@@ -77672,7 +77804,7 @@ function useSiteBillingConfigurationRepo() {
|
|
|
77672
77804
|
});
|
|
77673
77805
|
return result;
|
|
77674
77806
|
} catch (error) {
|
|
77675
|
-
if (error instanceof
|
|
77807
|
+
if (error instanceof AppError35) {
|
|
77676
77808
|
throw error;
|
|
77677
77809
|
} else {
|
|
77678
77810
|
throw new InternalServerError62(
|
|
@@ -79116,7 +79248,7 @@ function MUnitBilling(value) {
|
|
|
79116
79248
|
|
|
79117
79249
|
// src/repositories/site-unit-billing.repo.ts
|
|
79118
79250
|
import {
|
|
79119
|
-
AppError as
|
|
79251
|
+
AppError as AppError36,
|
|
79120
79252
|
BadRequestError as BadRequestError182,
|
|
79121
79253
|
InternalServerError as InternalServerError64,
|
|
79122
79254
|
logger as logger152,
|
|
@@ -79193,7 +79325,7 @@ function useSiteUnitBillingRepo() {
|
|
|
79193
79325
|
if (isDuplicated) {
|
|
79194
79326
|
throw new BadRequestError182("Site Unit Billing already exist.");
|
|
79195
79327
|
}
|
|
79196
|
-
if (error instanceof
|
|
79328
|
+
if (error instanceof AppError36) {
|
|
79197
79329
|
throw error;
|
|
79198
79330
|
} else {
|
|
79199
79331
|
throw new Error("Failed to create Site Unit Billing");
|
|
@@ -79349,7 +79481,7 @@ function useSiteUnitBillingRepo() {
|
|
|
79349
79481
|
});
|
|
79350
79482
|
return result;
|
|
79351
79483
|
} catch (error) {
|
|
79352
|
-
if (error instanceof
|
|
79484
|
+
if (error instanceof AppError36) {
|
|
79353
79485
|
throw error;
|
|
79354
79486
|
} else {
|
|
79355
79487
|
throw new InternalServerError64("Failed to get site unit billing by id.");
|
|
@@ -83116,7 +83248,7 @@ function MStatementOfAccount(value) {
|
|
|
83116
83248
|
|
|
83117
83249
|
// src/repositories/site-soa.repo.ts
|
|
83118
83250
|
import {
|
|
83119
|
-
AppError as
|
|
83251
|
+
AppError as AppError37,
|
|
83120
83252
|
BadRequestError as BadRequestError194,
|
|
83121
83253
|
InternalServerError as InternalServerError67,
|
|
83122
83254
|
logger as logger162,
|
|
@@ -83179,7 +83311,7 @@ function useStatementOfAccountRepo() {
|
|
|
83179
83311
|
if (isDuplicated) {
|
|
83180
83312
|
throw new BadRequestError194("Site SOA already exist.");
|
|
83181
83313
|
}
|
|
83182
|
-
if (error instanceof
|
|
83314
|
+
if (error instanceof AppError37) {
|
|
83183
83315
|
throw error;
|
|
83184
83316
|
} else {
|
|
83185
83317
|
throw new Error("Failed to create Site SOA");
|
|
@@ -83303,7 +83435,7 @@ function useStatementOfAccountRepo() {
|
|
|
83303
83435
|
});
|
|
83304
83436
|
return result;
|
|
83305
83437
|
} catch (error) {
|
|
83306
|
-
if (error instanceof
|
|
83438
|
+
if (error instanceof AppError37) {
|
|
83307
83439
|
throw error;
|
|
83308
83440
|
} else {
|
|
83309
83441
|
throw new InternalServerError67("Failed to get soa by id.");
|
|
@@ -84892,7 +85024,7 @@ function MNfcPatrolRoute(value) {
|
|
|
84892
85024
|
|
|
84893
85025
|
// src/repositories/nfc-patrol-route.repository.ts
|
|
84894
85026
|
import {
|
|
84895
|
-
AppError as
|
|
85027
|
+
AppError as AppError38,
|
|
84896
85028
|
BadRequestError as BadRequestError202,
|
|
84897
85029
|
InternalServerError as InternalServerError70,
|
|
84898
85030
|
logger as logger171,
|
|
@@ -85113,7 +85245,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
85113
85245
|
});
|
|
85114
85246
|
return result;
|
|
85115
85247
|
} catch (error) {
|
|
85116
|
-
if (error instanceof
|
|
85248
|
+
if (error instanceof AppError38) {
|
|
85117
85249
|
throw error;
|
|
85118
85250
|
} else {
|
|
85119
85251
|
throw new InternalServerError70(
|
|
@@ -85166,7 +85298,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
85166
85298
|
if (isDuplicated) {
|
|
85167
85299
|
throw new BadRequestError202("NFC Patrol Route already exists.");
|
|
85168
85300
|
}
|
|
85169
|
-
if (error2 instanceof
|
|
85301
|
+
if (error2 instanceof AppError38) {
|
|
85170
85302
|
throw error2;
|
|
85171
85303
|
} else {
|
|
85172
85304
|
throw new Error("Failed to update NFC Patrol Route.");
|
|
@@ -94783,7 +94915,7 @@ import {
|
|
|
94783
94915
|
logger as logger209,
|
|
94784
94916
|
BadRequestError as BadRequestError238,
|
|
94785
94917
|
NotFoundError as NotFoundError85,
|
|
94786
|
-
AppError as
|
|
94918
|
+
AppError as AppError44,
|
|
94787
94919
|
paginate as paginate67
|
|
94788
94920
|
} from "@7365admin1/node-server-utils";
|
|
94789
94921
|
var useRedDotPaymentRepo = () => {
|
|
@@ -94844,7 +94976,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
94844
94976
|
}
|
|
94845
94977
|
return payment;
|
|
94846
94978
|
} catch (error) {
|
|
94847
|
-
if (error instanceof
|
|
94979
|
+
if (error instanceof AppError44) {
|
|
94848
94980
|
throw error;
|
|
94849
94981
|
}
|
|
94850
94982
|
logger209.log({
|
|
@@ -94869,7 +95001,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
94869
95001
|
if (isDuplicated) {
|
|
94870
95002
|
throw new BadRequestError238("Payment already exist.");
|
|
94871
95003
|
}
|
|
94872
|
-
if (error instanceof
|
|
95004
|
+
if (error instanceof AppError44) {
|
|
94873
95005
|
throw error;
|
|
94874
95006
|
} else {
|
|
94875
95007
|
throw new Error("Failed to create Payment.");
|
|
@@ -94898,7 +95030,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
94898
95030
|
if (isDuplicated) {
|
|
94899
95031
|
throw new BadRequestError238("payment already exist.");
|
|
94900
95032
|
}
|
|
94901
|
-
if (error instanceof
|
|
95033
|
+
if (error instanceof AppError44) {
|
|
94902
95034
|
throw error;
|
|
94903
95035
|
} else {
|
|
94904
95036
|
throw new Error("Failed to create payment");
|
|
@@ -94966,7 +95098,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
94966
95098
|
const data = paginate67(items, page2, limit, totalCount);
|
|
94967
95099
|
return data;
|
|
94968
95100
|
} catch (error) {
|
|
94969
|
-
if (error instanceof
|
|
95101
|
+
if (error instanceof AppError44) {
|
|
94970
95102
|
throw error;
|
|
94971
95103
|
}
|
|
94972
95104
|
logger209.log({
|
|
@@ -95178,7 +95310,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
95178
95310
|
}
|
|
95179
95311
|
return res;
|
|
95180
95312
|
} catch (error) {
|
|
95181
|
-
if (error instanceof
|
|
95313
|
+
if (error instanceof AppError44) {
|
|
95182
95314
|
throw error;
|
|
95183
95315
|
}
|
|
95184
95316
|
throw new InternalServerError83("Failed to update payment status.");
|
|
@@ -95532,7 +95664,7 @@ import {
|
|
|
95532
95664
|
BadRequestError as BadRequestError240,
|
|
95533
95665
|
paginate as paginate68,
|
|
95534
95666
|
NotFoundError as NotFoundError86,
|
|
95535
|
-
AppError as
|
|
95667
|
+
AppError as AppError45,
|
|
95536
95668
|
useCache as useCache72,
|
|
95537
95669
|
makeCacheKey as makeCacheKey65,
|
|
95538
95670
|
toObjectId as toObjectId23
|
|
@@ -95670,7 +95802,7 @@ function useUserRepoV2() {
|
|
|
95670
95802
|
);
|
|
95671
95803
|
return data;
|
|
95672
95804
|
} catch (error) {
|
|
95673
|
-
if (error instanceof
|
|
95805
|
+
if (error instanceof AppError45)
|
|
95674
95806
|
throw error;
|
|
95675
95807
|
throw new InternalServerError85("Failed to get user by id.");
|
|
95676
95808
|
}
|
|
@@ -104016,7 +104148,7 @@ function emptyPersonalEmergencyChain(user) {
|
|
|
104016
104148
|
// src/repositories/personal-emergency-chain.repo.ts
|
|
104017
104149
|
import { ObjectId as ObjectId200 } from "mongodb";
|
|
104018
104150
|
import {
|
|
104019
|
-
AppError as
|
|
104151
|
+
AppError as AppError46,
|
|
104020
104152
|
BadRequestError as BadRequestError274,
|
|
104021
104153
|
InternalServerError as InternalServerError102,
|
|
104022
104154
|
logger as logger236,
|
|
@@ -104053,7 +104185,7 @@ function usePersonalEmergencyChainRepo() {
|
|
|
104053
104185
|
const doc = await collection().findOne({ user: new ObjectId200(user) });
|
|
104054
104186
|
return doc ?? emptyPersonalEmergencyChain(user);
|
|
104055
104187
|
} catch (error) {
|
|
104056
|
-
if (error instanceof
|
|
104188
|
+
if (error instanceof AppError46)
|
|
104057
104189
|
throw error;
|
|
104058
104190
|
logger236.log({ level: "error", message: error.message });
|
|
104059
104191
|
throw new InternalServerError102("Failed to retrieve emergency contacts.");
|
|
@@ -104079,7 +104211,7 @@ function usePersonalEmergencyChainRepo() {
|
|
|
104079
104211
|
);
|
|
104080
104212
|
return doc;
|
|
104081
104213
|
} catch (error) {
|
|
104082
|
-
if (error instanceof
|
|
104214
|
+
if (error instanceof AppError46)
|
|
104083
104215
|
throw error;
|
|
104084
104216
|
logger236.log({ level: "error", message: error.message });
|
|
104085
104217
|
throw new InternalServerError102("Failed to save emergency contacts.");
|
|
@@ -104376,6 +104508,7 @@ export {
|
|
|
104376
104508
|
OUNITECH_BRAND,
|
|
104377
104509
|
OUNITECH_CAPABILITIES,
|
|
104378
104510
|
OUNITECH_PENDING_COMMANDS,
|
|
104511
|
+
OUNITECH_TIMESTAMP_FORMAT,
|
|
104379
104512
|
OpenRmfError,
|
|
104380
104513
|
OrgNature,
|
|
104381
104514
|
OvernightParkingRequestSort,
|
|
@@ -104423,6 +104556,7 @@ export {
|
|
|
104423
104556
|
ROBOT_CLOUD_DOC_CONFIRMATIONS,
|
|
104424
104557
|
ROBOT_CLOUD_PATHS,
|
|
104425
104558
|
ROBOT_CLOUD_TIMEOUT_MS,
|
|
104559
|
+
ROBOT_CLOUD_TIMESTAMP_FORMATS,
|
|
104426
104560
|
ROBOT_CREDENTIALS_ENV,
|
|
104427
104561
|
ROBOT_MODULE,
|
|
104428
104562
|
ROBOT_PERMISSIONS,
|
|
@@ -104452,6 +104586,7 @@ export {
|
|
|
104452
104586
|
SubjectSort,
|
|
104453
104587
|
SubscriptionBillingMode,
|
|
104454
104588
|
SubscriptionType,
|
|
104589
|
+
TIMESTAMP_OFFSET_CANDIDATES,
|
|
104455
104590
|
TRACKING_BACKOFF_BASE_MS,
|
|
104456
104591
|
TRACKING_BACKOFF_CAP_MS,
|
|
104457
104592
|
TRACKING_IDLE_TIMEOUT_MS,
|