@7365admin1/core 3.93.0 → 3.95.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 +16 -0
- package/dist/index.d.ts +391 -117
- package/dist/index.js +866 -224
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +957 -336
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/e2e/harness.mjs +1 -0
- package/test/e2e/open-rmf.e2e.test.mjs +185 -0
- package/test/fixtures/open-rmf/building_map.json +1168 -0
- package/test/fixtures/open-rmf/door_state.json +10 -0
- package/test/fixtures/open-rmf/fleets.json +109 -0
- package/test/fixtures/open-rmf/lift_state.json +19 -0
- package/test/fixtures/open-rmf/robot_task_response.json +42 -0
- package/test/fixtures/open-rmf/schemas/LICENSE.md +201 -0
- package/test/fixtures/open-rmf/schemas/NOTICE.md +7 -0
- package/test/fixtures/open-rmf/schemas/cancel_task_request.json +24 -0
- package/test/fixtures/open-rmf/schemas/fleet_state.json +15 -0
- package/test/fixtures/open-rmf/schemas/interrupt_task_request.json +24 -0
- package/test/fixtures/open-rmf/schemas/location_2D.json +14 -0
- package/test/fixtures/open-rmf/schemas/resume_task_request.json +30 -0
- package/test/fixtures/open-rmf/schemas/robot_state.json +69 -0
- package/test/fixtures/open-rmf/schemas/robot_task_request.json +24 -0
- package/test/fixtures/open-rmf/schemas/task_request.json +42 -0
- package/test/fixtures/open-rmf/schemas/task_state.json +278 -0
- package/test/fixtures/open-rmf/task_state_clean_completed.json +119 -0
- package/test/fixtures/open-rmf/task_state_patrol.json +1 -0
- package/test/open-rmf.test.mjs +297 -0
package/dist/index.mjs
CHANGED
|
@@ -10167,11 +10167,11 @@ function moduleGateData() {
|
|
|
10167
10167
|
};
|
|
10168
10168
|
}
|
|
10169
10169
|
function memoisedGateData(data) {
|
|
10170
|
-
const
|
|
10170
|
+
const cache2 = /* @__PURE__ */ new Map();
|
|
10171
10171
|
const once = (key, load) => {
|
|
10172
|
-
if (!
|
|
10173
|
-
|
|
10174
|
-
return
|
|
10172
|
+
if (!cache2.has(key))
|
|
10173
|
+
cache2.set(key, load());
|
|
10174
|
+
return cache2.get(key);
|
|
10175
10175
|
};
|
|
10176
10176
|
return {
|
|
10177
10177
|
...data,
|
|
@@ -17507,13 +17507,44 @@ function vehicleViewOf(value) {
|
|
|
17507
17507
|
return "residents" /* RESIDENTS */;
|
|
17508
17508
|
}
|
|
17509
17509
|
var VEHICLE_HISTORY_LIMIT = 20;
|
|
17510
|
+
function vehicleHistoryValue(field, value) {
|
|
17511
|
+
if (value === void 0 || value === null)
|
|
17512
|
+
return null;
|
|
17513
|
+
if (value instanceof Date) {
|
|
17514
|
+
return Number.isNaN(value.getTime()) ? null : value.toISOString();
|
|
17515
|
+
}
|
|
17516
|
+
if (value instanceof ObjectId46)
|
|
17517
|
+
return value.toHexString();
|
|
17518
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
17519
|
+
return value;
|
|
17520
|
+
const text2 = String(value).trim();
|
|
17521
|
+
if (!text2)
|
|
17522
|
+
return null;
|
|
17523
|
+
if (field === "nric")
|
|
17524
|
+
return text2.length > 4 ? `*****${text2.slice(-4)}` : "****";
|
|
17525
|
+
return text2.length > 300 ? `${text2.slice(0, 300)}...` : text2;
|
|
17526
|
+
}
|
|
17510
17527
|
function vehicleHistoryEntry(action, user, fields) {
|
|
17511
17528
|
const id = String(user ?? "");
|
|
17529
|
+
const changes = [];
|
|
17530
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
17531
|
+
for (const item of fields) {
|
|
17532
|
+
if (!item || typeof item === "string" || !item.field || seen2.has(item.field))
|
|
17533
|
+
continue;
|
|
17534
|
+
seen2.add(item.field);
|
|
17535
|
+
changes.push({
|
|
17536
|
+
field: item.field,
|
|
17537
|
+
from: vehicleHistoryValue(item.field, item.from),
|
|
17538
|
+
to: vehicleHistoryValue(item.field, item.to)
|
|
17539
|
+
});
|
|
17540
|
+
}
|
|
17541
|
+
const names = fields.map((item) => typeof item === "string" ? item : item?.field).filter((name) => !!name);
|
|
17512
17542
|
return {
|
|
17513
17543
|
action,
|
|
17514
17544
|
updatedBy: ObjectId46.isValid(id) ? new ObjectId46(id) : null,
|
|
17515
17545
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
17516
|
-
fields: Array.from(new Set(
|
|
17546
|
+
fields: Array.from(new Set(names)),
|
|
17547
|
+
...changes.length ? { changes } : {}
|
|
17517
17548
|
};
|
|
17518
17549
|
}
|
|
17519
17550
|
var VehicleOrder = /* @__PURE__ */ ((VehicleOrder2) => {
|
|
@@ -18289,11 +18320,51 @@ function useVehicleRepo() {
|
|
|
18289
18320
|
for (const user of users)
|
|
18290
18321
|
names.set(String(user._id), String(user.name ?? ""));
|
|
18291
18322
|
}
|
|
18323
|
+
const PLACE_COLLECTIONS = {
|
|
18324
|
+
block: "buildings",
|
|
18325
|
+
level: "building-levels",
|
|
18326
|
+
unit: "building-units"
|
|
18327
|
+
};
|
|
18328
|
+
const placeIds = { block: /* @__PURE__ */ new Set(), level: /* @__PURE__ */ new Set(), unit: /* @__PURE__ */ new Set() };
|
|
18329
|
+
for (const entry of history) {
|
|
18330
|
+
for (const change of entry?.changes ?? []) {
|
|
18331
|
+
const bucket = placeIds[change?.field];
|
|
18332
|
+
if (!bucket)
|
|
18333
|
+
continue;
|
|
18334
|
+
for (const v of [change.from, change.to]) {
|
|
18335
|
+
if (typeof v === "string" && ObjectId47.isValid(v))
|
|
18336
|
+
bucket.add(v);
|
|
18337
|
+
}
|
|
18338
|
+
}
|
|
18339
|
+
}
|
|
18340
|
+
const placeNames = /* @__PURE__ */ new Map();
|
|
18341
|
+
if (db2) {
|
|
18342
|
+
for (const [field, set] of Object.entries(placeIds)) {
|
|
18343
|
+
if (!set.size)
|
|
18344
|
+
continue;
|
|
18345
|
+
const docs = await db2.collection(PLACE_COLLECTIONS[field]).find(
|
|
18346
|
+
{ _id: { $in: Array.from(set).map((id) => new ObjectId47(id)) } },
|
|
18347
|
+
{ projection: { name: 1 } }
|
|
18348
|
+
).toArray();
|
|
18349
|
+
for (const doc of docs)
|
|
18350
|
+
placeNames.set(`${field}:${String(doc._id)}`, String(doc.name ?? ""));
|
|
18351
|
+
}
|
|
18352
|
+
}
|
|
18353
|
+
const placeName = (field, v) => typeof v === "string" ? placeNames.get(`${field}:${v}`) : void 0;
|
|
18292
18354
|
return {
|
|
18293
18355
|
...result,
|
|
18294
18356
|
history: history.map((entry) => ({
|
|
18295
18357
|
...entry,
|
|
18296
|
-
updatedByName: entry?.updatedBy ? names.get(String(entry.updatedBy)) ?? "" : ""
|
|
18358
|
+
updatedByName: entry?.updatedBy ? names.get(String(entry.updatedBy)) ?? "" : "",
|
|
18359
|
+
...Array.isArray(entry?.changes) && {
|
|
18360
|
+
changes: entry.changes.map(
|
|
18361
|
+
(change) => PLACE_COLLECTIONS[change.field] ? {
|
|
18362
|
+
...change,
|
|
18363
|
+
fromName: placeName(change.field, change.from),
|
|
18364
|
+
toName: placeName(change.field, change.to)
|
|
18365
|
+
} : change
|
|
18366
|
+
)
|
|
18367
|
+
}
|
|
18297
18368
|
}))
|
|
18298
18369
|
};
|
|
18299
18370
|
} catch (error) {
|
|
@@ -34163,7 +34234,11 @@ function useVehicleService() {
|
|
|
34163
34234
|
} = useVehicleRepo();
|
|
34164
34235
|
function changedFields(record, next) {
|
|
34165
34236
|
const asText = (v) => v instanceof Date ? String(v.getTime()) : String(v ?? "");
|
|
34166
|
-
return Object.entries(next).filter(([key, value]) => asText(value) !== asText(record?.[key])).map(([key]) =>
|
|
34237
|
+
return Object.entries(next).filter(([key, value]) => asText(value) !== asText(record?.[key])).map(([key, value]) => ({
|
|
34238
|
+
field: key,
|
|
34239
|
+
from: record?.[key] ?? null,
|
|
34240
|
+
to: value ?? null
|
|
34241
|
+
}));
|
|
34167
34242
|
}
|
|
34168
34243
|
function anprCameraSummary(cameras, list) {
|
|
34169
34244
|
return cameras.map((camera) => ({
|
|
@@ -34912,6 +34987,7 @@ function useVehicleService() {
|
|
|
34912
34987
|
vehicleHistoryEntry(
|
|
34913
34988
|
"created",
|
|
34914
34989
|
user,
|
|
34990
|
+
// Created: each value it was saved with, from nothing.
|
|
34915
34991
|
Object.entries({
|
|
34916
34992
|
plateNumber: vehicleValue.plateNumber,
|
|
34917
34993
|
name: vehicleValue.name,
|
|
@@ -34927,7 +35003,7 @@ function useVehicleService() {
|
|
|
34927
35003
|
start: vehicleValue.start,
|
|
34928
35004
|
end: vehicleValue.end,
|
|
34929
35005
|
remarks: vehicleValue.remarks
|
|
34930
|
-
}).filter(([, v]) => v !== void 0 && v !== null && String(v) !== "").map(([k]) => k)
|
|
35006
|
+
}).filter(([, v]) => v !== void 0 && v !== null && String(v) !== "").map(([k, v]) => ({ field: k, from: null, to: v }))
|
|
34931
35007
|
)
|
|
34932
35008
|
];
|
|
34933
35009
|
await _add(vehicleValue, session);
|
|
@@ -35011,7 +35087,9 @@ function useVehicleService() {
|
|
|
35011
35087
|
session
|
|
35012
35088
|
);
|
|
35013
35089
|
await session.commitTransaction();
|
|
35014
|
-
await recordHistory(_id, "deleted", user, [
|
|
35090
|
+
await recordHistory(_id, "deleted", user, [
|
|
35091
|
+
{ field: "status", from: vehicle?.status ?? null, to: "deleted" /* DELETED */ }
|
|
35092
|
+
]);
|
|
35015
35093
|
return `Vehicle plate number deleted from ${type} record successfully.`;
|
|
35016
35094
|
} catch (error) {
|
|
35017
35095
|
logger68.error("Error in vehicle service delete:", error);
|
|
@@ -35113,7 +35191,7 @@ function useVehicleService() {
|
|
|
35113
35191
|
};
|
|
35114
35192
|
await _updateVehicleById(id, formattedValue, session);
|
|
35115
35193
|
await session.commitTransaction();
|
|
35116
|
-
await recordHistory(id, "approved", user,
|
|
35194
|
+
await recordHistory(id, "approved", user, changedFields(vehicle, formattedValue));
|
|
35117
35195
|
return "Vehicle plate number approved and added successfully.";
|
|
35118
35196
|
} catch (error) {
|
|
35119
35197
|
logger68.error("Error in vehicle service approving and adding:", error);
|
|
@@ -35269,7 +35347,7 @@ function useVehicleService() {
|
|
|
35269
35347
|
};
|
|
35270
35348
|
await _updateVehicleById(id, formattedValue, session);
|
|
35271
35349
|
await session.commitTransaction();
|
|
35272
|
-
await recordHistory(id, "restored", user,
|
|
35350
|
+
await recordHistory(id, "restored", user, changedFields(vehicle, formattedValue));
|
|
35273
35351
|
return "Vehicle reactivated successfully.";
|
|
35274
35352
|
} catch (error) {
|
|
35275
35353
|
logger68.error("Error in vehicle service reactivation:", error);
|
|
@@ -60354,7 +60432,7 @@ var OUNITECH_PENDING_COMMANDS = ["pause", "resume", "cancel"].map(
|
|
|
60354
60432
|
);
|
|
60355
60433
|
function createOunitechAdapter(credentials, options) {
|
|
60356
60434
|
const cloud = useRobotCloudService(credentials, options);
|
|
60357
|
-
function
|
|
60435
|
+
function toAdapterRobot2(raw) {
|
|
60358
60436
|
return {
|
|
60359
60437
|
robotSn: raw.robotSn,
|
|
60360
60438
|
name: raw.robotName,
|
|
@@ -60376,7 +60454,7 @@ function createOunitechAdapter(credentials, options) {
|
|
|
60376
60454
|
capabilities: OUNITECH_CAPABILITIES,
|
|
60377
60455
|
async listRobots() {
|
|
60378
60456
|
const fleet2 = await cloud.getRobots();
|
|
60379
|
-
return fleet2.map(
|
|
60457
|
+
return fleet2.map(toAdapterRobot2);
|
|
60380
60458
|
},
|
|
60381
60459
|
async getRobot(robotSn) {
|
|
60382
60460
|
const fleet2 = await cloud.getRobots();
|
|
@@ -60393,7 +60471,7 @@ function createOunitechAdapter(credentials, options) {
|
|
|
60393
60471
|
position: null
|
|
60394
60472
|
};
|
|
60395
60473
|
}
|
|
60396
|
-
return
|
|
60474
|
+
return toAdapterRobot2(match);
|
|
60397
60475
|
},
|
|
60398
60476
|
async sendCommand(robotSn, command) {
|
|
60399
60477
|
const options2 = {
|
|
@@ -60931,6 +61009,708 @@ function registerDemoBrand() {
|
|
|
60931
61009
|
}
|
|
60932
61010
|
registerDemoBrand();
|
|
60933
61011
|
|
|
61012
|
+
// src/utils/lift-contract.util.ts
|
|
61013
|
+
var LIFT_DOOR = {
|
|
61014
|
+
CLOSED: 0,
|
|
61015
|
+
MOVING: 1,
|
|
61016
|
+
OPEN: 2
|
|
61017
|
+
};
|
|
61018
|
+
var LIFT_MOTION = {
|
|
61019
|
+
STOPPED: 0,
|
|
61020
|
+
UP: 1,
|
|
61021
|
+
DOWN: 2,
|
|
61022
|
+
UNKNOWN: 3
|
|
61023
|
+
};
|
|
61024
|
+
var LIFT_MODE = {
|
|
61025
|
+
UNKNOWN: 0,
|
|
61026
|
+
HUMAN: 1,
|
|
61027
|
+
AGV: 2,
|
|
61028
|
+
FIRE: 3,
|
|
61029
|
+
OFFLINE: 4,
|
|
61030
|
+
EMERGENCY: 5
|
|
61031
|
+
};
|
|
61032
|
+
var LIFT_REQUEST = {
|
|
61033
|
+
END_SESSION: 0,
|
|
61034
|
+
AGV_MODE: 1,
|
|
61035
|
+
HUMAN_MODE: 2
|
|
61036
|
+
};
|
|
61037
|
+
function isLiftAvailable(state) {
|
|
61038
|
+
if (!state)
|
|
61039
|
+
return false;
|
|
61040
|
+
return state.currentMode === LIFT_MODE.HUMAN || state.currentMode === LIFT_MODE.AGV;
|
|
61041
|
+
}
|
|
61042
|
+
function isSafeToCross(state, floor) {
|
|
61043
|
+
if (!isLiftAvailable(state) || !state)
|
|
61044
|
+
return false;
|
|
61045
|
+
if (state.currentFloor !== floor)
|
|
61046
|
+
return false;
|
|
61047
|
+
if (state.motionState !== LIFT_MOTION.STOPPED)
|
|
61048
|
+
return false;
|
|
61049
|
+
return state.doorState === LIFT_DOOR.OPEN;
|
|
61050
|
+
}
|
|
61051
|
+
function holdsLift(state, sessionId) {
|
|
61052
|
+
if (!state || !sessionId)
|
|
61053
|
+
return false;
|
|
61054
|
+
return state.sessionId === sessionId;
|
|
61055
|
+
}
|
|
61056
|
+
function servesFloor(state, floor) {
|
|
61057
|
+
if (!state || !floor)
|
|
61058
|
+
return false;
|
|
61059
|
+
return state.availableFloors.includes(floor);
|
|
61060
|
+
}
|
|
61061
|
+
function createLiftSimulator(options) {
|
|
61062
|
+
const { name, floors } = options;
|
|
61063
|
+
if (floors.length === 0)
|
|
61064
|
+
throw new Error("A lift must serve some floors.");
|
|
61065
|
+
const msPerFloor = options.msPerFloor ?? 2e3;
|
|
61066
|
+
const doorDwellMs = options.doorDwellMs ?? 5e3;
|
|
61067
|
+
const state = {
|
|
61068
|
+
liftName: name,
|
|
61069
|
+
liftTime: 0,
|
|
61070
|
+
availableFloors: [...floors],
|
|
61071
|
+
currentFloor: options.startFloor ?? floors[0],
|
|
61072
|
+
destinationFloor: options.startFloor ?? floors[0],
|
|
61073
|
+
doorState: LIFT_DOOR.CLOSED,
|
|
61074
|
+
motionState: LIFT_MOTION.STOPPED,
|
|
61075
|
+
currentMode: LIFT_MODE.HUMAN,
|
|
61076
|
+
sessionId: ""
|
|
61077
|
+
};
|
|
61078
|
+
let travelRemaining = 0;
|
|
61079
|
+
let doorTimer = 0;
|
|
61080
|
+
function tick(ms) {
|
|
61081
|
+
state.liftTime += ms;
|
|
61082
|
+
if (state.motionState !== LIFT_MOTION.STOPPED) {
|
|
61083
|
+
travelRemaining -= ms;
|
|
61084
|
+
if (travelRemaining <= 0) {
|
|
61085
|
+
state.currentFloor = state.destinationFloor;
|
|
61086
|
+
state.motionState = LIFT_MOTION.STOPPED;
|
|
61087
|
+
state.doorState = LIFT_DOOR.OPEN;
|
|
61088
|
+
doorTimer = doorDwellMs;
|
|
61089
|
+
}
|
|
61090
|
+
return;
|
|
61091
|
+
}
|
|
61092
|
+
if (state.doorState === LIFT_DOOR.OPEN) {
|
|
61093
|
+
doorTimer -= ms;
|
|
61094
|
+
if (doorTimer <= 0)
|
|
61095
|
+
state.doorState = LIFT_DOOR.CLOSED;
|
|
61096
|
+
}
|
|
61097
|
+
}
|
|
61098
|
+
return {
|
|
61099
|
+
name,
|
|
61100
|
+
state,
|
|
61101
|
+
tick,
|
|
61102
|
+
async read() {
|
|
61103
|
+
return { ...state, availableFloors: [...state.availableFloors] };
|
|
61104
|
+
},
|
|
61105
|
+
async request(request2) {
|
|
61106
|
+
if (request2.requestType === LIFT_REQUEST.END_SESSION) {
|
|
61107
|
+
if (state.sessionId === request2.sessionId) {
|
|
61108
|
+
state.sessionId = "";
|
|
61109
|
+
state.currentMode = LIFT_MODE.HUMAN;
|
|
61110
|
+
}
|
|
61111
|
+
return;
|
|
61112
|
+
}
|
|
61113
|
+
if (state.sessionId && state.sessionId !== request2.sessionId) {
|
|
61114
|
+
throw new Error(`Lift ${name} is held by ${state.sessionId}.`);
|
|
61115
|
+
}
|
|
61116
|
+
if (!state.availableFloors.includes(request2.destinationFloor)) {
|
|
61117
|
+
throw new Error(
|
|
61118
|
+
`Lift ${name} does not serve ${request2.destinationFloor}.`
|
|
61119
|
+
);
|
|
61120
|
+
}
|
|
61121
|
+
state.sessionId = request2.sessionId;
|
|
61122
|
+
state.currentMode = request2.requestType === LIFT_REQUEST.AGV_MODE ? LIFT_MODE.AGV : LIFT_MODE.HUMAN;
|
|
61123
|
+
state.destinationFloor = request2.destinationFloor;
|
|
61124
|
+
if (state.currentFloor === request2.destinationFloor) {
|
|
61125
|
+
state.motionState = LIFT_MOTION.STOPPED;
|
|
61126
|
+
state.doorState = LIFT_DOOR.OPEN;
|
|
61127
|
+
doorTimer = doorDwellMs;
|
|
61128
|
+
return;
|
|
61129
|
+
}
|
|
61130
|
+
const from = state.availableFloors.indexOf(state.currentFloor);
|
|
61131
|
+
const to = state.availableFloors.indexOf(request2.destinationFloor);
|
|
61132
|
+
state.motionState = to > from ? LIFT_MOTION.UP : LIFT_MOTION.DOWN;
|
|
61133
|
+
state.doorState = LIFT_DOOR.CLOSED;
|
|
61134
|
+
travelRemaining = Math.abs(to - from) * msPerFloor;
|
|
61135
|
+
},
|
|
61136
|
+
async refresh(sessionId) {
|
|
61137
|
+
if (state.sessionId !== sessionId)
|
|
61138
|
+
return;
|
|
61139
|
+
if (state.doorState === LIFT_DOOR.OPEN)
|
|
61140
|
+
doorTimer = doorDwellMs;
|
|
61141
|
+
},
|
|
61142
|
+
async release(sessionId) {
|
|
61143
|
+
if (state.sessionId !== sessionId)
|
|
61144
|
+
return;
|
|
61145
|
+
state.sessionId = "";
|
|
61146
|
+
state.currentMode = LIFT_MODE.HUMAN;
|
|
61147
|
+
}
|
|
61148
|
+
};
|
|
61149
|
+
}
|
|
61150
|
+
var LIFT_QUEUE_TTL_MS = 10 * 6e4;
|
|
61151
|
+
var LIFT_LEASE_MS = 3 * 6e4;
|
|
61152
|
+
var LIFT_SIM_MS_PER_FLOOR = 4e3;
|
|
61153
|
+
var LIFT_SIM_DOOR_DWELL_MS = 8e3;
|
|
61154
|
+
var LIFT_SIM_BOARD_MS = 6e3;
|
|
61155
|
+
var LIFT_SESSION_STATUS = [
|
|
61156
|
+
"queued",
|
|
61157
|
+
"active",
|
|
61158
|
+
"released",
|
|
61159
|
+
"expired",
|
|
61160
|
+
"cancelled"
|
|
61161
|
+
];
|
|
61162
|
+
async function simulatedLiftState(options) {
|
|
61163
|
+
const sim = createLiftSimulator({
|
|
61164
|
+
name: options.name,
|
|
61165
|
+
floors: options.floors,
|
|
61166
|
+
msPerFloor: LIFT_SIM_MS_PER_FLOOR,
|
|
61167
|
+
doorDwellMs: LIFT_SIM_DOOR_DWELL_MS
|
|
61168
|
+
});
|
|
61169
|
+
const session = options.session;
|
|
61170
|
+
if (!session || !options.floors.includes(session.fromFloor) || !options.floors.includes(session.toFloor)) {
|
|
61171
|
+
return { state: await sim.read(), phase: "idle" };
|
|
61172
|
+
}
|
|
61173
|
+
const STEP = 250;
|
|
61174
|
+
const elapsed = Math.max(0, options.now - session.activeAt);
|
|
61175
|
+
let phase = "to-pickup";
|
|
61176
|
+
let boardingLeft = LIFT_SIM_BOARD_MS;
|
|
61177
|
+
await sim.request({
|
|
61178
|
+
liftName: options.name,
|
|
61179
|
+
sessionId: session.id,
|
|
61180
|
+
requestType: LIFT_REQUEST.AGV_MODE,
|
|
61181
|
+
destinationFloor: session.fromFloor,
|
|
61182
|
+
doorState: LIFT_DOOR.OPEN
|
|
61183
|
+
});
|
|
61184
|
+
if (isSafeToCross(sim.state, session.fromFloor))
|
|
61185
|
+
phase = "boarding";
|
|
61186
|
+
for (let t = 0; t < elapsed; t += STEP) {
|
|
61187
|
+
const ms = Math.min(STEP, elapsed - t);
|
|
61188
|
+
sim.tick(ms);
|
|
61189
|
+
const s = sim.state;
|
|
61190
|
+
if (phase === "to-pickup") {
|
|
61191
|
+
if (isSafeToCross(s, session.fromFloor))
|
|
61192
|
+
phase = "boarding";
|
|
61193
|
+
} else if (phase === "boarding") {
|
|
61194
|
+
await sim.refresh(session.id);
|
|
61195
|
+
boardingLeft -= ms;
|
|
61196
|
+
if (boardingLeft <= 0) {
|
|
61197
|
+
phase = "to-destination";
|
|
61198
|
+
await sim.request({
|
|
61199
|
+
liftName: options.name,
|
|
61200
|
+
sessionId: session.id,
|
|
61201
|
+
requestType: LIFT_REQUEST.AGV_MODE,
|
|
61202
|
+
destinationFloor: session.toFloor,
|
|
61203
|
+
doorState: LIFT_DOOR.CLOSED
|
|
61204
|
+
});
|
|
61205
|
+
}
|
|
61206
|
+
} else if (phase === "to-destination") {
|
|
61207
|
+
if (isSafeToCross(s, session.toFloor))
|
|
61208
|
+
phase = "arrived";
|
|
61209
|
+
} else if (phase === "arrived") {
|
|
61210
|
+
await sim.refresh(session.id);
|
|
61211
|
+
}
|
|
61212
|
+
}
|
|
61213
|
+
return { state: await sim.read(), phase };
|
|
61214
|
+
}
|
|
61215
|
+
function liftQueueKey(mapId, liftName) {
|
|
61216
|
+
return `${mapId}:${liftName}`;
|
|
61217
|
+
}
|
|
61218
|
+
|
|
61219
|
+
// src/utils/door-contract.util.ts
|
|
61220
|
+
var DOOR_MODE = {
|
|
61221
|
+
CLOSED: 0,
|
|
61222
|
+
MOVING: 1,
|
|
61223
|
+
OPEN: 2,
|
|
61224
|
+
OFFLINE: 3,
|
|
61225
|
+
UNKNOWN: 4
|
|
61226
|
+
};
|
|
61227
|
+
var MODES = new Set(Object.values(DOOR_MODE));
|
|
61228
|
+
function doorModeOf(value) {
|
|
61229
|
+
return typeof value === "number" && MODES.has(value) ? value : DOOR_MODE.UNKNOWN;
|
|
61230
|
+
}
|
|
61231
|
+
function isDoorPassable(state) {
|
|
61232
|
+
return state?.currentMode === DOOR_MODE.OPEN;
|
|
61233
|
+
}
|
|
61234
|
+
|
|
61235
|
+
// src/services/open-rmf.adapter.ts
|
|
61236
|
+
var OPEN_RMF_BRAND = "fleet-core";
|
|
61237
|
+
var OPEN_RMF_DISPLAY_NAME = "HERO Fleet Core";
|
|
61238
|
+
var OPEN_RMF_CAPABILITIES = {
|
|
61239
|
+
readLocation: true,
|
|
61240
|
+
// robot_state.location {map, x, y, yaw}
|
|
61241
|
+
battery: true,
|
|
61242
|
+
// robot_state.battery 0..1
|
|
61243
|
+
floorReporting: true,
|
|
61244
|
+
// location.map = level name
|
|
61245
|
+
multiFloor: true,
|
|
61246
|
+
// RMF rides lifts itself (lift supervisor)
|
|
61247
|
+
startProcess: true,
|
|
61248
|
+
// clean / patrol tasks
|
|
61249
|
+
pauseProcess: true,
|
|
61250
|
+
// interrupt_task / resume_task / cancel_task
|
|
61251
|
+
pauseResume: true,
|
|
61252
|
+
// same calls
|
|
61253
|
+
processCompletion: true,
|
|
61254
|
+
// task_state.status
|
|
61255
|
+
pathAndEta: true,
|
|
61256
|
+
// task_state.estimate_millis
|
|
61257
|
+
sendToDock: true,
|
|
61258
|
+
// go_to_place the robot's charger waypoint
|
|
61259
|
+
navigateToPoint: false,
|
|
61260
|
+
// api takes waypoint names only
|
|
61261
|
+
relocalize: false,
|
|
61262
|
+
// no api call
|
|
61263
|
+
spotClean: false
|
|
61264
|
+
// clean zones are named waypoints, not points
|
|
61265
|
+
};
|
|
61266
|
+
function openRmfConfig(env2 = process.env) {
|
|
61267
|
+
const baseUrl = (env2.OPEN_RMF_API_URL ?? "").trim().replace(/\/+$/, "");
|
|
61268
|
+
if (!/^https?:\/\/\S+$/.test(baseUrl))
|
|
61269
|
+
return null;
|
|
61270
|
+
return { baseUrl, token: (env2.OPEN_RMF_TOKEN ?? "").trim() };
|
|
61271
|
+
}
|
|
61272
|
+
var OpenRmfError = class extends Error {
|
|
61273
|
+
};
|
|
61274
|
+
var TIMEOUT_MS = 4e3;
|
|
61275
|
+
var cache = /* @__PURE__ */ new Map();
|
|
61276
|
+
function createOpenRmfClient(config2, deps) {
|
|
61277
|
+
const doFetch = deps?.fetch ?? globalThis.fetch;
|
|
61278
|
+
const now = deps?.now ?? Date.now;
|
|
61279
|
+
async function call(method, path5, body) {
|
|
61280
|
+
if (!config2)
|
|
61281
|
+
throw new OpenRmfError("Fleet Core is not configured on this server.");
|
|
61282
|
+
let res;
|
|
61283
|
+
try {
|
|
61284
|
+
res = await doFetch(config2.baseUrl + path5, {
|
|
61285
|
+
method,
|
|
61286
|
+
headers: {
|
|
61287
|
+
...config2.token ? { Authorization: `Bearer ${config2.token}` } : {},
|
|
61288
|
+
...body === void 0 ? {} : { "Content-Type": "application/json" }
|
|
61289
|
+
},
|
|
61290
|
+
body: body === void 0 ? void 0 : JSON.stringify(body),
|
|
61291
|
+
signal: AbortSignal.timeout(deps?.timeoutMs ?? TIMEOUT_MS)
|
|
61292
|
+
});
|
|
61293
|
+
} catch (e) {
|
|
61294
|
+
throw new OpenRmfError(
|
|
61295
|
+
`The fleet server did not answer (${e?.name === "TimeoutError" ? "timed out" : "unreachable"}).`
|
|
61296
|
+
);
|
|
61297
|
+
}
|
|
61298
|
+
const text2 = await res.text();
|
|
61299
|
+
if (!res.ok)
|
|
61300
|
+
throw new OpenRmfError(`The fleet server refused ${method} ${path5.split("?")[0]} (HTTP ${res.status}).`);
|
|
61301
|
+
try {
|
|
61302
|
+
return text2 ? JSON.parse(text2) : null;
|
|
61303
|
+
} catch {
|
|
61304
|
+
throw new OpenRmfError("The fleet server sent a reply that is not JSON.");
|
|
61305
|
+
}
|
|
61306
|
+
}
|
|
61307
|
+
function cached(key, ttlMs, load) {
|
|
61308
|
+
const k = `${config2?.baseUrl}|${key}`;
|
|
61309
|
+
const hit = cache.get(k);
|
|
61310
|
+
if (hit && now() - hit.at < ttlMs)
|
|
61311
|
+
return hit.value;
|
|
61312
|
+
const value = load();
|
|
61313
|
+
cache.set(k, { at: now(), value });
|
|
61314
|
+
value.catch(() => cache.delete(k));
|
|
61315
|
+
return value;
|
|
61316
|
+
}
|
|
61317
|
+
const enc2 = encodeURIComponent;
|
|
61318
|
+
return {
|
|
61319
|
+
fleets: () => cached("fleets", 1500, () => call("GET", "/fleets")),
|
|
61320
|
+
buildingMap: () => cached("building_map", 6e4, () => call("GET", "/building_map")),
|
|
61321
|
+
doors: () => call("GET", "/doors"),
|
|
61322
|
+
doorState: (name) => call("GET", `/doors/${enc2(name)}/state`),
|
|
61323
|
+
doorRequest: (name, mode) => call("POST", `/doors/${enc2(name)}/request`, { mode }),
|
|
61324
|
+
liftState: (name) => call("GET", `/lifts/${enc2(name)}/state`),
|
|
61325
|
+
liftRequest: (name, body) => call("POST", `/lifts/${enc2(name)}/request`, body),
|
|
61326
|
+
robotTask: (fleet2, robot, request2) => call("POST", "/tasks/robot_task", {
|
|
61327
|
+
type: "robot_task_request",
|
|
61328
|
+
fleet: fleet2,
|
|
61329
|
+
robot,
|
|
61330
|
+
request: request2
|
|
61331
|
+
}),
|
|
61332
|
+
cancelTask: (taskId) => call("POST", "/tasks/cancel_task", { type: "cancel_task_request", task_id: taskId }),
|
|
61333
|
+
interruptTask: (taskId) => call("POST", "/tasks/interrupt_task", { type: "interrupt_task_request", task_id: taskId, labels: ["iservice365"] }),
|
|
61334
|
+
// RMF answers a resume only when it names the interruption tokens to discard.
|
|
61335
|
+
resumeTask: (taskId, tokens) => call("POST", "/tasks/resume_task", {
|
|
61336
|
+
type: "resume_task_request",
|
|
61337
|
+
for_task: taskId,
|
|
61338
|
+
for_tokens: tokens,
|
|
61339
|
+
labels: ["iservice365"]
|
|
61340
|
+
}),
|
|
61341
|
+
taskState: (taskId) => call("GET", `/tasks/${enc2(taskId)}/state`)
|
|
61342
|
+
};
|
|
61343
|
+
}
|
|
61344
|
+
function floorNoOf(map) {
|
|
61345
|
+
if (typeof map !== "string")
|
|
61346
|
+
return null;
|
|
61347
|
+
const m = /^(L|B)(\d{1,3})$/i.exec(map.trim());
|
|
61348
|
+
if (m)
|
|
61349
|
+
return m[1].toUpperCase() === "B" ? -Number(m[2]) : Number(m[2]);
|
|
61350
|
+
return /^G$/i.test(map.trim()) ? 0 : null;
|
|
61351
|
+
}
|
|
61352
|
+
function splitRobotSn(robotSn) {
|
|
61353
|
+
const i = robotSn.indexOf("/");
|
|
61354
|
+
if (i <= 0 || i === robotSn.length - 1)
|
|
61355
|
+
return null;
|
|
61356
|
+
return { fleet: robotSn.slice(0, i), robot: robotSn.slice(i + 1) };
|
|
61357
|
+
}
|
|
61358
|
+
var hasParam = (v, p) => (v.params ?? []).some((x) => x.name === p);
|
|
61359
|
+
function levelBounds(building, map) {
|
|
61360
|
+
const level2 = building?.levels.find((l) => l.name === map);
|
|
61361
|
+
if (!level2)
|
|
61362
|
+
return null;
|
|
61363
|
+
const xs = [];
|
|
61364
|
+
const ys = [];
|
|
61365
|
+
for (const g of level2.nav_graphs)
|
|
61366
|
+
for (const v of g.vertices)
|
|
61367
|
+
xs.push(v.x), ys.push(v.y);
|
|
61368
|
+
for (const d of level2.doors)
|
|
61369
|
+
xs.push(d.v1_x, d.v2_x), ys.push(d.v1_y, d.v2_y);
|
|
61370
|
+
if (!xs.length)
|
|
61371
|
+
return null;
|
|
61372
|
+
const pad = 3;
|
|
61373
|
+
return { minX: Math.min(...xs) - pad, maxX: Math.max(...xs) + pad, minY: Math.min(...ys) - pad, maxY: Math.max(...ys) + pad };
|
|
61374
|
+
}
|
|
61375
|
+
function planShareOf(building, loc) {
|
|
61376
|
+
if (!loc)
|
|
61377
|
+
return null;
|
|
61378
|
+
const b = levelBounds(building, loc.map);
|
|
61379
|
+
if (!b)
|
|
61380
|
+
return null;
|
|
61381
|
+
const pct = (v) => Math.round(Math.min(100, Math.max(0, v)) * 10) / 10;
|
|
61382
|
+
return { x: pct((loc.x - b.minX) / (b.maxX - b.minX) * 100), y: pct((b.maxY - loc.y) / (b.maxY - b.minY) * 100) };
|
|
61383
|
+
}
|
|
61384
|
+
var MODE_BY_STATUS2 = {
|
|
61385
|
+
idle: "IDLE",
|
|
61386
|
+
working: "WORKING",
|
|
61387
|
+
charging: "CHARGING_CYCLE",
|
|
61388
|
+
error: "MAINTENANCE"
|
|
61389
|
+
};
|
|
61390
|
+
function toAdapterRobot(fleet2, name, s, building, paused = false) {
|
|
61391
|
+
const status = s.status ?? "uninitialized";
|
|
61392
|
+
const online = !["offline", "shutdown", "uninitialized"].includes(status);
|
|
61393
|
+
let mode = online ? MODE_BY_STATUS2[status] ?? "UNAVAILABLE" : "UNAVAILABLE";
|
|
61394
|
+
if (mode === "CHARGING_CYCLE" && (s.battery ?? 0) >= 0.995)
|
|
61395
|
+
mode = "CHARGED";
|
|
61396
|
+
if (paused && mode === "WORKING")
|
|
61397
|
+
mode = "PAUSED";
|
|
61398
|
+
const issue = (s.issues ?? []).find((i) => i?.category);
|
|
61399
|
+
const loc = s.location ?? null;
|
|
61400
|
+
const floorNo2 = floorNoOf(loc?.map);
|
|
61401
|
+
return {
|
|
61402
|
+
robotSn: `${fleet2}/${name}`,
|
|
61403
|
+
name,
|
|
61404
|
+
model: fleet2,
|
|
61405
|
+
online,
|
|
61406
|
+
mode,
|
|
61407
|
+
statusName: s.task_id ? `${status} \xB7 task ${s.task_id.slice(0, 8)}` : status,
|
|
61408
|
+
batteryPercent: typeof s.battery === "number" ? Math.round(s.battery * 100) : null,
|
|
61409
|
+
floorNo: floorNo2,
|
|
61410
|
+
floorKnown: floorNo2 !== null,
|
|
61411
|
+
position: loc ? { x: loc.x, y: loc.y, theta: loc.yaw } : null,
|
|
61412
|
+
planPosition: planShareOf(building, loc),
|
|
61413
|
+
fault: issue ? {
|
|
61414
|
+
code: String(issue.category).slice(0, 60),
|
|
61415
|
+
message: (typeof issue.detail === "string" ? issue.detail : JSON.stringify(issue.detail ?? "")).slice(0, 200)
|
|
61416
|
+
} : null
|
|
61417
|
+
};
|
|
61418
|
+
}
|
|
61419
|
+
function robotGraphIndex(building, loc) {
|
|
61420
|
+
const level2 = loc && building?.levels.find((l) => l.name === loc.map);
|
|
61421
|
+
if (!level2)
|
|
61422
|
+
return null;
|
|
61423
|
+
let best = null;
|
|
61424
|
+
for (const g of level2.nav_graphs) {
|
|
61425
|
+
for (const v of g.vertices) {
|
|
61426
|
+
const d = (v.x - loc.x) ** 2 + (v.y - loc.y) ** 2;
|
|
61427
|
+
if (!best || d < best.d)
|
|
61428
|
+
best = { name: g.name, d };
|
|
61429
|
+
}
|
|
61430
|
+
}
|
|
61431
|
+
return best?.name ?? null;
|
|
61432
|
+
}
|
|
61433
|
+
function waypointsFor(building, loc) {
|
|
61434
|
+
const graph = robotGraphIndex(building, loc);
|
|
61435
|
+
const level2 = loc && building?.levels.find((l) => l.name === loc.map);
|
|
61436
|
+
const vertices = level2?.nav_graphs.find((g) => g.name === graph)?.vertices.filter((v) => v.name) ?? [];
|
|
61437
|
+
return {
|
|
61438
|
+
chargers: vertices.filter((v) => hasParam(v, "is_charger")),
|
|
61439
|
+
cleaningZones: vertices.filter((v) => hasParam(v, "is_cleaning_zone")),
|
|
61440
|
+
places: vertices.filter((v) => !hasParam(v, "is_charger") && !hasParam(v, "is_cleaning_zone"))
|
|
61441
|
+
};
|
|
61442
|
+
}
|
|
61443
|
+
function cleanActivities(zone) {
|
|
61444
|
+
return [
|
|
61445
|
+
{ category: "go_to_place", description: zone },
|
|
61446
|
+
{
|
|
61447
|
+
category: "perform_action",
|
|
61448
|
+
description: {
|
|
61449
|
+
unix_millis_action_duration_estimate: 6e4,
|
|
61450
|
+
category: "clean",
|
|
61451
|
+
expected_finish_location: zone,
|
|
61452
|
+
description: { zone },
|
|
61453
|
+
use_tool_sink: true
|
|
61454
|
+
}
|
|
61455
|
+
}
|
|
61456
|
+
];
|
|
61457
|
+
}
|
|
61458
|
+
var composed = (category, activities) => ({
|
|
61459
|
+
category: "compose",
|
|
61460
|
+
requester: "iservice365",
|
|
61461
|
+
description: {
|
|
61462
|
+
category,
|
|
61463
|
+
phases: [{ activity: { category: "sequence", description: { activities } } }]
|
|
61464
|
+
}
|
|
61465
|
+
});
|
|
61466
|
+
function taskRequestFor(command, robotType, wp) {
|
|
61467
|
+
const pick = (names, allowed, what) => {
|
|
61468
|
+
const known = new Set(allowed.map((v) => v.name));
|
|
61469
|
+
const bad = names.filter((n) => !known.has(n));
|
|
61470
|
+
if (!names.length || bad.length) {
|
|
61471
|
+
throw new OpenRmfError(
|
|
61472
|
+
`Unknown ${what}${bad.length ? `: ${bad.join(", ")}` : ""}. Known: ${[...known].join(", ") || "none"}.`
|
|
61473
|
+
);
|
|
61474
|
+
}
|
|
61475
|
+
return names;
|
|
61476
|
+
};
|
|
61477
|
+
switch (command.kind) {
|
|
61478
|
+
case "full":
|
|
61479
|
+
if (robotType === "security") {
|
|
61480
|
+
return { category: "patrol", requester: "iservice365", description: { places: pick(wp.places.map((v) => v.name), wp.places, "patrol places"), rounds: 1 } };
|
|
61481
|
+
}
|
|
61482
|
+
return composed("clean", pick(wp.cleaningZones.map((v) => v.name), wp.cleaningZones, "cleaning zones").flatMap(cleanActivities));
|
|
61483
|
+
case "area":
|
|
61484
|
+
if (robotType === "security") {
|
|
61485
|
+
return { category: "patrol", requester: "iservice365", description: { places: command.areas.slice(0, 20), rounds: 1 } };
|
|
61486
|
+
}
|
|
61487
|
+
return composed("clean", pick(command.areas.slice(0, 20), wp.cleaningZones, "cleaning zones").flatMap(cleanActivities));
|
|
61488
|
+
case "return": {
|
|
61489
|
+
const charger = wp.chargers[0]?.name;
|
|
61490
|
+
if (!charger)
|
|
61491
|
+
throw new OpenRmfError("This robot has no charger on its current floor.");
|
|
61492
|
+
return composed("go_to_place", [{ category: "go_to_place", description: charger }]);
|
|
61493
|
+
}
|
|
61494
|
+
default:
|
|
61495
|
+
throw new OpenRmfError(`These robots do not take "${command.kind}".`);
|
|
61496
|
+
}
|
|
61497
|
+
}
|
|
61498
|
+
var DOOR_TYPE_SLIDING = /* @__PURE__ */ new Set([1, 2, 3, 4]);
|
|
61499
|
+
function buildingFromRmf(building) {
|
|
61500
|
+
const levels = building.levels.slice(0, 200);
|
|
61501
|
+
const floorOf = (name, i) => floorNoOf(name) ?? i + 1;
|
|
61502
|
+
const byName = new Map(levels.map((l, i) => [l.name, floorOf(l.name, i)]));
|
|
61503
|
+
return {
|
|
61504
|
+
name: String(building.name ?? "Building").slice(0, 60),
|
|
61505
|
+
levels: levels.map((l, i) => ({ floorNo: floorOf(l.name, i), name: l.name, elevationM: l.elevation })),
|
|
61506
|
+
doors: levels.flatMap(
|
|
61507
|
+
(l, i) => l.doors.map((d) => ({
|
|
61508
|
+
name: d.name,
|
|
61509
|
+
floorNo: floorOf(l.name, i),
|
|
61510
|
+
type: DOOR_TYPE_SLIDING.has(d.door_type) ? "sliding" : "hinged",
|
|
61511
|
+
start: { x: d.v1_x, y: d.v1_y },
|
|
61512
|
+
end: { x: d.v2_x, y: d.v2_y }
|
|
61513
|
+
}))
|
|
61514
|
+
),
|
|
61515
|
+
lifts: building.lifts.map((l) => ({
|
|
61516
|
+
name: l.name,
|
|
61517
|
+
x: l.ref_x,
|
|
61518
|
+
y: l.ref_y,
|
|
61519
|
+
widthM: l.width,
|
|
61520
|
+
depthM: l.depth,
|
|
61521
|
+
floors: l.levels.map((n) => byName.get(n)).filter((n) => typeof n === "number")
|
|
61522
|
+
}))
|
|
61523
|
+
};
|
|
61524
|
+
}
|
|
61525
|
+
function openRmfDoorDriver(client, doorName) {
|
|
61526
|
+
return {
|
|
61527
|
+
name: doorName,
|
|
61528
|
+
async read() {
|
|
61529
|
+
const s = await client.doorState(doorName).catch((e) => {
|
|
61530
|
+
if (/HTTP 404/.test(String(e?.message)))
|
|
61531
|
+
return null;
|
|
61532
|
+
throw e;
|
|
61533
|
+
});
|
|
61534
|
+
if (!s)
|
|
61535
|
+
return null;
|
|
61536
|
+
const t = s.door_time ?? {};
|
|
61537
|
+
return {
|
|
61538
|
+
doorName: s.door_name ?? doorName,
|
|
61539
|
+
doorTime: Number(t.sec ?? 0) * 1e3 + Math.round(Number(t.nanosec ?? 0) / 1e6),
|
|
61540
|
+
currentMode: doorModeOf(s.current_mode?.value)
|
|
61541
|
+
};
|
|
61542
|
+
},
|
|
61543
|
+
async request(request2) {
|
|
61544
|
+
if (request2.requestedMode !== DOOR_MODE.OPEN && request2.requestedMode !== DOOR_MODE.CLOSED) {
|
|
61545
|
+
throw new OpenRmfError("A door can only be asked to open or close.");
|
|
61546
|
+
}
|
|
61547
|
+
await client.doorRequest(doorName, request2.requestedMode);
|
|
61548
|
+
}
|
|
61549
|
+
};
|
|
61550
|
+
}
|
|
61551
|
+
function openRmfLiftDriver(client, liftName) {
|
|
61552
|
+
const destinations = /* @__PURE__ */ new Map();
|
|
61553
|
+
const send2 = (requestType, sessionId, destination, doorState) => client.liftRequest(liftName, {
|
|
61554
|
+
request_type: requestType,
|
|
61555
|
+
door_mode: doorState,
|
|
61556
|
+
destination,
|
|
61557
|
+
additional_session_ids: [sessionId]
|
|
61558
|
+
});
|
|
61559
|
+
return {
|
|
61560
|
+
name: liftName,
|
|
61561
|
+
async read() {
|
|
61562
|
+
const s = await client.liftState(liftName).catch((e) => {
|
|
61563
|
+
if (/HTTP 404/.test(String(e?.message)))
|
|
61564
|
+
return null;
|
|
61565
|
+
throw e;
|
|
61566
|
+
});
|
|
61567
|
+
if (!s)
|
|
61568
|
+
return null;
|
|
61569
|
+
const t = s.lift_time ?? {};
|
|
61570
|
+
return {
|
|
61571
|
+
liftName: s.lift_name ?? liftName,
|
|
61572
|
+
liftTime: Number(t.sec ?? 0) * 1e3 + Math.round(Number(t.nanosec ?? 0) / 1e6),
|
|
61573
|
+
availableFloors: Array.isArray(s.available_floors) ? s.available_floors.map(String) : [],
|
|
61574
|
+
currentFloor: String(s.current_floor ?? ""),
|
|
61575
|
+
destinationFloor: String(s.destination_floor ?? ""),
|
|
61576
|
+
doorState: [0, 1, 2].includes(s.door_state) ? s.door_state : 0,
|
|
61577
|
+
motionState: [0, 1, 2, 3].includes(s.motion_state) ? s.motion_state : 3,
|
|
61578
|
+
currentMode: [0, 1, 2, 3, 4, 5].includes(s.current_mode) ? s.current_mode : 0,
|
|
61579
|
+
sessionId: String(s.session_id ?? "")
|
|
61580
|
+
};
|
|
61581
|
+
},
|
|
61582
|
+
async request(r) {
|
|
61583
|
+
destinations.set(r.sessionId, r.destinationFloor);
|
|
61584
|
+
await send2(r.requestType, r.sessionId, r.destinationFloor, r.doorState);
|
|
61585
|
+
},
|
|
61586
|
+
async refresh(sessionId) {
|
|
61587
|
+
const destination = destinations.get(sessionId);
|
|
61588
|
+
if (destination)
|
|
61589
|
+
await send2(LIFT_REQUEST.AGV_MODE, sessionId, destination, 2);
|
|
61590
|
+
},
|
|
61591
|
+
async release(sessionId) {
|
|
61592
|
+
destinations.delete(sessionId);
|
|
61593
|
+
await send2(LIFT_REQUEST.END_SESSION, sessionId, "", 0);
|
|
61594
|
+
}
|
|
61595
|
+
};
|
|
61596
|
+
}
|
|
61597
|
+
function createOpenRmfAdapter(options) {
|
|
61598
|
+
const client = createOpenRmfClient(options && "config" in options ? options.config ?? null : openRmfConfig(), {
|
|
61599
|
+
fetch: options?.fetch,
|
|
61600
|
+
timeoutMs: options?.timeoutMs
|
|
61601
|
+
});
|
|
61602
|
+
async function states() {
|
|
61603
|
+
const [fleets, building] = await Promise.all([client.fleets(), client.buildingMap().catch(() => null)]);
|
|
61604
|
+
return { fleets: fleets ?? [], building };
|
|
61605
|
+
}
|
|
61606
|
+
async function openInterruptions(taskId) {
|
|
61607
|
+
if (!taskId)
|
|
61608
|
+
return [];
|
|
61609
|
+
const t = await client.taskState(taskId).catch(() => null);
|
|
61610
|
+
return Object.entries(t?.interruptions ?? {}).filter(([, v]) => !v?.resumed_by).map(([token]) => token);
|
|
61611
|
+
}
|
|
61612
|
+
async function find(robotSn) {
|
|
61613
|
+
const key = splitRobotSn(robotSn);
|
|
61614
|
+
if (!key)
|
|
61615
|
+
return null;
|
|
61616
|
+
const { fleets, building } = await states();
|
|
61617
|
+
const s = fleets.find((f) => f.name === key.fleet)?.robots?.[key.robot];
|
|
61618
|
+
return s ? { key, s, building } : null;
|
|
61619
|
+
}
|
|
61620
|
+
return {
|
|
61621
|
+
client,
|
|
61622
|
+
brand: OPEN_RMF_BRAND,
|
|
61623
|
+
displayName: OPEN_RMF_DISPLAY_NAME,
|
|
61624
|
+
capabilities: OPEN_RMF_CAPABILITIES,
|
|
61625
|
+
async listRobots() {
|
|
61626
|
+
const { fleets, building } = await states();
|
|
61627
|
+
return fleets.flatMap((f) => Object.entries(f.robots ?? {}).map(([n, s]) => toAdapterRobot(f.name, n, s, building)));
|
|
61628
|
+
},
|
|
61629
|
+
async getRobot(robotSn) {
|
|
61630
|
+
const hit = await find(robotSn);
|
|
61631
|
+
if (!hit)
|
|
61632
|
+
return null;
|
|
61633
|
+
return toAdapterRobot(hit.key.fleet, hit.key.robot, hit.s, hit.building, (await openInterruptions(hit.s.task_id)).length > 0);
|
|
61634
|
+
},
|
|
61635
|
+
async sendCommand(robotSn, command) {
|
|
61636
|
+
const hit = await find(robotSn);
|
|
61637
|
+
if (!hit)
|
|
61638
|
+
throw new OpenRmfError(`The fleet server does not list the robot "${robotSn}".`);
|
|
61639
|
+
const taskId = hit.s.task_id ?? "";
|
|
61640
|
+
if (command.kind === "pause" || command.kind === "resume" || command.kind === "cancel") {
|
|
61641
|
+
if (!taskId)
|
|
61642
|
+
throw new OpenRmfError("This robot has no task to " + command.kind + ".");
|
|
61643
|
+
let res2;
|
|
61644
|
+
if (command.kind === "resume") {
|
|
61645
|
+
const tokens = await openInterruptions(taskId);
|
|
61646
|
+
if (!tokens.length)
|
|
61647
|
+
throw new OpenRmfError("This robot's task is not paused.");
|
|
61648
|
+
res2 = await client.resumeTask(taskId, tokens);
|
|
61649
|
+
} else {
|
|
61650
|
+
res2 = command.kind === "pause" ? await client.interruptTask(taskId) : await client.cancelTask(taskId);
|
|
61651
|
+
}
|
|
61652
|
+
if (res2 && res2.success === false)
|
|
61653
|
+
throw new OpenRmfError(`The fleet server refused to ${command.kind} the task.`);
|
|
61654
|
+
return;
|
|
61655
|
+
}
|
|
61656
|
+
const wp = waypointsFor(hit.building, hit.s.location);
|
|
61657
|
+
const request2 = taskRequestFor(command, wp.cleaningZones.length ? "cleaning" : "security", wp);
|
|
61658
|
+
const res = await client.robotTask(hit.key.fleet, hit.key.robot, request2);
|
|
61659
|
+
if (!res?.success)
|
|
61660
|
+
throw new OpenRmfError("The fleet server did not accept the task.");
|
|
61661
|
+
},
|
|
61662
|
+
/**
|
|
61663
|
+
* The robot's current patrol, from its task state: each phase is
|
|
61664
|
+
* "Go to [place:<name>]", in order, and the active phase is the checkpoint
|
|
61665
|
+
* it is heading for. (A direct robot task keeps no request record on the
|
|
61666
|
+
* api-server, so the state is the only source.)
|
|
61667
|
+
*/
|
|
61668
|
+
async getPatrolRoutes(robotSn) {
|
|
61669
|
+
const none = { routes: [], schedule: [] };
|
|
61670
|
+
const hit = await find(robotSn);
|
|
61671
|
+
const taskId = hit?.s.task_id;
|
|
61672
|
+
if (!hit || !taskId)
|
|
61673
|
+
return none;
|
|
61674
|
+
const t = await client.taskState(taskId).catch(() => null);
|
|
61675
|
+
if (!t || !/^patrol$/i.test(String(t.category ?? "")))
|
|
61676
|
+
return none;
|
|
61677
|
+
const level2 = hit.building?.levels.find((l) => l.name === hit.s.location?.map);
|
|
61678
|
+
const vertex = (name) => level2?.nav_graphs.flatMap((g) => g.vertices).find((v) => v.name === name);
|
|
61679
|
+
const phases = Object.entries(t.phases ?? {}).sort(([a], [b]) => Number(a) - Number(b)).map(([id, p]) => ({ id: Number(id), place: /\[place:([^\]]+)\]/.exec(String(p?.category ?? ""))?.[1] ?? "" })).filter((p) => p.place && vertex(p.place));
|
|
61680
|
+
const checkpoints = phases.map((p) => {
|
|
61681
|
+
const v = vertex(p.place);
|
|
61682
|
+
return { name: p.place, ...planShareOf(hit.building, { map: level2.name, x: v.x, y: v.y, yaw: 0 }) };
|
|
61683
|
+
});
|
|
61684
|
+
const current = phases.findIndex((p) => p.id === t.active);
|
|
61685
|
+
return {
|
|
61686
|
+
routes: [
|
|
61687
|
+
{
|
|
61688
|
+
id: taskId,
|
|
61689
|
+
name: `Patrol \xB7 ${checkpoints.map((c) => c.name).join(" \u2192 ")}`.slice(0, 80),
|
|
61690
|
+
floorNo: floorNoOf(level2?.name),
|
|
61691
|
+
checkpoints,
|
|
61692
|
+
currentCheckpoint: current >= 0 ? current : null
|
|
61693
|
+
}
|
|
61694
|
+
],
|
|
61695
|
+
schedule: []
|
|
61696
|
+
};
|
|
61697
|
+
}
|
|
61698
|
+
};
|
|
61699
|
+
}
|
|
61700
|
+
function registerOpenRmfBrand(env2 = process.env) {
|
|
61701
|
+
if (!openRmfConfig(env2))
|
|
61702
|
+
return false;
|
|
61703
|
+
registerRobotBrand({
|
|
61704
|
+
brand: OPEN_RMF_BRAND,
|
|
61705
|
+
displayName: OPEN_RMF_DISPLAY_NAME,
|
|
61706
|
+
capabilities: OPEN_RMF_CAPABILITIES,
|
|
61707
|
+
types: ["cleaning", "security"],
|
|
61708
|
+
create: () => createOpenRmfAdapter()
|
|
61709
|
+
});
|
|
61710
|
+
return true;
|
|
61711
|
+
}
|
|
61712
|
+
registerOpenRmfBrand();
|
|
61713
|
+
|
|
60934
61714
|
// src/services/robot-fleet.service.ts
|
|
60935
61715
|
function useRobotFleetService(deps) {
|
|
60936
61716
|
const adapterFor = deps?.adapterFor ?? ((robot) => adapterForRobot(robot));
|
|
@@ -61478,213 +62258,6 @@ function robotActionsFor(actor) {
|
|
|
61478
62258
|
);
|
|
61479
62259
|
}
|
|
61480
62260
|
|
|
61481
|
-
// src/utils/lift-contract.util.ts
|
|
61482
|
-
var LIFT_DOOR = {
|
|
61483
|
-
CLOSED: 0,
|
|
61484
|
-
MOVING: 1,
|
|
61485
|
-
OPEN: 2
|
|
61486
|
-
};
|
|
61487
|
-
var LIFT_MOTION = {
|
|
61488
|
-
STOPPED: 0,
|
|
61489
|
-
UP: 1,
|
|
61490
|
-
DOWN: 2,
|
|
61491
|
-
UNKNOWN: 3
|
|
61492
|
-
};
|
|
61493
|
-
var LIFT_MODE = {
|
|
61494
|
-
UNKNOWN: 0,
|
|
61495
|
-
HUMAN: 1,
|
|
61496
|
-
AGV: 2,
|
|
61497
|
-
FIRE: 3,
|
|
61498
|
-
OFFLINE: 4,
|
|
61499
|
-
EMERGENCY: 5
|
|
61500
|
-
};
|
|
61501
|
-
var LIFT_REQUEST = {
|
|
61502
|
-
END_SESSION: 0,
|
|
61503
|
-
AGV_MODE: 1,
|
|
61504
|
-
HUMAN_MODE: 2
|
|
61505
|
-
};
|
|
61506
|
-
function isLiftAvailable(state) {
|
|
61507
|
-
if (!state)
|
|
61508
|
-
return false;
|
|
61509
|
-
return state.currentMode === LIFT_MODE.HUMAN || state.currentMode === LIFT_MODE.AGV;
|
|
61510
|
-
}
|
|
61511
|
-
function isSafeToCross(state, floor) {
|
|
61512
|
-
if (!isLiftAvailable(state) || !state)
|
|
61513
|
-
return false;
|
|
61514
|
-
if (state.currentFloor !== floor)
|
|
61515
|
-
return false;
|
|
61516
|
-
if (state.motionState !== LIFT_MOTION.STOPPED)
|
|
61517
|
-
return false;
|
|
61518
|
-
return state.doorState === LIFT_DOOR.OPEN;
|
|
61519
|
-
}
|
|
61520
|
-
function holdsLift(state, sessionId) {
|
|
61521
|
-
if (!state || !sessionId)
|
|
61522
|
-
return false;
|
|
61523
|
-
return state.sessionId === sessionId;
|
|
61524
|
-
}
|
|
61525
|
-
function servesFloor(state, floor) {
|
|
61526
|
-
if (!state || !floor)
|
|
61527
|
-
return false;
|
|
61528
|
-
return state.availableFloors.includes(floor);
|
|
61529
|
-
}
|
|
61530
|
-
function createLiftSimulator(options) {
|
|
61531
|
-
const { name, floors } = options;
|
|
61532
|
-
if (floors.length === 0)
|
|
61533
|
-
throw new Error("A lift must serve some floors.");
|
|
61534
|
-
const msPerFloor = options.msPerFloor ?? 2e3;
|
|
61535
|
-
const doorDwellMs = options.doorDwellMs ?? 5e3;
|
|
61536
|
-
const state = {
|
|
61537
|
-
liftName: name,
|
|
61538
|
-
liftTime: 0,
|
|
61539
|
-
availableFloors: [...floors],
|
|
61540
|
-
currentFloor: options.startFloor ?? floors[0],
|
|
61541
|
-
destinationFloor: options.startFloor ?? floors[0],
|
|
61542
|
-
doorState: LIFT_DOOR.CLOSED,
|
|
61543
|
-
motionState: LIFT_MOTION.STOPPED,
|
|
61544
|
-
currentMode: LIFT_MODE.HUMAN,
|
|
61545
|
-
sessionId: ""
|
|
61546
|
-
};
|
|
61547
|
-
let travelRemaining = 0;
|
|
61548
|
-
let doorTimer = 0;
|
|
61549
|
-
function tick(ms) {
|
|
61550
|
-
state.liftTime += ms;
|
|
61551
|
-
if (state.motionState !== LIFT_MOTION.STOPPED) {
|
|
61552
|
-
travelRemaining -= ms;
|
|
61553
|
-
if (travelRemaining <= 0) {
|
|
61554
|
-
state.currentFloor = state.destinationFloor;
|
|
61555
|
-
state.motionState = LIFT_MOTION.STOPPED;
|
|
61556
|
-
state.doorState = LIFT_DOOR.OPEN;
|
|
61557
|
-
doorTimer = doorDwellMs;
|
|
61558
|
-
}
|
|
61559
|
-
return;
|
|
61560
|
-
}
|
|
61561
|
-
if (state.doorState === LIFT_DOOR.OPEN) {
|
|
61562
|
-
doorTimer -= ms;
|
|
61563
|
-
if (doorTimer <= 0)
|
|
61564
|
-
state.doorState = LIFT_DOOR.CLOSED;
|
|
61565
|
-
}
|
|
61566
|
-
}
|
|
61567
|
-
return {
|
|
61568
|
-
name,
|
|
61569
|
-
state,
|
|
61570
|
-
tick,
|
|
61571
|
-
async read() {
|
|
61572
|
-
return { ...state, availableFloors: [...state.availableFloors] };
|
|
61573
|
-
},
|
|
61574
|
-
async request(request2) {
|
|
61575
|
-
if (request2.requestType === LIFT_REQUEST.END_SESSION) {
|
|
61576
|
-
if (state.sessionId === request2.sessionId) {
|
|
61577
|
-
state.sessionId = "";
|
|
61578
|
-
state.currentMode = LIFT_MODE.HUMAN;
|
|
61579
|
-
}
|
|
61580
|
-
return;
|
|
61581
|
-
}
|
|
61582
|
-
if (state.sessionId && state.sessionId !== request2.sessionId) {
|
|
61583
|
-
throw new Error(`Lift ${name} is held by ${state.sessionId}.`);
|
|
61584
|
-
}
|
|
61585
|
-
if (!state.availableFloors.includes(request2.destinationFloor)) {
|
|
61586
|
-
throw new Error(
|
|
61587
|
-
`Lift ${name} does not serve ${request2.destinationFloor}.`
|
|
61588
|
-
);
|
|
61589
|
-
}
|
|
61590
|
-
state.sessionId = request2.sessionId;
|
|
61591
|
-
state.currentMode = request2.requestType === LIFT_REQUEST.AGV_MODE ? LIFT_MODE.AGV : LIFT_MODE.HUMAN;
|
|
61592
|
-
state.destinationFloor = request2.destinationFloor;
|
|
61593
|
-
if (state.currentFloor === request2.destinationFloor) {
|
|
61594
|
-
state.motionState = LIFT_MOTION.STOPPED;
|
|
61595
|
-
state.doorState = LIFT_DOOR.OPEN;
|
|
61596
|
-
doorTimer = doorDwellMs;
|
|
61597
|
-
return;
|
|
61598
|
-
}
|
|
61599
|
-
const from = state.availableFloors.indexOf(state.currentFloor);
|
|
61600
|
-
const to = state.availableFloors.indexOf(request2.destinationFloor);
|
|
61601
|
-
state.motionState = to > from ? LIFT_MOTION.UP : LIFT_MOTION.DOWN;
|
|
61602
|
-
state.doorState = LIFT_DOOR.CLOSED;
|
|
61603
|
-
travelRemaining = Math.abs(to - from) * msPerFloor;
|
|
61604
|
-
},
|
|
61605
|
-
async refresh(sessionId) {
|
|
61606
|
-
if (state.sessionId !== sessionId)
|
|
61607
|
-
return;
|
|
61608
|
-
if (state.doorState === LIFT_DOOR.OPEN)
|
|
61609
|
-
doorTimer = doorDwellMs;
|
|
61610
|
-
},
|
|
61611
|
-
async release(sessionId) {
|
|
61612
|
-
if (state.sessionId !== sessionId)
|
|
61613
|
-
return;
|
|
61614
|
-
state.sessionId = "";
|
|
61615
|
-
state.currentMode = LIFT_MODE.HUMAN;
|
|
61616
|
-
}
|
|
61617
|
-
};
|
|
61618
|
-
}
|
|
61619
|
-
var LIFT_QUEUE_TTL_MS = 10 * 6e4;
|
|
61620
|
-
var LIFT_LEASE_MS = 3 * 6e4;
|
|
61621
|
-
var LIFT_SIM_MS_PER_FLOOR = 4e3;
|
|
61622
|
-
var LIFT_SIM_DOOR_DWELL_MS = 8e3;
|
|
61623
|
-
var LIFT_SIM_BOARD_MS = 6e3;
|
|
61624
|
-
var LIFT_SESSION_STATUS = [
|
|
61625
|
-
"queued",
|
|
61626
|
-
"active",
|
|
61627
|
-
"released",
|
|
61628
|
-
"expired",
|
|
61629
|
-
"cancelled"
|
|
61630
|
-
];
|
|
61631
|
-
async function simulatedLiftState(options) {
|
|
61632
|
-
const sim = createLiftSimulator({
|
|
61633
|
-
name: options.name,
|
|
61634
|
-
floors: options.floors,
|
|
61635
|
-
msPerFloor: LIFT_SIM_MS_PER_FLOOR,
|
|
61636
|
-
doorDwellMs: LIFT_SIM_DOOR_DWELL_MS
|
|
61637
|
-
});
|
|
61638
|
-
const session = options.session;
|
|
61639
|
-
if (!session || !options.floors.includes(session.fromFloor) || !options.floors.includes(session.toFloor)) {
|
|
61640
|
-
return { state: await sim.read(), phase: "idle" };
|
|
61641
|
-
}
|
|
61642
|
-
const STEP = 250;
|
|
61643
|
-
const elapsed = Math.max(0, options.now - session.activeAt);
|
|
61644
|
-
let phase = "to-pickup";
|
|
61645
|
-
let boardingLeft = LIFT_SIM_BOARD_MS;
|
|
61646
|
-
await sim.request({
|
|
61647
|
-
liftName: options.name,
|
|
61648
|
-
sessionId: session.id,
|
|
61649
|
-
requestType: LIFT_REQUEST.AGV_MODE,
|
|
61650
|
-
destinationFloor: session.fromFloor,
|
|
61651
|
-
doorState: LIFT_DOOR.OPEN
|
|
61652
|
-
});
|
|
61653
|
-
if (isSafeToCross(sim.state, session.fromFloor))
|
|
61654
|
-
phase = "boarding";
|
|
61655
|
-
for (let t = 0; t < elapsed; t += STEP) {
|
|
61656
|
-
const ms = Math.min(STEP, elapsed - t);
|
|
61657
|
-
sim.tick(ms);
|
|
61658
|
-
const s = sim.state;
|
|
61659
|
-
if (phase === "to-pickup") {
|
|
61660
|
-
if (isSafeToCross(s, session.fromFloor))
|
|
61661
|
-
phase = "boarding";
|
|
61662
|
-
} else if (phase === "boarding") {
|
|
61663
|
-
await sim.refresh(session.id);
|
|
61664
|
-
boardingLeft -= ms;
|
|
61665
|
-
if (boardingLeft <= 0) {
|
|
61666
|
-
phase = "to-destination";
|
|
61667
|
-
await sim.request({
|
|
61668
|
-
liftName: options.name,
|
|
61669
|
-
sessionId: session.id,
|
|
61670
|
-
requestType: LIFT_REQUEST.AGV_MODE,
|
|
61671
|
-
destinationFloor: session.toFloor,
|
|
61672
|
-
doorState: LIFT_DOOR.CLOSED
|
|
61673
|
-
});
|
|
61674
|
-
}
|
|
61675
|
-
} else if (phase === "to-destination") {
|
|
61676
|
-
if (isSafeToCross(s, session.toFloor))
|
|
61677
|
-
phase = "arrived";
|
|
61678
|
-
} else if (phase === "arrived") {
|
|
61679
|
-
await sim.refresh(session.id);
|
|
61680
|
-
}
|
|
61681
|
-
}
|
|
61682
|
-
return { state: await sim.read(), phase };
|
|
61683
|
-
}
|
|
61684
|
-
function liftQueueKey(mapId, liftName) {
|
|
61685
|
-
return `${mapId}:${liftName}`;
|
|
61686
|
-
}
|
|
61687
|
-
|
|
61688
62261
|
// src/utils/building-map.util.ts
|
|
61689
62262
|
var WALL_HEIGHT_M = 2.5;
|
|
61690
62263
|
var WALL_THICKNESS_M = 0.1;
|
|
@@ -62428,7 +63001,7 @@ function useRobotFleetController(deps) {
|
|
|
62428
63001
|
|
|
62429
63002
|
`);
|
|
62430
63003
|
};
|
|
62431
|
-
const handle = robot.brand === DEMO_BRAND ? startDemoTracking(getFleet2().adapterFor(robot), robotSn, send2) : startRobotTracking({
|
|
63004
|
+
const handle = robot.brand === DEMO_BRAND || robot.brand === OPEN_RMF_BRAND ? startDemoTracking(getFleet2().adapterFor(robot), robotSn, send2) : startRobotTracking({
|
|
62432
63005
|
credentials: {
|
|
62433
63006
|
appid: (robot.appKey ?? "").trim(),
|
|
62434
63007
|
secret: (robot.appToken ?? "").trim()
|
|
@@ -62833,7 +63406,7 @@ function useRobotLiftSessionRepo() {
|
|
|
62833
63406
|
|
|
62834
63407
|
// src/controllers/robot-map.controller.ts
|
|
62835
63408
|
import Joi78 from "joi";
|
|
62836
|
-
import { AppError as AppError22, BadRequestError as BadRequestError137, logger as logger108 } from "@7365admin1/node-server-utils";
|
|
63409
|
+
import { AppError as AppError22, BadRequestError as BadRequestError137, NotFoundError as NotFoundError45, logger as logger108 } from "@7365admin1/node-server-utils";
|
|
62837
63410
|
function useRobotMapController(deps) {
|
|
62838
63411
|
const now = () => deps?.now?.() ?? Date.now();
|
|
62839
63412
|
const robots = () => useRobotRepo();
|
|
@@ -63138,7 +63711,34 @@ function useRobotMapController(deps) {
|
|
|
63138
63711
|
fail(next, e);
|
|
63139
63712
|
}
|
|
63140
63713
|
}
|
|
63714
|
+
async function getOpenRmfBuilding(req, res, next) {
|
|
63715
|
+
const { error, value } = Joi78.object({ site: hexId, appSlug: Joi78.string().allow("") }).validate(req.query);
|
|
63716
|
+
if (error)
|
|
63717
|
+
return fail(next, new BadRequestError137(error.message));
|
|
63718
|
+
try {
|
|
63719
|
+
await requireSiteReach(req, value.site);
|
|
63720
|
+
const config2 = openRmfConfig();
|
|
63721
|
+
if (!config2)
|
|
63722
|
+
throw new NotFoundError45("Fleet Core is not configured on this server.");
|
|
63723
|
+
const client = createOpenRmfClient(config2);
|
|
63724
|
+
const building = buildingFromRmf(await client.buildingMap());
|
|
63725
|
+
const [doorStates, liftStates] = await Promise.all([
|
|
63726
|
+
Promise.all(building.doors.slice(0, 100).map((d) => openRmfDoorDriver(client, d.name).read().catch(() => null))),
|
|
63727
|
+
Promise.all(building.lifts.slice(0, 20).map((l) => openRmfLiftDriver(client, l.name).read().catch(() => null)))
|
|
63728
|
+
]);
|
|
63729
|
+
res.json({
|
|
63730
|
+
source: "fleet-core",
|
|
63731
|
+
readOnly: true,
|
|
63732
|
+
...building,
|
|
63733
|
+
doorStates: doorStates.filter(Boolean),
|
|
63734
|
+
liftStates: liftStates.filter(Boolean)
|
|
63735
|
+
});
|
|
63736
|
+
} catch (e) {
|
|
63737
|
+
fail(next, e instanceof OpenRmfError ? new AppError22(e.message, 502) : e);
|
|
63738
|
+
}
|
|
63739
|
+
}
|
|
63141
63740
|
return {
|
|
63741
|
+
getOpenRmfBuilding,
|
|
63142
63742
|
listMaps,
|
|
63143
63743
|
getMap,
|
|
63144
63744
|
createMap,
|
|
@@ -63158,7 +63758,7 @@ import { BadRequestError as BadRequestError139, logger as logger110 } from "@736
|
|
|
63158
63758
|
|
|
63159
63759
|
// src/controllers/robot-site.controller.ts
|
|
63160
63760
|
import Joi79 from "joi";
|
|
63161
|
-
import { BadRequestError as BadRequestError138, NotFoundError as
|
|
63761
|
+
import { BadRequestError as BadRequestError138, NotFoundError as NotFoundError46, logger as logger109 } from "@7365admin1/node-server-utils";
|
|
63162
63762
|
var ROBOT_AUDIT_ACTIONS = Object.values(ConsoleAuditAction).filter((a) => a.startsWith("robot."));
|
|
63163
63763
|
var SITE_STATES_MAX = 50;
|
|
63164
63764
|
async function readLiveItems(robots) {
|
|
@@ -63349,7 +63949,7 @@ function useRobotSiteController() {
|
|
|
63349
63949
|
let targets;
|
|
63350
63950
|
if (q.robot) {
|
|
63351
63951
|
if (!robotIds.includes(String(q.robot)))
|
|
63352
|
-
throw new
|
|
63952
|
+
throw new NotFoundError46("Robot not found.");
|
|
63353
63953
|
targets = [String(q.robot)];
|
|
63354
63954
|
} else {
|
|
63355
63955
|
targets = [...robotIds, ...await useRobotBuildingMapRepo().getMapIdsAtSite(q.site)];
|
|
@@ -63454,7 +64054,7 @@ function useRobotSiteController() {
|
|
|
63454
64054
|
}
|
|
63455
64055
|
|
|
63456
64056
|
// src/controllers/robot-network.controller.ts
|
|
63457
|
-
var
|
|
64057
|
+
var MODES2 = ["IDLE", "CHARGED", "WORKING", "PAUSED", "CHARGING_CYCLE", "MAINTENANCE", "IN_TRANSIT", "MANUAL", "UNAVAILABLE"];
|
|
63458
64058
|
var NETWORK_STATES_MAX = 50;
|
|
63459
64059
|
function useRobotNetworkController() {
|
|
63460
64060
|
const hex = Joi80.string().hex().length(24).allow("", null);
|
|
@@ -63470,7 +64070,7 @@ function useRobotNetworkController() {
|
|
|
63470
64070
|
brand: Joi80.string().trim().max(60).allow("", null),
|
|
63471
64071
|
faultsOnly: Joi80.boolean().default(false),
|
|
63472
64072
|
offlineOnly: Joi80.boolean().default(false),
|
|
63473
|
-
status: Joi80.string().valid(...
|
|
64073
|
+
status: Joi80.string().valid(...MODES2).allow("", null)
|
|
63474
64074
|
});
|
|
63475
64075
|
const faultsSchema = Joi80.object({
|
|
63476
64076
|
page: Joi80.number().integer().min(1).max(1e4).default(1),
|
|
@@ -64093,10 +64693,10 @@ import {
|
|
|
64093
64693
|
import { ObjectId as ObjectId110 } from "mongodb";
|
|
64094
64694
|
|
|
64095
64695
|
// src/utils/update-result.util.ts
|
|
64096
|
-
import { NotFoundError as
|
|
64696
|
+
import { NotFoundError as NotFoundError47 } from "@7365admin1/node-server-utils";
|
|
64097
64697
|
function assertUpdateMatched(result, message) {
|
|
64098
64698
|
if (result?.matchedCount === 0) {
|
|
64099
|
-
throw new
|
|
64699
|
+
throw new NotFoundError47(message);
|
|
64100
64700
|
}
|
|
64101
64701
|
return result;
|
|
64102
64702
|
}
|
|
@@ -65258,7 +65858,7 @@ function usePatrolLogRepo() {
|
|
|
65258
65858
|
import {
|
|
65259
65859
|
BadRequestError as BadRequestError148,
|
|
65260
65860
|
logger as logger119,
|
|
65261
|
-
NotFoundError as
|
|
65861
|
+
NotFoundError as NotFoundError48,
|
|
65262
65862
|
useAtlas as useAtlas83
|
|
65263
65863
|
} from "@7365admin1/node-server-utils";
|
|
65264
65864
|
function patrolProblem(status) {
|
|
@@ -65298,7 +65898,7 @@ function usePatrolLogService() {
|
|
|
65298
65898
|
session
|
|
65299
65899
|
);
|
|
65300
65900
|
if (file.matchedCount === 0) {
|
|
65301
|
-
throw new
|
|
65901
|
+
throw new NotFoundError48(`File not found: ${fileId}`);
|
|
65302
65902
|
}
|
|
65303
65903
|
}
|
|
65304
65904
|
}
|
|
@@ -65663,7 +66263,7 @@ import {
|
|
|
65663
66263
|
BadRequestError as BadRequestError151,
|
|
65664
66264
|
InternalServerError as InternalServerError55,
|
|
65665
66265
|
logger as logger121,
|
|
65666
|
-
NotFoundError as
|
|
66266
|
+
NotFoundError as NotFoundError49,
|
|
65667
66267
|
paginate as paginate38,
|
|
65668
66268
|
useAtlas as useAtlas84
|
|
65669
66269
|
} from "@7365admin1/node-server-utils";
|
|
@@ -65853,7 +66453,7 @@ function usePatrolEmailRepo() {
|
|
|
65853
66453
|
throw new InternalServerError55("Failed to retrieve the patrol email.");
|
|
65854
66454
|
}
|
|
65855
66455
|
if (!data) {
|
|
65856
|
-
throw new
|
|
66456
|
+
throw new NotFoundError49("Patrol email not found.");
|
|
65857
66457
|
}
|
|
65858
66458
|
const [decorated] = await withResendState([data], session);
|
|
65859
66459
|
return decorated;
|
|
@@ -65868,7 +66468,7 @@ function usePatrolEmailRepo() {
|
|
|
65868
66468
|
{ session }
|
|
65869
66469
|
);
|
|
65870
66470
|
if (result.matchedCount === 0) {
|
|
65871
|
-
throw new
|
|
66471
|
+
throw new NotFoundError49("Patrol email not found.");
|
|
65872
66472
|
}
|
|
65873
66473
|
return result;
|
|
65874
66474
|
} catch (error) {
|
|
@@ -65897,7 +66497,7 @@ import {
|
|
|
65897
66497
|
compileHandlebar as compileHandlebar5,
|
|
65898
66498
|
getDirectory as getDirectory5,
|
|
65899
66499
|
logger as logger123,
|
|
65900
|
-
NotFoundError as
|
|
66500
|
+
NotFoundError as NotFoundError50,
|
|
65901
66501
|
useMailer as useMailer5
|
|
65902
66502
|
} from "@7365admin1/node-server-utils";
|
|
65903
66503
|
|
|
@@ -66092,7 +66692,7 @@ function usePatrolEmailService() {
|
|
|
66092
66692
|
for (const id of logIds) {
|
|
66093
66693
|
const log = await _getPatrolLogById(id);
|
|
66094
66694
|
if (!log) {
|
|
66095
|
-
throw new
|
|
66695
|
+
throw new NotFoundError50("Patrol log not found.");
|
|
66096
66696
|
}
|
|
66097
66697
|
if (String(log.site) !== String(site)) {
|
|
66098
66698
|
throw new BadRequestError154(
|
|
@@ -66142,7 +66742,7 @@ function usePatrolEmailService() {
|
|
|
66142
66742
|
async function claimUploadedPdf(fileId) {
|
|
66143
66743
|
const file = await _getFileById(fileId);
|
|
66144
66744
|
if (!file) {
|
|
66145
|
-
throw new
|
|
66745
|
+
throw new NotFoundError50("Uploaded PDF not found.");
|
|
66146
66746
|
}
|
|
66147
66747
|
if (!isClaimableUpload(file)) {
|
|
66148
66748
|
throw new BadRequestError154(
|
|
@@ -66151,7 +66751,7 @@ function usePatrolEmailService() {
|
|
|
66151
66751
|
}
|
|
66152
66752
|
const promoted = await _updateFileStatusById(fileId, { status: "active" });
|
|
66153
66753
|
if (promoted.matchedCount === 0) {
|
|
66154
|
-
throw new
|
|
66754
|
+
throw new NotFoundError50("Uploaded PDF not found.");
|
|
66155
66755
|
}
|
|
66156
66756
|
return {
|
|
66157
66757
|
file: fileId,
|
|
@@ -66160,7 +66760,7 @@ function usePatrolEmailService() {
|
|
|
66160
66760
|
};
|
|
66161
66761
|
}
|
|
66162
66762
|
function sanitizeError(error) {
|
|
66163
|
-
if (error instanceof BadRequestError154 || error instanceof
|
|
66763
|
+
if (error instanceof BadRequestError154 || error instanceof NotFoundError50) {
|
|
66164
66764
|
return error.message;
|
|
66165
66765
|
}
|
|
66166
66766
|
return "Failed to send the patrol log email.";
|
|
@@ -66761,7 +67361,7 @@ import {
|
|
|
66761
67361
|
InternalServerError as InternalServerError56,
|
|
66762
67362
|
logger as logger125,
|
|
66763
67363
|
makeCacheKey as makeCacheKey39,
|
|
66764
|
-
NotFoundError as
|
|
67364
|
+
NotFoundError as NotFoundError51,
|
|
66765
67365
|
paginate as paginate39,
|
|
66766
67366
|
useAtlas as useAtlas85,
|
|
66767
67367
|
useCache as useCache44
|
|
@@ -66892,7 +67492,7 @@ function useSiteFacilityRepo() {
|
|
|
66892
67492
|
try {
|
|
66893
67493
|
const data = await collection.findOne({ _id }, { session });
|
|
66894
67494
|
if (!data) {
|
|
66895
|
-
throw new
|
|
67495
|
+
throw new NotFoundError51("Site facility not found.");
|
|
66896
67496
|
}
|
|
66897
67497
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
66898
67498
|
logger125.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -67017,7 +67617,7 @@ function useSiteFacilityRepo() {
|
|
|
67017
67617
|
try {
|
|
67018
67618
|
const data = await collection.findOne(query2, { session });
|
|
67019
67619
|
if (!data) {
|
|
67020
|
-
throw new
|
|
67620
|
+
throw new NotFoundError51("Site facility not found.");
|
|
67021
67621
|
}
|
|
67022
67622
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
67023
67623
|
logger125.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -67158,7 +67758,7 @@ function useSiteFacilityService() {
|
|
|
67158
67758
|
// src/controllers/site-facility.controller.ts
|
|
67159
67759
|
import {
|
|
67160
67760
|
BadRequestError as BadRequestError157,
|
|
67161
|
-
NotFoundError as
|
|
67761
|
+
NotFoundError as NotFoundError52,
|
|
67162
67762
|
UnauthorizedError as UnauthorizedError19,
|
|
67163
67763
|
logger as logger126
|
|
67164
67764
|
} from "@7365admin1/node-server-utils";
|
|
@@ -67178,7 +67778,7 @@ function useSiteFacilityController() {
|
|
|
67178
67778
|
const facility = await _getSiteFacilityById(id);
|
|
67179
67779
|
const { canReach } = await siteReachOf(req);
|
|
67180
67780
|
if (!await canReach(facility)) {
|
|
67181
|
-
throw new
|
|
67781
|
+
throw new NotFoundError52("Site facility not found.");
|
|
67182
67782
|
}
|
|
67183
67783
|
return facility;
|
|
67184
67784
|
}
|
|
@@ -67443,7 +68043,7 @@ import {
|
|
|
67443
68043
|
InternalServerError as InternalServerError57,
|
|
67444
68044
|
logger as logger127,
|
|
67445
68045
|
makeCacheKey as makeCacheKey40,
|
|
67446
|
-
NotFoundError as
|
|
68046
|
+
NotFoundError as NotFoundError53,
|
|
67447
68047
|
paginate as paginate40,
|
|
67448
68048
|
useAtlas as useAtlas87,
|
|
67449
68049
|
useCache as useCache45
|
|
@@ -67558,7 +68158,7 @@ function useServiceProviderBillingRepo() {
|
|
|
67558
68158
|
try {
|
|
67559
68159
|
const data = await collection.findOne({ _id }, { session });
|
|
67560
68160
|
if (!data) {
|
|
67561
|
-
throw new
|
|
68161
|
+
throw new NotFoundError53("Service provider billing not found.");
|
|
67562
68162
|
}
|
|
67563
68163
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
67564
68164
|
logger127.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -68113,7 +68713,7 @@ import {
|
|
|
68113
68713
|
InternalServerError as InternalServerError58,
|
|
68114
68714
|
logger as logger129,
|
|
68115
68715
|
makeCacheKey as makeCacheKey41,
|
|
68116
|
-
NotFoundError as
|
|
68716
|
+
NotFoundError as NotFoundError54,
|
|
68117
68717
|
paginate as paginate41,
|
|
68118
68718
|
toObjectId as toObjectId18,
|
|
68119
68719
|
useAtlas as useAtlas89,
|
|
@@ -68229,7 +68829,7 @@ function useSiteFacilityBookingRepo() {
|
|
|
68229
68829
|
try {
|
|
68230
68830
|
const data = await collection.findOne({ _id }, { session });
|
|
68231
68831
|
if (!data) {
|
|
68232
|
-
throw new
|
|
68832
|
+
throw new NotFoundError54("Site facility booking not found.");
|
|
68233
68833
|
}
|
|
68234
68834
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
68235
68835
|
logger129.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -68372,7 +68972,7 @@ function useSiteFacilityBookingService() {
|
|
|
68372
68972
|
// src/controllers/site-facility-booking.controller.ts
|
|
68373
68973
|
import {
|
|
68374
68974
|
BadRequestError as BadRequestError161,
|
|
68375
|
-
NotFoundError as
|
|
68975
|
+
NotFoundError as NotFoundError55,
|
|
68376
68976
|
logger as logger130
|
|
68377
68977
|
} from "@7365admin1/node-server-utils";
|
|
68378
68978
|
import Joi94 from "joi";
|
|
@@ -68390,7 +68990,7 @@ function useSiteFacilityBookingController() {
|
|
|
68390
68990
|
const booking = await _getSiteFacilityBookingById(id);
|
|
68391
68991
|
const { canReach } = await siteReachOf(req);
|
|
68392
68992
|
if (!await canReach(booking)) {
|
|
68393
|
-
throw new
|
|
68993
|
+
throw new NotFoundError55("Site facility booking not found.");
|
|
68394
68994
|
}
|
|
68395
68995
|
return booking;
|
|
68396
68996
|
}
|
|
@@ -68682,7 +69282,7 @@ import {
|
|
|
68682
69282
|
InternalServerError as InternalServerError59,
|
|
68683
69283
|
logger as logger131,
|
|
68684
69284
|
makeCacheKey as makeCacheKey42,
|
|
68685
|
-
NotFoundError as
|
|
69285
|
+
NotFoundError as NotFoundError56,
|
|
68686
69286
|
paginate as paginate42,
|
|
68687
69287
|
useAtlas as useAtlas91,
|
|
68688
69288
|
useCache as useCache47
|
|
@@ -68856,7 +69456,7 @@ function useDocumentManagementRepo() {
|
|
|
68856
69456
|
}
|
|
68857
69457
|
]).toArray();
|
|
68858
69458
|
if (!data || !data.length) {
|
|
68859
|
-
throw new
|
|
69459
|
+
throw new NotFoundError56("Document not found.");
|
|
68860
69460
|
}
|
|
68861
69461
|
setCache(cacheKey, data[0], 15 * 60).then(() => {
|
|
68862
69462
|
logger131.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -68929,7 +69529,7 @@ function useDocumentManagementRepo() {
|
|
|
68929
69529
|
{ $set: updateValue }
|
|
68930
69530
|
);
|
|
68931
69531
|
if (res.matchedCount === 0) {
|
|
68932
|
-
throw new
|
|
69532
|
+
throw new NotFoundError56("Folder not found.");
|
|
68933
69533
|
}
|
|
68934
69534
|
delNamespace().then(() => {
|
|
68935
69535
|
logger131.info(`Cache cleared for namespace: ${namespace_collection3}`);
|
|
@@ -69019,7 +69619,7 @@ function useDocumentManagementRepo() {
|
|
|
69019
69619
|
session ? { session } : void 0
|
|
69020
69620
|
).toArray();
|
|
69021
69621
|
if (!folders || folders.length === 0) {
|
|
69022
|
-
throw new
|
|
69622
|
+
throw new NotFoundError56("Folder not found.");
|
|
69023
69623
|
}
|
|
69024
69624
|
const ids2 = folders[0].ids;
|
|
69025
69625
|
const res = await collection.updateMany(
|
|
@@ -69348,7 +69948,7 @@ function useDocumentManagementService() {
|
|
|
69348
69948
|
import {
|
|
69349
69949
|
BadRequestError as BadRequestError164,
|
|
69350
69950
|
logger as logger133,
|
|
69351
|
-
NotFoundError as
|
|
69951
|
+
NotFoundError as NotFoundError57
|
|
69352
69952
|
} from "@7365admin1/node-server-utils";
|
|
69353
69953
|
import Joi96 from "joi";
|
|
69354
69954
|
function useDocumentManagementController() {
|
|
@@ -69374,7 +69974,7 @@ function useDocumentManagementController() {
|
|
|
69374
69974
|
return;
|
|
69375
69975
|
const org = doc?.org?.toString() ?? "";
|
|
69376
69976
|
if (!org || !actor.orgIds.includes(org)) {
|
|
69377
|
-
throw new
|
|
69977
|
+
throw new NotFoundError57("Document not found.");
|
|
69378
69978
|
}
|
|
69379
69979
|
}
|
|
69380
69980
|
async function add(req, res, next) {
|
|
@@ -69782,7 +70382,7 @@ import {
|
|
|
69782
70382
|
InternalServerError as InternalServerError60,
|
|
69783
70383
|
logger as logger134,
|
|
69784
70384
|
makeCacheKey as makeCacheKey43,
|
|
69785
|
-
NotFoundError as
|
|
70385
|
+
NotFoundError as NotFoundError58,
|
|
69786
70386
|
paginate as paginate43,
|
|
69787
70387
|
useAtlas as useAtlas93,
|
|
69788
70388
|
useCache as useCache48
|
|
@@ -69918,7 +70518,7 @@ function useBulletinBoardRepo() {
|
|
|
69918
70518
|
try {
|
|
69919
70519
|
const data = await collection.findOne({ _id }, { session });
|
|
69920
70520
|
if (!data) {
|
|
69921
|
-
throw new
|
|
70521
|
+
throw new NotFoundError58("Bulletin board not found.");
|
|
69922
70522
|
}
|
|
69923
70523
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
69924
70524
|
logger134.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -70017,7 +70617,7 @@ function useBulletinBoardRepo() {
|
|
|
70017
70617
|
{ session }
|
|
70018
70618
|
);
|
|
70019
70619
|
if (res.matchedCount === 0) {
|
|
70020
|
-
throw new
|
|
70620
|
+
throw new NotFoundError58("No bulletin boards found to update.");
|
|
70021
70621
|
}
|
|
70022
70622
|
delNamespace().then(() => {
|
|
70023
70623
|
logger134.info(
|
|
@@ -70052,7 +70652,7 @@ function useBulletinBoardRepo() {
|
|
|
70052
70652
|
{ session }
|
|
70053
70653
|
);
|
|
70054
70654
|
if (res.matchedCount === 0) {
|
|
70055
|
-
throw new
|
|
70655
|
+
throw new NotFoundError58(
|
|
70056
70656
|
"No upcoming bulletin boards found to activate."
|
|
70057
70657
|
);
|
|
70058
70658
|
}
|
|
@@ -70084,7 +70684,7 @@ function useBulletinBoardRepo() {
|
|
|
70084
70684
|
}
|
|
70085
70685
|
|
|
70086
70686
|
// src/services/bulletin-board.service.ts
|
|
70087
|
-
import { useAtlas as useAtlas94, NotFoundError as
|
|
70687
|
+
import { useAtlas as useAtlas94, NotFoundError as NotFoundError59 } from "@7365admin1/node-server-utils";
|
|
70088
70688
|
import { ObjectId as ObjectId126 } from "mongodb";
|
|
70089
70689
|
|
|
70090
70690
|
// src/utils/bulletin-service-apps.util.ts
|
|
@@ -70131,7 +70731,7 @@ function useBulletinBoardService() {
|
|
|
70131
70731
|
session
|
|
70132
70732
|
);
|
|
70133
70733
|
if (!file) {
|
|
70134
|
-
throw new
|
|
70734
|
+
throw new NotFoundError59("File not found.");
|
|
70135
70735
|
}
|
|
70136
70736
|
}
|
|
70137
70737
|
}
|
|
@@ -70280,7 +70880,7 @@ function useBulletinBoardService() {
|
|
|
70280
70880
|
// src/controllers/bulletin-board.controller.ts
|
|
70281
70881
|
import {
|
|
70282
70882
|
BadRequestError as BadRequestError166,
|
|
70283
|
-
NotFoundError as
|
|
70883
|
+
NotFoundError as NotFoundError60,
|
|
70284
70884
|
UnauthorizedError as UnauthorizedError20,
|
|
70285
70885
|
logger as logger135
|
|
70286
70886
|
} from "@7365admin1/node-server-utils";
|
|
@@ -70297,7 +70897,7 @@ function useBulletinBoardController() {
|
|
|
70297
70897
|
const bulletin = await _getBulletinBoardById(id);
|
|
70298
70898
|
const { canReach } = await siteReachOf(req);
|
|
70299
70899
|
if (!await canReach(scopeOf(bulletin))) {
|
|
70300
|
-
throw new
|
|
70900
|
+
throw new NotFoundError60("Bulletin board not found.");
|
|
70301
70901
|
}
|
|
70302
70902
|
return bulletin;
|
|
70303
70903
|
}
|
|
@@ -71877,7 +72477,7 @@ import {
|
|
|
71877
72477
|
InternalServerError as InternalServerError63,
|
|
71878
72478
|
logger as logger144,
|
|
71879
72479
|
makeCacheKey as makeCacheKey46,
|
|
71880
|
-
NotFoundError as
|
|
72480
|
+
NotFoundError as NotFoundError63,
|
|
71881
72481
|
paginate as paginate46,
|
|
71882
72482
|
useAtlas as useAtlas99,
|
|
71883
72483
|
useCache as useCache51
|
|
@@ -72051,7 +72651,7 @@ function useEventManagementRepo() {
|
|
|
72051
72651
|
try {
|
|
72052
72652
|
const data = await collection.findOne({ _id }, { session });
|
|
72053
72653
|
if (!data) {
|
|
72054
|
-
throw new
|
|
72654
|
+
throw new NotFoundError63("Event not found.");
|
|
72055
72655
|
}
|
|
72056
72656
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
72057
72657
|
logger144.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -72148,7 +72748,7 @@ function useEventManagementRepo() {
|
|
|
72148
72748
|
{ session }
|
|
72149
72749
|
);
|
|
72150
72750
|
if (res.matchedCount === 0) {
|
|
72151
|
-
throw new
|
|
72751
|
+
throw new NotFoundError63("No bulletin boards found to update.");
|
|
72152
72752
|
}
|
|
72153
72753
|
delNamespace().then(() => {
|
|
72154
72754
|
logger144.info(
|
|
@@ -72260,7 +72860,7 @@ function useEventManagementService() {
|
|
|
72260
72860
|
// src/controllers/event-management.controller.ts
|
|
72261
72861
|
import {
|
|
72262
72862
|
BadRequestError as BadRequestError176,
|
|
72263
|
-
NotFoundError as
|
|
72863
|
+
NotFoundError as NotFoundError64,
|
|
72264
72864
|
logger as logger145
|
|
72265
72865
|
} from "@7365admin1/node-server-utils";
|
|
72266
72866
|
import Joi104 from "joi";
|
|
@@ -72275,7 +72875,7 @@ function useEventManagementController() {
|
|
|
72275
72875
|
const event = await _getEventManagementById(id);
|
|
72276
72876
|
const { canReach } = await siteReachOf(req);
|
|
72277
72877
|
if (!await canReach(event)) {
|
|
72278
|
-
throw new
|
|
72878
|
+
throw new NotFoundError64("Event not found.");
|
|
72279
72879
|
}
|
|
72280
72880
|
return event;
|
|
72281
72881
|
}
|
|
@@ -75196,7 +75796,7 @@ import {
|
|
|
75196
75796
|
InternalServerError as InternalServerError65,
|
|
75197
75797
|
logger as logger150,
|
|
75198
75798
|
makeCacheKey as makeCacheKey48,
|
|
75199
|
-
NotFoundError as
|
|
75799
|
+
NotFoundError as NotFoundError66,
|
|
75200
75800
|
paginate as paginate48,
|
|
75201
75801
|
useAtlas as useAtlas104,
|
|
75202
75802
|
useCache as useCache53
|
|
@@ -75399,7 +75999,7 @@ function useNfcPatrolTagRepo() {
|
|
|
75399
75999
|
}
|
|
75400
76000
|
const tag = await collection.findOne({ _id }, { session });
|
|
75401
76001
|
if (!tag) {
|
|
75402
|
-
throw new
|
|
76002
|
+
throw new NotFoundError66("NFC Patrol Tag not found.");
|
|
75403
76003
|
}
|
|
75404
76004
|
return tag;
|
|
75405
76005
|
}
|
|
@@ -75996,7 +76596,7 @@ import {
|
|
|
75996
76596
|
InternalServerError as InternalServerError66,
|
|
75997
76597
|
logger as logger154,
|
|
75998
76598
|
makeCacheKey as makeCacheKey49,
|
|
75999
|
-
NotFoundError as
|
|
76599
|
+
NotFoundError as NotFoundError67,
|
|
76000
76600
|
paginate as paginate49,
|
|
76001
76601
|
useAtlas as useAtlas106,
|
|
76002
76602
|
useCache as useCache54
|
|
@@ -76137,7 +76737,7 @@ function useBulletinVideoRepo() {
|
|
|
76137
76737
|
{ session }
|
|
76138
76738
|
);
|
|
76139
76739
|
if (!data) {
|
|
76140
|
-
throw new
|
|
76740
|
+
throw new NotFoundError67("Bulletin video not found.");
|
|
76141
76741
|
}
|
|
76142
76742
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
76143
76743
|
logger154.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -76229,7 +76829,7 @@ function useBulletinVideoRepo() {
|
|
|
76229
76829
|
}
|
|
76230
76830
|
|
|
76231
76831
|
// src/services/bulletin-video.service.ts
|
|
76232
|
-
import { useAtlas as useAtlas107, NotFoundError as
|
|
76832
|
+
import { useAtlas as useAtlas107, NotFoundError as NotFoundError68 } from "@7365admin1/node-server-utils";
|
|
76233
76833
|
function useBulletinVideoService() {
|
|
76234
76834
|
const {
|
|
76235
76835
|
add: _add,
|
|
@@ -76250,7 +76850,7 @@ function useBulletinVideoService() {
|
|
|
76250
76850
|
session
|
|
76251
76851
|
);
|
|
76252
76852
|
if (!file) {
|
|
76253
|
-
throw new
|
|
76853
|
+
throw new NotFoundError68("File not found.");
|
|
76254
76854
|
}
|
|
76255
76855
|
}
|
|
76256
76856
|
await _add(value, session);
|
|
@@ -76306,7 +76906,7 @@ function useBulletinVideoService() {
|
|
|
76306
76906
|
// src/controllers/bulletin-video.controller.ts
|
|
76307
76907
|
import {
|
|
76308
76908
|
BadRequestError as BadRequestError188,
|
|
76309
|
-
NotFoundError as
|
|
76909
|
+
NotFoundError as NotFoundError69,
|
|
76310
76910
|
logger as logger155
|
|
76311
76911
|
} from "@7365admin1/node-server-utils";
|
|
76312
76912
|
import Joi113 from "joi";
|
|
@@ -76321,7 +76921,7 @@ function useBulletinVideoController() {
|
|
|
76321
76921
|
const video = await _getBulletinVideoById(id);
|
|
76322
76922
|
const { canReach } = await siteReachOf(req);
|
|
76323
76923
|
if (!await canReach(video)) {
|
|
76324
|
-
throw new
|
|
76924
|
+
throw new NotFoundError69("Bulletin video not found.");
|
|
76325
76925
|
}
|
|
76326
76926
|
return video;
|
|
76327
76927
|
}
|
|
@@ -77615,7 +78215,7 @@ import {
|
|
|
77615
78215
|
InternalServerError as InternalServerError68,
|
|
77616
78216
|
logger as logger161,
|
|
77617
78217
|
makeCacheKey as makeCacheKey51,
|
|
77618
|
-
NotFoundError as
|
|
78218
|
+
NotFoundError as NotFoundError71,
|
|
77619
78219
|
paginate as paginate51,
|
|
77620
78220
|
useAtlas as useAtlas110,
|
|
77621
78221
|
useCache as useCache56
|
|
@@ -77783,7 +78383,7 @@ function useEntryPassSettingsRepo() {
|
|
|
77783
78383
|
}
|
|
77784
78384
|
]).toArray();
|
|
77785
78385
|
if (!data || !data.length) {
|
|
77786
|
-
throw new
|
|
78386
|
+
throw new NotFoundError71("Entry Pass Settings not found.");
|
|
77787
78387
|
}
|
|
77788
78388
|
setCache(cacheKey, data[0], 15 * 60).then(() => {
|
|
77789
78389
|
logger161.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -77919,7 +78519,7 @@ function useEntryPassSettingsRepo() {
|
|
|
77919
78519
|
}
|
|
77920
78520
|
]).toArray();
|
|
77921
78521
|
if (!data || !data.length) {
|
|
77922
|
-
throw new
|
|
78522
|
+
throw new NotFoundError71("Entry Pass Settings not found.");
|
|
77923
78523
|
}
|
|
77924
78524
|
setCache(cacheKey, data[0], 15 * 60).then(() => {
|
|
77925
78525
|
logger161.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -78728,7 +79328,7 @@ function useNfcPatrolRouteService() {
|
|
|
78728
79328
|
import {
|
|
78729
79329
|
BadRequestError as BadRequestError200,
|
|
78730
79330
|
logger as logger168,
|
|
78731
|
-
NotFoundError as
|
|
79331
|
+
NotFoundError as NotFoundError73
|
|
78732
79332
|
} from "@7365admin1/node-server-utils";
|
|
78733
79333
|
import Joi120 from "joi";
|
|
78734
79334
|
function useNfcPatrolRouteController() {
|
|
@@ -78820,7 +79420,7 @@ function useNfcPatrolRouteController() {
|
|
|
78820
79420
|
const nfcPatrolRoute = await _getById(value?.id, value?.isStart);
|
|
78821
79421
|
await requireSiteReachIfSignedIn(req, nfcPatrolRoute?.site);
|
|
78822
79422
|
if (!nfcPatrolRoute) {
|
|
78823
|
-
throw new
|
|
79423
|
+
throw new NotFoundError73("NFC Patrol Route not found.");
|
|
78824
79424
|
}
|
|
78825
79425
|
res.json({
|
|
78826
79426
|
message: "Successfully retrieved nfc patrol route.",
|
|
@@ -79218,7 +79818,7 @@ function MIncidentReport(value) {
|
|
|
79218
79818
|
import {
|
|
79219
79819
|
useAtlas as useAtlas115,
|
|
79220
79820
|
BadRequestError as BadRequestError202,
|
|
79221
|
-
NotFoundError as
|
|
79821
|
+
NotFoundError as NotFoundError75
|
|
79222
79822
|
} from "@7365admin1/node-server-utils";
|
|
79223
79823
|
|
|
79224
79824
|
// src/repositories/incident-report.repo.ts
|
|
@@ -79227,7 +79827,7 @@ import {
|
|
|
79227
79827
|
InternalServerError as InternalServerError71,
|
|
79228
79828
|
logger as logger169,
|
|
79229
79829
|
makeCacheKey as makeCacheKey54,
|
|
79230
|
-
NotFoundError as
|
|
79830
|
+
NotFoundError as NotFoundError74,
|
|
79231
79831
|
paginate as paginate53,
|
|
79232
79832
|
useAtlas as useAtlas114,
|
|
79233
79833
|
useCache as useCache59
|
|
@@ -79485,7 +80085,7 @@ function useIncidentReportRepo() {
|
|
|
79485
80085
|
{ session }
|
|
79486
80086
|
);
|
|
79487
80087
|
if (!data) {
|
|
79488
|
-
throw new
|
|
80088
|
+
throw new NotFoundError74("Incident report not found.");
|
|
79489
80089
|
}
|
|
79490
80090
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
79491
80091
|
logger169.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -79768,7 +80368,7 @@ function useIncidentReportService() {
|
|
|
79768
80368
|
session
|
|
79769
80369
|
);
|
|
79770
80370
|
if (!file) {
|
|
79771
|
-
throw new
|
|
80371
|
+
throw new NotFoundError75("File not found.");
|
|
79772
80372
|
}
|
|
79773
80373
|
}
|
|
79774
80374
|
}
|
|
@@ -80251,7 +80851,7 @@ import {
|
|
|
80251
80851
|
InternalServerError as InternalServerError72,
|
|
80252
80852
|
logger as logger172,
|
|
80253
80853
|
makeCacheKey as makeCacheKey55,
|
|
80254
|
-
NotFoundError as
|
|
80854
|
+
NotFoundError as NotFoundError76,
|
|
80255
80855
|
useAtlas as useAtlas116,
|
|
80256
80856
|
useCache as useCache60
|
|
80257
80857
|
} from "@7365admin1/node-server-utils";
|
|
@@ -80341,7 +80941,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
80341
80941
|
{ session }
|
|
80342
80942
|
);
|
|
80343
80943
|
if (res.matchedCount === 0) {
|
|
80344
|
-
throw new
|
|
80944
|
+
throw new NotFoundError76("NFC patrol settings not found for this site.");
|
|
80345
80945
|
}
|
|
80346
80946
|
delNamespace().then(() => {
|
|
80347
80947
|
logger172.info(`Cache cleared for namespace: ${namespace_collection3}`);
|
|
@@ -80508,7 +81108,7 @@ import {
|
|
|
80508
81108
|
InternalServerError as InternalServerError73,
|
|
80509
81109
|
logger as logger175,
|
|
80510
81110
|
makeCacheKey as makeCacheKey56,
|
|
80511
|
-
NotFoundError as
|
|
81111
|
+
NotFoundError as NotFoundError77,
|
|
80512
81112
|
paginate as paginate54,
|
|
80513
81113
|
useAtlas as useAtlas118,
|
|
80514
81114
|
useCache as useCache61
|
|
@@ -80736,7 +81336,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
80736
81336
|
try {
|
|
80737
81337
|
const data = await collection.findOne({ _id }, { session });
|
|
80738
81338
|
if (!data) {
|
|
80739
|
-
throw new
|
|
81339
|
+
throw new NotFoundError77("Occurrence subject not found.");
|
|
80740
81340
|
}
|
|
80741
81341
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
80742
81342
|
logger175.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -81217,7 +81817,7 @@ import {
|
|
|
81217
81817
|
InternalServerError as InternalServerError74,
|
|
81218
81818
|
logger as logger177,
|
|
81219
81819
|
makeCacheKey as makeCacheKey57,
|
|
81220
|
-
NotFoundError as
|
|
81820
|
+
NotFoundError as NotFoundError78,
|
|
81221
81821
|
paginate as paginate55,
|
|
81222
81822
|
useAtlas as useAtlas120,
|
|
81223
81823
|
useCache as useCache62
|
|
@@ -81363,7 +81963,7 @@ function useOnlineFormRepo() {
|
|
|
81363
81963
|
}
|
|
81364
81964
|
]).toArray();
|
|
81365
81965
|
if (!data || !data.length) {
|
|
81366
|
-
throw new
|
|
81966
|
+
throw new NotFoundError78("Document not found.");
|
|
81367
81967
|
}
|
|
81368
81968
|
setCache(cacheKey, data[0], 15 * 60).then(() => {
|
|
81369
81969
|
logger177.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -81507,7 +82107,7 @@ function useOnlineFormRepo() {
|
|
|
81507
82107
|
// src/controllers/online-form.controller.ts
|
|
81508
82108
|
import {
|
|
81509
82109
|
BadRequestError as BadRequestError211,
|
|
81510
|
-
NotFoundError as
|
|
82110
|
+
NotFoundError as NotFoundError79,
|
|
81511
82111
|
UnauthorizedError as UnauthorizedError23,
|
|
81512
82112
|
logger as logger178
|
|
81513
82113
|
} from "@7365admin1/node-server-utils";
|
|
@@ -81525,7 +82125,7 @@ function useOnlineFormController() {
|
|
|
81525
82125
|
const form = await _getOnlineFormById(id);
|
|
81526
82126
|
const { canReach } = await siteReachOf(req);
|
|
81527
82127
|
if (!await canReach(form)) {
|
|
81528
|
-
throw new
|
|
82128
|
+
throw new NotFoundError79("Document not found.");
|
|
81529
82129
|
}
|
|
81530
82130
|
return form;
|
|
81531
82131
|
}
|
|
@@ -82104,7 +82704,7 @@ function useNfcPatrolLogRepo() {
|
|
|
82104
82704
|
// src/services/nfc-patrol-log.service.ts
|
|
82105
82705
|
import {
|
|
82106
82706
|
BadRequestError as BadRequestError214,
|
|
82107
|
-
NotFoundError as
|
|
82707
|
+
NotFoundError as NotFoundError81,
|
|
82108
82708
|
useAtlas as useAtlas123
|
|
82109
82709
|
} from "@7365admin1/node-server-utils";
|
|
82110
82710
|
function useNfcPatrolLogService() {
|
|
@@ -82261,7 +82861,7 @@ function useNfcPatrolLogService() {
|
|
|
82261
82861
|
async function sign(id, value) {
|
|
82262
82862
|
const log = await getById(id);
|
|
82263
82863
|
if (!log) {
|
|
82264
|
-
throw new
|
|
82864
|
+
throw new NotFoundError81("Patrol log not found.");
|
|
82265
82865
|
}
|
|
82266
82866
|
const canSign = log.checkPoints.every(
|
|
82267
82867
|
(c) => c.status === "Completed" || c.status === "Skipped"
|
|
@@ -85492,7 +86092,7 @@ function useManpowerDesignationRepo() {
|
|
|
85492
86092
|
// src/controllers/manpower-designations.controller.ts
|
|
85493
86093
|
import {
|
|
85494
86094
|
BadRequestError as BadRequestError223,
|
|
85495
|
-
NotFoundError as
|
|
86095
|
+
NotFoundError as NotFoundError84,
|
|
85496
86096
|
logger as logger189
|
|
85497
86097
|
} from "@7365admin1/node-server-utils";
|
|
85498
86098
|
import Joi136 from "joi";
|
|
@@ -85507,7 +86107,7 @@ function useManpowerDesignationCtrl() {
|
|
|
85507
86107
|
const row = await _getManpowerDesignationsById(_id);
|
|
85508
86108
|
const { canReach } = await siteReachOf(req);
|
|
85509
86109
|
if (!row || !await canReach({ site: row.siteId })) {
|
|
85510
|
-
throw new
|
|
86110
|
+
throw new NotFoundError84("Manpower designations not found.");
|
|
85511
86111
|
}
|
|
85512
86112
|
return row;
|
|
85513
86113
|
}
|
|
@@ -85521,7 +86121,7 @@ function useManpowerDesignationCtrl() {
|
|
|
85521
86121
|
}
|
|
85522
86122
|
const { actor, canReach } = await siteReachOf(req);
|
|
85523
86123
|
if (!await canReach({ site: payload.siteId })) {
|
|
85524
|
-
throw new
|
|
86124
|
+
throw new NotFoundError84("Site not found.");
|
|
85525
86125
|
}
|
|
85526
86126
|
payload.createdBy = actor.id;
|
|
85527
86127
|
payload.createdByName = actor.name;
|
|
@@ -88259,7 +88859,7 @@ import {
|
|
|
88259
88859
|
useAtlas as useAtlas136,
|
|
88260
88860
|
logger as logger204,
|
|
88261
88861
|
BadRequestError as BadRequestError234,
|
|
88262
|
-
NotFoundError as
|
|
88862
|
+
NotFoundError as NotFoundError85,
|
|
88263
88863
|
AppError as AppError37,
|
|
88264
88864
|
paginate as paginate66
|
|
88265
88865
|
} from "@7365admin1/node-server-utils";
|
|
@@ -88317,7 +88917,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
88317
88917
|
{ session }
|
|
88318
88918
|
);
|
|
88319
88919
|
if (!payment) {
|
|
88320
|
-
throw new
|
|
88920
|
+
throw new NotFoundError85("Payment not found.");
|
|
88321
88921
|
}
|
|
88322
88922
|
return payment;
|
|
88323
88923
|
} catch (error) {
|
|
@@ -88649,7 +89249,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
88649
89249
|
{ session }
|
|
88650
89250
|
);
|
|
88651
89251
|
if (res.matchedCount === 0) {
|
|
88652
|
-
throw new
|
|
89252
|
+
throw new NotFoundError85(
|
|
88653
89253
|
"Payment not found or is no longer pending."
|
|
88654
89254
|
);
|
|
88655
89255
|
}
|
|
@@ -88980,7 +89580,7 @@ import {
|
|
|
88980
89580
|
logger as logger207,
|
|
88981
89581
|
getDirectory as getDirectory7,
|
|
88982
89582
|
BadRequestError as BadRequestError238,
|
|
88983
|
-
NotFoundError as
|
|
89583
|
+
NotFoundError as NotFoundError88,
|
|
88984
89584
|
InternalServerError as InternalServerError87,
|
|
88985
89585
|
UnauthorizedError as UnauthorizedError24,
|
|
88986
89586
|
useAtlas as useAtlas140,
|
|
@@ -88994,7 +89594,7 @@ import {
|
|
|
88994
89594
|
BadRequestError as BadRequestError237,
|
|
88995
89595
|
comparePassword as comparePassword3,
|
|
88996
89596
|
InternalServerError as InternalServerError86,
|
|
88997
|
-
NotFoundError as
|
|
89597
|
+
NotFoundError as NotFoundError87,
|
|
88998
89598
|
useAtlas as useAtlas139,
|
|
88999
89599
|
useCache as useCache73
|
|
89000
89600
|
} from "@7365admin1/node-server-utils";
|
|
@@ -89008,7 +89608,7 @@ import {
|
|
|
89008
89608
|
logger as logger206,
|
|
89009
89609
|
BadRequestError as BadRequestError236,
|
|
89010
89610
|
paginate as paginate67,
|
|
89011
|
-
NotFoundError as
|
|
89611
|
+
NotFoundError as NotFoundError86,
|
|
89012
89612
|
AppError as AppError38,
|
|
89013
89613
|
useCache as useCache72,
|
|
89014
89614
|
makeCacheKey as makeCacheKey65,
|
|
@@ -89141,7 +89741,7 @@ function useUserRepoV2() {
|
|
|
89141
89741
|
]).toArray();
|
|
89142
89742
|
const data = results.length > 0 ? results[0] : null;
|
|
89143
89743
|
if (!data)
|
|
89144
|
-
throw new
|
|
89744
|
+
throw new NotFoundError86("User not found.");
|
|
89145
89745
|
setCache(cacheKey, data, 15 * 60).then(() => logger206.info(`Cache set for key: ${cacheKey}`)).catch(
|
|
89146
89746
|
(err) => logger206.error(`Failed to set cache for key: ${cacheKey}`, err)
|
|
89147
89747
|
);
|
|
@@ -89507,7 +90107,7 @@ function useAuthServiceV2() {
|
|
|
89507
90107
|
try {
|
|
89508
90108
|
const user = await getUserByEmail(email);
|
|
89509
90109
|
if (!user) {
|
|
89510
|
-
throw new
|
|
90110
|
+
throw new NotFoundError87(
|
|
89511
90111
|
"Invalid user email. Please check your email and try again."
|
|
89512
90112
|
);
|
|
89513
90113
|
}
|
|
@@ -89770,7 +90370,7 @@ function useVerificationServiceV2() {
|
|
|
89770
90370
|
session?.startTransaction();
|
|
89771
90371
|
const item = await _getByVerificationCode(verificationCode);
|
|
89772
90372
|
if (!item) {
|
|
89773
|
-
throw new
|
|
90373
|
+
throw new NotFoundError88("Verification not found.");
|
|
89774
90374
|
}
|
|
89775
90375
|
switch (item.status) {
|
|
89776
90376
|
case "expired" /* EXPIRED */:
|
|
@@ -90032,7 +90632,7 @@ function useVerificationServiceV2() {
|
|
|
90032
90632
|
async function resendSignUpVerification(email) {
|
|
90033
90633
|
const item = await _getPendingVerificationByEmail(email);
|
|
90034
90634
|
if (!item) {
|
|
90035
|
-
throw new
|
|
90635
|
+
throw new NotFoundError88(
|
|
90036
90636
|
"Pending verification not found."
|
|
90037
90637
|
);
|
|
90038
90638
|
}
|
|
@@ -90088,7 +90688,7 @@ function useVerificationServiceV2() {
|
|
|
90088
90688
|
}
|
|
90089
90689
|
async function assertInviteOpen(invite) {
|
|
90090
90690
|
if (!invite) {
|
|
90091
|
-
throw new
|
|
90691
|
+
throw new NotFoundError88("Invitation not found.");
|
|
90092
90692
|
}
|
|
90093
90693
|
if (invite.type !== "user-invite" /* USER_INVITE */ && invite.type !== "member-invite" /* MEMBER_INVITE */) {
|
|
90094
90694
|
throw new BadRequestError238("This link is not a user invitation.");
|
|
@@ -90256,7 +90856,7 @@ function useVerificationServiceV2() {
|
|
|
90256
90856
|
const email = await callerEmail(userId);
|
|
90257
90857
|
const invite = await _getVerificationByIdFresh(inviteId);
|
|
90258
90858
|
if (!invite) {
|
|
90259
|
-
throw new
|
|
90859
|
+
throw new NotFoundError88("Invitation not found.");
|
|
90260
90860
|
}
|
|
90261
90861
|
if (invite.email.toLowerCase() !== email.toLowerCase()) {
|
|
90262
90862
|
throw new UnauthorizedError24("Not authorized.");
|
|
@@ -91020,7 +91620,7 @@ import {
|
|
|
91020
91620
|
comparePassword as comparePassword4,
|
|
91021
91621
|
hashPassword as hashPassword5,
|
|
91022
91622
|
InternalServerError as InternalServerError88,
|
|
91023
|
-
NotFoundError as
|
|
91623
|
+
NotFoundError as NotFoundError89,
|
|
91024
91624
|
useAtlas as useAtlas141,
|
|
91025
91625
|
useS3 as useS33
|
|
91026
91626
|
} from "@7365admin1/node-server-utils";
|
|
@@ -91124,14 +91724,14 @@ function useUserServiceV2() {
|
|
|
91124
91724
|
try {
|
|
91125
91725
|
const otpDoc = await _getVerificationById(id);
|
|
91126
91726
|
if (!otpDoc) {
|
|
91127
|
-
throw new
|
|
91727
|
+
throw new NotFoundError89("You are using an invalid reset link.");
|
|
91128
91728
|
}
|
|
91129
91729
|
if (otpDoc.status === "complete" /* COMPLETE */) {
|
|
91130
91730
|
throw new BadRequestError241("This link has already been invalidated.");
|
|
91131
91731
|
}
|
|
91132
91732
|
const user = await _getUserByEmail(otpDoc.email);
|
|
91133
91733
|
if (!user) {
|
|
91134
|
-
throw new
|
|
91734
|
+
throw new NotFoundError89("User not found.");
|
|
91135
91735
|
}
|
|
91136
91736
|
if (!user._id) {
|
|
91137
91737
|
throw new InternalServerError88("Invalid user ID.");
|
|
@@ -92002,7 +92602,7 @@ function MPost(value) {
|
|
|
92002
92602
|
import {
|
|
92003
92603
|
BadRequestError as BadRequestError247,
|
|
92004
92604
|
InternalServerError as InternalServerError90,
|
|
92005
|
-
NotFoundError as
|
|
92605
|
+
NotFoundError as NotFoundError90,
|
|
92006
92606
|
paginate as paginate68,
|
|
92007
92607
|
useAtlas as useAtlas143
|
|
92008
92608
|
} from "@7365admin1/node-server-utils";
|
|
@@ -92225,7 +92825,7 @@ function usePostPrelovedRepo() {
|
|
|
92225
92825
|
]).toArray();
|
|
92226
92826
|
const data = result[0] ?? null;
|
|
92227
92827
|
if (!data)
|
|
92228
|
-
throw new
|
|
92828
|
+
throw new NotFoundError90("Post not found.");
|
|
92229
92829
|
return data;
|
|
92230
92830
|
} catch (error) {
|
|
92231
92831
|
throw error;
|
|
@@ -92535,7 +93135,7 @@ import { useAtlas as useAtlas145 } from "@7365admin1/node-server-utils";
|
|
|
92535
93135
|
import {
|
|
92536
93136
|
BadRequestError as BadRequestError248,
|
|
92537
93137
|
InternalServerError as InternalServerError91,
|
|
92538
|
-
NotFoundError as
|
|
93138
|
+
NotFoundError as NotFoundError91,
|
|
92539
93139
|
useAtlas as useAtlas144
|
|
92540
93140
|
} from "@7365admin1/node-server-utils";
|
|
92541
93141
|
import { ObjectId as ObjectId179 } from "mongodb";
|
|
@@ -92631,7 +93231,7 @@ function usePostFavoriteRepo() {
|
|
|
92631
93231
|
}
|
|
92632
93232
|
const result = await collection.findOne({ _id });
|
|
92633
93233
|
if (!result)
|
|
92634
|
-
throw new
|
|
93234
|
+
throw new NotFoundError91("Favorite not found.");
|
|
92635
93235
|
return result;
|
|
92636
93236
|
}
|
|
92637
93237
|
async function getByPostId(postId) {
|
|
@@ -92642,7 +93242,7 @@ function usePostFavoriteRepo() {
|
|
|
92642
93242
|
}
|
|
92643
93243
|
const result = await collection.findOne({ postId });
|
|
92644
93244
|
if (!result)
|
|
92645
|
-
throw new
|
|
93245
|
+
throw new NotFoundError91("Favorite not found.");
|
|
92646
93246
|
return result;
|
|
92647
93247
|
}
|
|
92648
93248
|
async function updateById(_id, userId, session) {
|
|
@@ -93154,7 +93754,7 @@ function MCategoryPreloved(value) {
|
|
|
93154
93754
|
import {
|
|
93155
93755
|
BadRequestError as BadRequestError251,
|
|
93156
93756
|
InternalServerError as InternalServerError92,
|
|
93157
|
-
NotFoundError as
|
|
93757
|
+
NotFoundError as NotFoundError92,
|
|
93158
93758
|
useAtlas as useAtlas147
|
|
93159
93759
|
} from "@7365admin1/node-server-utils";
|
|
93160
93760
|
import { ObjectId as ObjectId182 } from "mongodb";
|
|
@@ -93197,7 +93797,7 @@ function useCategoryPrelovedRepo() {
|
|
|
93197
93797
|
try {
|
|
93198
93798
|
const data = await collection.findOne({ _id: objectId2 });
|
|
93199
93799
|
if (!data) {
|
|
93200
|
-
throw new
|
|
93800
|
+
throw new NotFoundError92("Category not found.");
|
|
93201
93801
|
}
|
|
93202
93802
|
return data;
|
|
93203
93803
|
} catch (error) {
|
|
@@ -93226,7 +93826,7 @@ function useCategoryPrelovedRepo() {
|
|
|
93226
93826
|
}
|
|
93227
93827
|
const existing = await collection.findOne({ _id: objectId2 });
|
|
93228
93828
|
if (!existing)
|
|
93229
|
-
throw new
|
|
93829
|
+
throw new NotFoundError92("Category not found.");
|
|
93230
93830
|
const res = await collection.updateOne(
|
|
93231
93831
|
{ _id: objectId2 },
|
|
93232
93832
|
{ $set: { ...value, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } }
|
|
@@ -93244,7 +93844,7 @@ function useCategoryPrelovedRepo() {
|
|
|
93244
93844
|
}
|
|
93245
93845
|
const existing = await collection.findOne({ _id: objectId2 });
|
|
93246
93846
|
if (!existing)
|
|
93247
|
-
throw new
|
|
93847
|
+
throw new NotFoundError92("Category not found.");
|
|
93248
93848
|
const res = await collection.deleteOne({ _id: objectId2 });
|
|
93249
93849
|
if (res.deletedCount === 0)
|
|
93250
93850
|
throw new InternalServerError92("Unable to delete category.");
|
|
@@ -93411,7 +94011,7 @@ function MSubcategoryPreloved(value) {
|
|
|
93411
94011
|
import {
|
|
93412
94012
|
BadRequestError as BadRequestError253,
|
|
93413
94013
|
InternalServerError as InternalServerError93,
|
|
93414
|
-
NotFoundError as
|
|
94014
|
+
NotFoundError as NotFoundError93,
|
|
93415
94015
|
useAtlas as useAtlas148
|
|
93416
94016
|
} from "@7365admin1/node-server-utils";
|
|
93417
94017
|
import { ObjectId as ObjectId184 } from "mongodb";
|
|
@@ -93462,7 +94062,7 @@ function useSubcategoryPrelovedRepo() {
|
|
|
93462
94062
|
try {
|
|
93463
94063
|
const data = await collection.findOne({ _id: objectId2 });
|
|
93464
94064
|
if (!data) {
|
|
93465
|
-
throw new
|
|
94065
|
+
throw new NotFoundError93("Subcategory not found.");
|
|
93466
94066
|
}
|
|
93467
94067
|
return data;
|
|
93468
94068
|
} catch (error) {
|
|
@@ -93737,7 +94337,7 @@ function MChatPreloved(value) {
|
|
|
93737
94337
|
import {
|
|
93738
94338
|
BadRequestError as BadRequestError255,
|
|
93739
94339
|
InternalServerError as InternalServerError94,
|
|
93740
|
-
NotFoundError as
|
|
94340
|
+
NotFoundError as NotFoundError94,
|
|
93741
94341
|
useAtlas as useAtlas149
|
|
93742
94342
|
} from "@7365admin1/node-server-utils";
|
|
93743
94343
|
import { ObjectId as ObjectId186 } from "mongodb";
|
|
@@ -93777,7 +94377,7 @@ function useChatPrelovedRepo() {
|
|
|
93777
94377
|
}
|
|
93778
94378
|
const existing = await collection.findOne({ _id: objectId2 });
|
|
93779
94379
|
if (!existing)
|
|
93780
|
-
throw new
|
|
94380
|
+
throw new NotFoundError94("Chat not found.");
|
|
93781
94381
|
value.edited = true;
|
|
93782
94382
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
93783
94383
|
const res = await collection.updateOne({ _id: objectId2 }, { $set: value });
|
|
@@ -93794,7 +94394,7 @@ function useChatPrelovedRepo() {
|
|
|
93794
94394
|
}
|
|
93795
94395
|
const existing = await collection.findOne({ _id: objectId2 });
|
|
93796
94396
|
if (!existing)
|
|
93797
|
-
throw new
|
|
94397
|
+
throw new NotFoundError94("Chat not found.");
|
|
93798
94398
|
const res = await collection.updateOne(
|
|
93799
94399
|
{ _id: objectId2 },
|
|
93800
94400
|
{ $set: { deletedAt: (/* @__PURE__ */ new Date()).toISOString(), updatedAt: (/* @__PURE__ */ new Date()).toISOString() } }
|
|
@@ -94527,7 +95127,7 @@ function useChannelPrelovedController() {
|
|
|
94527
95127
|
// src/repositories/bid-preloved.repo.ts
|
|
94528
95128
|
import {
|
|
94529
95129
|
InternalServerError as InternalServerError98,
|
|
94530
|
-
NotFoundError as
|
|
95130
|
+
NotFoundError as NotFoundError95,
|
|
94531
95131
|
useAtlas as useAtlas153
|
|
94532
95132
|
} from "@7365admin1/node-server-utils";
|
|
94533
95133
|
import { ObjectId as ObjectId190 } from "mongodb";
|
|
@@ -94549,7 +95149,7 @@ function useBidPrelovedRepo() {
|
|
|
94549
95149
|
const objectId2 = typeof _id === "string" ? new ObjectId190(_id) : _id;
|
|
94550
95150
|
const existing = await collection.findOne({ _id: objectId2 });
|
|
94551
95151
|
if (!existing)
|
|
94552
|
-
throw new
|
|
95152
|
+
throw new NotFoundError95("Bid not found.");
|
|
94553
95153
|
const res = await collection.updateOne(
|
|
94554
95154
|
{ _id: objectId2 },
|
|
94555
95155
|
{ $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } }
|
|
@@ -94563,7 +95163,7 @@ function useBidPrelovedRepo() {
|
|
|
94563
95163
|
_id = new ObjectId190(_id);
|
|
94564
95164
|
const result = await collection.findOne({ _id });
|
|
94565
95165
|
if (!result)
|
|
94566
|
-
throw new
|
|
95166
|
+
throw new NotFoundError95("Bid not found.");
|
|
94567
95167
|
return result;
|
|
94568
95168
|
}
|
|
94569
95169
|
return { add, getById, updateStatus };
|
|
@@ -94870,7 +95470,7 @@ var residentFormEntry = Joi168.object({
|
|
|
94870
95470
|
import {
|
|
94871
95471
|
BadRequestError as BadRequestError260,
|
|
94872
95472
|
InternalServerError as InternalServerError100,
|
|
94873
|
-
NotFoundError as
|
|
95473
|
+
NotFoundError as NotFoundError96,
|
|
94874
95474
|
paginate as paginate71,
|
|
94875
95475
|
useAtlas as useAtlas155,
|
|
94876
95476
|
useCache as useCache76
|
|
@@ -94975,7 +95575,7 @@ function useFormEntryRepo() {
|
|
|
94975
95575
|
try {
|
|
94976
95576
|
const [data] = await collection.aggregate([{ $match: query2 }]).toArray();
|
|
94977
95577
|
if (!data) {
|
|
94978
|
-
throw new
|
|
95578
|
+
throw new NotFoundError96("Document not found.");
|
|
94979
95579
|
}
|
|
94980
95580
|
return data;
|
|
94981
95581
|
} catch (error) {
|
|
@@ -94999,7 +95599,7 @@ function useFormEntryRepo() {
|
|
|
94999
95599
|
}
|
|
95000
95600
|
const onlineFormRequest = await collection.findOne({ _id });
|
|
95001
95601
|
if (!onlineFormRequest) {
|
|
95002
|
-
throw new
|
|
95602
|
+
throw new NotFoundError96("Online form not found.");
|
|
95003
95603
|
}
|
|
95004
95604
|
if (onlineFormRequest.userId) {
|
|
95005
95605
|
const user = await getUserById(onlineFormRequest.userId.toString());
|
|
@@ -95112,7 +95712,7 @@ function useFormEntryRepo() {
|
|
|
95112
95712
|
// src/controllers/online-forms-v2.controller.ts
|
|
95113
95713
|
import {
|
|
95114
95714
|
BadRequestError as BadRequestError261,
|
|
95115
|
-
NotFoundError as
|
|
95715
|
+
NotFoundError as NotFoundError97,
|
|
95116
95716
|
UnauthorizedError as UnauthorizedError27,
|
|
95117
95717
|
logger as logger224
|
|
95118
95718
|
} from "@7365admin1/node-server-utils";
|
|
@@ -95135,7 +95735,7 @@ function useFormEntryController() {
|
|
|
95135
95735
|
const owner = entry?.userId?.toString?.() ?? "";
|
|
95136
95736
|
const isOwner = Boolean(actor.id) && owner === actor.id;
|
|
95137
95737
|
if (!isOwner && !await canReach(entry)) {
|
|
95138
|
-
throw new
|
|
95738
|
+
throw new NotFoundError97("Document not found.");
|
|
95139
95739
|
}
|
|
95140
95740
|
return { entry, isOwner, actor };
|
|
95141
95741
|
}
|
|
@@ -97419,6 +98019,7 @@ export {
|
|
|
97419
98019
|
DEMO_ROUTES,
|
|
97420
98020
|
DEVICE_STATUS,
|
|
97421
98021
|
DOBStatus,
|
|
98022
|
+
DOOR_MODE,
|
|
97422
98023
|
DUPLICATE_TERMS_VERSION_MESSAGE,
|
|
97423
98024
|
DayOfWeek,
|
|
97424
98025
|
E164,
|
|
@@ -97558,6 +98159,9 @@ export {
|
|
|
97558
98159
|
NotificationModule,
|
|
97559
98160
|
NotificationService,
|
|
97560
98161
|
OFFLINE_FAULT_CODE,
|
|
98162
|
+
OPEN_RMF_BRAND,
|
|
98163
|
+
OPEN_RMF_CAPABILITIES,
|
|
98164
|
+
OPEN_RMF_DISPLAY_NAME,
|
|
97561
98165
|
ORG_MARKETPLACE_VENDOR_FIELD,
|
|
97562
98166
|
ORG_OWNER_REPAIR_CLAIM_STALE_MS,
|
|
97563
98167
|
ORG_OWNER_REPAIR_CLAIM_TAKEN_REASON,
|
|
@@ -97566,6 +98170,7 @@ export {
|
|
|
97566
98170
|
OUNITECH_BRAND,
|
|
97567
98171
|
OUNITECH_CAPABILITIES,
|
|
97568
98172
|
OUNITECH_PENDING_COMMANDS,
|
|
98173
|
+
OpenRmfError,
|
|
97569
98174
|
OrgNature,
|
|
97570
98175
|
OvernightParkingRequestSort,
|
|
97571
98176
|
OvernightParkingRequestStatus,
|
|
@@ -97662,6 +98267,7 @@ export {
|
|
|
97662
98267
|
attendanceSchema,
|
|
97663
98268
|
attendanceSettingsSchema,
|
|
97664
98269
|
buildSelfServiceEmailContext,
|
|
98270
|
+
buildingFromRmf,
|
|
97665
98271
|
buildingMapBodySchema,
|
|
97666
98272
|
buildingMapCreateSchema,
|
|
97667
98273
|
buildingMapFromRobotMaps,
|
|
@@ -97703,6 +98309,8 @@ export {
|
|
|
97703
98309
|
createDemoAdapter,
|
|
97704
98310
|
createLiftSimulator,
|
|
97705
98311
|
createManpowerRemarksDaily,
|
|
98312
|
+
createOpenRmfAdapter,
|
|
98313
|
+
createOpenRmfClient,
|
|
97706
98314
|
createOunitechAdapter,
|
|
97707
98315
|
createSseParser,
|
|
97708
98316
|
customerSchema,
|
|
@@ -97725,6 +98333,7 @@ export {
|
|
|
97725
98333
|
deviceHttpTimeoutMs,
|
|
97726
98334
|
deviceProbeTtlSeconds,
|
|
97727
98335
|
disconnectedState,
|
|
98336
|
+
doorModeOf,
|
|
97728
98337
|
emitNotificationCreated,
|
|
97729
98338
|
emptyPersonalEmergencyChain,
|
|
97730
98339
|
encodeGreyscalePng,
|
|
@@ -97741,6 +98350,7 @@ export {
|
|
|
97741
98350
|
ffmpegFrameArgs,
|
|
97742
98351
|
ffmpegPath,
|
|
97743
98352
|
filterByAccess,
|
|
98353
|
+
floorNoOf,
|
|
97744
98354
|
formatCapabilityTrace,
|
|
97745
98355
|
formatDahuaDate,
|
|
97746
98356
|
getIO,
|
|
@@ -97763,6 +98373,7 @@ export {
|
|
|
97763
98373
|
isAvailableForWork,
|
|
97764
98374
|
isCameraEntitled,
|
|
97765
98375
|
isDispatchable,
|
|
98376
|
+
isDoorPassable,
|
|
97766
98377
|
isDuplicateMemberError,
|
|
97767
98378
|
isDuplicateVersionError,
|
|
97768
98379
|
isLiftAvailable,
|
|
@@ -97817,6 +98428,9 @@ export {
|
|
|
97817
98428
|
occurrence_book_namespace_collection,
|
|
97818
98429
|
onBookTimezonesChanged,
|
|
97819
98430
|
online_forms_namespace_collection,
|
|
98431
|
+
openRmfConfig,
|
|
98432
|
+
openRmfDoorDriver,
|
|
98433
|
+
openRmfLiftDriver,
|
|
97820
98434
|
orgLevelRoles,
|
|
97821
98435
|
orgModulesHandlers,
|
|
97822
98436
|
orgOwnerRepairHandlers,
|
|
@@ -97839,6 +98453,7 @@ export {
|
|
|
97839
98453
|
planDayFromJsDay,
|
|
97840
98454
|
planDemoRobots,
|
|
97841
98455
|
planOrgOwnerRepair,
|
|
98456
|
+
planShareOf,
|
|
97842
98457
|
platform_terms_namespace_collection,
|
|
97843
98458
|
playbackRelays,
|
|
97844
98459
|
playbackWindowRefusal,
|
|
@@ -97855,6 +98470,7 @@ export {
|
|
|
97855
98470
|
refuseServiceProviderInviteAction,
|
|
97856
98471
|
registerCameraTransport,
|
|
97857
98472
|
registerDemoBrand,
|
|
98473
|
+
registerOpenRmfBrand,
|
|
97858
98474
|
registerOunitechBrand,
|
|
97859
98475
|
registerRobotBrand,
|
|
97860
98476
|
registeredRobotBrands,
|
|
@@ -98055,6 +98671,7 @@ export {
|
|
|
98055
98671
|
site_people_namespace_collection,
|
|
98056
98672
|
snapshotEndpoint,
|
|
98057
98673
|
snapshotRefusalReason,
|
|
98674
|
+
splitRobotSn,
|
|
98058
98675
|
staffMayBypass,
|
|
98059
98676
|
startDemoTracking,
|
|
98060
98677
|
startRobotTracking,
|
|
@@ -98064,6 +98681,8 @@ export {
|
|
|
98064
98681
|
subscriptionPlanSchema,
|
|
98065
98682
|
summariseBulkCameraPlan,
|
|
98066
98683
|
supports,
|
|
98684
|
+
taskRequestFor,
|
|
98685
|
+
toAdapterRobot,
|
|
98067
98686
|
trackingBackoffMs,
|
|
98068
98687
|
uncontrollableFleetWarning,
|
|
98069
98688
|
updateRemarksStatusEod,
|
|
@@ -98312,6 +98931,7 @@ export {
|
|
|
98312
98931
|
userSchema,
|
|
98313
98932
|
vehicleCategoryFor,
|
|
98314
98933
|
vehicleHistoryEntry,
|
|
98934
|
+
vehicleHistoryValue,
|
|
98315
98935
|
vehicleListViewQuery,
|
|
98316
98936
|
vehicleSchema,
|
|
98317
98937
|
vehicleViewOf,
|
|
@@ -98320,6 +98940,7 @@ export {
|
|
|
98320
98940
|
visitors_namespace_collection,
|
|
98321
98941
|
wallConfig,
|
|
98322
98942
|
wallsFromOccupancyGrid,
|
|
98943
|
+
waypointsFor,
|
|
98323
98944
|
withLiveLink,
|
|
98324
98945
|
workOrderSchema,
|
|
98325
98946
|
work_orders2_namespace_collection,
|