@7365admin1/core 3.52.13 → 3.52.14

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
@@ -10965,6 +10965,7 @@ var orgSchema = Joi8.object({
10965
10965
  busInst: Joi8.string().optional().allow("", null),
10966
10966
  status: Joi8.string().optional().allow("", null),
10967
10967
  defaultSite: Joi8.string().hex().optional().allow("", null),
10968
+ createdBy: Joi8.string().hex().optional().allow("", null),
10968
10969
  terms: Joi8.string().optional().allow("", null),
10969
10970
  policies: Joi8.string().optional().allow("", null),
10970
10971
  createdAt: Joi8.string().optional().allow("", null),
@@ -10994,6 +10995,7 @@ function MOrg(value) {
10994
10995
  busInst: value.busInst,
10995
10996
  status: value.status || "active",
10996
10997
  defaultSite: value.defaultSite,
10998
+ createdBy: value.createdBy && ObjectId18.isValid(value.createdBy.toString()) ? new ObjectId18(value.createdBy.toString()) : void 0,
10997
10999
  terms: value.terms ?? "",
10998
11000
  policies: value.policies ?? "",
10999
11001
  createdAt: value.createdAt || /* @__PURE__ */ new Date(),
@@ -13496,6 +13498,30 @@ async function orgLevelRoles(db2, roles) {
13496
13498
  }
13497
13499
  return orgLevel;
13498
13500
  }
13501
+ async function hasOrgOwnership(userId, orgId) {
13502
+ const id = userId?.toString() ?? "";
13503
+ const org = orgId?.toString() ?? "";
13504
+ if (!id || !org || !ObjectId25.isValid(id) || !ObjectId25.isValid(org)) {
13505
+ return false;
13506
+ }
13507
+ const db2 = useAtlas16.getDb();
13508
+ if (!db2)
13509
+ return false;
13510
+ const user = await db2.collection("users").findOne({ _id: new ObjectId25(id) }, { projection: { email: 1 } });
13511
+ const email = user?.email?.toString?.().trim() ?? "";
13512
+ const reach = [
13513
+ { createdBy: new ObjectId25(id) },
13514
+ // older rows may carry the id as a string
13515
+ { createdBy: id }
13516
+ ];
13517
+ if (email)
13518
+ reach.push({ email });
13519
+ const found = await db2.collection("organizations").findOne(
13520
+ { _id: new ObjectId25(org), $or: reach },
13521
+ { projection: { _id: 1 }, collation: { locale: "en", strength: 2 } }
13522
+ );
13523
+ return Boolean(found);
13524
+ }
13499
13525
 
13500
13526
  // src/services/service-provider-invite.service.ts
13501
13527
  import {
@@ -18009,15 +18035,7 @@ async function requireSelfOrPlatformStaff(req, userId) {
18009
18035
  return await requirePlatformStaff(req);
18010
18036
  }
18011
18037
  async function requireOrgAccess(req, orgId) {
18012
- const id = callerId(req);
18013
- if (!id)
18014
- throw new UnauthorizedError3("Not authorized.");
18015
- const actor = await resolveInviteActor(id);
18016
- const org = orgId?.toString() ?? "";
18017
- if (!actor.isSuperAdmin && !(org && actor.orgIds.includes(org))) {
18018
- throw new UnauthorizedError3("Not authorized.");
18019
- }
18020
- return id;
18038
+ return await requireOrgReach(req, orgId);
18021
18039
  }
18022
18040
  async function requirePlatformOwner(req) {
18023
18041
  const id = callerId(req);
@@ -18038,6 +18056,8 @@ async function requireOrgReach(req, orgId) {
18038
18056
  return id;
18039
18057
  if (org && await hasOrgInvitation(id, org))
18040
18058
  return id;
18059
+ if (org && await hasOrgOwnership(id, org))
18060
+ return id;
18041
18061
  throw new UnauthorizedError3("Not authorized.");
18042
18062
  }
18043
18063
  async function requireInviteReach(req, org, app) {
@@ -18048,6 +18068,11 @@ async function requireInviteReach(req, org, app) {
18048
18068
  if (org)
18049
18069
  await requireOrgReach(req, org);
18050
18070
  }
18071
+ async function requireUserFieldWrite(req, userId, field) {
18072
+ if (field === "email")
18073
+ return await requirePlatformStaff(req);
18074
+ return await requireSelfOrPlatformStaff(req, userId);
18075
+ }
18051
18076
 
18052
18077
  // src/utils/user-response.util.ts
18053
18078
  function withoutCredentials(user) {
@@ -18308,7 +18333,7 @@ function useUserController() {
18308
18333
  return;
18309
18334
  }
18310
18335
  try {
18311
- await requireSelfOrPlatformStaff(req, _id);
18336
+ await requireUserFieldWrite(req, _id, payload.field);
18312
18337
  let message;
18313
18338
  if (payload.field === "plateNumber") {
18314
18339
  message = await updatePlateNumberByUserId(
@@ -27062,7 +27087,8 @@ function useFileController() {
27062
27087
  import {
27063
27088
  BadRequestError as BadRequestError54,
27064
27089
  logger as logger38,
27065
- NotFoundError as NotFoundError17
27090
+ NotFoundError as NotFoundError17,
27091
+ UnauthorizedError as UnauthorizedError7
27066
27092
  } from "@7365admin1/node-server-utils";
27067
27093
  import Joi31 from "joi";
27068
27094
 
@@ -28266,8 +28292,8 @@ function useOrgController() {
28266
28292
  return;
28267
28293
  }
28268
28294
  try {
28269
- await requirePlatformStaff(req);
28270
- await _add(req.body);
28295
+ const createdBy = await requirePlatformStaff(req);
28296
+ await _add({ ...req.body, createdBy });
28271
28297
  res.status(201).json({ message: "Successfully created organization." });
28272
28298
  return;
28273
28299
  } catch (error2) {
@@ -28333,7 +28359,10 @@ function useOrgController() {
28333
28359
  return;
28334
28360
  }
28335
28361
  try {
28336
- const _id = await _add(req.body);
28362
+ const createdBy = callerId(req);
28363
+ if (!createdBy)
28364
+ throw new UnauthorizedError7("Not authorized.");
28365
+ const _id = await _add({ ...req.body, createdBy });
28337
28366
  const data = await _getById(_id);
28338
28367
  res.status(201).json({
28339
28368
  message: "Successfully created organization.",
@@ -30833,7 +30862,7 @@ function useSubscriptionService() {
30833
30862
  import Joi36 from "joi";
30834
30863
  import {
30835
30864
  BadRequestError as BadRequestError70,
30836
- UnauthorizedError as UnauthorizedError7,
30865
+ UnauthorizedError as UnauthorizedError8,
30837
30866
  logger as logger48
30838
30867
  } from "@7365admin1/node-server-utils";
30839
30868
 
@@ -31252,7 +31281,7 @@ function useSubscriptionController() {
31252
31281
  try {
31253
31282
  const subscription = await _getSubscriptionById(subscriptionId);
31254
31283
  if (!subscription) {
31255
- throw new UnauthorizedError7("Not authorized.");
31284
+ throw new UnauthorizedError8("Not authorized.");
31256
31285
  }
31257
31286
  await requireOrgAccess(req, subscription.org?.toString());
31258
31287
  const _res = await _updateSubscriptionSeats({
@@ -41583,7 +41612,7 @@ function useCustomerSiteService() {
41583
41612
  import Joi59 from "joi";
41584
41613
  import {
41585
41614
  BadRequestError as BadRequestError106,
41586
- UnauthorizedError as UnauthorizedError8,
41615
+ UnauthorizedError as UnauthorizedError9,
41587
41616
  logger as logger78
41588
41617
  } from "@7365admin1/node-server-utils";
41589
41618
  async function requireEitherOrg(req, ...orgs) {
@@ -41592,7 +41621,7 @@ async function requireEitherOrg(req, ...orgs) {
41592
41621
  if (actor.isSuperAdmin)
41593
41622
  return;
41594
41623
  if (wanted.length === 0 || !wanted.some((org) => actor.orgIds.includes(org))) {
41595
- throw new UnauthorizedError8("Not authorized.");
41624
+ throw new UnauthorizedError9("Not authorized.");
41596
41625
  }
41597
41626
  }
41598
41627
  function useCustomerSiteController() {
@@ -44805,7 +44834,7 @@ import {
44805
44834
  BadRequestError as BadRequestError120,
44806
44835
  InternalServerError as InternalServerError42,
44807
44836
  NotFoundError as NotFoundError34,
44808
- UnauthorizedError as UnauthorizedError9,
44837
+ UnauthorizedError as UnauthorizedError10,
44809
44838
  logger as logger90
44810
44839
  } from "@7365admin1/node-server-utils";
44811
44840
 
@@ -48339,8 +48368,8 @@ function useHidAmicoService() {
48339
48368
  await siteAccess.authorizeSite({ siteId, userId: value.userId, permissions });
48340
48369
  }
48341
48370
  } catch (error) {
48342
- if (error instanceof UnauthorizedError9) {
48343
- throw new UnauthorizedError9("You do not have permission to manage HID access at this site.");
48371
+ if (error instanceof UnauthorizedError10) {
48372
+ throw new UnauthorizedError10("You do not have permission to manage HID access at this site.");
48344
48373
  }
48345
48374
  throw error;
48346
48375
  }
@@ -48364,7 +48393,7 @@ function useHidAmicoService() {
48364
48393
  try {
48365
48394
  await authorizeSiteForCaller(String(reader.site || ""), userId);
48366
48395
  } catch (error) {
48367
- if (error instanceof UnauthorizedError9)
48396
+ if (error instanceof UnauthorizedError10)
48368
48397
  throw error;
48369
48398
  throw new NotFoundError34(HID_READER_NOT_FOUND);
48370
48399
  }
@@ -48416,10 +48445,10 @@ function useHidAmicoService() {
48416
48445
  async function assertUserReaderPermission(reader, userId, options = {}) {
48417
48446
  const permission = await getReaderPermissionForUser(reader, userId);
48418
48447
  if (!permission.granted) {
48419
- throw new UnauthorizedError9("You do not have HID access permission for this reader.");
48448
+ throw new UnauthorizedError10("You do not have HID access permission for this reader.");
48420
48449
  }
48421
48450
  if (options.intercom && !permission.intercom) {
48422
- throw new UnauthorizedError9("You do not have HID intercom permission for this reader.");
48451
+ throw new UnauthorizedError10("You do not have HID intercom permission for this reader.");
48423
48452
  }
48424
48453
  return permission;
48425
48454
  }
@@ -49757,10 +49786,10 @@ function useHidAmicoService() {
49757
49786
  const hasActiveMembership = memberships.some((membership) => membership.status !== "deleted" && membership.status !== "inactive");
49758
49787
  const resolvedIssuer = issuer || (hasResidentMembership ? "resident" : "property_management");
49759
49788
  if (resolvedIssuer === "resident" && !hasResidentMembership) {
49760
- throw new UnauthorizedError9("Only a Resident account can issue a Resident visitor QR code.");
49789
+ throw new UnauthorizedError10("Only a Resident account can issue a Resident visitor QR code.");
49761
49790
  }
49762
49791
  if (resolvedIssuer === "property_management" && !hasActiveMembership) {
49763
- throw new UnauthorizedError9("Only a site Property Management account can issue this visitor QR code.");
49792
+ throw new UnauthorizedError10("Only a site Property Management account can issue this visitor QR code.");
49764
49793
  }
49765
49794
  const configuredGateIds = site?.metadata?.hidQrCodePass?.qrGatePermissions?.[resolvedIssuer === "resident" ? "resident" : "propertyManagement"] || [];
49766
49795
  const gateReaderIds = configuredGateIds.filter((readerId) => typeof readerId === "string" && /^[a-f0-9]{24}$/i.test(readerId)).map(String);
@@ -52159,7 +52188,7 @@ function useVisitorTransactionService() {
52159
52188
  unitName: unit?.name,
52160
52189
  org: inviter?.org?.toString(),
52161
52190
  site: inviter?.site.toString(),
52162
- status: value?.type === "contractor" ? isAutoApprovedInvitation ? "approved" /* APPROVED */ : "pending" /* PENDING */ : "pending" /* PENDING */,
52191
+ status: value?.type === "contractor" ? isAutoApprovedInvitation ? "approved" /* APPROVED */ : "pending" /* PENDING */ : "approved" /* APPROVED */,
52163
52192
  inviterId: userId
52164
52193
  };
52165
52194
  const leadId = new ObjectId86();
@@ -57522,7 +57551,7 @@ function useGuestManagementController() {
57522
57551
  // src/controllers/person.controller.ts
57523
57552
  import Joi70 from "joi";
57524
57553
  import { BadRequestError as BadRequestError126, logger as logger97 } from "@7365admin1/node-server-utils";
57525
- import { NotFoundError as NotFoundError37, UnauthorizedError as UnauthorizedError10 } from "@7365admin1/node-server-utils";
57554
+ import { NotFoundError as NotFoundError37, UnauthorizedError as UnauthorizedError11 } from "@7365admin1/node-server-utils";
57526
57555
  function usePersonController() {
57527
57556
  const {
57528
57557
  getAll: _getAll,
@@ -57556,7 +57585,7 @@ function usePersonController() {
57556
57585
  }
57557
57586
  const org = person.org?.toString() ?? "";
57558
57587
  if (!org || !actor.orgIds.includes(org)) {
57559
- throw new UnauthorizedError10("Not authorized.");
57588
+ throw new UnauthorizedError11("Not authorized.");
57560
57589
  }
57561
57590
  return actor;
57562
57591
  }
@@ -57682,7 +57711,7 @@ function usePersonController() {
57682
57711
  });
57683
57712
  } else if (org) {
57684
57713
  if (!actor.orgIds.includes(org)) {
57685
- throw new UnauthorizedError10("Not authorized.");
57714
+ throw new UnauthorizedError11("Not authorized.");
57686
57715
  }
57687
57716
  } else {
57688
57717
  orgs = actor.orgIds;
@@ -61988,7 +62017,7 @@ function useSiteFacilityService() {
61988
62017
  import {
61989
62018
  BadRequestError as BadRequestError148,
61990
62019
  NotFoundError as NotFoundError43,
61991
- UnauthorizedError as UnauthorizedError11,
62020
+ UnauthorizedError as UnauthorizedError12,
61992
62021
  logger as logger116
61993
62022
  } from "@7365admin1/node-server-utils";
61994
62023
  import Joi82 from "joi";
@@ -62075,7 +62104,7 @@ function useSiteFacilityController() {
62075
62104
  } else {
62076
62105
  const { actor } = await siteReachOf(req);
62077
62106
  if (!actor.isSuperAdmin)
62078
- throw new UnauthorizedError11("Not authorized.");
62107
+ throw new UnauthorizedError12("Not authorized.");
62079
62108
  }
62080
62109
  const data = await _getAll({
62081
62110
  search,
@@ -65110,7 +65139,7 @@ function useBulletinBoardService() {
65110
65139
  import {
65111
65140
  BadRequestError as BadRequestError157,
65112
65141
  NotFoundError as NotFoundError51,
65113
- UnauthorizedError as UnauthorizedError12,
65142
+ UnauthorizedError as UnauthorizedError13,
65114
65143
  logger as logger125
65115
65144
  } from "@7365admin1/node-server-utils";
65116
65145
  import Joi90 from "joi";
@@ -65146,7 +65175,7 @@ function useBulletinBoardController() {
65146
65175
  } else {
65147
65176
  const { canReach } = await siteReachOf(req);
65148
65177
  if (!await canReach(scopeOf(value))) {
65149
- throw new UnauthorizedError12("Not authorized.");
65178
+ throw new UnauthorizedError13("Not authorized.");
65150
65179
  }
65151
65180
  }
65152
65181
  const data = await _add(value);
@@ -65703,7 +65732,7 @@ import { BadRequestError as BadRequestError163, logger as logger131 } from "@736
65703
65732
  import {
65704
65733
  BadRequestError as BadRequestError162,
65705
65734
  logger as logger130,
65706
- UnauthorizedError as UnauthorizedError13,
65735
+ UnauthorizedError as UnauthorizedError14,
65707
65736
  useAtlas as useAtlas88
65708
65737
  } from "@7365admin1/node-server-utils";
65709
65738
 
@@ -66087,7 +66116,7 @@ function useSiteBillingItemService() {
66087
66116
  function assertUnitAtSite(buildingUnit, site) {
66088
66117
  const siteId = site?.toString?.() ?? "";
66089
66118
  if (!siteId || (buildingUnit?.site?.toString() ?? "") !== siteId) {
66090
- throw new UnauthorizedError13("Not authorized.");
66119
+ throw new UnauthorizedError14("Not authorized.");
66091
66120
  }
66092
66121
  }
66093
66122
  async function add(value) {
@@ -66258,7 +66287,7 @@ function useSiteBillingItemService() {
66258
66287
  message: error.message
66259
66288
  });
66260
66289
  await session.abortTransaction();
66261
- if (error instanceof BadRequestError162 || error instanceof UnauthorizedError13) {
66290
+ if (error instanceof BadRequestError162 || error instanceof UnauthorizedError14) {
66262
66291
  throw error;
66263
66292
  }
66264
66293
  throw new BadRequestError162("Failed to update Site Billing Item.");
@@ -68227,7 +68256,7 @@ import Joi98 from "joi";
68227
68256
 
68228
68257
  // src/utils/resident-unit.util.ts
68229
68258
  import { ObjectId as ObjectId123 } from "mongodb";
68230
- import { UnauthorizedError as UnauthorizedError14, useAtlas as useAtlas94 } from "@7365admin1/node-server-utils";
68259
+ import { UnauthorizedError as UnauthorizedError15, useAtlas as useAtlas94 } from "@7365admin1/node-server-utils";
68231
68260
  async function requireOwnUnit(req, site, unitId) {
68232
68261
  const actor = await resolveInviteActor(callerId(req));
68233
68262
  if (actor.isSuperAdmin)
@@ -68235,7 +68264,7 @@ async function requireOwnUnit(req, site, unitId) {
68235
68264
  const unit = unitId?.toString?.() ?? "";
68236
68265
  const siteId = site?.toString?.() ?? "";
68237
68266
  if (!ObjectId123.isValid(unit) || !ObjectId123.isValid(siteId) || !actor.id) {
68238
- throw new UnauthorizedError14("Not authorized.");
68267
+ throw new UnauthorizedError15("Not authorized.");
68239
68268
  }
68240
68269
  const db2 = useAtlas94.getDb();
68241
68270
  if (!db2)
@@ -68247,7 +68276,7 @@ async function requireOwnUnit(req, site, unitId) {
68247
68276
  status: { $ne: "deleted" }
68248
68277
  });
68249
68278
  if (!own)
68250
- throw new UnauthorizedError14("Not authorized.");
68279
+ throw new UnauthorizedError15("Not authorized.");
68251
68280
  }
68252
68281
 
68253
68282
  // src/controllers/site-unit-billing.controller.ts
@@ -76799,7 +76828,7 @@ function useOnlineFormRepo() {
76799
76828
  import {
76800
76829
  BadRequestError as BadRequestError203,
76801
76830
  NotFoundError as NotFoundError71,
76802
- UnauthorizedError as UnauthorizedError15,
76831
+ UnauthorizedError as UnauthorizedError16,
76803
76832
  logger as logger169
76804
76833
  } from "@7365admin1/node-server-utils";
76805
76834
  import Joi121 from "joi";
@@ -76871,10 +76900,10 @@ function useOnlineFormController() {
76871
76900
  if (site) {
76872
76901
  await requireSiteReach(req, site);
76873
76902
  } else if (!actor.isSuperAdmin) {
76874
- throw new UnauthorizedError15("Not authorized.");
76903
+ throw new UnauthorizedError16("Not authorized.");
76875
76904
  }
76876
76905
  if (org && !actor.isSuperAdmin && !actor.orgIds.includes(org)) {
76877
- throw new UnauthorizedError15("Not authorized.");
76906
+ throw new UnauthorizedError16("Not authorized.");
76878
76907
  }
76879
76908
  const data = await _getAll({ search, page, limit, status, org, site });
76880
76909
  res.json(data);
@@ -76939,7 +76968,7 @@ function useOnlineFormController() {
76939
76968
  if (payload.org) {
76940
76969
  const { actor } = await siteReachOf(req);
76941
76970
  if (!actor.isSuperAdmin && !actor.orgIds.includes(payload.org)) {
76942
- throw new UnauthorizedError15("Not authorized.");
76971
+ throw new UnauthorizedError16("Not authorized.");
76943
76972
  }
76944
76973
  }
76945
76974
  await _updateOnlineFormById(_id, payload);
@@ -84185,7 +84214,7 @@ import {
84185
84214
  BadRequestError as BadRequestError228,
84186
84215
  NotFoundError as NotFoundError78,
84187
84216
  InternalServerError as InternalServerError81,
84188
- UnauthorizedError as UnauthorizedError16,
84217
+ UnauthorizedError as UnauthorizedError17,
84189
84218
  useAtlas as useAtlas131,
84190
84219
  hashPassword as hashPassword4
84191
84220
  } from "@7365admin1/node-server-utils";
@@ -84454,10 +84483,10 @@ function useVerificationServiceV2() {
84454
84483
  const org = await getOrgById(orgId);
84455
84484
  const actor = await resolveInviteActor(invitedBy);
84456
84485
  if (!actor.id) {
84457
- throw new UnauthorizedError16("Sign in to continue.");
84486
+ throw new UnauthorizedError17("Sign in to continue.");
84458
84487
  }
84459
84488
  if (!actor.isSuperAdmin && !actor.orgIds.includes(orgId)) {
84460
- throw new UnauthorizedError16(
84489
+ throw new UnauthorizedError17(
84461
84490
  "You can only invite service providers to your own organisation's sites."
84462
84491
  );
84463
84492
  }
@@ -86329,7 +86358,7 @@ function useUserControllerV2() {
86329
86358
  return;
86330
86359
  }
86331
86360
  try {
86332
- await requireSelfOrPlatformStaff(req, _id);
86361
+ await requireUserFieldWrite(req, _id, payload.field);
86333
86362
  const message = await _updateUserFieldById({ _id, ...payload });
86334
86363
  res.json({ message });
86335
86364
  return;
@@ -88836,7 +88865,7 @@ import Joi157 from "joi";
88836
88865
  import { ObjectId as ObjectId178 } from "mongodb";
88837
88866
  import {
88838
88867
  InternalServerError as InternalServerError93,
88839
- UnauthorizedError as UnauthorizedError17,
88868
+ UnauthorizedError as UnauthorizedError18,
88840
88869
  useAtlas as useAtlas145
88841
88870
  } from "@7365admin1/node-server-utils";
88842
88871
  function db() {
@@ -88852,7 +88881,7 @@ function asObjectId(value) {
88852
88881
  function requireCaller(req) {
88853
88882
  const id = callerId(req);
88854
88883
  if (!id || !ObjectId178.isValid(id)) {
88855
- throw new UnauthorizedError17("Not authorized.");
88884
+ throw new UnauthorizedError18("Not authorized.");
88856
88885
  }
88857
88886
  return id;
88858
88887
  }
@@ -88860,7 +88889,7 @@ function requireSelfId(req, claimed) {
88860
88889
  const caller = requireCaller(req);
88861
88890
  const asked = claimed?.toString?.() ?? "";
88862
88891
  if (!asked || asked !== caller) {
88863
- throw new UnauthorizedError17("Not authorized.");
88892
+ throw new UnauthorizedError18("Not authorized.");
88864
88893
  }
88865
88894
  return caller;
88866
88895
  }
@@ -88868,11 +88897,11 @@ async function requireOwnChannel(req, channelId) {
88868
88897
  const caller = requireCaller(req);
88869
88898
  const _id = asObjectId(channelId);
88870
88899
  if (!_id)
88871
- throw new UnauthorizedError17("Not authorized.");
88900
+ throw new UnauthorizedError18("Not authorized.");
88872
88901
  const channel = await db().collection("channel-preloved").findOne({ _id }, { projection: { senderId: 1, receiverId: 1, postId: 1 } });
88873
88902
  const participants = [channel?.senderId, channel?.receiverId].map((id) => id?.toString?.() ?? "").filter(Boolean);
88874
88903
  if (!channel || !participants.includes(caller)) {
88875
- throw new UnauthorizedError17("Not authorized.");
88904
+ throw new UnauthorizedError18("Not authorized.");
88876
88905
  }
88877
88906
  return { caller, channel };
88878
88907
  }
@@ -88880,10 +88909,10 @@ async function requireOwnChatMessage(req, chatId) {
88880
88909
  const caller = requireCaller(req);
88881
88910
  const _id = asObjectId(chatId);
88882
88911
  if (!_id)
88883
- throw new UnauthorizedError17("Not authorized.");
88912
+ throw new UnauthorizedError18("Not authorized.");
88884
88913
  const message = await db().collection("chat-preloved").findOne({ _id }, { projection: { senderId: 1 } });
88885
88914
  if (!message || message.senderId?.toString?.() !== caller) {
88886
- throw new UnauthorizedError17("Not authorized.");
88915
+ throw new UnauthorizedError18("Not authorized.");
88887
88916
  }
88888
88917
  return caller;
88889
88918
  }
@@ -89309,7 +89338,7 @@ function useBidPrelovedService() {
89309
89338
  // src/controllers/bid-preloved.controller.ts
89310
89339
  import {
89311
89340
  BadRequestError as BadRequestError251,
89312
- UnauthorizedError as UnauthorizedError18,
89341
+ UnauthorizedError as UnauthorizedError19,
89313
89342
  logger as logger212
89314
89343
  } from "@7365admin1/node-server-utils";
89315
89344
  import Joi160 from "joi";
@@ -89361,7 +89390,7 @@ function useBidPrelovedController() {
89361
89390
  const bid = await _getById(params.id);
89362
89391
  const seller = await sellerOfPost(bid?.postId);
89363
89392
  if (!seller || seller !== caller) {
89364
- throw new UnauthorizedError18("Not authorized.");
89393
+ throw new UnauthorizedError19("Not authorized.");
89365
89394
  }
89366
89395
  const data = await _updateStatus(params.id, body.status);
89367
89396
  res.status(200).json(data);
@@ -89385,7 +89414,7 @@ function useBidPrelovedController() {
89385
89414
  const data = await _getById(params.id);
89386
89415
  const seller = await sellerOfPost(data?.postId);
89387
89416
  if (data?.buyerId?.toString?.() !== caller && seller !== caller) {
89388
- throw new UnauthorizedError18("Not authorized.");
89417
+ throw new UnauthorizedError19("Not authorized.");
89389
89418
  }
89390
89419
  res.status(200).json(data);
89391
89420
  } catch (error2) {
@@ -89783,7 +89812,7 @@ function useFormEntryRepo() {
89783
89812
  import {
89784
89813
  BadRequestError as BadRequestError253,
89785
89814
  NotFoundError as NotFoundError89,
89786
- UnauthorizedError as UnauthorizedError19,
89815
+ UnauthorizedError as UnauthorizedError20,
89787
89816
  logger as logger214
89788
89817
  } from "@7365admin1/node-server-utils";
89789
89818
  import Joi162 from "joi";
@@ -89893,7 +89922,7 @@ function useFormEntryController() {
89893
89922
  } else {
89894
89923
  const { actor } = await siteReachOf(req);
89895
89924
  if (!actor.isSuperAdmin)
89896
- throw new UnauthorizedError19("Not authorized.");
89925
+ throw new UnauthorizedError20("Not authorized.");
89897
89926
  }
89898
89927
  const data = await _getAll({ search, page, limit, status, org, site });
89899
89928
  res.json(data);
@@ -89944,7 +89973,7 @@ function useFormEntryController() {
89944
89973
  await requireSiteReach(req, rest.site);
89945
89974
  delete rest.userId;
89946
89975
  if (isOwner && rest.status && rest.status !== "pending") {
89947
- throw new UnauthorizedError19("Not authorized.");
89976
+ throw new UnauthorizedError20("Not authorized.");
89948
89977
  }
89949
89978
  await _updateFormEntryById(_id, rest);
89950
89979
  res.json({ message: "Successfully updated online form." });
@@ -90001,7 +90030,7 @@ function useFormEntryController() {
90001
90030
  async function residentFormSubmission(req, res, next) {
90002
90031
  const userId = callerId(req);
90003
90032
  if (!userId) {
90004
- next(new UnauthorizedError19("Not authorized."));
90033
+ next(new UnauthorizedError20("Not authorized."));
90005
90034
  return;
90006
90035
  }
90007
90036
  const payload = { ...req.body, userId };
@@ -91232,7 +91261,7 @@ function useHidAmicoController() {
91232
91261
  import {
91233
91262
  BadRequestError as BadRequestError256,
91234
91263
  logger as logger216,
91235
- UnauthorizedError as UnauthorizedError20
91264
+ UnauthorizedError as UnauthorizedError21
91236
91265
  } from "@7365admin1/node-server-utils";
91237
91266
  import Joi164 from "joi";
91238
91267
  function usePlatformTermsController() {
@@ -91248,7 +91277,7 @@ function usePlatformTermsController() {
91248
91277
  async function requireOwnRecord(req, user, { staffMayRead = false } = {}) {
91249
91278
  const id = callerId(req);
91250
91279
  if (!id) {
91251
- throw new UnauthorizedError20("Not authorized.");
91280
+ throw new UnauthorizedError21("Not authorized.");
91252
91281
  }
91253
91282
  if (id === user) {
91254
91283
  return id;
@@ -91256,7 +91285,7 @@ function usePlatformTermsController() {
91256
91285
  if (staffMayRead) {
91257
91286
  return await requirePlatformStaff(req);
91258
91287
  }
91259
- throw new UnauthorizedError20("Not authorized.");
91288
+ throw new UnauthorizedError21("Not authorized.");
91260
91289
  }
91261
91290
  async function getLatest(_req, res, next) {
91262
91291
  try {
@@ -91462,7 +91491,7 @@ function useConsoleAuditController() {
91462
91491
  // src/controllers/notification.controller.ts
91463
91492
  import {
91464
91493
  BadRequestError as BadRequestError258,
91465
- UnauthorizedError as UnauthorizedError21,
91494
+ UnauthorizedError as UnauthorizedError22,
91466
91495
  logger as logger218
91467
91496
  } from "@7365admin1/node-server-utils";
91468
91497
  function useNotificationController() {
@@ -91480,10 +91509,10 @@ function useNotificationController() {
91480
91509
  function inboxOwner(req, claimed) {
91481
91510
  const caller = callerId5(req);
91482
91511
  if (!caller) {
91483
- throw new UnauthorizedError21("Not authorized.");
91512
+ throw new UnauthorizedError22("Not authorized.");
91484
91513
  }
91485
91514
  if (claimed && claimed !== caller) {
91486
- throw new UnauthorizedError21("Not authorized.");
91515
+ throw new UnauthorizedError22("Not authorized.");
91487
91516
  }
91488
91517
  return caller;
91489
91518
  }
@@ -91495,7 +91524,7 @@ function useNotificationController() {
91495
91524
  }
91496
91525
  try {
91497
91526
  if (!await isSuperAdmin(callerId5(req))) {
91498
- throw new UnauthorizedError21("Not authorized.");
91527
+ throw new UnauthorizedError22("Not authorized.");
91499
91528
  }
91500
91529
  const inserted = await _addMany(value.to, {
91501
91530
  title: value.title,
@@ -92031,6 +92060,7 @@ export {
92031
92060
  hasAnyCapability,
92032
92061
  hasAnyPermission,
92033
92062
  hasOrgInvitation,
92063
+ hasOrgOwnership,
92034
92064
  hidRawUint64,
92035
92065
  incidentReportLog,
92036
92066
  incidents_namespace_collection,