@7365admin1/core 3.53.1 → 3.53.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/dist/index.mjs CHANGED
@@ -16237,6 +16237,8 @@ var MFile = class {
16237
16237
  this.size = value.size ?? 0;
16238
16238
  this.status = value.status ?? "draft";
16239
16239
  this.createdAt = value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString();
16240
+ if (value.createdBy)
16241
+ this.createdBy = value.createdBy.toString();
16240
16242
  }
16241
16243
  };
16242
16244
 
@@ -21988,13 +21990,14 @@ function useFileService() {
21988
21990
  bucket: SPACES_BUCKET,
21989
21991
  forcePathStyle: true
21990
21992
  });
21991
- async function createFile(value, folder = "default") {
21993
+ async function createFile(value, folder = "default", createdBy) {
21992
21994
  const session = useAtlas29.getClient()?.startSession();
21993
21995
  session?.startTransaction();
21994
21996
  const file = {
21995
21997
  name: value.originalname,
21996
21998
  size: value.size ?? (value.buffer ? value.buffer.length : 0),
21997
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
21999
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
22000
+ ...createdBy ? { createdBy } : {}
21998
22001
  };
21999
22002
  try {
22000
22003
  const id = await _createFile(file, session);
@@ -27078,8 +27081,55 @@ function useVerificationController() {
27078
27081
  }
27079
27082
 
27080
27083
  // src/controllers/file.controller.ts
27081
- import { BadRequestError as BadRequestError50, logger as logger35 } from "@7365admin1/node-server-utils";
27084
+ import {
27085
+ BadRequestError as BadRequestError50,
27086
+ UnauthorizedError as UnauthorizedError7,
27087
+ logger as logger35
27088
+ } from "@7365admin1/node-server-utils";
27082
27089
  import Joi27 from "joi";
27090
+
27091
+ // src/utils/file-owner.util.ts
27092
+ function fileOwnerId(file) {
27093
+ return file?.createdBy?.toString?.() ?? "";
27094
+ }
27095
+ function mayDeleteFile(params) {
27096
+ if (!params.ownerId)
27097
+ return true;
27098
+ if (!params.callerId)
27099
+ return false;
27100
+ if (params.callerId === params.ownerId)
27101
+ return true;
27102
+ if (params.callerIsSuperAdmin)
27103
+ return true;
27104
+ const ownerOrgs = new Set((params.ownerOrgIds ?? []).map(String));
27105
+ return (params.callerOrgIds ?? []).some((org) => ownerOrgs.has(String(org)));
27106
+ }
27107
+
27108
+ // src/controllers/file.controller.ts
27109
+ async function requireFileDelete(req, file) {
27110
+ const ownerId = fileOwnerId(file);
27111
+ if (!ownerId)
27112
+ return;
27113
+ const caller = callerId(req);
27114
+ if (!caller)
27115
+ throw new UnauthorizedError7("Not authorized.");
27116
+ if (caller === ownerId)
27117
+ return;
27118
+ const [me, owner] = await Promise.all([
27119
+ resolveInviteActor(caller),
27120
+ resolveInviteActor(ownerId)
27121
+ ]);
27122
+ if (mayDeleteFile({
27123
+ ownerId,
27124
+ callerId: caller,
27125
+ callerIsSuperAdmin: me.isSuperAdmin,
27126
+ callerOrgIds: me.orgIds,
27127
+ ownerOrgIds: owner.orgIds
27128
+ })) {
27129
+ return;
27130
+ }
27131
+ throw new UnauthorizedError7("Not authorized.");
27132
+ }
27083
27133
  function useFileController() {
27084
27134
  const { createFile, deleteFile: _deleteFile } = useFileService();
27085
27135
  const { getFileById: _getFileById } = useFileRepo();
@@ -27089,7 +27139,7 @@ function useFileController() {
27089
27139
  return;
27090
27140
  }
27091
27141
  try {
27092
- const id = await createFile(req.file);
27142
+ const id = await createFile(req.file, "default", callerId(req) || void 0);
27093
27143
  res.status(201).json({ message: "Successfully uploaded file", id });
27094
27144
  return;
27095
27145
  } catch (error) {
@@ -27108,6 +27158,7 @@ function useFileController() {
27108
27158
  return;
27109
27159
  }
27110
27160
  try {
27161
+ await requireFileDelete(req, await _getFileById(_id));
27111
27162
  const message = await _deleteFile(_id);
27112
27163
  res.json({ message });
27113
27164
  return;
@@ -27150,7 +27201,7 @@ import {
27150
27201
  BadRequestError as BadRequestError54,
27151
27202
  logger as logger38,
27152
27203
  NotFoundError as NotFoundError17,
27153
- UnauthorizedError as UnauthorizedError7
27204
+ UnauthorizedError as UnauthorizedError8
27154
27205
  } from "@7365admin1/node-server-utils";
27155
27206
  import Joi31 from "joi";
27156
27207
 
@@ -28423,7 +28474,7 @@ function useOrgController() {
28423
28474
  try {
28424
28475
  const createdBy = callerId(req);
28425
28476
  if (!createdBy)
28426
- throw new UnauthorizedError7("Not authorized.");
28477
+ throw new UnauthorizedError8("Not authorized.");
28427
28478
  const _id = await _add({ ...req.body, createdBy });
28428
28479
  const data = await _getById(_id);
28429
28480
  res.status(201).json({
@@ -30924,7 +30975,7 @@ function useSubscriptionService() {
30924
30975
  import Joi36 from "joi";
30925
30976
  import {
30926
30977
  BadRequestError as BadRequestError70,
30927
- UnauthorizedError as UnauthorizedError8,
30978
+ UnauthorizedError as UnauthorizedError9,
30928
30979
  logger as logger48
30929
30980
  } from "@7365admin1/node-server-utils";
30930
30981
 
@@ -31345,7 +31396,7 @@ function useSubscriptionController() {
31345
31396
  try {
31346
31397
  const subscription = await _getSubscriptionById(subscriptionId);
31347
31398
  if (!subscription) {
31348
- throw new UnauthorizedError8("Not authorized.");
31399
+ throw new UnauthorizedError9("Not authorized.");
31349
31400
  }
31350
31401
  await requireOrgAccess(req, subscription.org?.toString());
31351
31402
  const _res = await _updateSubscriptionSeats({
@@ -41677,7 +41728,7 @@ function useCustomerSiteService() {
41677
41728
  import Joi59 from "joi";
41678
41729
  import {
41679
41730
  BadRequestError as BadRequestError106,
41680
- UnauthorizedError as UnauthorizedError9,
41731
+ UnauthorizedError as UnauthorizedError10,
41681
41732
  logger as logger78
41682
41733
  } from "@7365admin1/node-server-utils";
41683
41734
  async function requireEitherOrg(req, ...orgs) {
@@ -41686,7 +41737,7 @@ async function requireEitherOrg(req, ...orgs) {
41686
41737
  if (actor.isSuperAdmin)
41687
41738
  return;
41688
41739
  if (wanted.length === 0 || !wanted.some((org) => actor.orgIds.includes(org))) {
41689
- throw new UnauthorizedError9("Not authorized.");
41740
+ throw new UnauthorizedError10("Not authorized.");
41690
41741
  }
41691
41742
  }
41692
41743
  function useCustomerSiteController() {
@@ -44899,7 +44950,7 @@ import {
44899
44950
  BadRequestError as BadRequestError120,
44900
44951
  InternalServerError as InternalServerError42,
44901
44952
  NotFoundError as NotFoundError34,
44902
- UnauthorizedError as UnauthorizedError10,
44953
+ UnauthorizedError as UnauthorizedError11,
44903
44954
  logger as logger90
44904
44955
  } from "@7365admin1/node-server-utils";
44905
44956
 
@@ -48433,8 +48484,8 @@ function useHidAmicoService() {
48433
48484
  await siteAccess.authorizeSite({ siteId, userId: value.userId, permissions });
48434
48485
  }
48435
48486
  } catch (error) {
48436
- if (error instanceof UnauthorizedError10) {
48437
- throw new UnauthorizedError10("You do not have permission to manage HID access at this site.");
48487
+ if (error instanceof UnauthorizedError11) {
48488
+ throw new UnauthorizedError11("You do not have permission to manage HID access at this site.");
48438
48489
  }
48439
48490
  throw error;
48440
48491
  }
@@ -48458,7 +48509,7 @@ function useHidAmicoService() {
48458
48509
  try {
48459
48510
  await authorizeSiteForCaller(String(reader.site || ""), userId);
48460
48511
  } catch (error) {
48461
- if (error instanceof UnauthorizedError10)
48512
+ if (error instanceof UnauthorizedError11)
48462
48513
  throw error;
48463
48514
  throw new NotFoundError34(HID_READER_NOT_FOUND);
48464
48515
  }
@@ -48510,10 +48561,10 @@ function useHidAmicoService() {
48510
48561
  async function assertUserReaderPermission(reader, userId, options = {}) {
48511
48562
  const permission = await getReaderPermissionForUser(reader, userId);
48512
48563
  if (!permission.granted) {
48513
- throw new UnauthorizedError10("You do not have HID access permission for this reader.");
48564
+ throw new UnauthorizedError11("You do not have HID access permission for this reader.");
48514
48565
  }
48515
48566
  if (options.intercom && !permission.intercom) {
48516
- throw new UnauthorizedError10("You do not have HID intercom permission for this reader.");
48567
+ throw new UnauthorizedError11("You do not have HID intercom permission for this reader.");
48517
48568
  }
48518
48569
  return permission;
48519
48570
  }
@@ -49851,10 +49902,10 @@ function useHidAmicoService() {
49851
49902
  const hasActiveMembership = memberships.some((membership) => membership.status !== "deleted" && membership.status !== "inactive");
49852
49903
  const resolvedIssuer = issuer || (hasResidentMembership ? "resident" : "property_management");
49853
49904
  if (resolvedIssuer === "resident" && !hasResidentMembership) {
49854
- throw new UnauthorizedError10("Only a Resident account can issue a Resident visitor QR code.");
49905
+ throw new UnauthorizedError11("Only a Resident account can issue a Resident visitor QR code.");
49855
49906
  }
49856
49907
  if (resolvedIssuer === "property_management" && !hasActiveMembership) {
49857
- throw new UnauthorizedError10("Only a site Property Management account can issue this visitor QR code.");
49908
+ throw new UnauthorizedError11("Only a site Property Management account can issue this visitor QR code.");
49858
49909
  }
49859
49910
  const configuredGateIds = site?.metadata?.hidQrCodePass?.qrGatePermissions?.[resolvedIssuer === "resident" ? "resident" : "propertyManagement"] || [];
49860
49911
  const gateReaderIds = configuredGateIds.filter((readerId) => typeof readerId === "string" && /^[a-f0-9]{24}$/i.test(readerId)).map(String);
@@ -52447,7 +52498,7 @@ function useVisitorTransactionService() {
52447
52498
  import Joi68 from "joi";
52448
52499
  import moment5 from "moment-timezone";
52449
52500
  import { ObjectId as ObjectId89 } from "mongodb";
52450
- import { BadRequestError as BadRequestError123, NotFoundError as NotFoundError36, InternalServerError as InternalServerError44, UnauthorizedError as UnauthorizedError11, logger as logger94 } from "@7365admin1/node-server-utils";
52501
+ import { BadRequestError as BadRequestError123, NotFoundError as NotFoundError36, InternalServerError as InternalServerError44, UnauthorizedError as UnauthorizedError12, logger as logger94 } from "@7365admin1/node-server-utils";
52451
52502
 
52452
52503
  // src/models/visitor-invite.model.ts
52453
52504
  import Joi66 from "joi";
@@ -57231,7 +57282,7 @@ function useVisitorTransactionController() {
57231
57282
  }
57232
57283
  const inviterUserId = callerId(req);
57233
57284
  if (!inviterUserId) {
57234
- next(new UnauthorizedError11("Not authorized."));
57285
+ next(new UnauthorizedError12("Not authorized."));
57235
57286
  return;
57236
57287
  }
57237
57288
  try {
@@ -57795,7 +57846,7 @@ function useGuestManagementController() {
57795
57846
  // src/controllers/person.controller.ts
57796
57847
  import Joi71 from "joi";
57797
57848
  import { BadRequestError as BadRequestError126, logger as logger97 } from "@7365admin1/node-server-utils";
57798
- import { NotFoundError as NotFoundError37, UnauthorizedError as UnauthorizedError12 } from "@7365admin1/node-server-utils";
57849
+ import { NotFoundError as NotFoundError37, UnauthorizedError as UnauthorizedError13 } from "@7365admin1/node-server-utils";
57799
57850
  function usePersonController() {
57800
57851
  const {
57801
57852
  getAll: _getAll,
@@ -57829,7 +57880,7 @@ function usePersonController() {
57829
57880
  }
57830
57881
  const org = person.org?.toString() ?? "";
57831
57882
  if (!org || !actor.orgIds.includes(org)) {
57832
- throw new UnauthorizedError12("Not authorized.");
57883
+ throw new UnauthorizedError13("Not authorized.");
57833
57884
  }
57834
57885
  return actor;
57835
57886
  }
@@ -57955,7 +58006,7 @@ function usePersonController() {
57955
58006
  });
57956
58007
  } else if (org) {
57957
58008
  if (!actor.orgIds.includes(org)) {
57958
- throw new UnauthorizedError12("Not authorized.");
58009
+ throw new UnauthorizedError13("Not authorized.");
57959
58010
  }
57960
58011
  } else {
57961
58012
  orgs = actor.orgIds;
@@ -62275,7 +62326,7 @@ function useSiteFacilityService() {
62275
62326
  import {
62276
62327
  BadRequestError as BadRequestError148,
62277
62328
  NotFoundError as NotFoundError43,
62278
- UnauthorizedError as UnauthorizedError13,
62329
+ UnauthorizedError as UnauthorizedError14,
62279
62330
  logger as logger116
62280
62331
  } from "@7365admin1/node-server-utils";
62281
62332
  import Joi83 from "joi";
@@ -62362,7 +62413,7 @@ function useSiteFacilityController() {
62362
62413
  } else {
62363
62414
  const { actor } = await siteReachOf(req);
62364
62415
  if (!actor.isSuperAdmin)
62365
- throw new UnauthorizedError13("Not authorized.");
62416
+ throw new UnauthorizedError14("Not authorized.");
62366
62417
  }
62367
62418
  const data = await _getAll({
62368
62419
  search,
@@ -65397,7 +65448,7 @@ function useBulletinBoardService() {
65397
65448
  import {
65398
65449
  BadRequestError as BadRequestError157,
65399
65450
  NotFoundError as NotFoundError51,
65400
- UnauthorizedError as UnauthorizedError14,
65451
+ UnauthorizedError as UnauthorizedError15,
65401
65452
  logger as logger125
65402
65453
  } from "@7365admin1/node-server-utils";
65403
65454
  import Joi91 from "joi";
@@ -65433,7 +65484,7 @@ function useBulletinBoardController() {
65433
65484
  } else {
65434
65485
  const { canReach } = await siteReachOf(req);
65435
65486
  if (!await canReach(scopeOf(value))) {
65436
- throw new UnauthorizedError14("Not authorized.");
65487
+ throw new UnauthorizedError15("Not authorized.");
65437
65488
  }
65438
65489
  }
65439
65490
  const data = await _add(value);
@@ -65990,7 +66041,7 @@ import { BadRequestError as BadRequestError163, logger as logger131 } from "@736
65990
66041
  import {
65991
66042
  BadRequestError as BadRequestError162,
65992
66043
  logger as logger130,
65993
- UnauthorizedError as UnauthorizedError15,
66044
+ UnauthorizedError as UnauthorizedError16,
65994
66045
  useAtlas as useAtlas88
65995
66046
  } from "@7365admin1/node-server-utils";
65996
66047
 
@@ -66374,7 +66425,7 @@ function useSiteBillingItemService() {
66374
66425
  function assertUnitAtSite(buildingUnit, site) {
66375
66426
  const siteId = site?.toString?.() ?? "";
66376
66427
  if (!siteId || (buildingUnit?.site?.toString() ?? "") !== siteId) {
66377
- throw new UnauthorizedError15("Not authorized.");
66428
+ throw new UnauthorizedError16("Not authorized.");
66378
66429
  }
66379
66430
  }
66380
66431
  async function add(value) {
@@ -66545,7 +66596,7 @@ function useSiteBillingItemService() {
66545
66596
  message: error.message
66546
66597
  });
66547
66598
  await session.abortTransaction();
66548
- if (error instanceof BadRequestError162 || error instanceof UnauthorizedError15) {
66599
+ if (error instanceof BadRequestError162 || error instanceof UnauthorizedError16) {
66549
66600
  throw error;
66550
66601
  }
66551
66602
  throw new BadRequestError162("Failed to update Site Billing Item.");
@@ -68514,7 +68565,7 @@ import Joi99 from "joi";
68514
68565
 
68515
68566
  // src/utils/resident-unit.util.ts
68516
68567
  import { ObjectId as ObjectId123 } from "mongodb";
68517
- import { UnauthorizedError as UnauthorizedError16, useAtlas as useAtlas94 } from "@7365admin1/node-server-utils";
68568
+ import { UnauthorizedError as UnauthorizedError17, useAtlas as useAtlas94 } from "@7365admin1/node-server-utils";
68518
68569
  async function requireOwnUnit(req, site, unitId) {
68519
68570
  const actor = await resolveInviteActor(callerId(req));
68520
68571
  if (actor.isSuperAdmin)
@@ -68522,7 +68573,7 @@ async function requireOwnUnit(req, site, unitId) {
68522
68573
  const unit = unitId?.toString?.() ?? "";
68523
68574
  const siteId = site?.toString?.() ?? "";
68524
68575
  if (!ObjectId123.isValid(unit) || !ObjectId123.isValid(siteId) || !actor.id) {
68525
- throw new UnauthorizedError16("Not authorized.");
68576
+ throw new UnauthorizedError17("Not authorized.");
68526
68577
  }
68527
68578
  const db2 = useAtlas94.getDb();
68528
68579
  if (!db2)
@@ -68534,7 +68585,7 @@ async function requireOwnUnit(req, site, unitId) {
68534
68585
  status: { $ne: "deleted" }
68535
68586
  });
68536
68587
  if (!own)
68537
- throw new UnauthorizedError16("Not authorized.");
68588
+ throw new UnauthorizedError17("Not authorized.");
68538
68589
  }
68539
68590
 
68540
68591
  // src/controllers/site-unit-billing.controller.ts
@@ -77086,7 +77137,7 @@ function useOnlineFormRepo() {
77086
77137
  import {
77087
77138
  BadRequestError as BadRequestError203,
77088
77139
  NotFoundError as NotFoundError71,
77089
- UnauthorizedError as UnauthorizedError17,
77140
+ UnauthorizedError as UnauthorizedError18,
77090
77141
  logger as logger169
77091
77142
  } from "@7365admin1/node-server-utils";
77092
77143
  import Joi122 from "joi";
@@ -77158,10 +77209,10 @@ function useOnlineFormController() {
77158
77209
  if (site) {
77159
77210
  await requireSiteReach(req, site);
77160
77211
  } else if (!actor.isSuperAdmin) {
77161
- throw new UnauthorizedError17("Not authorized.");
77212
+ throw new UnauthorizedError18("Not authorized.");
77162
77213
  }
77163
77214
  if (org && !actor.isSuperAdmin && !actor.orgIds.includes(org)) {
77164
- throw new UnauthorizedError17("Not authorized.");
77215
+ throw new UnauthorizedError18("Not authorized.");
77165
77216
  }
77166
77217
  const data = await _getAll({ search, page, limit, status, org, site });
77167
77218
  res.json(data);
@@ -77226,7 +77277,7 @@ function useOnlineFormController() {
77226
77277
  if (payload.org) {
77227
77278
  const { actor } = await siteReachOf(req);
77228
77279
  if (!actor.isSuperAdmin && !actor.orgIds.includes(payload.org)) {
77229
- throw new UnauthorizedError17("Not authorized.");
77280
+ throw new UnauthorizedError18("Not authorized.");
77230
77281
  }
77231
77282
  }
77232
77283
  await _updateOnlineFormById(_id, payload);
@@ -84472,7 +84523,7 @@ import {
84472
84523
  BadRequestError as BadRequestError228,
84473
84524
  NotFoundError as NotFoundError78,
84474
84525
  InternalServerError as InternalServerError81,
84475
- UnauthorizedError as UnauthorizedError18,
84526
+ UnauthorizedError as UnauthorizedError19,
84476
84527
  useAtlas as useAtlas131,
84477
84528
  hashPassword as hashPassword4
84478
84529
  } from "@7365admin1/node-server-utils";
@@ -84741,10 +84792,10 @@ function useVerificationServiceV2() {
84741
84792
  const org = await getOrgById(orgId);
84742
84793
  const actor = await resolveInviteActor(invitedBy);
84743
84794
  if (!actor.id) {
84744
- throw new UnauthorizedError18("Sign in to continue.");
84795
+ throw new UnauthorizedError19("Sign in to continue.");
84745
84796
  }
84746
84797
  if (!actor.isSuperAdmin && !actor.orgIds.includes(orgId)) {
84747
- throw new UnauthorizedError18(
84798
+ throw new UnauthorizedError19(
84748
84799
  "You can only invite service providers to your own organisation's sites."
84749
84800
  );
84750
84801
  }
@@ -89147,7 +89198,7 @@ import Joi158 from "joi";
89147
89198
  import { ObjectId as ObjectId178 } from "mongodb";
89148
89199
  import {
89149
89200
  InternalServerError as InternalServerError93,
89150
- UnauthorizedError as UnauthorizedError19,
89201
+ UnauthorizedError as UnauthorizedError20,
89151
89202
  useAtlas as useAtlas145
89152
89203
  } from "@7365admin1/node-server-utils";
89153
89204
  function db() {
@@ -89163,7 +89214,7 @@ function asObjectId(value) {
89163
89214
  function requireCaller(req) {
89164
89215
  const id = callerId(req);
89165
89216
  if (!id || !ObjectId178.isValid(id)) {
89166
- throw new UnauthorizedError19("Not authorized.");
89217
+ throw new UnauthorizedError20("Not authorized.");
89167
89218
  }
89168
89219
  return id;
89169
89220
  }
@@ -89171,7 +89222,7 @@ function requireSelfId(req, claimed) {
89171
89222
  const caller = requireCaller(req);
89172
89223
  const asked = claimed?.toString?.() ?? "";
89173
89224
  if (!asked || asked !== caller) {
89174
- throw new UnauthorizedError19("Not authorized.");
89225
+ throw new UnauthorizedError20("Not authorized.");
89175
89226
  }
89176
89227
  return caller;
89177
89228
  }
@@ -89179,11 +89230,11 @@ async function requireOwnChannel(req, channelId) {
89179
89230
  const caller = requireCaller(req);
89180
89231
  const _id = asObjectId(channelId);
89181
89232
  if (!_id)
89182
- throw new UnauthorizedError19("Not authorized.");
89233
+ throw new UnauthorizedError20("Not authorized.");
89183
89234
  const channel = await db().collection("channel-preloved").findOne({ _id }, { projection: { senderId: 1, receiverId: 1, postId: 1 } });
89184
89235
  const participants = [channel?.senderId, channel?.receiverId].map((id) => id?.toString?.() ?? "").filter(Boolean);
89185
89236
  if (!channel || !participants.includes(caller)) {
89186
- throw new UnauthorizedError19("Not authorized.");
89237
+ throw new UnauthorizedError20("Not authorized.");
89187
89238
  }
89188
89239
  return { caller, channel };
89189
89240
  }
@@ -89191,10 +89242,10 @@ async function requireOwnChatMessage(req, chatId) {
89191
89242
  const caller = requireCaller(req);
89192
89243
  const _id = asObjectId(chatId);
89193
89244
  if (!_id)
89194
- throw new UnauthorizedError19("Not authorized.");
89245
+ throw new UnauthorizedError20("Not authorized.");
89195
89246
  const message = await db().collection("chat-preloved").findOne({ _id }, { projection: { senderId: 1 } });
89196
89247
  if (!message || message.senderId?.toString?.() !== caller) {
89197
- throw new UnauthorizedError19("Not authorized.");
89248
+ throw new UnauthorizedError20("Not authorized.");
89198
89249
  }
89199
89250
  return caller;
89200
89251
  }
@@ -89620,7 +89671,7 @@ function useBidPrelovedService() {
89620
89671
  // src/controllers/bid-preloved.controller.ts
89621
89672
  import {
89622
89673
  BadRequestError as BadRequestError251,
89623
- UnauthorizedError as UnauthorizedError20,
89674
+ UnauthorizedError as UnauthorizedError21,
89624
89675
  logger as logger212
89625
89676
  } from "@7365admin1/node-server-utils";
89626
89677
  import Joi161 from "joi";
@@ -89672,7 +89723,7 @@ function useBidPrelovedController() {
89672
89723
  const bid = await _getById(params.id);
89673
89724
  const seller = await sellerOfPost(bid?.postId);
89674
89725
  if (!seller || seller !== caller) {
89675
- throw new UnauthorizedError20("Not authorized.");
89726
+ throw new UnauthorizedError21("Not authorized.");
89676
89727
  }
89677
89728
  const data = await _updateStatus(params.id, body.status);
89678
89729
  res.status(200).json(data);
@@ -89696,7 +89747,7 @@ function useBidPrelovedController() {
89696
89747
  const data = await _getById(params.id);
89697
89748
  const seller = await sellerOfPost(data?.postId);
89698
89749
  if (data?.buyerId?.toString?.() !== caller && seller !== caller) {
89699
- throw new UnauthorizedError20("Not authorized.");
89750
+ throw new UnauthorizedError21("Not authorized.");
89700
89751
  }
89701
89752
  res.status(200).json(data);
89702
89753
  } catch (error2) {
@@ -90094,7 +90145,7 @@ function useFormEntryRepo() {
90094
90145
  import {
90095
90146
  BadRequestError as BadRequestError253,
90096
90147
  NotFoundError as NotFoundError89,
90097
- UnauthorizedError as UnauthorizedError21,
90148
+ UnauthorizedError as UnauthorizedError22,
90098
90149
  logger as logger214
90099
90150
  } from "@7365admin1/node-server-utils";
90100
90151
  import Joi163 from "joi";
@@ -90204,7 +90255,7 @@ function useFormEntryController() {
90204
90255
  } else {
90205
90256
  const { actor } = await siteReachOf(req);
90206
90257
  if (!actor.isSuperAdmin)
90207
- throw new UnauthorizedError21("Not authorized.");
90258
+ throw new UnauthorizedError22("Not authorized.");
90208
90259
  }
90209
90260
  const data = await _getAll({ search, page, limit, status, org, site });
90210
90261
  res.json(data);
@@ -90255,7 +90306,7 @@ function useFormEntryController() {
90255
90306
  await requireSiteReach(req, rest.site);
90256
90307
  delete rest.userId;
90257
90308
  if (isOwner && rest.status && rest.status !== "pending") {
90258
- throw new UnauthorizedError21("Not authorized.");
90309
+ throw new UnauthorizedError22("Not authorized.");
90259
90310
  }
90260
90311
  await _updateFormEntryById(_id, rest);
90261
90312
  res.json({ message: "Successfully updated online form." });
@@ -90312,7 +90363,7 @@ function useFormEntryController() {
90312
90363
  async function residentFormSubmission(req, res, next) {
90313
90364
  const userId = callerId(req);
90314
90365
  if (!userId) {
90315
- next(new UnauthorizedError21("Not authorized."));
90366
+ next(new UnauthorizedError22("Not authorized."));
90316
90367
  return;
90317
90368
  }
90318
90369
  const payload = { ...req.body, userId };
@@ -91543,7 +91594,7 @@ function useHidAmicoController() {
91543
91594
  import {
91544
91595
  BadRequestError as BadRequestError256,
91545
91596
  logger as logger216,
91546
- UnauthorizedError as UnauthorizedError22
91597
+ UnauthorizedError as UnauthorizedError23
91547
91598
  } from "@7365admin1/node-server-utils";
91548
91599
  import Joi165 from "joi";
91549
91600
  function usePlatformTermsController() {
@@ -91559,7 +91610,7 @@ function usePlatformTermsController() {
91559
91610
  async function requireOwnRecord(req, user, { staffMayRead = false } = {}) {
91560
91611
  const id = callerId(req);
91561
91612
  if (!id) {
91562
- throw new UnauthorizedError22("Not authorized.");
91613
+ throw new UnauthorizedError23("Not authorized.");
91563
91614
  }
91564
91615
  if (id === user) {
91565
91616
  return id;
@@ -91567,7 +91618,7 @@ function usePlatformTermsController() {
91567
91618
  if (staffMayRead) {
91568
91619
  return await requirePlatformStaff(req);
91569
91620
  }
91570
- throw new UnauthorizedError22("Not authorized.");
91621
+ throw new UnauthorizedError23("Not authorized.");
91571
91622
  }
91572
91623
  async function getLatest(_req, res, next) {
91573
91624
  try {
@@ -91773,7 +91824,7 @@ function useConsoleAuditController() {
91773
91824
  // src/controllers/notification.controller.ts
91774
91825
  import {
91775
91826
  BadRequestError as BadRequestError258,
91776
- UnauthorizedError as UnauthorizedError23,
91827
+ UnauthorizedError as UnauthorizedError24,
91777
91828
  logger as logger218
91778
91829
  } from "@7365admin1/node-server-utils";
91779
91830
  function useNotificationController() {
@@ -91791,10 +91842,10 @@ function useNotificationController() {
91791
91842
  function inboxOwner(req, claimed) {
91792
91843
  const caller = callerId5(req);
91793
91844
  if (!caller) {
91794
- throw new UnauthorizedError23("Not authorized.");
91845
+ throw new UnauthorizedError24("Not authorized.");
91795
91846
  }
91796
91847
  if (claimed && claimed !== caller) {
91797
- throw new UnauthorizedError23("Not authorized.");
91848
+ throw new UnauthorizedError24("Not authorized.");
91798
91849
  }
91799
91850
  return caller;
91800
91851
  }
@@ -91806,7 +91857,7 @@ function useNotificationController() {
91806
91857
  }
91807
91858
  try {
91808
91859
  if (!await isSuperAdmin(callerId5(req))) {
91809
- throw new UnauthorizedError23("Not authorized.");
91860
+ throw new UnauthorizedError24("Not authorized.");
91810
91861
  }
91811
91862
  const inserted = await _addMany(value.to, {
91812
91863
  title: value.title,