@7365admin1/core 3.129.0 → 3.129.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.js +92 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +343 -336
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/role-inventory-presets.e2e.test.mjs +175 -0
- package/test/e2e/role-template-restore.e2e.test.mjs +7 -7
- package/test/e2e/visitor-search.e2e.test.mjs +27 -0
- package/test/org-modules.test.mjs +21 -0
- package/test/site-modules.test.mjs +13 -0
- package/test/visitor-search.test.mjs +4 -1
package/dist/index.mjs
CHANGED
|
@@ -4869,7 +4869,7 @@ import {
|
|
|
4869
4869
|
BadRequestError as BadRequestError47,
|
|
4870
4870
|
NotFoundError as NotFoundError16,
|
|
4871
4871
|
InternalServerError as InternalServerError21,
|
|
4872
|
-
UnauthorizedError as
|
|
4872
|
+
UnauthorizedError as UnauthorizedError5,
|
|
4873
4873
|
useAtlas as useAtlas37
|
|
4874
4874
|
} from "@7365admin1/node-server-utils";
|
|
4875
4875
|
|
|
@@ -5359,7 +5359,7 @@ var ROBOT_CLOUD_TIMEOUT_MS = Number(
|
|
|
5359
5359
|
|
|
5360
5360
|
// src/repositories/organization.repo.ts
|
|
5361
5361
|
import {
|
|
5362
|
-
AppError as
|
|
5362
|
+
AppError as AppError4,
|
|
5363
5363
|
BadRequestError as BadRequestError21,
|
|
5364
5364
|
InternalServerError as InternalServerError9,
|
|
5365
5365
|
logger as logger11,
|
|
@@ -5449,10 +5449,25 @@ function boundToOwnerGrant(ceiling, next, previous) {
|
|
|
5449
5449
|
return { permissions: [...ceiling], refused: [] };
|
|
5450
5450
|
const held = new Set(previous ?? []);
|
|
5451
5451
|
const refused = list.filter(
|
|
5452
|
-
(p) => !held.has(p) && !ceiling
|
|
5452
|
+
(p) => !held.has(p) && !ceilingCovers(ceiling, p) && !ALWAYS_ALLOWED.includes(p.split(":")[0])
|
|
5453
5453
|
);
|
|
5454
5454
|
return { permissions: list, refused };
|
|
5455
5455
|
}
|
|
5456
|
+
var PERMISSION_COVERS = Object.freeze({
|
|
5457
|
+
"inventory:manage-inventory": ["inventory:*"],
|
|
5458
|
+
"inventory:request-stock": ["inventory:record-usage"],
|
|
5459
|
+
"inventory:view-inventory": ["inventory:view-reports"],
|
|
5460
|
+
"inventory:approve-requests": ["inventory:view-reports"]
|
|
5461
|
+
});
|
|
5462
|
+
function ceilingCovers(ceiling, permission) {
|
|
5463
|
+
if (ceiling.includes(permission))
|
|
5464
|
+
return true;
|
|
5465
|
+
const moduleWide = `${permission.split(":")[0]}:*`;
|
|
5466
|
+
return ceiling.some((granted) => {
|
|
5467
|
+
const covers = PERMISSION_COVERS[granted];
|
|
5468
|
+
return !!covers && (covers.includes(permission) || covers.includes(moduleWide));
|
|
5469
|
+
});
|
|
5470
|
+
}
|
|
5456
5471
|
|
|
5457
5472
|
// src/models/site.model.ts
|
|
5458
5473
|
import {
|
|
@@ -5462,7 +5477,7 @@ import {
|
|
|
5462
5477
|
import Joi9 from "joi";
|
|
5463
5478
|
|
|
5464
5479
|
// src/utils/site-modules.util.ts
|
|
5465
|
-
import {
|
|
5480
|
+
import { AppError as AppError3 } from "@7365admin1/node-server-utils";
|
|
5466
5481
|
var siteModulesSchema = modulesSchema;
|
|
5467
5482
|
function narrows(modules) {
|
|
5468
5483
|
return Array.isArray(modules) && modules.length > 0;
|
|
@@ -5507,6 +5522,9 @@ function permissionsOutsideModules2(effective, next, previous) {
|
|
|
5507
5522
|
if (!Array.isArray(next) || !next.length || next.includes("*"))
|
|
5508
5523
|
return [];
|
|
5509
5524
|
const held = new Set(Array.isArray(previous) ? previous : []);
|
|
5525
|
+
const heldModules = new Set(
|
|
5526
|
+
[...held].map((p) => typeof p === "string" ? p.split(":")[0]?.trim() : "").filter(Boolean)
|
|
5527
|
+
);
|
|
5510
5528
|
const allowed = normaliseModules(effective);
|
|
5511
5529
|
const refused = [];
|
|
5512
5530
|
for (const permission of next) {
|
|
@@ -5515,6 +5533,8 @@ function permissionsOutsideModules2(effective, next, previous) {
|
|
|
5515
5533
|
if (held.has(permission))
|
|
5516
5534
|
continue;
|
|
5517
5535
|
const resource = permission.split(":")[0]?.trim();
|
|
5536
|
+
if (resource && heldModules.has(resource))
|
|
5537
|
+
continue;
|
|
5518
5538
|
if (!resource)
|
|
5519
5539
|
continue;
|
|
5520
5540
|
if (!orgAllowsModule(allowed, resource))
|
|
@@ -5526,8 +5546,9 @@ function requireWithinModules(effective, next, previous) {
|
|
|
5526
5546
|
const refused = permissionsOutsideModules2(effective, next, previous);
|
|
5527
5547
|
if (!refused.length)
|
|
5528
5548
|
return;
|
|
5529
|
-
throw new
|
|
5530
|
-
"This site has not been given " + refused.join(", ") + ". Ask Seven365 to add the module to the organisation first."
|
|
5549
|
+
throw new AppError3(
|
|
5550
|
+
"This site has not been given " + refused.join(", ") + ". Ask Seven365 to add the module to the organisation first.",
|
|
5551
|
+
403
|
|
5531
5552
|
);
|
|
5532
5553
|
}
|
|
5533
5554
|
|
|
@@ -5930,7 +5951,7 @@ function useOrgRepo() {
|
|
|
5930
5951
|
return res.insertedId;
|
|
5931
5952
|
} catch (error) {
|
|
5932
5953
|
logger11.log({ level: "error", message: error.message });
|
|
5933
|
-
if (error instanceof
|
|
5954
|
+
if (error instanceof AppError4) {
|
|
5934
5955
|
throw error;
|
|
5935
5956
|
} else {
|
|
5936
5957
|
const isDuplicated = error.message.includes("duplicate");
|
|
@@ -5960,7 +5981,7 @@ function useOrgRepo() {
|
|
|
5960
5981
|
level: "error",
|
|
5961
5982
|
message: `Organization update failed for ${id}: ${error?.name ?? "Error"}${error?.code !== void 0 ? ` code=${error.code}` : ""}${duplicatedField(error) ? ` key=${duplicatedField(error)}` : ""} fields=[${Object.keys(value ?? {}).join(",")}] ${error?.message ?? ""}`
|
|
5962
5983
|
});
|
|
5963
|
-
if (error instanceof
|
|
5984
|
+
if (error instanceof AppError4)
|
|
5964
5985
|
throw error;
|
|
5965
5986
|
const field = duplicatedField(error);
|
|
5966
5987
|
if (field) {
|
|
@@ -6094,7 +6115,7 @@ function useOrgRepo() {
|
|
|
6094
6115
|
});
|
|
6095
6116
|
return data;
|
|
6096
6117
|
} catch (error) {
|
|
6097
|
-
if (error instanceof
|
|
6118
|
+
if (error instanceof AppError4) {
|
|
6098
6119
|
throw error;
|
|
6099
6120
|
} else {
|
|
6100
6121
|
throw new InternalServerError9("Failed to get organization.");
|
|
@@ -6120,7 +6141,7 @@ function useOrgRepo() {
|
|
|
6120
6141
|
});
|
|
6121
6142
|
return data;
|
|
6122
6143
|
} catch (error) {
|
|
6123
|
-
if (error instanceof
|
|
6144
|
+
if (error instanceof AppError4) {
|
|
6124
6145
|
throw error;
|
|
6125
6146
|
} else {
|
|
6126
6147
|
throw new InternalServerError9("Failed to get organization.");
|
|
@@ -6253,7 +6274,7 @@ function useOrgRepo() {
|
|
|
6253
6274
|
});
|
|
6254
6275
|
return "Successfully updated organization status.";
|
|
6255
6276
|
} catch (error) {
|
|
6256
|
-
if (error instanceof
|
|
6277
|
+
if (error instanceof AppError4) {
|
|
6257
6278
|
throw error;
|
|
6258
6279
|
}
|
|
6259
6280
|
throw new InternalServerError9("Failed to update organization status.");
|
|
@@ -6439,7 +6460,7 @@ function useOrgRepo() {
|
|
|
6439
6460
|
await delNamespace();
|
|
6440
6461
|
return "Successfully completed organization onboarding.";
|
|
6441
6462
|
} catch (error) {
|
|
6442
|
-
if (error instanceof
|
|
6463
|
+
if (error instanceof AppError4) {
|
|
6443
6464
|
throw error;
|
|
6444
6465
|
}
|
|
6445
6466
|
throw new InternalServerError9(
|
|
@@ -6480,7 +6501,7 @@ import {
|
|
|
6480
6501
|
useCache as useCache10,
|
|
6481
6502
|
logger as logger12,
|
|
6482
6503
|
makeCacheKey as makeCacheKey8,
|
|
6483
|
-
AppError as
|
|
6504
|
+
AppError as AppError5,
|
|
6484
6505
|
toObjectId as toObjectId3
|
|
6485
6506
|
} from "@7365admin1/node-server-utils";
|
|
6486
6507
|
import Joi11 from "joi";
|
|
@@ -6661,7 +6682,7 @@ function useSiteRepo() {
|
|
|
6661
6682
|
});
|
|
6662
6683
|
return data;
|
|
6663
6684
|
} catch (error2) {
|
|
6664
|
-
if (error2 instanceof
|
|
6685
|
+
if (error2 instanceof AppError5) {
|
|
6665
6686
|
throw error2;
|
|
6666
6687
|
}
|
|
6667
6688
|
throw new InternalServerError10("Failed to retrieve site.");
|
|
@@ -8882,7 +8903,7 @@ async function holdsRole(userId, roleId, orgId) {
|
|
|
8882
8903
|
// src/services/service-provider-invite.service.ts
|
|
8883
8904
|
import {
|
|
8884
8905
|
BadRequestError as BadRequestError46,
|
|
8885
|
-
UnauthorizedError as
|
|
8906
|
+
UnauthorizedError as UnauthorizedError4,
|
|
8886
8907
|
NotFoundError as NotFoundError15,
|
|
8887
8908
|
compileHandlebar,
|
|
8888
8909
|
getDirectory,
|
|
@@ -9092,7 +9113,7 @@ function MNotification(value) {
|
|
|
9092
9113
|
|
|
9093
9114
|
// src/repositories/notification.repo.ts
|
|
9094
9115
|
import {
|
|
9095
|
-
AppError as
|
|
9116
|
+
AppError as AppError6,
|
|
9096
9117
|
BadRequestError as BadRequestError26,
|
|
9097
9118
|
InternalServerError as InternalServerError13,
|
|
9098
9119
|
NotFoundError as NotFoundError9,
|
|
@@ -9298,7 +9319,7 @@ function useNotificationRepo() {
|
|
|
9298
9319
|
]);
|
|
9299
9320
|
return paginate11(items, page2, limit, totalCount);
|
|
9300
9321
|
} catch (error) {
|
|
9301
|
-
if (error instanceof
|
|
9322
|
+
if (error instanceof AppError6)
|
|
9302
9323
|
throw error;
|
|
9303
9324
|
logger16.log({ level: "error", message: error.message });
|
|
9304
9325
|
throw new InternalServerError13("Failed to retrieve notifications.");
|
|
@@ -9327,7 +9348,7 @@ function useNotificationRepo() {
|
|
|
9327
9348
|
}
|
|
9328
9349
|
return doc;
|
|
9329
9350
|
} catch (error) {
|
|
9330
|
-
if (error instanceof
|
|
9351
|
+
if (error instanceof AppError6)
|
|
9331
9352
|
throw error;
|
|
9332
9353
|
logger16.log({ level: "error", message: error.message });
|
|
9333
9354
|
throw new InternalServerError13("Failed to update notification.");
|
|
@@ -9350,7 +9371,7 @@ function useNotificationRepo() {
|
|
|
9350
9371
|
);
|
|
9351
9372
|
return { modifiedCount: res.modifiedCount };
|
|
9352
9373
|
} catch (error) {
|
|
9353
|
-
if (error instanceof
|
|
9374
|
+
if (error instanceof AppError6)
|
|
9354
9375
|
throw error;
|
|
9355
9376
|
logger16.log({ level: "error", message: error.message });
|
|
9356
9377
|
throw new InternalServerError13("Failed to update notifications.");
|
|
@@ -9386,7 +9407,7 @@ function useNotificationRepo() {
|
|
|
9386
9407
|
// src/repositories/notification-preference.repo.ts
|
|
9387
9408
|
import { ObjectId as ObjectId30 } from "mongodb";
|
|
9388
9409
|
import {
|
|
9389
|
-
AppError as
|
|
9410
|
+
AppError as AppError7,
|
|
9390
9411
|
BadRequestError as BadRequestError28,
|
|
9391
9412
|
InternalServerError as InternalServerError14,
|
|
9392
9413
|
logger as logger17,
|
|
@@ -9877,7 +9898,7 @@ function useNotificationPreferenceRepo() {
|
|
|
9877
9898
|
const doc = await collection().findOne({ userId: new ObjectId30(userId) });
|
|
9878
9899
|
return doc?.off ?? [];
|
|
9879
9900
|
} catch (error) {
|
|
9880
|
-
if (error instanceof
|
|
9901
|
+
if (error instanceof AppError7)
|
|
9881
9902
|
throw error;
|
|
9882
9903
|
logger17.log({ level: "error", message: error.message });
|
|
9883
9904
|
throw new InternalServerError14("Failed to retrieve notification settings.");
|
|
@@ -9905,7 +9926,7 @@ function useNotificationPreferenceRepo() {
|
|
|
9905
9926
|
);
|
|
9906
9927
|
return doc.off;
|
|
9907
9928
|
} catch (error) {
|
|
9908
|
-
if (error instanceof
|
|
9929
|
+
if (error instanceof AppError7)
|
|
9909
9930
|
throw error;
|
|
9910
9931
|
logger17.log({ level: "error", message: error.message });
|
|
9911
9932
|
throw new InternalServerError14("Failed to save notification settings.");
|
|
@@ -13912,7 +13933,7 @@ function useCustomerSiteService() {
|
|
|
13912
13933
|
// src/utils/console-authz.util.ts
|
|
13913
13934
|
import {
|
|
13914
13935
|
BadRequestError as BadRequestError45,
|
|
13915
|
-
UnauthorizedError as
|
|
13936
|
+
UnauthorizedError as UnauthorizedError3,
|
|
13916
13937
|
useAtlas as useAtlas36
|
|
13917
13938
|
} from "@7365admin1/node-server-utils";
|
|
13918
13939
|
import { ObjectId as ObjectId54 } from "mongodb";
|
|
@@ -14030,15 +14051,15 @@ function assignRoleRefusal(role, member) {
|
|
|
14030
14051
|
}
|
|
14031
14052
|
|
|
14032
14053
|
// src/utils/site-reach.util.ts
|
|
14033
|
-
import { useAtlas as useAtlas35, UnauthorizedError as
|
|
14054
|
+
import { useAtlas as useAtlas35, UnauthorizedError as UnauthorizedError2 } from "@7365admin1/node-server-utils";
|
|
14034
14055
|
import { ObjectId as ObjectId53 } from "mongodb";
|
|
14035
14056
|
|
|
14036
14057
|
// src/services/camera-view.service.ts
|
|
14037
14058
|
import {
|
|
14038
|
-
AppError as
|
|
14059
|
+
AppError as AppError11,
|
|
14039
14060
|
BadRequestError as BadRequestError44,
|
|
14040
14061
|
NotFoundError as NotFoundError14,
|
|
14041
|
-
UnauthorizedError
|
|
14062
|
+
UnauthorizedError,
|
|
14042
14063
|
logger as logger33,
|
|
14043
14064
|
useAtlas as useAtlas34,
|
|
14044
14065
|
useCache as useCache19
|
|
@@ -14049,7 +14070,7 @@ import { ObjectId as ObjectId52 } from "mongodb";
|
|
|
14049
14070
|
|
|
14050
14071
|
// src/repositories/site-camera.repo.ts
|
|
14051
14072
|
import {
|
|
14052
|
-
AppError as
|
|
14073
|
+
AppError as AppError10,
|
|
14053
14074
|
BadRequestError as BadRequestError43,
|
|
14054
14075
|
logger as logger32,
|
|
14055
14076
|
makeCacheKey as makeCacheKey15,
|
|
@@ -15078,7 +15099,8 @@ function useVisitorTransactionRepo() {
|
|
|
15078
15099
|
throw new InternalServerError18("Unable to connect to server.");
|
|
15079
15100
|
}
|
|
15080
15101
|
const collection = db2.collection(visitors_namespace_collection);
|
|
15081
|
-
|
|
15102
|
+
const searchDb = db2;
|
|
15103
|
+
async function buildSearchStages(search, siteIds) {
|
|
15082
15104
|
const text2 = normaliseVisitorSearch(search);
|
|
15083
15105
|
if (!text2)
|
|
15084
15106
|
return [];
|
|
@@ -15092,99 +15114,79 @@ function useVisitorTransactionRepo() {
|
|
|
15092
15114
|
$regex: `(^|\\s)${escape(value)}$`,
|
|
15093
15115
|
$options: "i"
|
|
15094
15116
|
});
|
|
15095
|
-
const
|
|
15096
|
-
|
|
15097
|
-
|
|
15098
|
-
|
|
15099
|
-
foreignField: "_id",
|
|
15100
|
-
pipeline: [{ $project: { _id: 0, name: 1 } }],
|
|
15101
|
-
as
|
|
15102
|
-
}
|
|
15103
|
-
});
|
|
15104
|
-
const keyNameLookup = (localField, as) => ({
|
|
15105
|
-
$lookup: {
|
|
15106
|
-
from: "keys",
|
|
15107
|
-
localField,
|
|
15108
|
-
foreignField: "_id",
|
|
15109
|
-
pipeline: [
|
|
15110
|
-
{
|
|
15111
|
-
$lookup: {
|
|
15112
|
-
from: "qr-code-templates",
|
|
15113
|
-
localField: "template",
|
|
15114
|
-
foreignField: "_id",
|
|
15115
|
-
pipeline: [{ $project: { prefixPass: 1 } }],
|
|
15116
|
-
as: "template"
|
|
15117
|
-
}
|
|
15118
|
-
},
|
|
15119
|
-
{
|
|
15120
|
-
$project: {
|
|
15121
|
-
_id: 0,
|
|
15122
|
-
prefixAndName: {
|
|
15123
|
-
$concat: [
|
|
15124
|
-
{ $ifNull: [{ $arrayElemAt: ["$template.prefixPass", 0] }, ""] },
|
|
15125
|
-
{ $ifNull: ["$name", ""] }
|
|
15126
|
-
]
|
|
15127
|
-
}
|
|
15128
|
-
}
|
|
15129
|
-
}
|
|
15130
|
-
],
|
|
15131
|
-
as
|
|
15132
|
-
}
|
|
15133
|
-
});
|
|
15134
|
-
const locationLookups = [
|
|
15135
|
-
nameLookup("buildings", "block", "_searchBlock"),
|
|
15136
|
-
nameLookup("building-levels", "level", "_searchLevel"),
|
|
15137
|
-
nameLookup("building-units", "unit", "_searchUnit")
|
|
15138
|
-
];
|
|
15139
|
-
const cleanup = {
|
|
15140
|
-
$project: {
|
|
15141
|
-
_searchBlock: 0,
|
|
15142
|
-
_searchLevel: 0,
|
|
15143
|
-
_searchUnit: 0,
|
|
15144
|
-
_searchPass: 0,
|
|
15145
|
-
_searchKeys: 0
|
|
15146
|
-
}
|
|
15147
|
-
};
|
|
15148
|
-
const unitMatch = (value, match = like) => ({
|
|
15149
|
-
$or: [{ "_searchUnit.name": match(value) }, { unitName: match(value) }]
|
|
15150
|
-
});
|
|
15117
|
+
const onSites = siteIds ? { site: { $in: siteIds } } : {};
|
|
15118
|
+
const levelOnSites = siteIds ? { $or: [{ site: { $in: siteIds } }, { site: null }, { site: "" }] } : {};
|
|
15119
|
+
const idsOf = (from, filter) => searchDb.collection(from).distinct("_id", filter);
|
|
15120
|
+
const inIds = (field, ids2) => ids2.length ? [{ [field]: { $in: ids2 } }] : [];
|
|
15151
15121
|
const parts = text2.split("/").map((part) => part.trim());
|
|
15152
15122
|
if (parts.length >= 2 && parts.length <= 3 && parts.every(Boolean)) {
|
|
15153
15123
|
const [block, level2, unit] = parts;
|
|
15124
|
+
const [blockIds2, levelIds2, unitIds2] = await Promise.all([
|
|
15125
|
+
idsOf("buildings", { ...onSites, name: blockName(block) }),
|
|
15126
|
+
idsOf("building-levels", { ...levelOnSites, name: exact(level2) }),
|
|
15127
|
+
unit ? idsOf("building-units", { ...onSites, name: exact(unit) }) : []
|
|
15128
|
+
]);
|
|
15154
15129
|
return [
|
|
15155
|
-
...locationLookups,
|
|
15156
15130
|
{
|
|
15157
15131
|
$match: {
|
|
15158
|
-
|
|
15159
|
-
|
|
15160
|
-
...unit &&
|
|
15132
|
+
block: { $in: blockIds2 },
|
|
15133
|
+
level: { $in: levelIds2 },
|
|
15134
|
+
...unit && {
|
|
15135
|
+
$or: [...inIds("unit", unitIds2), { unitName: exact(unit) }]
|
|
15136
|
+
}
|
|
15161
15137
|
}
|
|
15162
|
-
}
|
|
15163
|
-
cleanup
|
|
15138
|
+
}
|
|
15164
15139
|
];
|
|
15165
15140
|
}
|
|
15166
15141
|
const compact = text2.replace(/\s+/g, "");
|
|
15142
|
+
const [blockIds, levelIds, unitIds, keyIds] = await Promise.all([
|
|
15143
|
+
idsOf("buildings", { ...onSites, name: like(text2) }),
|
|
15144
|
+
idsOf("building-levels", { ...levelOnSites, name: like(text2) }),
|
|
15145
|
+
idsOf("building-units", { ...onSites, name: like(text2) }),
|
|
15146
|
+
compact ? matchingKeyIds(compact) : []
|
|
15147
|
+
]);
|
|
15167
15148
|
return [
|
|
15168
|
-
...locationLookups,
|
|
15169
|
-
keyNameLookup("visitorPass.keyId", "_searchPass"),
|
|
15170
|
-
keyNameLookup("passKeys.keyId", "_searchKeys"),
|
|
15171
15149
|
{
|
|
15172
15150
|
$match: {
|
|
15173
15151
|
$or: [
|
|
15174
15152
|
// name, company, purpose, NRIC, types, members; plates ignoring
|
|
15175
15153
|
// spaces/hyphens/case; phones by digits - visitor-search.util.
|
|
15176
15154
|
...visitorRowSearchOr(text2),
|
|
15177
|
-
|
|
15178
|
-
|
|
15179
|
-
|
|
15180
|
-
{
|
|
15181
|
-
|
|
15155
|
+
...inIds("block", blockIds),
|
|
15156
|
+
...inIds("level", levelIds),
|
|
15157
|
+
...inIds("unit", unitIds),
|
|
15158
|
+
{ unitName: like(text2) },
|
|
15159
|
+
...inIds("visitorPass.keyId", keyIds),
|
|
15160
|
+
...inIds("passKeys.keyId", keyIds)
|
|
15182
15161
|
]
|
|
15183
15162
|
}
|
|
15184
|
-
}
|
|
15185
|
-
cleanup
|
|
15163
|
+
}
|
|
15186
15164
|
];
|
|
15187
15165
|
}
|
|
15166
|
+
async function matchingKeyIds(compact) {
|
|
15167
|
+
const t = compact.toLowerCase();
|
|
15168
|
+
const templates = await searchDb.collection("qr-code-templates").find({ prefixPass: { $nin: [null, ""] } }, { projection: { prefixPass: 1 } }).toArray();
|
|
15169
|
+
const or = [
|
|
15170
|
+
{ name: { $regex: escapeRegex2(compact), $options: "i" } }
|
|
15171
|
+
];
|
|
15172
|
+
for (const tpl of templates) {
|
|
15173
|
+
const prefix = String(tpl.prefixPass).toLowerCase();
|
|
15174
|
+
const template = { $in: [tpl._id, String(tpl._id)] };
|
|
15175
|
+
if (prefix.includes(t)) {
|
|
15176
|
+
or.push({ template });
|
|
15177
|
+
continue;
|
|
15178
|
+
}
|
|
15179
|
+
for (let i = 1; i < t.length; i++) {
|
|
15180
|
+
if (prefix.endsWith(t.slice(0, i))) {
|
|
15181
|
+
or.push({
|
|
15182
|
+
template,
|
|
15183
|
+
name: { $regex: `^${escapeRegex2(compact.slice(i))}`, $options: "i" }
|
|
15184
|
+
});
|
|
15185
|
+
}
|
|
15186
|
+
}
|
|
15187
|
+
}
|
|
15188
|
+
return await searchDb.collection("keys").distinct("_id", { $or: or });
|
|
15189
|
+
}
|
|
15188
15190
|
async function createTextIndex() {
|
|
15189
15191
|
try {
|
|
15190
15192
|
await collection.createIndex({
|
|
@@ -15287,10 +15289,11 @@ function useVisitorTransactionRepo() {
|
|
|
15287
15289
|
...passOrKey?.type == "key" && { passKeys: { $elemMatch: { keyId: new ObjectId46(passOrKey.keyId) } } }
|
|
15288
15290
|
};
|
|
15289
15291
|
const finalSort = Object.keys(sort).length > 0 ? sort : { latestDate: -1 };
|
|
15292
|
+
const searchSiteIds = query2.site instanceof ObjectId46 ? [query2.site] : query2.site?.$in ?? null;
|
|
15290
15293
|
try {
|
|
15291
15294
|
const basePipeline = [
|
|
15292
15295
|
{ $match: query2 },
|
|
15293
|
-
...buildSearchStages(search),
|
|
15296
|
+
...await buildSearchStages(search, searchSiteIds),
|
|
15294
15297
|
{
|
|
15295
15298
|
$addFields: {
|
|
15296
15299
|
latestDate: { $max: ["$createdAt", "$updatedAt"] }
|
|
@@ -16180,7 +16183,7 @@ function useVisitorTransactionRepo() {
|
|
|
16180
16183
|
|
|
16181
16184
|
// src/repositories/vehicle.repo.ts
|
|
16182
16185
|
import {
|
|
16183
|
-
AppError as
|
|
16186
|
+
AppError as AppError8,
|
|
16184
16187
|
BadRequestError as BadRequestError40,
|
|
16185
16188
|
InternalServerError as InternalServerError19,
|
|
16186
16189
|
logger as logger29,
|
|
@@ -16601,7 +16604,7 @@ function useVehicleRepo() {
|
|
|
16601
16604
|
level: "error",
|
|
16602
16605
|
message: error.message
|
|
16603
16606
|
});
|
|
16604
|
-
if (error instanceof
|
|
16607
|
+
if (error instanceof AppError8) {
|
|
16605
16608
|
throw error;
|
|
16606
16609
|
} else {
|
|
16607
16610
|
throw new Error("Failed to create vehicle.");
|
|
@@ -17583,7 +17586,7 @@ function useVehicleRepo() {
|
|
|
17583
17586
|
level: "error",
|
|
17584
17587
|
message: error.message
|
|
17585
17588
|
});
|
|
17586
|
-
if (error instanceof
|
|
17589
|
+
if (error instanceof AppError8) {
|
|
17587
17590
|
throw error;
|
|
17588
17591
|
}
|
|
17589
17592
|
throw new Error("Failed to bulk upsert vehicles.");
|
|
@@ -17749,7 +17752,7 @@ import {
|
|
|
17749
17752
|
makeCacheKey as makeCacheKey14,
|
|
17750
17753
|
useAtlas as useAtlas30,
|
|
17751
17754
|
useCache as useCache17,
|
|
17752
|
-
AppError as
|
|
17755
|
+
AppError as AppError9
|
|
17753
17756
|
} from "@7365admin1/node-server-utils";
|
|
17754
17757
|
|
|
17755
17758
|
// src/models/file.model.ts
|
|
@@ -17902,7 +17905,7 @@ function useFileRepo() {
|
|
|
17902
17905
|
});
|
|
17903
17906
|
return result;
|
|
17904
17907
|
} catch (error) {
|
|
17905
|
-
if (error instanceof
|
|
17908
|
+
if (error instanceof AppError9) {
|
|
17906
17909
|
throw error;
|
|
17907
17910
|
} else {
|
|
17908
17911
|
throw new InternalServerError20("Failed to get file by id.");
|
|
@@ -19795,7 +19798,7 @@ function useSiteCameraRepo() {
|
|
|
19795
19798
|
if (isDuplicated) {
|
|
19796
19799
|
throw new BadRequestError43("ANPR already exist.");
|
|
19797
19800
|
}
|
|
19798
|
-
if (error instanceof
|
|
19801
|
+
if (error instanceof AppError10) {
|
|
19799
19802
|
throw error;
|
|
19800
19803
|
} else {
|
|
19801
19804
|
throw new Error("Failed to create ANPR.");
|
|
@@ -20120,7 +20123,7 @@ function useSiteCameraRepo() {
|
|
|
20120
20123
|
if (isDuplicated) {
|
|
20121
20124
|
throw new BadRequestError43("ANPR already exist.");
|
|
20122
20125
|
}
|
|
20123
|
-
if (error2 instanceof
|
|
20126
|
+
if (error2 instanceof AppError10) {
|
|
20124
20127
|
throw error2;
|
|
20125
20128
|
}
|
|
20126
20129
|
throw new Error("Failed to update ANPR.");
|
|
@@ -20143,7 +20146,7 @@ function useSiteCameraRepo() {
|
|
|
20143
20146
|
level: "error",
|
|
20144
20147
|
message: error.message
|
|
20145
20148
|
});
|
|
20146
|
-
if (error instanceof
|
|
20149
|
+
if (error instanceof AppError10) {
|
|
20147
20150
|
throw error;
|
|
20148
20151
|
}
|
|
20149
20152
|
throw new Error("Failed to delete site camera.");
|
|
@@ -22072,7 +22075,7 @@ function useCameraViewService() {
|
|
|
22072
22075
|
}
|
|
22073
22076
|
async function authorizeCamera(params) {
|
|
22074
22077
|
if (!params.userId || !ObjectId52.isValid(params.userId)) {
|
|
22075
|
-
throw new
|
|
22078
|
+
throw new UnauthorizedError("Not signed in.");
|
|
22076
22079
|
}
|
|
22077
22080
|
if (!ObjectId52.isValid(params.cameraId)) {
|
|
22078
22081
|
throw new BadRequestError44("Invalid camera id.");
|
|
@@ -22101,7 +22104,7 @@ function useCameraViewService() {
|
|
|
22101
22104
|
memberships
|
|
22102
22105
|
);
|
|
22103
22106
|
if (!hasAnyPermission(permissions, params.permissions)) {
|
|
22104
|
-
throw new
|
|
22107
|
+
throw new UnauthorizedError(
|
|
22105
22108
|
"You do not have permission to use this camera."
|
|
22106
22109
|
);
|
|
22107
22110
|
}
|
|
@@ -22209,7 +22212,7 @@ function useCameraViewService() {
|
|
|
22209
22212
|
}
|
|
22210
22213
|
async function entitleSite(params) {
|
|
22211
22214
|
if (!params.userId || !ObjectId52.isValid(params.userId)) {
|
|
22212
|
-
throw new
|
|
22215
|
+
throw new UnauthorizedError("Not signed in.");
|
|
22213
22216
|
}
|
|
22214
22217
|
if (!ObjectId52.isValid(params.siteId)) {
|
|
22215
22218
|
throw new BadRequestError44("Invalid site id.");
|
|
@@ -22242,7 +22245,7 @@ function useCameraViewService() {
|
|
|
22242
22245
|
);
|
|
22243
22246
|
const required = params.permissions ?? CAMERA_VIEW_PERMISSIONS;
|
|
22244
22247
|
if (!hasAnyPermission(permissions, required)) {
|
|
22245
|
-
throw new
|
|
22248
|
+
throw new UnauthorizedError(
|
|
22246
22249
|
params.message ?? (required === CAMERA_VIEW_PERMISSIONS ? "You do not have permission to view these cameras." : "You do not have permission to set up cameras on this site.")
|
|
22247
22250
|
);
|
|
22248
22251
|
}
|
|
@@ -22633,8 +22636,8 @@ function useCameraViewService() {
|
|
|
22633
22636
|
permissions: CAMERA_RECORDINGS_PERMISSIONS
|
|
22634
22637
|
});
|
|
22635
22638
|
} catch (error) {
|
|
22636
|
-
if (error instanceof
|
|
22637
|
-
throw new
|
|
22639
|
+
if (error instanceof UnauthorizedError && params.userId && ObjectId52.isValid(params.userId)) {
|
|
22640
|
+
throw new AppError11("You do not have permission to watch recorded footage.", 403);
|
|
22638
22641
|
}
|
|
22639
22642
|
throw error;
|
|
22640
22643
|
}
|
|
@@ -22646,7 +22649,7 @@ function useCameraViewService() {
|
|
|
22646
22649
|
const key = playbackKeys[authority];
|
|
22647
22650
|
const link = capabilities.playback.state === "supported" && key ? signPlaybackLink({ host: camera.host, key, start: params.start, end: params.end }) : null;
|
|
22648
22651
|
if (!link) {
|
|
22649
|
-
throw new
|
|
22652
|
+
throw new AppError11(
|
|
22650
22653
|
capabilities.playback.detail ?? "Recorded footage is not set up for this camera yet.",
|
|
22651
22654
|
409
|
|
22652
22655
|
);
|
|
@@ -22698,7 +22701,7 @@ function membershipPreferenceOf(req) {
|
|
|
22698
22701
|
async function requireSiteReach(req, site, permission) {
|
|
22699
22702
|
const siteId = site?.toString?.() ?? "";
|
|
22700
22703
|
if (!siteId)
|
|
22701
|
-
throw new
|
|
22704
|
+
throw new UnauthorizedError2("Not authorized.");
|
|
22702
22705
|
const actor = await resolveInviteActor(callerId(req));
|
|
22703
22706
|
if (staffMayBypass(actor))
|
|
22704
22707
|
return;
|
|
@@ -22813,10 +22816,10 @@ async function requirePlatformStaff(req, grant) {
|
|
|
22813
22816
|
const id = callerId(req);
|
|
22814
22817
|
const role = id ? await resolveStaffRole(id) : null;
|
|
22815
22818
|
if (!role) {
|
|
22816
|
-
throw new
|
|
22819
|
+
throw new UnauthorizedError3("Not authorized.");
|
|
22817
22820
|
}
|
|
22818
22821
|
if (grant && !consoleRoleAllows(role.permissions, grant.resource, grant.action)) {
|
|
22819
|
-
throw new
|
|
22822
|
+
throw new UnauthorizedError3("Not authorized.");
|
|
22820
22823
|
}
|
|
22821
22824
|
return id;
|
|
22822
22825
|
}
|
|
@@ -22836,7 +22839,7 @@ async function requireOrgAccess(req, orgId) {
|
|
|
22836
22839
|
async function requirePlatformOwner(req, grant) {
|
|
22837
22840
|
const id = callerId(req);
|
|
22838
22841
|
if (!id || !await isPlatformOwner(id)) {
|
|
22839
|
-
throw new
|
|
22842
|
+
throw new UnauthorizedError3("Not authorized.");
|
|
22840
22843
|
}
|
|
22841
22844
|
if (grant)
|
|
22842
22845
|
await requirePlatformStaff(req, grant);
|
|
@@ -22845,7 +22848,7 @@ async function requirePlatformOwner(req, grant) {
|
|
|
22845
22848
|
async function requireOrgReach(req, orgId) {
|
|
22846
22849
|
const id = callerId(req);
|
|
22847
22850
|
if (!id)
|
|
22848
|
-
throw new
|
|
22851
|
+
throw new UnauthorizedError3("Not authorized.");
|
|
22849
22852
|
const org = orgId?.toString() ?? "";
|
|
22850
22853
|
const actor = await resolveInviteActor(id);
|
|
22851
22854
|
if (staffMayBypass(actor))
|
|
@@ -22856,7 +22859,7 @@ async function requireOrgReach(req, orgId) {
|
|
|
22856
22859
|
return id;
|
|
22857
22860
|
if (org && await hasOrgOwnership(id, org))
|
|
22858
22861
|
return id;
|
|
22859
|
-
throw new
|
|
22862
|
+
throw new UnauthorizedError3("Not authorized.");
|
|
22860
22863
|
}
|
|
22861
22864
|
async function requireSelfEnrolRole(req, orgId, roleId) {
|
|
22862
22865
|
const id = callerId(req);
|
|
@@ -22870,7 +22873,7 @@ async function requireSelfEnrolRole(req, orgId, roleId) {
|
|
|
22870
22873
|
return;
|
|
22871
22874
|
if (await invitationOffersRole(id, org, role))
|
|
22872
22875
|
return;
|
|
22873
|
-
throw new
|
|
22876
|
+
throw new UnauthorizedError3("Not authorized.");
|
|
22874
22877
|
}
|
|
22875
22878
|
async function canReadOrgRecord(req, orgId) {
|
|
22876
22879
|
const id = callerId(req);
|
|
@@ -22937,7 +22940,7 @@ async function requireInviteReach(req, org, app, role, site) {
|
|
|
22937
22940
|
await requireSiteServedByOrg(site, org);
|
|
22938
22941
|
await requireSiteReachInOrg(req, site, org);
|
|
22939
22942
|
} else if (org && await pinnedSitesIn(req, org) !== null) {
|
|
22940
|
-
throw new
|
|
22943
|
+
throw new UnauthorizedError3(
|
|
22941
22944
|
"Your access is limited to your site. Invite people from that site's Invitations page."
|
|
22942
22945
|
);
|
|
22943
22946
|
}
|
|
@@ -22994,13 +22997,13 @@ async function requireRoleAssignable(req, member, role, app) {
|
|
|
22994
22997
|
async function requireSiteAccessEditor(req, orgId) {
|
|
22995
22998
|
const id = callerId(req);
|
|
22996
22999
|
if (!id)
|
|
22997
|
-
throw new
|
|
23000
|
+
throw new UnauthorizedError3("Not authorized.");
|
|
22998
23001
|
if (staffMayBypass(await resolveInviteActor(id)))
|
|
22999
23002
|
return id;
|
|
23000
23003
|
if (await hasOrgOwnership(id, orgId))
|
|
23001
23004
|
return id;
|
|
23002
23005
|
if (await pinnedSitesIn(req, orgId) !== null) {
|
|
23003
|
-
throw new
|
|
23006
|
+
throw new UnauthorizedError3("Only the organisation's owner or an organisation admin can change site access.");
|
|
23004
23007
|
}
|
|
23005
23008
|
return await requireRoleAssigner(req, orgId);
|
|
23006
23009
|
}
|
|
@@ -23012,7 +23015,7 @@ async function requireNotOwnerUnlessOwner(req, orgId, targetUser) {
|
|
|
23012
23015
|
return;
|
|
23013
23016
|
if (staffMayBypass(await resolveInviteActor(id)))
|
|
23014
23017
|
return;
|
|
23015
|
-
throw new
|
|
23018
|
+
throw new UnauthorizedError3("Only the organisation's owner can change the owner's access.");
|
|
23016
23019
|
}
|
|
23017
23020
|
async function requireSiteReachInOrg(req, siteId, orgId) {
|
|
23018
23021
|
if (await hasOrgOwnership(callerId(req), orgId)) {
|
|
@@ -23074,7 +23077,7 @@ async function requireVerificationReach(req, verification) {
|
|
|
23074
23077
|
if (site) {
|
|
23075
23078
|
await requireSiteReachInOrg(req, site, org);
|
|
23076
23079
|
} else if (await pinnedSitesIn(req, org) !== null) {
|
|
23077
|
-
throw new
|
|
23080
|
+
throw new UnauthorizedError3(
|
|
23078
23081
|
"This invitation was sent from the organisation, not your site."
|
|
23079
23082
|
);
|
|
23080
23083
|
}
|
|
@@ -23082,13 +23085,13 @@ async function requireVerificationReach(req, verification) {
|
|
|
23082
23085
|
async function requireRoleAssigner(req, orgId) {
|
|
23083
23086
|
const id = callerId(req);
|
|
23084
23087
|
if (!id)
|
|
23085
|
-
throw new
|
|
23088
|
+
throw new UnauthorizedError3("Not authorized.");
|
|
23086
23089
|
const actor = await resolveInviteActor(id);
|
|
23087
23090
|
if (staffMayBypass(actor))
|
|
23088
23091
|
return id;
|
|
23089
23092
|
const org = orgId?.toString() ?? "";
|
|
23090
23093
|
if (!org || !ObjectId54.isValid(org) || !ObjectId54.isValid(id)) {
|
|
23091
|
-
throw new
|
|
23094
|
+
throw new UnauthorizedError3("Not authorized.");
|
|
23092
23095
|
}
|
|
23093
23096
|
if (await hasOrgOwnership(id, org))
|
|
23094
23097
|
return id;
|
|
@@ -23113,7 +23116,7 @@ async function requireRoleAssigner(req, orgId) {
|
|
|
23113
23116
|
return id;
|
|
23114
23117
|
}
|
|
23115
23118
|
}
|
|
23116
|
-
throw new
|
|
23119
|
+
throw new UnauthorizedError3("You do not have permission to assign roles.");
|
|
23117
23120
|
}
|
|
23118
23121
|
|
|
23119
23122
|
// src/services/service-provider-invite.service.ts
|
|
@@ -23155,7 +23158,7 @@ async function assertServiceProviderInviteScope(actor, orgId, siteId) {
|
|
|
23155
23158
|
)
|
|
23156
23159
|
});
|
|
23157
23160
|
if (!scope.ok)
|
|
23158
|
-
throw new
|
|
23161
|
+
throw new UnauthorizedError4(scope.reason);
|
|
23159
23162
|
return { sender: scope.sender, siteOwnerOrg };
|
|
23160
23163
|
}
|
|
23161
23164
|
function useServiceProviderInviteService() {
|
|
@@ -23253,13 +23256,13 @@ function useServiceProviderInviteService() {
|
|
|
23253
23256
|
const org = inviteOrgId(invite);
|
|
23254
23257
|
if (org && actor.orgIds.includes(org))
|
|
23255
23258
|
return;
|
|
23256
|
-
throw new
|
|
23259
|
+
throw new UnauthorizedError4(
|
|
23257
23260
|
"This invitation belongs to another organisation."
|
|
23258
23261
|
);
|
|
23259
23262
|
}
|
|
23260
23263
|
function assertSuperAdmin(actor) {
|
|
23261
23264
|
if (!staffMayBypass(actor)) {
|
|
23262
|
-
throw new
|
|
23265
|
+
throw new UnauthorizedError4(
|
|
23263
23266
|
"Only a Seven365 administrator can approve or reject invitations."
|
|
23264
23267
|
);
|
|
23265
23268
|
}
|
|
@@ -23272,7 +23275,7 @@ function useServiceProviderInviteService() {
|
|
|
23272
23275
|
async function actorFor(userId) {
|
|
23273
23276
|
const actor = await resolveInviteActor(userId);
|
|
23274
23277
|
if (!actor.id)
|
|
23275
|
-
throw new
|
|
23278
|
+
throw new UnauthorizedError4("Sign in to continue.");
|
|
23276
23279
|
return actor;
|
|
23277
23280
|
}
|
|
23278
23281
|
async function listApprovals({
|
|
@@ -23353,7 +23356,7 @@ function useServiceProviderInviteService() {
|
|
|
23353
23356
|
let scope = actor.orgIds;
|
|
23354
23357
|
if (orgId) {
|
|
23355
23358
|
if (!staffMayBypass(actor) && !actor.orgIds.includes(orgId)) {
|
|
23356
|
-
throw new
|
|
23359
|
+
throw new UnauthorizedError4(
|
|
23357
23360
|
"You are not a member of that organisation."
|
|
23358
23361
|
);
|
|
23359
23362
|
}
|
|
@@ -23581,7 +23584,7 @@ function useServiceProviderInviteService() {
|
|
|
23581
23584
|
);
|
|
23582
23585
|
const invitedUserId = user?._id?.toString();
|
|
23583
23586
|
if (!invitedUserId || invitedUserId !== userId) {
|
|
23584
|
-
throw new
|
|
23587
|
+
throw new UnauthorizedError4("This invitation was sent to someone else.");
|
|
23585
23588
|
}
|
|
23586
23589
|
}
|
|
23587
23590
|
async function decline({ id, userId }) {
|
|
@@ -23685,7 +23688,7 @@ function useServiceProviderInviteService() {
|
|
|
23685
23688
|
(m) => m.org === id && (m.companyWideRole === true || !m.siteId && m.orgLevelRole === true)
|
|
23686
23689
|
);
|
|
23687
23690
|
if (!runs) {
|
|
23688
|
-
throw new
|
|
23691
|
+
throw new UnauthorizedError4(
|
|
23689
23692
|
"Only an administrator of that company can answer this invitation for it."
|
|
23690
23693
|
);
|
|
23691
23694
|
}
|
|
@@ -24125,7 +24128,7 @@ function useVerificationService() {
|
|
|
24125
24128
|
const org = await getOrgById(orgId);
|
|
24126
24129
|
const actor = await resolveInviteActor(invitedBy);
|
|
24127
24130
|
if (!actor.id) {
|
|
24128
|
-
throw new
|
|
24131
|
+
throw new UnauthorizedError5("Sign in to continue.");
|
|
24129
24132
|
}
|
|
24130
24133
|
const { sender } = await assertServiceProviderInviteScope(
|
|
24131
24134
|
actor,
|
|
@@ -25410,7 +25413,7 @@ import {
|
|
|
25410
25413
|
paginate as paginate19,
|
|
25411
25414
|
useAtlas as useAtlas40,
|
|
25412
25415
|
useCache as useCache21,
|
|
25413
|
-
AppError as
|
|
25416
|
+
AppError as AppError12,
|
|
25414
25417
|
toObjectId as toObjectId9
|
|
25415
25418
|
} from "@7365admin1/node-server-utils";
|
|
25416
25419
|
import { ObjectId as ObjectId58 } from "mongodb";
|
|
@@ -25755,7 +25758,7 @@ function usePersonRepo() {
|
|
|
25755
25758
|
});
|
|
25756
25759
|
return result;
|
|
25757
25760
|
} catch (error) {
|
|
25758
|
-
if (error instanceof
|
|
25761
|
+
if (error instanceof AppError12) {
|
|
25759
25762
|
throw error;
|
|
25760
25763
|
} else {
|
|
25761
25764
|
throw new InternalServerError24("Failed to get person by id.");
|
|
@@ -26187,7 +26190,7 @@ function usePersonRepo() {
|
|
|
26187
26190
|
});
|
|
26188
26191
|
return result;
|
|
26189
26192
|
} catch (error) {
|
|
26190
|
-
if (error instanceof
|
|
26193
|
+
if (error instanceof AppError12) {
|
|
26191
26194
|
throw error;
|
|
26192
26195
|
} else {
|
|
26193
26196
|
throw new InternalServerError24("Failed to get person by user.");
|
|
@@ -26798,7 +26801,7 @@ function useRoleService() {
|
|
|
26798
26801
|
}
|
|
26799
26802
|
|
|
26800
26803
|
// src/utils/role-scope.util.ts
|
|
26801
|
-
import {
|
|
26804
|
+
import { AppError as AppError13 } from "@7365admin1/node-server-utils";
|
|
26802
26805
|
function roleScope(role) {
|
|
26803
26806
|
if ((role?.type ?? "") === PLATFORM_STAFF_ROLE_TYPE)
|
|
26804
26807
|
return "platform";
|
|
@@ -26832,8 +26835,9 @@ function requireNoPlatformGrant(role, next) {
|
|
|
26832
26835
|
const added = platformPermissionsAdded(next, role?.permissions);
|
|
26833
26836
|
if (added.length === 0)
|
|
26834
26837
|
return;
|
|
26835
|
-
throw new
|
|
26836
|
-
"These are Seven365 console permissions and cannot be granted on a client role: " + added.join(", ")
|
|
26838
|
+
throw new AppError13(
|
|
26839
|
+
"These are Seven365 console permissions and cannot be granted on a client role: " + added.join(", "),
|
|
26840
|
+
403
|
|
26837
26841
|
);
|
|
26838
26842
|
}
|
|
26839
26843
|
function permissionsMeanEverything(permissions) {
|
|
@@ -26846,15 +26850,17 @@ function refuseSharedClientTemplate(role, next) {
|
|
|
26846
26850
|
return true;
|
|
26847
26851
|
if (Array.isArray(next) && restorableFromHistory(role, next))
|
|
26848
26852
|
return true;
|
|
26849
|
-
throw new
|
|
26850
|
-
"This role is shared by every client that was invited with it and cannot be changed here."
|
|
26853
|
+
throw new AppError13(
|
|
26854
|
+
"This role is shared by every client that was invited with it and cannot be changed here.",
|
|
26855
|
+
403
|
|
26851
26856
|
);
|
|
26852
26857
|
}
|
|
26853
26858
|
function refuseNewSharedClientTemplate(role) {
|
|
26854
26859
|
if (roleScope(role) !== "client-template")
|
|
26855
26860
|
return;
|
|
26856
|
-
throw new
|
|
26857
|
-
"A role with no organisation would be shared by every client and cannot be created. Choose the organisation this role belongs to."
|
|
26861
|
+
throw new AppError13(
|
|
26862
|
+
"A role with no organisation would be shared by every client and cannot be created. Choose the organisation this role belongs to.",
|
|
26863
|
+
403
|
|
26858
26864
|
);
|
|
26859
26865
|
}
|
|
26860
26866
|
function samePermissionSet(a, b) {
|
|
@@ -26998,7 +27004,7 @@ function clientInviteOwnerPermissionsOn(env2 = process.env) {
|
|
|
26998
27004
|
}
|
|
26999
27005
|
|
|
27000
27006
|
// src/utils/module-ceiling.util.ts
|
|
27001
|
-
import {
|
|
27007
|
+
import { AppError as AppError14 } from "@7365admin1/node-server-utils";
|
|
27002
27008
|
async function moduleCeiling(org, site) {
|
|
27003
27009
|
const orgId = org?.toString() ?? "";
|
|
27004
27010
|
const siteId = site?.toString() ?? "";
|
|
@@ -27049,8 +27055,9 @@ async function boundRoleToOwnerGrant(req, role, next, previous) {
|
|
|
27049
27055
|
return list;
|
|
27050
27056
|
const { permissions, refused } = boundToOwnerGrant(ceiling, list, previous);
|
|
27051
27057
|
if (refused.length) {
|
|
27052
|
-
throw new
|
|
27053
|
-
"Seven365 has not given this organisation " + refused.join(", ") + "."
|
|
27058
|
+
throw new AppError14(
|
|
27059
|
+
"Seven365 has not given this organisation " + refused.join(", ") + ".",
|
|
27060
|
+
403
|
|
27054
27061
|
);
|
|
27055
27062
|
}
|
|
27056
27063
|
return permissions;
|
|
@@ -27454,18 +27461,18 @@ function useRoleController() {
|
|
|
27454
27461
|
|
|
27455
27462
|
// src/controllers/member.controller.ts
|
|
27456
27463
|
import Joi29 from "joi";
|
|
27457
|
-
import { BadRequestError as BadRequestError57, logger as logger43, UnauthorizedError as
|
|
27464
|
+
import { BadRequestError as BadRequestError57, logger as logger43, UnauthorizedError as UnauthorizedError8 } from "@7365admin1/node-server-utils";
|
|
27458
27465
|
|
|
27459
27466
|
// src/services/member.service.ts
|
|
27460
27467
|
import {
|
|
27461
27468
|
BadRequestError as BadRequestError55,
|
|
27462
|
-
UnauthorizedError as
|
|
27469
|
+
UnauthorizedError as UnauthorizedError6,
|
|
27463
27470
|
useAtlas as useAtlas43
|
|
27464
27471
|
} from "@7365admin1/node-server-utils";
|
|
27465
27472
|
import { ObjectId as ObjectId60 } from "mongodb";
|
|
27466
27473
|
async function requireStaffCaller(callerId5, what) {
|
|
27467
27474
|
if (!await isSuperAdmin(callerId5)) {
|
|
27468
|
-
throw new
|
|
27475
|
+
throw new UnauthorizedError6(
|
|
27469
27476
|
`Only Seven365 staff can ${what}.`
|
|
27470
27477
|
);
|
|
27471
27478
|
}
|
|
@@ -27701,7 +27708,7 @@ function useMemberService() {
|
|
|
27701
27708
|
}
|
|
27702
27709
|
|
|
27703
27710
|
// src/services/member-site-access.service.ts
|
|
27704
|
-
import { BadRequestError as BadRequestError56, UnauthorizedError as
|
|
27711
|
+
import { BadRequestError as BadRequestError56, UnauthorizedError as UnauthorizedError7, useAtlas as useAtlas44 } from "@7365admin1/node-server-utils";
|
|
27705
27712
|
import { ObjectId as ObjectId61 } from "mongodb";
|
|
27706
27713
|
var EXCLUDED_TYPES = ["resident", PLATFORM_STAFF_MEMBER_TYPE];
|
|
27707
27714
|
var both = (id) => [id, new ObjectId61(id)];
|
|
@@ -27774,7 +27781,7 @@ function useMemberSiteAccessService() {
|
|
|
27774
27781
|
actor
|
|
27775
27782
|
}) {
|
|
27776
27783
|
if (user === actor)
|
|
27777
|
-
throw new
|
|
27784
|
+
throw new UnauthorizedError7("You cannot change your own site access.");
|
|
27778
27785
|
const current = await get({ org, user });
|
|
27779
27786
|
const known = new Map(current.sites.map((s) => [s.site, s]));
|
|
27780
27787
|
const seen2 = /* @__PURE__ */ new Set();
|
|
@@ -28115,7 +28122,7 @@ function useMemberController() {
|
|
|
28115
28122
|
const scope = staffMayBypass(actor) ? null : memberListSiteScope(actor.memberships, org);
|
|
28116
28123
|
if (scope) {
|
|
28117
28124
|
if (siteId && !scope.includes(siteId.toLowerCase())) {
|
|
28118
|
-
throw new
|
|
28125
|
+
throw new UnauthorizedError8("Not authorized.");
|
|
28119
28126
|
}
|
|
28120
28127
|
if (!siteId)
|
|
28121
28128
|
siteIds = scope;
|
|
@@ -29024,7 +29031,7 @@ function useVerificationController() {
|
|
|
29024
29031
|
// src/controllers/file.controller.ts
|
|
29025
29032
|
import {
|
|
29026
29033
|
BadRequestError as BadRequestError59,
|
|
29027
|
-
UnauthorizedError as
|
|
29034
|
+
UnauthorizedError as UnauthorizedError9,
|
|
29028
29035
|
logger as logger45
|
|
29029
29036
|
} from "@7365admin1/node-server-utils";
|
|
29030
29037
|
import Joi31 from "joi";
|
|
@@ -29053,7 +29060,7 @@ async function requireFileDelete(req, file) {
|
|
|
29053
29060
|
return;
|
|
29054
29061
|
const caller = callerId(req);
|
|
29055
29062
|
if (!caller)
|
|
29056
|
-
throw new
|
|
29063
|
+
throw new UnauthorizedError9("Not authorized.");
|
|
29057
29064
|
if (caller === ownerId)
|
|
29058
29065
|
return;
|
|
29059
29066
|
const [me, owner] = await Promise.all([
|
|
@@ -29069,7 +29076,7 @@ async function requireFileDelete(req, file) {
|
|
|
29069
29076
|
})) {
|
|
29070
29077
|
return;
|
|
29071
29078
|
}
|
|
29072
|
-
throw new
|
|
29079
|
+
throw new UnauthorizedError9("Not authorized.");
|
|
29073
29080
|
}
|
|
29074
29081
|
function useFileController() {
|
|
29075
29082
|
const { createFile, deleteFile: _deleteFile } = useFileService();
|
|
@@ -29139,11 +29146,11 @@ function useFileController() {
|
|
|
29139
29146
|
|
|
29140
29147
|
// src/controllers/organization.controller.ts
|
|
29141
29148
|
import {
|
|
29142
|
-
AppError as
|
|
29149
|
+
AppError as AppError15,
|
|
29143
29150
|
BadRequestError as BadRequestError62,
|
|
29144
29151
|
logger as logger47,
|
|
29145
29152
|
NotFoundError as NotFoundError20,
|
|
29146
|
-
UnauthorizedError as
|
|
29153
|
+
UnauthorizedError as UnauthorizedError10
|
|
29147
29154
|
} from "@7365admin1/node-server-utils";
|
|
29148
29155
|
import Joi34 from "joi";
|
|
29149
29156
|
import { ObjectId as ObjectId65 } from "mongodb";
|
|
@@ -30166,7 +30173,7 @@ function orgModulesHandlers({
|
|
|
30166
30173
|
const residentAppModules = req.body.residentAppModules;
|
|
30167
30174
|
const preview = await orgModulePreview(await _getById(orgId), modules, gateData);
|
|
30168
30175
|
if (mustAcknowledge(preview, req.body.acknowledgeImpact)) {
|
|
30169
|
-
next(new
|
|
30176
|
+
next(new AppError15(impactUnacknowledgedMessage(preview), 409));
|
|
30170
30177
|
return;
|
|
30171
30178
|
}
|
|
30172
30179
|
await _update(orgId, {
|
|
@@ -30455,7 +30462,7 @@ function useOrgController() {
|
|
|
30455
30462
|
try {
|
|
30456
30463
|
const createdBy = callerId(req);
|
|
30457
30464
|
if (!createdBy)
|
|
30458
|
-
throw new
|
|
30465
|
+
throw new UnauthorizedError10("Not authorized.");
|
|
30459
30466
|
const { inviteId, ...body } = req.body ?? {};
|
|
30460
30467
|
let invitedFrom = null;
|
|
30461
30468
|
let invitedRole = null;
|
|
@@ -30959,7 +30966,7 @@ function useOrgControllerV2() {
|
|
|
30959
30966
|
|
|
30960
30967
|
// src/services/subscription.service.ts
|
|
30961
30968
|
import {
|
|
30962
|
-
AppError as
|
|
30969
|
+
AppError as AppError17,
|
|
30963
30970
|
BadRequestError as BadRequestError75,
|
|
30964
30971
|
logger as logger55,
|
|
30965
30972
|
useAtlas as useAtlas53
|
|
@@ -32251,7 +32258,7 @@ function usePaymentRepo() {
|
|
|
32251
32258
|
|
|
32252
32259
|
// src/repositories/price.repo.ts
|
|
32253
32260
|
import {
|
|
32254
|
-
AppError as
|
|
32261
|
+
AppError as AppError16,
|
|
32255
32262
|
BadRequestError as BadRequestError74,
|
|
32256
32263
|
InternalServerError as InternalServerError33,
|
|
32257
32264
|
logger as logger54,
|
|
@@ -32391,7 +32398,7 @@ function usePriceRepo() {
|
|
|
32391
32398
|
});
|
|
32392
32399
|
return data;
|
|
32393
32400
|
} catch (error) {
|
|
32394
|
-
if (error instanceof
|
|
32401
|
+
if (error instanceof AppError16) {
|
|
32395
32402
|
throw error;
|
|
32396
32403
|
} else {
|
|
32397
32404
|
throw new InternalServerError33("Failed to get price.");
|
|
@@ -33043,7 +33050,7 @@ function useSubscriptionService() {
|
|
|
33043
33050
|
level: "error",
|
|
33044
33051
|
message: `Failed to update subscription seats: ${error}`
|
|
33045
33052
|
});
|
|
33046
|
-
if (error instanceof
|
|
33053
|
+
if (error instanceof AppError17) {
|
|
33047
33054
|
throw error;
|
|
33048
33055
|
}
|
|
33049
33056
|
throw new BadRequestError75("Failed to update subscription seats.");
|
|
@@ -33128,13 +33135,13 @@ function useSubscriptionService() {
|
|
|
33128
33135
|
import Joi39 from "joi";
|
|
33129
33136
|
import {
|
|
33130
33137
|
BadRequestError as BadRequestError78,
|
|
33131
|
-
UnauthorizedError as
|
|
33138
|
+
UnauthorizedError as UnauthorizedError11,
|
|
33132
33139
|
logger as logger57
|
|
33133
33140
|
} from "@7365admin1/node-server-utils";
|
|
33134
33141
|
|
|
33135
33142
|
// src/repositories/subscription-plan.repo.ts
|
|
33136
33143
|
import {
|
|
33137
|
-
AppError as
|
|
33144
|
+
AppError as AppError18,
|
|
33138
33145
|
BadRequestError as BadRequestError77,
|
|
33139
33146
|
InternalServerError as InternalServerError34,
|
|
33140
33147
|
logger as logger56,
|
|
@@ -33245,7 +33252,7 @@ function useSubscriptionPlanRepo() {
|
|
|
33245
33252
|
return res.insertedId;
|
|
33246
33253
|
} catch (error) {
|
|
33247
33254
|
logger56.log({ level: "error", message: error.message });
|
|
33248
|
-
if (error instanceof
|
|
33255
|
+
if (error instanceof AppError18) {
|
|
33249
33256
|
throw error;
|
|
33250
33257
|
} else {
|
|
33251
33258
|
throw new InternalServerError34("Failed to create subscription plan.");
|
|
@@ -33353,7 +33360,7 @@ function useSubscriptionPlanRepo() {
|
|
|
33353
33360
|
});
|
|
33354
33361
|
return data;
|
|
33355
33362
|
} catch (error) {
|
|
33356
|
-
if (error instanceof
|
|
33363
|
+
if (error instanceof AppError18) {
|
|
33357
33364
|
throw error;
|
|
33358
33365
|
} else {
|
|
33359
33366
|
throw new InternalServerError34("Failed to get subscription plan.");
|
|
@@ -33408,7 +33415,7 @@ function useSubscriptionPlanRepo() {
|
|
|
33408
33415
|
});
|
|
33409
33416
|
return "Successfully updated subscription plan status.";
|
|
33410
33417
|
} catch (error) {
|
|
33411
|
-
if (error instanceof
|
|
33418
|
+
if (error instanceof AppError18) {
|
|
33412
33419
|
throw error;
|
|
33413
33420
|
}
|
|
33414
33421
|
throw new InternalServerError34(
|
|
@@ -33549,7 +33556,7 @@ function useSubscriptionController() {
|
|
|
33549
33556
|
try {
|
|
33550
33557
|
const subscription = await _getSubscriptionById(subscriptionId);
|
|
33551
33558
|
if (!subscription) {
|
|
33552
|
-
throw new
|
|
33559
|
+
throw new UnauthorizedError11("Not authorized.");
|
|
33553
33560
|
}
|
|
33554
33561
|
await requireOrgAccess(req, subscription.org?.toString());
|
|
33555
33562
|
const _res = await _updateSubscriptionSeats({
|
|
@@ -34980,7 +34987,7 @@ function useWorkOrderController() {
|
|
|
34980
34987
|
import Joi46 from "joi";
|
|
34981
34988
|
import {
|
|
34982
34989
|
BadRequestError as BadRequestError88,
|
|
34983
|
-
UnauthorizedError as
|
|
34990
|
+
UnauthorizedError as UnauthorizedError12,
|
|
34984
34991
|
logger as logger64
|
|
34985
34992
|
} from "@7365admin1/node-server-utils";
|
|
34986
34993
|
|
|
@@ -35282,7 +35289,7 @@ function useServiceProviderController() {
|
|
|
35282
35289
|
throw new BadRequestError88(`Invalid input: ${error.message}`);
|
|
35283
35290
|
await requireSiteReach(req, value.siteId);
|
|
35284
35291
|
if (!await isSiteClient(req, value.siteId)) {
|
|
35285
|
-
throw new
|
|
35292
|
+
throw new UnauthorizedError12(
|
|
35286
35293
|
"Only the site's own organisation can see its service providers' people."
|
|
35287
35294
|
);
|
|
35288
35295
|
}
|
|
@@ -36117,7 +36124,7 @@ function useCustomerController() {
|
|
|
36117
36124
|
|
|
36118
36125
|
// src/services/site.service.ts
|
|
36119
36126
|
import {
|
|
36120
|
-
AppError as
|
|
36127
|
+
AppError as AppError20,
|
|
36121
36128
|
BadRequestError as BadRequestError96,
|
|
36122
36129
|
logger as logger71,
|
|
36123
36130
|
useAtlas as useAtlas61
|
|
@@ -36135,7 +36142,7 @@ import { ObjectId as ObjectId81 } from "mongodb";
|
|
|
36135
36142
|
|
|
36136
36143
|
// src/repositories/building-unit.repository.ts
|
|
36137
36144
|
import {
|
|
36138
|
-
AppError as
|
|
36145
|
+
AppError as AppError19,
|
|
36139
36146
|
BadRequestError as BadRequestError94,
|
|
36140
36147
|
InternalServerError as InternalServerError36,
|
|
36141
36148
|
logger as logger69,
|
|
@@ -36439,7 +36446,7 @@ function useBuildingUnitRepo() {
|
|
|
36439
36446
|
if (isDuplicated) {
|
|
36440
36447
|
throw new BadRequestError94("Building unit already exists.");
|
|
36441
36448
|
}
|
|
36442
|
-
if (error instanceof
|
|
36449
|
+
if (error instanceof AppError19) {
|
|
36443
36450
|
throw error;
|
|
36444
36451
|
} else {
|
|
36445
36452
|
throw new Error("Failed to create building unit.");
|
|
@@ -36498,7 +36505,7 @@ function useBuildingUnitRepo() {
|
|
|
36498
36505
|
if (isDuplicated) {
|
|
36499
36506
|
throw new BadRequestError94("Building unit already exists.");
|
|
36500
36507
|
}
|
|
36501
|
-
if (error2 instanceof
|
|
36508
|
+
if (error2 instanceof AppError19) {
|
|
36502
36509
|
throw error2;
|
|
36503
36510
|
} else {
|
|
36504
36511
|
throw new Error("Failed to create building unit.");
|
|
@@ -36532,7 +36539,7 @@ function useBuildingUnitRepo() {
|
|
|
36532
36539
|
if (isDuplicated) {
|
|
36533
36540
|
throw new BadRequestError94("Building unit already exists.");
|
|
36534
36541
|
}
|
|
36535
|
-
if (error2 instanceof
|
|
36542
|
+
if (error2 instanceof AppError19) {
|
|
36536
36543
|
throw error2;
|
|
36537
36544
|
} else {
|
|
36538
36545
|
throw new Error("Failed to create building unit.");
|
|
@@ -36809,7 +36816,7 @@ function useBuildingUnitRepo() {
|
|
|
36809
36816
|
}
|
|
36810
36817
|
return result;
|
|
36811
36818
|
} catch (error) {
|
|
36812
|
-
if (error instanceof
|
|
36819
|
+
if (error instanceof AppError19) {
|
|
36813
36820
|
throw error;
|
|
36814
36821
|
} else {
|
|
36815
36822
|
throw new InternalServerError36("Failed to get building unit.");
|
|
@@ -36853,7 +36860,7 @@ function useBuildingUnitRepo() {
|
|
|
36853
36860
|
});
|
|
36854
36861
|
return result;
|
|
36855
36862
|
} catch (error) {
|
|
36856
|
-
if (error instanceof
|
|
36863
|
+
if (error instanceof AppError19) {
|
|
36857
36864
|
throw error;
|
|
36858
36865
|
} else {
|
|
36859
36866
|
throw new InternalServerError36("Failed to get building unit.");
|
|
@@ -36883,7 +36890,7 @@ function useBuildingUnitRepo() {
|
|
|
36883
36890
|
delCachedData();
|
|
36884
36891
|
return result;
|
|
36885
36892
|
} catch (error) {
|
|
36886
|
-
if (error instanceof
|
|
36893
|
+
if (error instanceof AppError19) {
|
|
36887
36894
|
throw error;
|
|
36888
36895
|
} else {
|
|
36889
36896
|
throw new InternalServerError36("Failed to update building unit level.");
|
|
@@ -36925,7 +36932,7 @@ function useBuildingUnitRepo() {
|
|
|
36925
36932
|
});
|
|
36926
36933
|
return result;
|
|
36927
36934
|
} catch (error) {
|
|
36928
|
-
if (error instanceof
|
|
36935
|
+
if (error instanceof AppError19) {
|
|
36929
36936
|
throw error;
|
|
36930
36937
|
} else {
|
|
36931
36938
|
throw new InternalServerError36("Failed to get building unit.");
|
|
@@ -36957,7 +36964,7 @@ function useBuildingUnitRepo() {
|
|
|
36957
36964
|
level: "error",
|
|
36958
36965
|
message: error.message
|
|
36959
36966
|
});
|
|
36960
|
-
if (error instanceof
|
|
36967
|
+
if (error instanceof AppError19) {
|
|
36961
36968
|
throw error;
|
|
36962
36969
|
} else {
|
|
36963
36970
|
throw new Error("Failed to deleted room/facility.");
|
|
@@ -36994,7 +37001,7 @@ function useBuildingUnitRepo() {
|
|
|
36994
37001
|
});
|
|
36995
37002
|
return data;
|
|
36996
37003
|
} catch (error) {
|
|
36997
|
-
if (error instanceof
|
|
37004
|
+
if (error instanceof AppError19) {
|
|
36998
37005
|
throw error;
|
|
36999
37006
|
} else {
|
|
37000
37007
|
throw new InternalServerError36("Failed to get building units.");
|
|
@@ -37017,7 +37024,7 @@ function useBuildingUnitRepo() {
|
|
|
37017
37024
|
const data = await collection.aggregate([{ $match: query2 }, { $project: { name: 1 } }]).toArray();
|
|
37018
37025
|
return data;
|
|
37019
37026
|
} catch (error) {
|
|
37020
|
-
if (error instanceof
|
|
37027
|
+
if (error instanceof AppError19) {
|
|
37021
37028
|
throw error;
|
|
37022
37029
|
} else {
|
|
37023
37030
|
throw new InternalServerError36("Failed to get building units.");
|
|
@@ -37072,7 +37079,7 @@ function useBuildingUnitRepo() {
|
|
|
37072
37079
|
]).toArray();
|
|
37073
37080
|
return data;
|
|
37074
37081
|
} catch (error) {
|
|
37075
|
-
if (error instanceof
|
|
37082
|
+
if (error instanceof AppError19) {
|
|
37076
37083
|
throw error;
|
|
37077
37084
|
} else {
|
|
37078
37085
|
throw new InternalServerError36(
|
|
@@ -37139,7 +37146,7 @@ function useBuildingUnitRepo() {
|
|
|
37139
37146
|
});
|
|
37140
37147
|
return result;
|
|
37141
37148
|
} catch (error) {
|
|
37142
|
-
if (error instanceof
|
|
37149
|
+
if (error instanceof AppError19) {
|
|
37143
37150
|
throw error;
|
|
37144
37151
|
} else {
|
|
37145
37152
|
throw new InternalServerError36("Failed to get building unit.");
|
|
@@ -37186,7 +37193,7 @@ function useBuildingUnitRepo() {
|
|
|
37186
37193
|
});
|
|
37187
37194
|
return result;
|
|
37188
37195
|
} catch (error) {
|
|
37189
|
-
if (error instanceof
|
|
37196
|
+
if (error instanceof AppError19) {
|
|
37190
37197
|
throw error;
|
|
37191
37198
|
} else {
|
|
37192
37199
|
throw new InternalServerError36("Failed to get building unit.");
|
|
@@ -37212,7 +37219,7 @@ function useBuildingUnitRepo() {
|
|
|
37212
37219
|
if (isDuplicated) {
|
|
37213
37220
|
throw new BadRequestError94("Some building units already exist.");
|
|
37214
37221
|
}
|
|
37215
|
-
if (error instanceof
|
|
37222
|
+
if (error instanceof AppError19) {
|
|
37216
37223
|
throw error;
|
|
37217
37224
|
} else {
|
|
37218
37225
|
throw new Error("Failed to bulk insert building units.");
|
|
@@ -39405,7 +39412,7 @@ function useSiteService() {
|
|
|
39405
39412
|
});
|
|
39406
39413
|
await deleteSiteCameraCache();
|
|
39407
39414
|
} catch (error2) {
|
|
39408
|
-
if (error2 instanceof
|
|
39415
|
+
if (error2 instanceof AppError20) {
|
|
39409
39416
|
throw error2;
|
|
39410
39417
|
}
|
|
39411
39418
|
throw new BadRequestError96("Failed to update guard post.");
|
|
@@ -39493,18 +39500,18 @@ function useSiteService() {
|
|
|
39493
39500
|
|
|
39494
39501
|
// src/controllers/site.controller.ts
|
|
39495
39502
|
import {
|
|
39496
|
-
AppError as
|
|
39503
|
+
AppError as AppError22,
|
|
39497
39504
|
BadRequestError as BadRequestError97,
|
|
39498
39505
|
logger as logger72,
|
|
39499
39506
|
NotFoundError as NotFoundError28,
|
|
39500
|
-
UnauthorizedError as
|
|
39507
|
+
UnauthorizedError as UnauthorizedError13,
|
|
39501
39508
|
useAtlas as useAtlas63
|
|
39502
39509
|
} from "@7365admin1/node-server-utils";
|
|
39503
39510
|
import Joi52 from "joi";
|
|
39504
39511
|
import { ObjectId as ObjectId83 } from "mongodb";
|
|
39505
39512
|
|
|
39506
39513
|
// src/utils/site-owner-edit.util.ts
|
|
39507
|
-
import { AppError as
|
|
39514
|
+
import { AppError as AppError21, useAtlas as useAtlas62 } from "@7365admin1/node-server-utils";
|
|
39508
39515
|
import { ObjectId as ObjectId82 } from "mongodb";
|
|
39509
39516
|
var SITE_OWNER_FIELDS = ["address", "timezone"];
|
|
39510
39517
|
function touchesSiteOwnerFields(body) {
|
|
@@ -39532,7 +39539,7 @@ async function requireSiteOwnerEdit(actor, staff, siteId) {
|
|
|
39532
39539
|
const ownerOrg = await ownerOfSite(siteId);
|
|
39533
39540
|
if (mayEditSiteDetails({ staff, actorOrgIds: actor.orgIds, ownerOrg }))
|
|
39534
39541
|
return;
|
|
39535
|
-
throw new
|
|
39542
|
+
throw new AppError21(siteOwnerOnlyMessage(await ownerOrgName(ownerOrg)), 403);
|
|
39536
39543
|
}
|
|
39537
39544
|
async function ownerOfSite(siteId) {
|
|
39538
39545
|
const id = String(siteId?.toString?.() ?? "");
|
|
@@ -39568,10 +39575,10 @@ async function requireSiteOwnerDelete(actor, staff, siteId) {
|
|
|
39568
39575
|
const permissions = member.role ? await getUserPermissions({ user: actor.id, org: owner, role: member.role, memberSite: member.siteId }) : [];
|
|
39569
39576
|
if (mayDeleteSite(permissions))
|
|
39570
39577
|
return;
|
|
39571
|
-
throw new
|
|
39578
|
+
throw new AppError21(NO_SITE_DELETE_PERMISSION, 403);
|
|
39572
39579
|
}
|
|
39573
39580
|
}
|
|
39574
|
-
throw new
|
|
39581
|
+
throw new AppError21(siteDeleteOwnerOnlyMessage(await ownerOrgName(owner)), 403);
|
|
39575
39582
|
}
|
|
39576
39583
|
|
|
39577
39584
|
// src/controllers/site.controller.ts
|
|
@@ -39643,7 +39650,7 @@ function siteModulesHandlers({
|
|
|
39643
39650
|
return;
|
|
39644
39651
|
}
|
|
39645
39652
|
if (!await mayManage(actor, site)) {
|
|
39646
|
-
throw new
|
|
39653
|
+
throw new UnauthorizedError13("Not authorized.");
|
|
39647
39654
|
}
|
|
39648
39655
|
const org = site.orgId ? await _getOrgById(site.orgId.toString()) : null;
|
|
39649
39656
|
const rejected = rejectedSiteModules(
|
|
@@ -39657,7 +39664,7 @@ function siteModulesHandlers({
|
|
|
39657
39664
|
const modules = normaliseModules(req.body.modules);
|
|
39658
39665
|
const preview = await siteModulePreview(site, org, modules, gateData);
|
|
39659
39666
|
if (mustAcknowledge(preview, req.body.acknowledgeImpact)) {
|
|
39660
|
-
next(new
|
|
39667
|
+
next(new AppError22(impactUnacknowledgedMessage(preview), 409));
|
|
39661
39668
|
return;
|
|
39662
39669
|
}
|
|
39663
39670
|
await _updateById(siteId, {
|
|
@@ -39705,7 +39712,7 @@ function siteModulesHandlers({
|
|
|
39705
39712
|
if (!site)
|
|
39706
39713
|
throw new NotFoundError28("Site not found.");
|
|
39707
39714
|
if (!await mayManage(actor, site))
|
|
39708
|
-
throw new
|
|
39715
|
+
throw new UnauthorizedError13("Not authorized.");
|
|
39709
39716
|
const org = site?.orgId ? await _getOrgById(site.orgId.toString()) : null;
|
|
39710
39717
|
res.json(
|
|
39711
39718
|
await siteModulePreview(site, org, normaliseModules(req.body.modules), gateData)
|
|
@@ -40177,7 +40184,7 @@ function useChatController() {
|
|
|
40177
40184
|
|
|
40178
40185
|
// src/repositories/building.repository.ts
|
|
40179
40186
|
import {
|
|
40180
|
-
AppError as
|
|
40187
|
+
AppError as AppError23,
|
|
40181
40188
|
BadRequestError as BadRequestError100,
|
|
40182
40189
|
InternalServerError as InternalServerError38,
|
|
40183
40190
|
logger as logger76,
|
|
@@ -40296,7 +40303,7 @@ function useBuildingRepo() {
|
|
|
40296
40303
|
if (isDuplicated) {
|
|
40297
40304
|
throw new BadRequestError100("Building already exists.");
|
|
40298
40305
|
}
|
|
40299
|
-
if (error instanceof
|
|
40306
|
+
if (error instanceof AppError23) {
|
|
40300
40307
|
throw error;
|
|
40301
40308
|
} else {
|
|
40302
40309
|
throw new Error("Failed to create building.");
|
|
@@ -40359,7 +40366,7 @@ function useBuildingRepo() {
|
|
|
40359
40366
|
if (isDuplicated) {
|
|
40360
40367
|
throw new BadRequestError100("Building already exists.");
|
|
40361
40368
|
}
|
|
40362
|
-
if (error instanceof
|
|
40369
|
+
if (error instanceof AppError23) {
|
|
40363
40370
|
throw error;
|
|
40364
40371
|
} else {
|
|
40365
40372
|
throw new Error("Failed to update building.");
|
|
@@ -40585,7 +40592,7 @@ function useBuildingRepo() {
|
|
|
40585
40592
|
});
|
|
40586
40593
|
return result;
|
|
40587
40594
|
} catch (error) {
|
|
40588
|
-
if (error instanceof
|
|
40595
|
+
if (error instanceof AppError23) {
|
|
40589
40596
|
throw error;
|
|
40590
40597
|
} else {
|
|
40591
40598
|
throw new InternalServerError38("Failed to get building.");
|
|
@@ -40611,7 +40618,7 @@ function useBuildingRepo() {
|
|
|
40611
40618
|
level: "error",
|
|
40612
40619
|
message: error.message
|
|
40613
40620
|
});
|
|
40614
|
-
if (error instanceof
|
|
40621
|
+
if (error instanceof AppError23) {
|
|
40615
40622
|
throw error;
|
|
40616
40623
|
} else {
|
|
40617
40624
|
throw new InternalServerError38("Failed to delete building.");
|
|
@@ -40653,7 +40660,7 @@ function useBuildingRepo() {
|
|
|
40653
40660
|
});
|
|
40654
40661
|
return result;
|
|
40655
40662
|
} catch (error) {
|
|
40656
|
-
if (error instanceof
|
|
40663
|
+
if (error instanceof AppError23) {
|
|
40657
40664
|
throw error;
|
|
40658
40665
|
} else {
|
|
40659
40666
|
throw new InternalServerError38("Failed to get building.");
|
|
@@ -40700,7 +40707,7 @@ function useBuildingRepo() {
|
|
|
40700
40707
|
]).toArray();
|
|
40701
40708
|
return result[0] ?? null;
|
|
40702
40709
|
} catch (error) {
|
|
40703
|
-
if (error instanceof
|
|
40710
|
+
if (error instanceof AppError23) {
|
|
40704
40711
|
throw error;
|
|
40705
40712
|
} else {
|
|
40706
40713
|
throw new InternalServerError38("Failed to get building.");
|
|
@@ -40787,7 +40794,7 @@ function useBuildingRepo() {
|
|
|
40787
40794
|
}
|
|
40788
40795
|
return result;
|
|
40789
40796
|
} catch (error) {
|
|
40790
|
-
if (error instanceof
|
|
40797
|
+
if (error instanceof AppError23) {
|
|
40791
40798
|
throw error;
|
|
40792
40799
|
} else {
|
|
40793
40800
|
throw new InternalServerError38("Failed to get building.");
|
|
@@ -40845,7 +40852,7 @@ function useBuildingRepo() {
|
|
|
40845
40852
|
data: result
|
|
40846
40853
|
};
|
|
40847
40854
|
} catch (error) {
|
|
40848
|
-
if (error instanceof
|
|
40855
|
+
if (error instanceof AppError23) {
|
|
40849
40856
|
throw error;
|
|
40850
40857
|
} else {
|
|
40851
40858
|
throw new InternalServerError38("Failed to get building.");
|
|
@@ -40888,7 +40895,7 @@ function useBuildingRepo() {
|
|
|
40888
40895
|
data: result
|
|
40889
40896
|
};
|
|
40890
40897
|
} catch (error) {
|
|
40891
|
-
if (error instanceof
|
|
40898
|
+
if (error instanceof AppError23) {
|
|
40892
40899
|
throw error;
|
|
40893
40900
|
} else {
|
|
40894
40901
|
throw new InternalServerError38("Failed to get buildings.");
|
|
@@ -40922,7 +40929,7 @@ import { ObjectId as ObjectId88 } from "mongodb";
|
|
|
40922
40929
|
|
|
40923
40930
|
// src/repositories/building-level.repository.ts
|
|
40924
40931
|
import {
|
|
40925
|
-
AppError as
|
|
40932
|
+
AppError as AppError24,
|
|
40926
40933
|
BadRequestError as BadRequestError102,
|
|
40927
40934
|
InternalServerError as InternalServerError39,
|
|
40928
40935
|
logger as logger78,
|
|
@@ -41082,7 +41089,7 @@ function useBuildingLevelRepo() {
|
|
|
41082
41089
|
if (isDuplicated) {
|
|
41083
41090
|
throw new BadRequestError102("Building level already exists.");
|
|
41084
41091
|
}
|
|
41085
|
-
if (error instanceof
|
|
41092
|
+
if (error instanceof AppError24) {
|
|
41086
41093
|
throw error;
|
|
41087
41094
|
} else {
|
|
41088
41095
|
throw new Error("Failed to create building level.");
|
|
@@ -41221,7 +41228,7 @@ function useBuildingLevelRepo() {
|
|
|
41221
41228
|
});
|
|
41222
41229
|
return result;
|
|
41223
41230
|
} catch (error) {
|
|
41224
|
-
if (error instanceof
|
|
41231
|
+
if (error instanceof AppError24) {
|
|
41225
41232
|
throw error;
|
|
41226
41233
|
} else {
|
|
41227
41234
|
throw new InternalServerError39("Failed to get building level.");
|
|
@@ -41267,7 +41274,7 @@ function useBuildingLevelRepo() {
|
|
|
41267
41274
|
delCachedData();
|
|
41268
41275
|
return result;
|
|
41269
41276
|
} catch (error) {
|
|
41270
|
-
if (error instanceof
|
|
41277
|
+
if (error instanceof AppError24) {
|
|
41271
41278
|
throw error;
|
|
41272
41279
|
} else {
|
|
41273
41280
|
throw new InternalServerError39("Failed to update building level.");
|
|
@@ -41306,7 +41313,7 @@ function useBuildingLevelRepo() {
|
|
|
41306
41313
|
level: "error",
|
|
41307
41314
|
message: error.message
|
|
41308
41315
|
});
|
|
41309
|
-
if (error instanceof
|
|
41316
|
+
if (error instanceof AppError24) {
|
|
41310
41317
|
throw error;
|
|
41311
41318
|
} else {
|
|
41312
41319
|
throw new Error("Failed to deleted building level.");
|
|
@@ -41369,7 +41376,7 @@ function useBuildingLevelRepo() {
|
|
|
41369
41376
|
if (isDuplicated) {
|
|
41370
41377
|
throw new BadRequestError102("Some levels already exist.");
|
|
41371
41378
|
}
|
|
41372
|
-
if (error instanceof
|
|
41379
|
+
if (error instanceof AppError24) {
|
|
41373
41380
|
throw error;
|
|
41374
41381
|
} else {
|
|
41375
41382
|
throw new Error("Failed to bulk insert levels.");
|
|
@@ -41404,7 +41411,7 @@ function useBuildingLevelRepo() {
|
|
|
41404
41411
|
if (isDuplicated) {
|
|
41405
41412
|
throw new BadRequestError102("Some building levels already exist.");
|
|
41406
41413
|
}
|
|
41407
|
-
if (error instanceof
|
|
41414
|
+
if (error instanceof AppError24) {
|
|
41408
41415
|
throw error;
|
|
41409
41416
|
} else {
|
|
41410
41417
|
throw new Error("Failed to batch update building levels.");
|
|
@@ -41456,7 +41463,7 @@ function useBuildingLevelRepo() {
|
|
|
41456
41463
|
data: result
|
|
41457
41464
|
};
|
|
41458
41465
|
} catch (error) {
|
|
41459
|
-
if (error instanceof
|
|
41466
|
+
if (error instanceof AppError24) {
|
|
41460
41467
|
throw error;
|
|
41461
41468
|
} else {
|
|
41462
41469
|
throw new InternalServerError39("Failed to get building level.");
|
|
@@ -45030,7 +45037,7 @@ function useCameraViewController() {
|
|
|
45030
45037
|
import Joi61 from "joi";
|
|
45031
45038
|
import {
|
|
45032
45039
|
BadRequestError as BadRequestError111,
|
|
45033
|
-
UnauthorizedError as
|
|
45040
|
+
UnauthorizedError as UnauthorizedError14,
|
|
45034
45041
|
logger as logger85
|
|
45035
45042
|
} from "@7365admin1/node-server-utils";
|
|
45036
45043
|
async function requireEitherOrg(req, ...orgs) {
|
|
@@ -45039,7 +45046,7 @@ async function requireEitherOrg(req, ...orgs) {
|
|
|
45039
45046
|
if (staffMayBypass(actor))
|
|
45040
45047
|
return actor;
|
|
45041
45048
|
if (wanted.length === 0 || !wanted.some((org) => actor.orgIds.includes(org))) {
|
|
45042
|
-
throw new
|
|
45049
|
+
throw new UnauthorizedError14("Not authorized.");
|
|
45043
45050
|
}
|
|
45044
45051
|
return actor;
|
|
45045
45052
|
}
|
|
@@ -48268,7 +48275,7 @@ import {
|
|
|
48268
48275
|
BadRequestError as BadRequestError125,
|
|
48269
48276
|
InternalServerError as InternalServerError45,
|
|
48270
48277
|
NotFoundError as NotFoundError38,
|
|
48271
|
-
UnauthorizedError as
|
|
48278
|
+
UnauthorizedError as UnauthorizedError15,
|
|
48272
48279
|
logger as logger97
|
|
48273
48280
|
} from "@7365admin1/node-server-utils";
|
|
48274
48281
|
|
|
@@ -51802,8 +51809,8 @@ function useHidAmicoService() {
|
|
|
51802
51809
|
await siteAccess.authorizeSite({ siteId, userId: value.userId, permissions });
|
|
51803
51810
|
}
|
|
51804
51811
|
} catch (error) {
|
|
51805
|
-
if (error instanceof
|
|
51806
|
-
throw new
|
|
51812
|
+
if (error instanceof UnauthorizedError15) {
|
|
51813
|
+
throw new UnauthorizedError15("You do not have permission to manage HID access at this site.");
|
|
51807
51814
|
}
|
|
51808
51815
|
throw error;
|
|
51809
51816
|
}
|
|
@@ -51827,7 +51834,7 @@ function useHidAmicoService() {
|
|
|
51827
51834
|
try {
|
|
51828
51835
|
await authorizeSiteForCaller(String(reader.site || ""), userId);
|
|
51829
51836
|
} catch (error) {
|
|
51830
|
-
if (error instanceof
|
|
51837
|
+
if (error instanceof UnauthorizedError15)
|
|
51831
51838
|
throw error;
|
|
51832
51839
|
throw new NotFoundError38(HID_READER_NOT_FOUND);
|
|
51833
51840
|
}
|
|
@@ -51879,10 +51886,10 @@ function useHidAmicoService() {
|
|
|
51879
51886
|
async function assertUserReaderPermission(reader, userId, options = {}) {
|
|
51880
51887
|
const permission = await getReaderPermissionForUser(reader, userId);
|
|
51881
51888
|
if (!permission.granted) {
|
|
51882
|
-
throw new
|
|
51889
|
+
throw new UnauthorizedError15("You do not have HID access permission for this reader.");
|
|
51883
51890
|
}
|
|
51884
51891
|
if (options.intercom && !permission.intercom) {
|
|
51885
|
-
throw new
|
|
51892
|
+
throw new UnauthorizedError15("You do not have HID intercom permission for this reader.");
|
|
51886
51893
|
}
|
|
51887
51894
|
return permission;
|
|
51888
51895
|
}
|
|
@@ -53220,10 +53227,10 @@ function useHidAmicoService() {
|
|
|
53220
53227
|
const hasActiveMembership = memberships.some((membership) => membership.status !== "deleted" && membership.status !== "inactive");
|
|
53221
53228
|
const resolvedIssuer = issuer || (hasResidentMembership ? "resident" : "property_management");
|
|
53222
53229
|
if (resolvedIssuer === "resident" && !hasResidentMembership) {
|
|
53223
|
-
throw new
|
|
53230
|
+
throw new UnauthorizedError15("Only a Resident account can issue a Resident visitor QR code.");
|
|
53224
53231
|
}
|
|
53225
53232
|
if (resolvedIssuer === "property_management" && !hasActiveMembership) {
|
|
53226
|
-
throw new
|
|
53233
|
+
throw new UnauthorizedError15("Only a site Property Management account can issue this visitor QR code.");
|
|
53227
53234
|
}
|
|
53228
53235
|
const configuredGateIds = site?.metadata?.hidQrCodePass?.qrGatePermissions?.[resolvedIssuer === "resident" ? "resident" : "propertyManagement"] || [];
|
|
53229
53236
|
const gateReaderIds = configuredGateIds.filter((readerId) => typeof readerId === "string" && /^[a-f0-9]{24}$/i.test(readerId)).map(String);
|
|
@@ -55816,7 +55823,7 @@ function useVisitorTransactionService() {
|
|
|
55816
55823
|
import Joi70 from "joi";
|
|
55817
55824
|
import moment5 from "moment-timezone";
|
|
55818
55825
|
import { ObjectId as ObjectId104 } from "mongodb";
|
|
55819
|
-
import { BadRequestError as BadRequestError128, NotFoundError as NotFoundError40, InternalServerError as InternalServerError47, UnauthorizedError as
|
|
55826
|
+
import { BadRequestError as BadRequestError128, NotFoundError as NotFoundError40, InternalServerError as InternalServerError47, UnauthorizedError as UnauthorizedError16, logger as logger101 } from "@7365admin1/node-server-utils";
|
|
55820
55827
|
|
|
55821
55828
|
// src/models/visitor-invite.model.ts
|
|
55822
55829
|
import Joi68 from "joi";
|
|
@@ -60689,7 +60696,7 @@ function useVisitorTransactionController() {
|
|
|
60689
60696
|
}
|
|
60690
60697
|
const inviterUserId = callerId(req);
|
|
60691
60698
|
if (!inviterUserId) {
|
|
60692
|
-
next(new
|
|
60699
|
+
next(new UnauthorizedError16("Not authorized."));
|
|
60693
60700
|
return;
|
|
60694
60701
|
}
|
|
60695
60702
|
try {
|
|
@@ -61253,7 +61260,7 @@ function useGuestManagementController() {
|
|
|
61253
61260
|
// src/controllers/person.controller.ts
|
|
61254
61261
|
import Joi73 from "joi";
|
|
61255
61262
|
import { BadRequestError as BadRequestError131, logger as logger104 } from "@7365admin1/node-server-utils";
|
|
61256
|
-
import { NotFoundError as NotFoundError41, UnauthorizedError as
|
|
61263
|
+
import { NotFoundError as NotFoundError41, UnauthorizedError as UnauthorizedError17 } from "@7365admin1/node-server-utils";
|
|
61257
61264
|
|
|
61258
61265
|
// src/utils/people-create-gate.util.ts
|
|
61259
61266
|
var PEOPLE_CREATE_REACH_MODE_DEFAULT = "enforce";
|
|
@@ -61320,7 +61327,7 @@ function usePersonController() {
|
|
|
61320
61327
|
}
|
|
61321
61328
|
const org = person.org?.toString() ?? "";
|
|
61322
61329
|
if (!org || !actor.orgIds.includes(org)) {
|
|
61323
|
-
throw new
|
|
61330
|
+
throw new UnauthorizedError17("Not authorized.");
|
|
61324
61331
|
}
|
|
61325
61332
|
return actor;
|
|
61326
61333
|
}
|
|
@@ -61403,7 +61410,7 @@ function usePersonController() {
|
|
|
61403
61410
|
});
|
|
61404
61411
|
}
|
|
61405
61412
|
if (verdict.refuse) {
|
|
61406
|
-
next(new
|
|
61413
|
+
next(new UnauthorizedError17("Not authorized."));
|
|
61407
61414
|
return;
|
|
61408
61415
|
}
|
|
61409
61416
|
}
|
|
@@ -61486,7 +61493,7 @@ function usePersonController() {
|
|
|
61486
61493
|
});
|
|
61487
61494
|
} else if (org) {
|
|
61488
61495
|
if (!actor.orgIds.includes(org)) {
|
|
61489
|
-
throw new
|
|
61496
|
+
throw new UnauthorizedError17("Not authorized.");
|
|
61490
61497
|
}
|
|
61491
61498
|
} else {
|
|
61492
61499
|
orgs = actor.orgIds;
|
|
@@ -62267,10 +62274,10 @@ function networkFaultsPipeline(q) {
|
|
|
62267
62274
|
|
|
62268
62275
|
// src/utils/robot-credentials.util.ts
|
|
62269
62276
|
import crypto9 from "crypto";
|
|
62270
|
-
import { AppError as
|
|
62277
|
+
import { AppError as AppError25 } from "@7365admin1/node-server-utils";
|
|
62271
62278
|
var ROBOT_CREDENTIALS_ENV = "ROBOT_CREDENTIALS_KEY";
|
|
62272
62279
|
var PREFIX = "rc1:";
|
|
62273
|
-
var RobotCredentialsError = class extends
|
|
62280
|
+
var RobotCredentialsError = class extends AppError25 {
|
|
62274
62281
|
constructor(message) {
|
|
62275
62282
|
super(message, 503);
|
|
62276
62283
|
}
|
|
@@ -63096,11 +63103,11 @@ function clearRobotBrands() {
|
|
|
63096
63103
|
}
|
|
63097
63104
|
|
|
63098
63105
|
// src/services/robot-fleet.service.ts
|
|
63099
|
-
import { AppError as
|
|
63106
|
+
import { AppError as AppError28, BadRequestError as BadRequestError137, NotFoundError as NotFoundError43 } from "@7365admin1/node-server-utils";
|
|
63100
63107
|
|
|
63101
63108
|
// src/services/robot-cloud.service.ts
|
|
63102
63109
|
import axios3 from "axios";
|
|
63103
|
-
import { AppError as
|
|
63110
|
+
import { AppError as AppError26, logger as logger107 } from "@7365admin1/node-server-utils";
|
|
63104
63111
|
|
|
63105
63112
|
// src/utils/robot-cloud.util.ts
|
|
63106
63113
|
import * as crypto10 from "crypto";
|
|
@@ -63473,7 +63480,7 @@ var STEP_NAMES = {
|
|
|
63473
63480
|
};
|
|
63474
63481
|
var robotCloudStepName = (path5) => STEP_NAMES[path5] ?? path5;
|
|
63475
63482
|
var SUCCESS_CODES = /* @__PURE__ */ new Set(["0", "200"]);
|
|
63476
|
-
var RobotCloudError = class extends
|
|
63483
|
+
var RobotCloudError = class extends AppError26 {
|
|
63477
63484
|
constructor(path5, message, opts = {}) {
|
|
63478
63485
|
const kind = opts.kind ?? (opts.refused ? "refused" : "input");
|
|
63479
63486
|
super(message, kind === "timeout" ? 504 : kind === "input" ? 400 : 502);
|
|
@@ -65095,7 +65102,7 @@ registerOpenRmfBrand();
|
|
|
65095
65102
|
|
|
65096
65103
|
// src/services/padbot.adapter.ts
|
|
65097
65104
|
import { createHash as createHash6 } from "crypto";
|
|
65098
|
-
import { AppError as
|
|
65105
|
+
import { AppError as AppError27, BadRequestError as BadRequestError136 } from "@7365admin1/node-server-utils";
|
|
65099
65106
|
|
|
65100
65107
|
// src/utils/padbot-sign.util.ts
|
|
65101
65108
|
import { createHash as createHash5, createHmac as createHmac2, randomUUID } from "crypto";
|
|
@@ -66004,19 +66011,19 @@ function createPadbotClient(credentials, options = {}) {
|
|
|
66004
66011
|
try {
|
|
66005
66012
|
res = await doFetch(`${baseUrl}${path5}`, { method: "POST", headers: req.headers, body: req.body, signal: AbortSignal.timeout(timeoutMs) });
|
|
66006
66013
|
} catch (error) {
|
|
66007
|
-
throw new
|
|
66014
|
+
throw new AppError27(`PadBot's cloud did not answer (${error?.name === "TimeoutError" ? "timed out" : "unreachable"}).`, 502);
|
|
66008
66015
|
}
|
|
66009
66016
|
if (res.status === 401)
|
|
66010
66017
|
throw new BadRequestError136("PadBot refused the AccessKey. Check the AccessKey ID and Secret (and the server clock).");
|
|
66011
66018
|
if (res.status === 403)
|
|
66012
66019
|
throw new BadRequestError136("This PadBot AccessKey is not allowed to do that.");
|
|
66013
66020
|
if (res.status !== 200)
|
|
66014
|
-
throw new
|
|
66021
|
+
throw new AppError27(`PadBot's cloud answered HTTP ${res.status}. Try again shortly.`, 502);
|
|
66015
66022
|
let json;
|
|
66016
66023
|
try {
|
|
66017
66024
|
json = JSON.parse(await res.text());
|
|
66018
66025
|
} catch {
|
|
66019
|
-
throw new
|
|
66026
|
+
throw new AppError27("PadBot's cloud sent an answer that is not JSON.", 502);
|
|
66020
66027
|
}
|
|
66021
66028
|
if (meta) {
|
|
66022
66029
|
meta.message = typeof json?.message === "string" ? json.message.slice(0, 200) : "";
|
|
@@ -66971,7 +66978,7 @@ function useRobotFleetService(deps) {
|
|
|
66971
66978
|
const last = lastTimestampProbe.get(key);
|
|
66972
66979
|
if (last && Date.now() - last < TIMESTAMP_PROBE_INTERVAL_MS) {
|
|
66973
66980
|
const wait = Math.ceil((TIMESTAMP_PROBE_INTERVAL_MS - (Date.now() - last)) / 1e3);
|
|
66974
|
-
throw new
|
|
66981
|
+
throw new AppError28(`The timestamp probe ran for this robot less than a minute ago - try again in ${wait} s.`, 429);
|
|
66975
66982
|
}
|
|
66976
66983
|
const pair = robotCloudCredentials(robot);
|
|
66977
66984
|
if (!pair.appid || !pair.secret) {
|
|
@@ -68465,7 +68472,7 @@ function startPadbotLiveFeed(deps = {}) {
|
|
|
68465
68472
|
|
|
68466
68473
|
// src/services/padbot-drive.service.ts
|
|
68467
68474
|
import { randomBytes as randomBytes3, randomUUID as randomUUID2 } from "crypto";
|
|
68468
|
-
import { AppError as
|
|
68475
|
+
import { AppError as AppError29, BadRequestError as BadRequestError139, logger as logger111 } from "@7365admin1/node-server-utils";
|
|
68469
68476
|
var sessions = /* @__PURE__ */ new Map();
|
|
68470
68477
|
var byRobot = /* @__PURE__ */ new Map();
|
|
68471
68478
|
var endedWhy = /* @__PURE__ */ new Map();
|
|
@@ -68506,7 +68513,7 @@ async function startPadbotDrive(robot, userId, deps = {}) {
|
|
|
68506
68513
|
if (current) {
|
|
68507
68514
|
const s = sessions.get(current);
|
|
68508
68515
|
if (s && s.userId !== userId)
|
|
68509
|
-
throw new
|
|
68516
|
+
throw new AppError29("Someone else is controlling this robot right now.", 409);
|
|
68510
68517
|
s?.watchdog.end("replaced");
|
|
68511
68518
|
}
|
|
68512
68519
|
if (!(deps.linkUp ?? padbotLinkUp)(robotId)) {
|
|
@@ -68583,7 +68590,7 @@ function padbotDriveSignal(robotId, sessionId, userId, signal) {
|
|
|
68583
68590
|
const s = sessions.get(sessionId);
|
|
68584
68591
|
if (!s || s.robotId !== robotId || s.userId !== userId) {
|
|
68585
68592
|
const why = endedWhy.get(sessionId);
|
|
68586
|
-
throw new
|
|
68593
|
+
throw new AppError29(DRIVE_END_TEXT[why?.reason ?? ""] ?? "Manual control has ended.", 410);
|
|
68587
68594
|
}
|
|
68588
68595
|
if (signal.seq <= s.seq)
|
|
68589
68596
|
return { ok: true, moving: s.watchdog.moving };
|
|
@@ -68607,7 +68614,7 @@ function padbotDriveSignal(robotId, sessionId, userId, signal) {
|
|
|
68607
68614
|
}
|
|
68608
68615
|
if (s.watchdog.ended) {
|
|
68609
68616
|
const why = endedWhy.get(sessionId);
|
|
68610
|
-
throw new
|
|
68617
|
+
throw new AppError29(DRIVE_END_TEXT[why?.reason ?? ""] ?? "Manual control has ended.", 410);
|
|
68611
68618
|
}
|
|
68612
68619
|
return { ok: true, moving: s.watchdog.moving };
|
|
68613
68620
|
}
|
|
@@ -69831,7 +69838,7 @@ function startRobotTracking(options) {
|
|
|
69831
69838
|
|
|
69832
69839
|
// src/controllers/robot-fleet.controller.ts
|
|
69833
69840
|
import Joi76 from "joi";
|
|
69834
|
-
import { AppError as
|
|
69841
|
+
import { AppError as AppError30, BadRequestError as BadRequestError140, logger as logger112 } from "@7365admin1/node-server-utils";
|
|
69835
69842
|
function useRobotFleetController(deps) {
|
|
69836
69843
|
let repo = null;
|
|
69837
69844
|
const getRepo = () => repo ?? (repo = useRobotRepo());
|
|
@@ -69861,7 +69868,7 @@ function useRobotFleetController(deps) {
|
|
|
69861
69868
|
if (error?.isOperational)
|
|
69862
69869
|
return next(error);
|
|
69863
69870
|
next(
|
|
69864
|
-
new
|
|
69871
|
+
new AppError30(
|
|
69865
69872
|
"Couldn't read this robot from its cloud (unexpected error). Seven365 staff can run Diagnose on the robot to see the failing step.",
|
|
69866
69873
|
502
|
|
69867
69874
|
)
|
|
@@ -70431,7 +70438,7 @@ import {
|
|
|
70431
70438
|
paginate as paginate35,
|
|
70432
70439
|
BadRequestError as BadRequestError141,
|
|
70433
70440
|
NotFoundError as NotFoundError44,
|
|
70434
|
-
AppError as
|
|
70441
|
+
AppError as AppError31
|
|
70435
70442
|
} from "@7365admin1/node-server-utils";
|
|
70436
70443
|
var NOT_DELETED2 = { deletedAt: { $in: ["", null] } };
|
|
70437
70444
|
function toObjectId16(id, what) {
|
|
@@ -70572,7 +70579,7 @@ function useRobotBuildingMapRepo() {
|
|
|
70572
70579
|
}
|
|
70573
70580
|
);
|
|
70574
70581
|
if (!res.matchedCount) {
|
|
70575
|
-
throw new
|
|
70582
|
+
throw new AppError31(
|
|
70576
70583
|
"This map was changed by someone else since you opened it. Reload it and make your change again.",
|
|
70577
70584
|
409
|
|
70578
70585
|
);
|
|
@@ -70600,7 +70607,7 @@ function useRobotBuildingMapRepo() {
|
|
|
70600
70607
|
const exists = await collection.countDocuments({ _id: id, ...NOT_DELETED2, "floorPlans.floorNo": floorNo2 });
|
|
70601
70608
|
if (!exists)
|
|
70602
70609
|
throw new NotFoundError44("This floor has no plan.");
|
|
70603
|
-
throw new
|
|
70610
|
+
throw new AppError31("This map was changed by someone else since you opened it. Reload it and make your change again.", 409);
|
|
70604
70611
|
}
|
|
70605
70612
|
return version + 1;
|
|
70606
70613
|
}
|
|
@@ -70621,7 +70628,7 @@ function useRobotBuildingMapRepo() {
|
|
|
70621
70628
|
}
|
|
70622
70629
|
);
|
|
70623
70630
|
if (!res.matchedCount) {
|
|
70624
|
-
throw new
|
|
70631
|
+
throw new AppError31(
|
|
70625
70632
|
"This map was changed by someone else since you opened it. Reload it and make your change again.",
|
|
70626
70633
|
409
|
|
70627
70634
|
);
|
|
@@ -70742,7 +70749,7 @@ function useRobotLiftSessionRepo() {
|
|
|
70742
70749
|
insertedId = res.insertedId;
|
|
70743
70750
|
} catch (error) {
|
|
70744
70751
|
if (isDuplicateKey(error)) {
|
|
70745
|
-
throw new
|
|
70752
|
+
throw new AppError31("This robot already has a lift request open. Release it first.", 409);
|
|
70746
70753
|
}
|
|
70747
70754
|
throw error;
|
|
70748
70755
|
}
|
|
@@ -70780,7 +70787,7 @@ function useRobotLiftSessionRepo() {
|
|
|
70780
70787
|
{ $set: { expiresAt: new Date(now.getTime() + LIFT_LEASE_MS), updatedAt: now } }
|
|
70781
70788
|
);
|
|
70782
70789
|
if (!res.matchedCount) {
|
|
70783
|
-
throw new
|
|
70790
|
+
throw new AppError31("This lift session is no longer active.", 409);
|
|
70784
70791
|
}
|
|
70785
70792
|
}
|
|
70786
70793
|
async function release(session, reason = "released") {
|
|
@@ -70838,7 +70845,7 @@ function useRobotLiftSessionRepo() {
|
|
|
70838
70845
|
|
|
70839
70846
|
// src/controllers/robot-map.controller.ts
|
|
70840
70847
|
import Joi78 from "joi";
|
|
70841
|
-
import { AppError as
|
|
70848
|
+
import { AppError as AppError32, BadRequestError as BadRequestError142, NotFoundError as NotFoundError45, logger as logger113 } from "@7365admin1/node-server-utils";
|
|
70842
70849
|
import { load as loadYaml, CORE_SCHEMA as YAML_CORE_SCHEMA } from "js-yaml";
|
|
70843
70850
|
function useRobotMapController(deps) {
|
|
70844
70851
|
const now = () => deps?.now?.() ?? Date.now();
|
|
@@ -71286,7 +71293,7 @@ function useRobotMapController(deps) {
|
|
|
71286
71293
|
try {
|
|
71287
71294
|
const session = await entitleSession(req);
|
|
71288
71295
|
if (!session.open)
|
|
71289
|
-
throw new
|
|
71296
|
+
throw new AppError32("This lift session is already closed.", 409);
|
|
71290
71297
|
await lifts().release(session);
|
|
71291
71298
|
await audit2(
|
|
71292
71299
|
req,
|
|
@@ -71352,7 +71359,7 @@ function useRobotMapController(deps) {
|
|
|
71352
71359
|
liftStates: liftStates.filter(Boolean)
|
|
71353
71360
|
});
|
|
71354
71361
|
} catch (e) {
|
|
71355
|
-
fail(next, e instanceof OpenRmfError ? new
|
|
71362
|
+
fail(next, e instanceof OpenRmfError ? new AppError32(e.message, 502) : e);
|
|
71356
71363
|
}
|
|
71357
71364
|
}
|
|
71358
71365
|
return {
|
|
@@ -71829,7 +71836,7 @@ function MPatrolQuestion(value) {
|
|
|
71829
71836
|
|
|
71830
71837
|
// src/repositories/patrol-question.repo.ts
|
|
71831
71838
|
import {
|
|
71832
|
-
AppError as
|
|
71839
|
+
AppError as AppError33,
|
|
71833
71840
|
BadRequestError as BadRequestError146,
|
|
71834
71841
|
InternalServerError as InternalServerError52,
|
|
71835
71842
|
logger as logger117,
|
|
@@ -71893,7 +71900,7 @@ function usePatrolQuestionRepo() {
|
|
|
71893
71900
|
if (isDuplicated) {
|
|
71894
71901
|
throw new BadRequestError146("Question already exist.");
|
|
71895
71902
|
}
|
|
71896
|
-
if (error instanceof
|
|
71903
|
+
if (error instanceof AppError33) {
|
|
71897
71904
|
throw error;
|
|
71898
71905
|
} else {
|
|
71899
71906
|
throw new Error("Failed to create Patrol Question.");
|
|
@@ -72294,7 +72301,7 @@ function MPatrolRoute(value) {
|
|
|
72294
72301
|
|
|
72295
72302
|
// src/repositories/patrol-route.repo.ts
|
|
72296
72303
|
import {
|
|
72297
|
-
AppError as
|
|
72304
|
+
AppError as AppError34,
|
|
72298
72305
|
BadRequestError as BadRequestError149,
|
|
72299
72306
|
InternalServerError as InternalServerError53,
|
|
72300
72307
|
logger as logger120,
|
|
@@ -72372,7 +72379,7 @@ function usePatrolRouteRepo() {
|
|
|
72372
72379
|
if (isDuplicated) {
|
|
72373
72380
|
throw new BadRequestError149("Route already exist.");
|
|
72374
72381
|
}
|
|
72375
|
-
if (error instanceof
|
|
72382
|
+
if (error instanceof AppError34) {
|
|
72376
72383
|
throw error;
|
|
72377
72384
|
} else {
|
|
72378
72385
|
throw new Error("Failed to create Patrol Route.");
|
|
@@ -73074,7 +73081,7 @@ function MPatrolLog(value) {
|
|
|
73074
73081
|
|
|
73075
73082
|
// src/repositories/patrol-log.repo.ts
|
|
73076
73083
|
import {
|
|
73077
|
-
AppError as
|
|
73084
|
+
AppError as AppError35,
|
|
73078
73085
|
BadRequestError as BadRequestError152,
|
|
73079
73086
|
InternalServerError as InternalServerError54,
|
|
73080
73087
|
logger as logger123,
|
|
@@ -73140,7 +73147,7 @@ function usePatrolLogRepo() {
|
|
|
73140
73147
|
if (isDuplicated) {
|
|
73141
73148
|
throw new BadRequestError152("Log already exist.");
|
|
73142
73149
|
}
|
|
73143
|
-
if (error instanceof
|
|
73150
|
+
if (error instanceof AppError35) {
|
|
73144
73151
|
throw error;
|
|
73145
73152
|
} else {
|
|
73146
73153
|
throw new Error("Failed to create Patrol Log.");
|
|
@@ -73872,7 +73879,7 @@ function MPatrolEmail(value) {
|
|
|
73872
73879
|
|
|
73873
73880
|
// src/repositories/patrol-email.repo.ts
|
|
73874
73881
|
import {
|
|
73875
|
-
AppError as
|
|
73882
|
+
AppError as AppError36,
|
|
73876
73883
|
BadRequestError as BadRequestError156,
|
|
73877
73884
|
InternalServerError as InternalServerError55,
|
|
73878
73885
|
logger as logger126,
|
|
@@ -73925,7 +73932,7 @@ function usePatrolEmailRepo() {
|
|
|
73925
73932
|
return { ...document2, _id: res.insertedId };
|
|
73926
73933
|
} catch (error) {
|
|
73927
73934
|
logger126.log({ level: "error", message: error.message });
|
|
73928
|
-
if (error instanceof
|
|
73935
|
+
if (error instanceof AppError36) {
|
|
73929
73936
|
throw error;
|
|
73930
73937
|
}
|
|
73931
73938
|
throw new InternalServerError55("Failed to record the patrol email.");
|
|
@@ -74085,7 +74092,7 @@ function usePatrolEmailRepo() {
|
|
|
74085
74092
|
}
|
|
74086
74093
|
return result;
|
|
74087
74094
|
} catch (error) {
|
|
74088
|
-
if (error instanceof
|
|
74095
|
+
if (error instanceof AppError36) {
|
|
74089
74096
|
throw error;
|
|
74090
74097
|
}
|
|
74091
74098
|
logger126.log({ level: "error", message: error.message });
|
|
@@ -75372,7 +75379,7 @@ function useSiteFacilityService() {
|
|
|
75372
75379
|
import {
|
|
75373
75380
|
BadRequestError as BadRequestError162,
|
|
75374
75381
|
NotFoundError as NotFoundError52,
|
|
75375
|
-
UnauthorizedError as
|
|
75382
|
+
UnauthorizedError as UnauthorizedError18,
|
|
75376
75383
|
logger as logger131
|
|
75377
75384
|
} from "@7365admin1/node-server-utils";
|
|
75378
75385
|
import Joi90 from "joi";
|
|
@@ -75459,7 +75466,7 @@ function useSiteFacilityController() {
|
|
|
75459
75466
|
} else {
|
|
75460
75467
|
const { actor } = await siteReachOf(req);
|
|
75461
75468
|
if (!actor.isSuperAdmin)
|
|
75462
|
-
throw new
|
|
75469
|
+
throw new UnauthorizedError18("Not authorized.");
|
|
75463
75470
|
}
|
|
75464
75471
|
const data = await _getAll({
|
|
75465
75472
|
search,
|
|
@@ -78494,7 +78501,7 @@ function useBulletinBoardService() {
|
|
|
78494
78501
|
import {
|
|
78495
78502
|
BadRequestError as BadRequestError171,
|
|
78496
78503
|
NotFoundError as NotFoundError60,
|
|
78497
|
-
UnauthorizedError as
|
|
78504
|
+
UnauthorizedError as UnauthorizedError19,
|
|
78498
78505
|
logger as logger140
|
|
78499
78506
|
} from "@7365admin1/node-server-utils";
|
|
78500
78507
|
import Joi98 from "joi";
|
|
@@ -78530,7 +78537,7 @@ function useBulletinBoardController() {
|
|
|
78530
78537
|
} else {
|
|
78531
78538
|
const { canReach } = await siteReachOf(req);
|
|
78532
78539
|
if (!await canReach(scopeOf(value))) {
|
|
78533
|
-
throw new
|
|
78540
|
+
throw new UnauthorizedError19("Not authorized.");
|
|
78534
78541
|
}
|
|
78535
78542
|
}
|
|
78536
78543
|
const data = await _add(value);
|
|
@@ -78832,7 +78839,7 @@ function MBillingItem(value) {
|
|
|
78832
78839
|
|
|
78833
78840
|
// src/repositories/site-billing-item.repo.ts
|
|
78834
78841
|
import {
|
|
78835
|
-
AppError as
|
|
78842
|
+
AppError as AppError37,
|
|
78836
78843
|
BadRequestError as BadRequestError173,
|
|
78837
78844
|
InternalServerError as InternalServerError61,
|
|
78838
78845
|
logger as logger142,
|
|
@@ -78888,7 +78895,7 @@ function useSiteBillingItemRepo() {
|
|
|
78888
78895
|
if (isDuplicated) {
|
|
78889
78896
|
throw new BadRequestError173("Site Billing Item already exist.");
|
|
78890
78897
|
}
|
|
78891
|
-
if (error instanceof
|
|
78898
|
+
if (error instanceof AppError37) {
|
|
78892
78899
|
throw error;
|
|
78893
78900
|
} else {
|
|
78894
78901
|
throw new Error("Failed to create Site Site Billing Item.");
|
|
@@ -78991,7 +78998,7 @@ function useSiteBillingItemRepo() {
|
|
|
78991
78998
|
});
|
|
78992
78999
|
return result;
|
|
78993
79000
|
} catch (error) {
|
|
78994
|
-
if (error instanceof
|
|
79001
|
+
if (error instanceof AppError37) {
|
|
78995
79002
|
throw error;
|
|
78996
79003
|
} else {
|
|
78997
79004
|
throw new InternalServerError61("Failed to get site billing item by id.");
|
|
@@ -79087,13 +79094,13 @@ import { BadRequestError as BadRequestError177, logger as logger146 } from "@736
|
|
|
79087
79094
|
import {
|
|
79088
79095
|
BadRequestError as BadRequestError176,
|
|
79089
79096
|
logger as logger145,
|
|
79090
|
-
UnauthorizedError as
|
|
79097
|
+
UnauthorizedError as UnauthorizedError20,
|
|
79091
79098
|
useAtlas as useAtlas101
|
|
79092
79099
|
} from "@7365admin1/node-server-utils";
|
|
79093
79100
|
|
|
79094
79101
|
// src/repositories/site-billing-configuration.repo.ts
|
|
79095
79102
|
import {
|
|
79096
|
-
AppError as
|
|
79103
|
+
AppError as AppError38,
|
|
79097
79104
|
BadRequestError as BadRequestError175,
|
|
79098
79105
|
InternalServerError as InternalServerError62,
|
|
79099
79106
|
logger as logger144,
|
|
@@ -79276,7 +79283,7 @@ function useSiteBillingConfigurationRepo() {
|
|
|
79276
79283
|
if (isDuplicated) {
|
|
79277
79284
|
throw new BadRequestError175("Site Billing Configuration already exist.");
|
|
79278
79285
|
}
|
|
79279
|
-
if (error instanceof
|
|
79286
|
+
if (error instanceof AppError38) {
|
|
79280
79287
|
throw error;
|
|
79281
79288
|
} else {
|
|
79282
79289
|
throw new Error("Failed to create Site Site Billing Configuration.");
|
|
@@ -79365,7 +79372,7 @@ function useSiteBillingConfigurationRepo() {
|
|
|
79365
79372
|
});
|
|
79366
79373
|
return result;
|
|
79367
79374
|
} catch (error) {
|
|
79368
|
-
if (error instanceof
|
|
79375
|
+
if (error instanceof AppError38) {
|
|
79369
79376
|
throw error;
|
|
79370
79377
|
} else {
|
|
79371
79378
|
throw new InternalServerError62(
|
|
@@ -79471,7 +79478,7 @@ function useSiteBillingItemService() {
|
|
|
79471
79478
|
function assertUnitAtSite(buildingUnit, site) {
|
|
79472
79479
|
const siteId = site?.toString?.() ?? "";
|
|
79473
79480
|
if (!siteId || (buildingUnit?.site?.toString() ?? "") !== siteId) {
|
|
79474
|
-
throw new
|
|
79481
|
+
throw new UnauthorizedError20("Not authorized.");
|
|
79475
79482
|
}
|
|
79476
79483
|
}
|
|
79477
79484
|
async function add(value) {
|
|
@@ -79642,7 +79649,7 @@ function useSiteBillingItemService() {
|
|
|
79642
79649
|
message: error.message
|
|
79643
79650
|
});
|
|
79644
79651
|
await session.abortTransaction();
|
|
79645
|
-
if (error instanceof BadRequestError176 || error instanceof
|
|
79652
|
+
if (error instanceof BadRequestError176 || error instanceof UnauthorizedError20) {
|
|
79646
79653
|
throw error;
|
|
79647
79654
|
}
|
|
79648
79655
|
throw new BadRequestError176("Failed to update Site Billing Item.");
|
|
@@ -80809,7 +80816,7 @@ function MUnitBilling(value) {
|
|
|
80809
80816
|
|
|
80810
80817
|
// src/repositories/site-unit-billing.repo.ts
|
|
80811
80818
|
import {
|
|
80812
|
-
AppError as
|
|
80819
|
+
AppError as AppError39,
|
|
80813
80820
|
BadRequestError as BadRequestError183,
|
|
80814
80821
|
InternalServerError as InternalServerError64,
|
|
80815
80822
|
logger as logger152,
|
|
@@ -80886,7 +80893,7 @@ function useSiteUnitBillingRepo() {
|
|
|
80886
80893
|
if (isDuplicated) {
|
|
80887
80894
|
throw new BadRequestError183("Site Unit Billing already exist.");
|
|
80888
80895
|
}
|
|
80889
|
-
if (error instanceof
|
|
80896
|
+
if (error instanceof AppError39) {
|
|
80890
80897
|
throw error;
|
|
80891
80898
|
} else {
|
|
80892
80899
|
throw new Error("Failed to create Site Unit Billing");
|
|
@@ -81042,7 +81049,7 @@ function useSiteUnitBillingRepo() {
|
|
|
81042
81049
|
});
|
|
81043
81050
|
return result;
|
|
81044
81051
|
} catch (error) {
|
|
81045
|
-
if (error instanceof
|
|
81052
|
+
if (error instanceof AppError39) {
|
|
81046
81053
|
throw error;
|
|
81047
81054
|
} else {
|
|
81048
81055
|
throw new InternalServerError64("Failed to get site unit billing by id.");
|
|
@@ -81611,7 +81618,7 @@ import Joi106 from "joi";
|
|
|
81611
81618
|
|
|
81612
81619
|
// src/utils/resident-unit.util.ts
|
|
81613
81620
|
import { ObjectId as ObjectId142 } from "mongodb";
|
|
81614
|
-
import { UnauthorizedError as
|
|
81621
|
+
import { UnauthorizedError as UnauthorizedError21, useAtlas as useAtlas107 } from "@7365admin1/node-server-utils";
|
|
81615
81622
|
async function requireOwnUnit(req, site, unitId) {
|
|
81616
81623
|
const actor = await resolveInviteActor(callerId(req));
|
|
81617
81624
|
if (staffMayBypass(actor))
|
|
@@ -81619,7 +81626,7 @@ async function requireOwnUnit(req, site, unitId) {
|
|
|
81619
81626
|
const unit = unitId?.toString?.() ?? "";
|
|
81620
81627
|
const siteId = site?.toString?.() ?? "";
|
|
81621
81628
|
if (!ObjectId142.isValid(unit) || !ObjectId142.isValid(siteId) || !actor.id) {
|
|
81622
|
-
throw new
|
|
81629
|
+
throw new UnauthorizedError21("Not authorized.");
|
|
81623
81630
|
}
|
|
81624
81631
|
const db2 = useAtlas107.getDb();
|
|
81625
81632
|
if (!db2)
|
|
@@ -81631,7 +81638,7 @@ async function requireOwnUnit(req, site, unitId) {
|
|
|
81631
81638
|
status: { $ne: "deleted" }
|
|
81632
81639
|
});
|
|
81633
81640
|
if (!own)
|
|
81634
|
-
throw new
|
|
81641
|
+
throw new UnauthorizedError21("Not authorized.");
|
|
81635
81642
|
}
|
|
81636
81643
|
|
|
81637
81644
|
// src/controllers/site-unit-billing.controller.ts
|
|
@@ -84809,7 +84816,7 @@ function MStatementOfAccount(value) {
|
|
|
84809
84816
|
|
|
84810
84817
|
// src/repositories/site-soa.repo.ts
|
|
84811
84818
|
import {
|
|
84812
|
-
AppError as
|
|
84819
|
+
AppError as AppError40,
|
|
84813
84820
|
BadRequestError as BadRequestError195,
|
|
84814
84821
|
InternalServerError as InternalServerError67,
|
|
84815
84822
|
logger as logger162,
|
|
@@ -84872,7 +84879,7 @@ function useStatementOfAccountRepo() {
|
|
|
84872
84879
|
if (isDuplicated) {
|
|
84873
84880
|
throw new BadRequestError195("Site SOA already exist.");
|
|
84874
84881
|
}
|
|
84875
|
-
if (error instanceof
|
|
84882
|
+
if (error instanceof AppError40) {
|
|
84876
84883
|
throw error;
|
|
84877
84884
|
} else {
|
|
84878
84885
|
throw new Error("Failed to create Site SOA");
|
|
@@ -84996,7 +85003,7 @@ function useStatementOfAccountRepo() {
|
|
|
84996
85003
|
});
|
|
84997
85004
|
return result;
|
|
84998
85005
|
} catch (error) {
|
|
84999
|
-
if (error instanceof
|
|
85006
|
+
if (error instanceof AppError40) {
|
|
85000
85007
|
throw error;
|
|
85001
85008
|
} else {
|
|
85002
85009
|
throw new InternalServerError67("Failed to get soa by id.");
|
|
@@ -86585,7 +86592,7 @@ function MNfcPatrolRoute(value) {
|
|
|
86585
86592
|
|
|
86586
86593
|
// src/repositories/nfc-patrol-route.repository.ts
|
|
86587
86594
|
import {
|
|
86588
|
-
AppError as
|
|
86595
|
+
AppError as AppError41,
|
|
86589
86596
|
BadRequestError as BadRequestError203,
|
|
86590
86597
|
InternalServerError as InternalServerError70,
|
|
86591
86598
|
logger as logger171,
|
|
@@ -86806,7 +86813,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
86806
86813
|
});
|
|
86807
86814
|
return result;
|
|
86808
86815
|
} catch (error) {
|
|
86809
|
-
if (error instanceof
|
|
86816
|
+
if (error instanceof AppError41) {
|
|
86810
86817
|
throw error;
|
|
86811
86818
|
} else {
|
|
86812
86819
|
throw new InternalServerError70(
|
|
@@ -86859,7 +86866,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
86859
86866
|
if (isDuplicated) {
|
|
86860
86867
|
throw new BadRequestError203("NFC Patrol Route already exists.");
|
|
86861
86868
|
}
|
|
86862
|
-
if (error2 instanceof
|
|
86869
|
+
if (error2 instanceof AppError41) {
|
|
86863
86870
|
throw error2;
|
|
86864
86871
|
} else {
|
|
86865
86872
|
throw new Error("Failed to update NFC Patrol Route.");
|
|
@@ -89721,7 +89728,7 @@ function useOnlineFormRepo() {
|
|
|
89721
89728
|
import {
|
|
89722
89729
|
BadRequestError as BadRequestError216,
|
|
89723
89730
|
NotFoundError as NotFoundError79,
|
|
89724
|
-
UnauthorizedError as
|
|
89731
|
+
UnauthorizedError as UnauthorizedError22,
|
|
89725
89732
|
logger as logger183
|
|
89726
89733
|
} from "@7365admin1/node-server-utils";
|
|
89727
89734
|
import Joi128 from "joi";
|
|
@@ -89793,10 +89800,10 @@ function useOnlineFormController() {
|
|
|
89793
89800
|
if (site) {
|
|
89794
89801
|
await requireSiteReach(req, site);
|
|
89795
89802
|
} else if (!staffMayBypass(actor)) {
|
|
89796
|
-
throw new
|
|
89803
|
+
throw new UnauthorizedError22("Not authorized.");
|
|
89797
89804
|
}
|
|
89798
89805
|
if (org && !staffMayBypass(actor) && !actor.orgIds.includes(org)) {
|
|
89799
|
-
throw new
|
|
89806
|
+
throw new UnauthorizedError22("Not authorized.");
|
|
89800
89807
|
}
|
|
89801
89808
|
const data = await _getAll({ search, page: page2, limit, status, org, site });
|
|
89802
89809
|
res.json(data);
|
|
@@ -89861,7 +89868,7 @@ function useOnlineFormController() {
|
|
|
89861
89868
|
if (payload.org) {
|
|
89862
89869
|
const { actor } = await siteReachOf(req);
|
|
89863
89870
|
if (!staffMayBypass(actor) && !actor.orgIds.includes(payload.org)) {
|
|
89864
|
-
throw new
|
|
89871
|
+
throw new UnauthorizedError22("Not authorized.");
|
|
89865
89872
|
}
|
|
89866
89873
|
}
|
|
89867
89874
|
await _updateOnlineFormById(_id, payload);
|
|
@@ -96471,7 +96478,7 @@ import {
|
|
|
96471
96478
|
logger as logger209,
|
|
96472
96479
|
BadRequestError as BadRequestError239,
|
|
96473
96480
|
NotFoundError as NotFoundError85,
|
|
96474
|
-
AppError as
|
|
96481
|
+
AppError as AppError47,
|
|
96475
96482
|
paginate as paginate67
|
|
96476
96483
|
} from "@7365admin1/node-server-utils";
|
|
96477
96484
|
var useRedDotPaymentRepo = () => {
|
|
@@ -96532,7 +96539,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
96532
96539
|
}
|
|
96533
96540
|
return payment;
|
|
96534
96541
|
} catch (error) {
|
|
96535
|
-
if (error instanceof
|
|
96542
|
+
if (error instanceof AppError47) {
|
|
96536
96543
|
throw error;
|
|
96537
96544
|
}
|
|
96538
96545
|
logger209.log({
|
|
@@ -96557,7 +96564,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
96557
96564
|
if (isDuplicated) {
|
|
96558
96565
|
throw new BadRequestError239("Payment already exist.");
|
|
96559
96566
|
}
|
|
96560
|
-
if (error instanceof
|
|
96567
|
+
if (error instanceof AppError47) {
|
|
96561
96568
|
throw error;
|
|
96562
96569
|
} else {
|
|
96563
96570
|
throw new Error("Failed to create Payment.");
|
|
@@ -96586,7 +96593,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
96586
96593
|
if (isDuplicated) {
|
|
96587
96594
|
throw new BadRequestError239("payment already exist.");
|
|
96588
96595
|
}
|
|
96589
|
-
if (error instanceof
|
|
96596
|
+
if (error instanceof AppError47) {
|
|
96590
96597
|
throw error;
|
|
96591
96598
|
} else {
|
|
96592
96599
|
throw new Error("Failed to create payment");
|
|
@@ -96654,7 +96661,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
96654
96661
|
const data = paginate67(items, page2, limit, totalCount);
|
|
96655
96662
|
return data;
|
|
96656
96663
|
} catch (error) {
|
|
96657
|
-
if (error instanceof
|
|
96664
|
+
if (error instanceof AppError47) {
|
|
96658
96665
|
throw error;
|
|
96659
96666
|
}
|
|
96660
96667
|
logger209.log({
|
|
@@ -96866,7 +96873,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
96866
96873
|
}
|
|
96867
96874
|
return res;
|
|
96868
96875
|
} catch (error) {
|
|
96869
|
-
if (error instanceof
|
|
96876
|
+
if (error instanceof AppError47) {
|
|
96870
96877
|
throw error;
|
|
96871
96878
|
}
|
|
96872
96879
|
throw new InternalServerError83("Failed to update payment status.");
|
|
@@ -97193,7 +97200,7 @@ import {
|
|
|
97193
97200
|
BadRequestError as BadRequestError243,
|
|
97194
97201
|
NotFoundError as NotFoundError88,
|
|
97195
97202
|
InternalServerError as InternalServerError87,
|
|
97196
|
-
UnauthorizedError as
|
|
97203
|
+
UnauthorizedError as UnauthorizedError23,
|
|
97197
97204
|
useAtlas as useAtlas144,
|
|
97198
97205
|
hashPassword as hashPassword4
|
|
97199
97206
|
} from "@7365admin1/node-server-utils";
|
|
@@ -97220,7 +97227,7 @@ import {
|
|
|
97220
97227
|
BadRequestError as BadRequestError241,
|
|
97221
97228
|
paginate as paginate68,
|
|
97222
97229
|
NotFoundError as NotFoundError86,
|
|
97223
|
-
AppError as
|
|
97230
|
+
AppError as AppError48,
|
|
97224
97231
|
useCache as useCache72,
|
|
97225
97232
|
makeCacheKey as makeCacheKey65,
|
|
97226
97233
|
toObjectId as toObjectId23
|
|
@@ -97358,7 +97365,7 @@ function useUserRepoV2() {
|
|
|
97358
97365
|
);
|
|
97359
97366
|
return data;
|
|
97360
97367
|
} catch (error) {
|
|
97361
|
-
if (error instanceof
|
|
97368
|
+
if (error instanceof AppError48)
|
|
97362
97369
|
throw error;
|
|
97363
97370
|
throw new InternalServerError85("Failed to get user by id.");
|
|
97364
97371
|
}
|
|
@@ -98119,7 +98126,7 @@ function useVerificationServiceV2() {
|
|
|
98119
98126
|
const org = await getOrgById(orgId);
|
|
98120
98127
|
const actor = await resolveInviteActor(invitedBy);
|
|
98121
98128
|
if (!actor.id) {
|
|
98122
|
-
throw new
|
|
98129
|
+
throw new UnauthorizedError23("Sign in to continue.");
|
|
98123
98130
|
}
|
|
98124
98131
|
const { sender } = await assertServiceProviderInviteScope(
|
|
98125
98132
|
actor,
|
|
@@ -98444,7 +98451,7 @@ function useVerificationServiceV2() {
|
|
|
98444
98451
|
const user = await _getUserById(userId).catch(() => null);
|
|
98445
98452
|
const email = user?.email;
|
|
98446
98453
|
if (!email) {
|
|
98447
|
-
throw new
|
|
98454
|
+
throw new UnauthorizedError23("Not authorized.");
|
|
98448
98455
|
}
|
|
98449
98456
|
return email;
|
|
98450
98457
|
}
|
|
@@ -98482,7 +98489,7 @@ function useVerificationServiceV2() {
|
|
|
98482
98489
|
throw new NotFoundError88("Invitation not found.");
|
|
98483
98490
|
}
|
|
98484
98491
|
if (invite.email.toLowerCase() !== email.toLowerCase()) {
|
|
98485
|
-
throw new
|
|
98492
|
+
throw new UnauthorizedError23("Not authorized.");
|
|
98486
98493
|
}
|
|
98487
98494
|
await _setOnboardingById({
|
|
98488
98495
|
_id: inviteId,
|
|
@@ -102455,7 +102462,7 @@ import Joi164 from "joi";
|
|
|
102455
102462
|
import { ObjectId as ObjectId195 } from "mongodb";
|
|
102456
102463
|
import {
|
|
102457
102464
|
InternalServerError as InternalServerError97,
|
|
102458
|
-
UnauthorizedError as
|
|
102465
|
+
UnauthorizedError as UnauthorizedError24,
|
|
102459
102466
|
useAtlas as useAtlas156
|
|
102460
102467
|
} from "@7365admin1/node-server-utils";
|
|
102461
102468
|
function db() {
|
|
@@ -102471,7 +102478,7 @@ function asObjectId(value) {
|
|
|
102471
102478
|
function requireCaller(req) {
|
|
102472
102479
|
const id = callerId(req);
|
|
102473
102480
|
if (!id || !ObjectId195.isValid(id)) {
|
|
102474
|
-
throw new
|
|
102481
|
+
throw new UnauthorizedError24("Not authorized.");
|
|
102475
102482
|
}
|
|
102476
102483
|
return id;
|
|
102477
102484
|
}
|
|
@@ -102479,7 +102486,7 @@ function requireSelfId(req, claimed) {
|
|
|
102479
102486
|
const caller = requireCaller(req);
|
|
102480
102487
|
const asked = claimed?.toString?.() ?? "";
|
|
102481
102488
|
if (!asked || asked !== caller) {
|
|
102482
|
-
throw new
|
|
102489
|
+
throw new UnauthorizedError24("Not authorized.");
|
|
102483
102490
|
}
|
|
102484
102491
|
return caller;
|
|
102485
102492
|
}
|
|
@@ -102487,11 +102494,11 @@ async function requireOwnChannel(req, channelId) {
|
|
|
102487
102494
|
const caller = requireCaller(req);
|
|
102488
102495
|
const _id = asObjectId(channelId);
|
|
102489
102496
|
if (!_id)
|
|
102490
|
-
throw new
|
|
102497
|
+
throw new UnauthorizedError24("Not authorized.");
|
|
102491
102498
|
const channel = await db().collection("channel-preloved").findOne({ _id }, { projection: { senderId: 1, receiverId: 1, postId: 1 } });
|
|
102492
102499
|
const participants = [channel?.senderId, channel?.receiverId].map((id) => id?.toString?.() ?? "").filter(Boolean);
|
|
102493
102500
|
if (!channel || !participants.includes(caller)) {
|
|
102494
|
-
throw new
|
|
102501
|
+
throw new UnauthorizedError24("Not authorized.");
|
|
102495
102502
|
}
|
|
102496
102503
|
return { caller, channel };
|
|
102497
102504
|
}
|
|
@@ -102499,10 +102506,10 @@ async function requireOwnChatMessage(req, chatId) {
|
|
|
102499
102506
|
const caller = requireCaller(req);
|
|
102500
102507
|
const _id = asObjectId(chatId);
|
|
102501
102508
|
if (!_id)
|
|
102502
|
-
throw new
|
|
102509
|
+
throw new UnauthorizedError24("Not authorized.");
|
|
102503
102510
|
const message = await db().collection("chat-preloved").findOne({ _id }, { projection: { senderId: 1 } });
|
|
102504
102511
|
if (!message || message.senderId?.toString?.() !== caller) {
|
|
102505
|
-
throw new
|
|
102512
|
+
throw new UnauthorizedError24("Not authorized.");
|
|
102506
102513
|
}
|
|
102507
102514
|
return caller;
|
|
102508
102515
|
}
|
|
@@ -102928,7 +102935,7 @@ function useBidPrelovedService() {
|
|
|
102928
102935
|
// src/controllers/bid-preloved.controller.ts
|
|
102929
102936
|
import {
|
|
102930
102937
|
BadRequestError as BadRequestError264,
|
|
102931
|
-
UnauthorizedError as
|
|
102938
|
+
UnauthorizedError as UnauthorizedError25,
|
|
102932
102939
|
logger as logger227
|
|
102933
102940
|
} from "@7365admin1/node-server-utils";
|
|
102934
102941
|
import Joi167 from "joi";
|
|
@@ -102980,7 +102987,7 @@ function useBidPrelovedController() {
|
|
|
102980
102987
|
const bid = await _getById(params.id);
|
|
102981
102988
|
const seller = await sellerOfPost(bid?.postId);
|
|
102982
102989
|
if (!seller || seller !== caller) {
|
|
102983
|
-
throw new
|
|
102990
|
+
throw new UnauthorizedError25("Not authorized.");
|
|
102984
102991
|
}
|
|
102985
102992
|
const data = await _updateStatus(params.id, body.status);
|
|
102986
102993
|
res.status(200).json(data);
|
|
@@ -103004,7 +103011,7 @@ function useBidPrelovedController() {
|
|
|
103004
103011
|
const data = await _getById(params.id);
|
|
103005
103012
|
const seller = await sellerOfPost(data?.postId);
|
|
103006
103013
|
if (data?.buyerId?.toString?.() !== caller && seller !== caller) {
|
|
103007
|
-
throw new
|
|
103014
|
+
throw new UnauthorizedError25("Not authorized.");
|
|
103008
103015
|
}
|
|
103009
103016
|
res.status(200).json(data);
|
|
103010
103017
|
} catch (error2) {
|
|
@@ -103402,7 +103409,7 @@ function useFormEntryRepo() {
|
|
|
103402
103409
|
import {
|
|
103403
103410
|
BadRequestError as BadRequestError266,
|
|
103404
103411
|
NotFoundError as NotFoundError97,
|
|
103405
|
-
UnauthorizedError as
|
|
103412
|
+
UnauthorizedError as UnauthorizedError26,
|
|
103406
103413
|
logger as logger229
|
|
103407
103414
|
} from "@7365admin1/node-server-utils";
|
|
103408
103415
|
import Joi169 from "joi";
|
|
@@ -103512,7 +103519,7 @@ function useFormEntryController() {
|
|
|
103512
103519
|
} else {
|
|
103513
103520
|
const { actor } = await siteReachOf(req);
|
|
103514
103521
|
if (!actor.isSuperAdmin)
|
|
103515
|
-
throw new
|
|
103522
|
+
throw new UnauthorizedError26("Not authorized.");
|
|
103516
103523
|
}
|
|
103517
103524
|
const data = await _getAll({ search, page: page2, limit, status, org, site });
|
|
103518
103525
|
res.json(data);
|
|
@@ -103563,7 +103570,7 @@ function useFormEntryController() {
|
|
|
103563
103570
|
await requireSiteReach(req, rest.site);
|
|
103564
103571
|
delete rest.userId;
|
|
103565
103572
|
if (isOwner && rest.status && rest.status !== "pending") {
|
|
103566
|
-
throw new
|
|
103573
|
+
throw new UnauthorizedError26("Not authorized.");
|
|
103567
103574
|
}
|
|
103568
103575
|
await _updateFormEntryById(_id, rest);
|
|
103569
103576
|
res.json({ message: "Successfully updated online form." });
|
|
@@ -103620,7 +103627,7 @@ function useFormEntryController() {
|
|
|
103620
103627
|
async function residentFormSubmission(req, res, next) {
|
|
103621
103628
|
const userId = callerId(req);
|
|
103622
103629
|
if (!userId) {
|
|
103623
|
-
next(new
|
|
103630
|
+
next(new UnauthorizedError26("Not authorized."));
|
|
103624
103631
|
return;
|
|
103625
103632
|
}
|
|
103626
103633
|
const payload = { ...req.body, userId };
|
|
@@ -104851,7 +104858,7 @@ function useHidAmicoController() {
|
|
|
104851
104858
|
import {
|
|
104852
104859
|
BadRequestError as BadRequestError269,
|
|
104853
104860
|
logger as logger231,
|
|
104854
|
-
UnauthorizedError as
|
|
104861
|
+
UnauthorizedError as UnauthorizedError27
|
|
104855
104862
|
} from "@7365admin1/node-server-utils";
|
|
104856
104863
|
import Joi171 from "joi";
|
|
104857
104864
|
function usePlatformTermsController() {
|
|
@@ -104867,7 +104874,7 @@ function usePlatformTermsController() {
|
|
|
104867
104874
|
async function requireOwnRecord(req, user, { staffMayRead = false } = {}) {
|
|
104868
104875
|
const id = callerId(req);
|
|
104869
104876
|
if (!id) {
|
|
104870
|
-
throw new
|
|
104877
|
+
throw new UnauthorizedError27("Not authorized.");
|
|
104871
104878
|
}
|
|
104872
104879
|
if (id === user) {
|
|
104873
104880
|
return id;
|
|
@@ -104875,7 +104882,7 @@ function usePlatformTermsController() {
|
|
|
104875
104882
|
if (staffMayRead) {
|
|
104876
104883
|
return await requireConsolePermission(req, "platform-terms", "see-platform-terms");
|
|
104877
104884
|
}
|
|
104878
|
-
throw new
|
|
104885
|
+
throw new UnauthorizedError27("Not authorized.");
|
|
104879
104886
|
}
|
|
104880
104887
|
async function getLatest(_req, res, next) {
|
|
104881
104888
|
try {
|
|
@@ -105084,7 +105091,7 @@ function useConsoleAuditController() {
|
|
|
105084
105091
|
// src/controllers/notification.controller.ts
|
|
105085
105092
|
import {
|
|
105086
105093
|
BadRequestError as BadRequestError271,
|
|
105087
|
-
UnauthorizedError as
|
|
105094
|
+
UnauthorizedError as UnauthorizedError28,
|
|
105088
105095
|
logger as logger233
|
|
105089
105096
|
} from "@7365admin1/node-server-utils";
|
|
105090
105097
|
function useNotificationController() {
|
|
@@ -105102,10 +105109,10 @@ function useNotificationController() {
|
|
|
105102
105109
|
function inboxOwner(req, claimed) {
|
|
105103
105110
|
const caller = callerId5(req);
|
|
105104
105111
|
if (!caller) {
|
|
105105
|
-
throw new
|
|
105112
|
+
throw new UnauthorizedError28("Not authorized.");
|
|
105106
105113
|
}
|
|
105107
105114
|
if (claimed && claimed !== caller) {
|
|
105108
|
-
throw new
|
|
105115
|
+
throw new UnauthorizedError28("Not authorized.");
|
|
105109
105116
|
}
|
|
105110
105117
|
return caller;
|
|
105111
105118
|
}
|
|
@@ -105117,7 +105124,7 @@ function useNotificationController() {
|
|
|
105117
105124
|
}
|
|
105118
105125
|
try {
|
|
105119
105126
|
if (!await isSuperAdmin(callerId5(req))) {
|
|
105120
|
-
throw new
|
|
105127
|
+
throw new UnauthorizedError28("Not authorized.");
|
|
105121
105128
|
}
|
|
105122
105129
|
const inserted = await _addMany(value.to, {
|
|
105123
105130
|
title: value.title,
|
|
@@ -105718,7 +105725,7 @@ function emptyPersonalEmergencyChain(user) {
|
|
|
105718
105725
|
// src/repositories/personal-emergency-chain.repo.ts
|
|
105719
105726
|
import { ObjectId as ObjectId201 } from "mongodb";
|
|
105720
105727
|
import {
|
|
105721
|
-
AppError as
|
|
105728
|
+
AppError as AppError49,
|
|
105722
105729
|
BadRequestError as BadRequestError275,
|
|
105723
105730
|
InternalServerError as InternalServerError102,
|
|
105724
105731
|
logger as logger236,
|
|
@@ -105755,7 +105762,7 @@ function usePersonalEmergencyChainRepo() {
|
|
|
105755
105762
|
const doc = await collection().findOne({ user: new ObjectId201(user) });
|
|
105756
105763
|
return doc ?? emptyPersonalEmergencyChain(user);
|
|
105757
105764
|
} catch (error) {
|
|
105758
|
-
if (error instanceof
|
|
105765
|
+
if (error instanceof AppError49)
|
|
105759
105766
|
throw error;
|
|
105760
105767
|
logger236.log({ level: "error", message: error.message });
|
|
105761
105768
|
throw new InternalServerError102("Failed to retrieve emergency contacts.");
|
|
@@ -105781,7 +105788,7 @@ function usePersonalEmergencyChainRepo() {
|
|
|
105781
105788
|
);
|
|
105782
105789
|
return doc;
|
|
105783
105790
|
} catch (error) {
|
|
105784
|
-
if (error instanceof
|
|
105791
|
+
if (error instanceof AppError49)
|
|
105785
105792
|
throw error;
|
|
105786
105793
|
logger236.log({ level: "error", message: error.message });
|
|
105787
105794
|
throw new InternalServerError102("Failed to save emergency contacts.");
|