@7365admin1/core 2.61.0 → 2.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3918,7 +3918,9 @@ function useVerificationRepo() {
3918
3918
  status = "active",
3919
3919
  app = "",
3920
3920
  type = {},
3921
- email = ""
3921
+ email = "",
3922
+ siteId = "",
3923
+ orgId = ""
3922
3924
  }) {
3923
3925
  page = page > 0 ? page - 1 : 0;
3924
3926
  const query = { status };
@@ -3945,6 +3947,24 @@ function useVerificationRepo() {
3945
3947
  query.email = email;
3946
3948
  cacheOptions.email = email;
3947
3949
  }
3950
+ if (siteId) {
3951
+ const siteCandidates = [siteId];
3952
+ try {
3953
+ siteCandidates.push(new ObjectId13(siteId));
3954
+ } catch {
3955
+ }
3956
+ query["metadata.siteId"] = { $in: siteCandidates };
3957
+ cacheOptions.siteId = siteId;
3958
+ }
3959
+ if (orgId) {
3960
+ const orgCandidates = [orgId];
3961
+ try {
3962
+ orgCandidates.push(new ObjectId13(orgId));
3963
+ } catch {
3964
+ }
3965
+ query["metadata.org"] = { $in: orgCandidates };
3966
+ cacheOptions.orgId = orgId;
3967
+ }
3948
3968
  const cacheKey = makeCacheKey7(namespace_collection, cacheOptions);
3949
3969
  const cachedData = await getCache(cacheKey);
3950
3970
  if (cachedData) {
@@ -8222,7 +8242,10 @@ function useVerificationController() {
8222
8242
  status: Joi16.string().required(),
8223
8243
  app: Joi16.string().optional().allow("", null),
8224
8244
  type: Joi16.alternatives().try(Joi16.string(), Joi16.array().items(Joi16.string())).optional().allow("", null),
8225
- email: Joi16.string().optional().allow("", null)
8245
+ email: Joi16.string().optional().allow("", null),
8246
+ siteId: Joi16.string().hex().optional().allow("", null),
8247
+ orgId: Joi16.string().hex().optional().allow("", null),
8248
+ limit: Joi16.number().integer().min(1).allow("", null).default(10)
8226
8249
  });
8227
8250
  const query = { ...req.query };
8228
8251
  const { error } = validation.validate(query);
@@ -8236,6 +8259,9 @@ function useVerificationController() {
8236
8259
  const status = req.query.status ?? "pending";
8237
8260
  const app = req.query.app ?? "";
8238
8261
  const email = req.query.email ?? "";
8262
+ const siteId = req.query.siteId ?? "";
8263
+ const orgId = req.query.orgId ?? "";
8264
+ const limit = parseInt(req.query.limit ?? "10");
8239
8265
  const type = req.query.type ? String(req.query.type).split(",") : "";
8240
8266
  const typeObj = {};
8241
8267
  if (type && Array.isArray(type) && type.length) {
@@ -8250,7 +8276,10 @@ function useVerificationController() {
8250
8276
  status,
8251
8277
  app,
8252
8278
  type: typeObj,
8253
- email
8279
+ email,
8280
+ siteId,
8281
+ orgId,
8282
+ limit
8254
8283
  });
8255
8284
  res.json(data);
8256
8285
  return;
@@ -12008,6 +12037,7 @@ function useServiceProviderRepo() {
12008
12037
  throw new BadRequestError54("Invalid site ID format.");
12009
12038
  }
12010
12039
  }
12040
+ cacheOptions.membersLookup = "1";
12011
12041
  const cacheKey = makeCacheKey20(namespace_collection, cacheOptions);
12012
12042
  const cachedData = await getCache(cacheKey);
12013
12043
  if (cachedData) {
@@ -12023,7 +12053,7 @@ function useServiceProviderRepo() {
12023
12053
  localField: "serviceProviderOrgId",
12024
12054
  foreignField: "_id",
12025
12055
  as: "organization",
12026
- pipeline: [{ $project: { nature: 1 } }]
12056
+ pipeline: [{ $project: { nature: 1, email: 1 } }]
12027
12057
  }
12028
12058
  },
12029
12059
  {
@@ -12032,17 +12062,50 @@ function useServiceProviderRepo() {
12032
12062
  preserveNullAndEmptyArrays: true
12033
12063
  }
12034
12064
  },
12065
+ {
12066
+ $lookup: {
12067
+ from: "members",
12068
+ let: { spOrgId: "$serviceProviderOrgId" },
12069
+ pipeline: [
12070
+ {
12071
+ $match: {
12072
+ $expr: { $eq: ["$org", "$$spOrgId"] },
12073
+ status: "active"
12074
+ }
12075
+ },
12076
+ { $count: "c" }
12077
+ ],
12078
+ as: "_memberCount"
12079
+ }
12080
+ },
12035
12081
  {
12036
12082
  $project: {
12037
12083
  name: 1,
12038
12084
  type: 1,
12085
+ email: {
12086
+ $cond: {
12087
+ if: {
12088
+ $gt: [{ $strLenCP: { $ifNull: ["$email", ""] } }, 0]
12089
+ },
12090
+ then: "$email",
12091
+ else: { $ifNull: ["$organization.email", ""] }
12092
+ }
12093
+ },
12039
12094
  nature: "$organization.nature",
12040
12095
  orgId: 1,
12041
12096
  siteId: 1,
12042
12097
  siteName: 1,
12043
12098
  serviceProviderOrgId: 1,
12044
12099
  status: 1,
12045
- category: 1
12100
+ category: 1,
12101
+ members: {
12102
+ $let: {
12103
+ vars: {
12104
+ mc: { $arrayElemAt: ["$_memberCount", 0] }
12105
+ },
12106
+ in: { $ifNull: ["$$mc.c", 0] }
12107
+ }
12108
+ }
12046
12109
  }
12047
12110
  },
12048
12111
  { $sort: sort },
@@ -18109,6 +18172,167 @@ function useVehicleService() {
18109
18172
  throw error;
18110
18173
  }
18111
18174
  }
18175
+ async function blocklistVehicles(_id, value) {
18176
+ const session = useAtlas34.getClient()?.startSession();
18177
+ if (!session) {
18178
+ throw new Error("Unable to start session for vehicle service.");
18179
+ }
18180
+ try {
18181
+ session.startTransaction();
18182
+ const vehicle = await _getVehicleById(_id);
18183
+ const plate = vehicle.plates.find((p) => p._id.toString() === _id);
18184
+ const _name = value.name ? value.name : vehicle.name;
18185
+ const _plateNumber = plate?.plateNumber;
18186
+ const _start = vehicle.start;
18187
+ const _end = vehicle.end;
18188
+ const _recNo = plate.recNo;
18189
+ const _type = plate.type;
18190
+ if (value.peopleId) {
18191
+ value.peopleId = new ObjectId46(value.peopleId);
18192
+ }
18193
+ const { site } = value;
18194
+ const startDahua = formatDahuaDate(_start);
18195
+ const endPlus24Hours = _end ? _end : new Date(new Date(_end).getTime() + 24 * 60 * 60 * 1e3);
18196
+ const endDahua = formatDahuaDate(endPlus24Hours);
18197
+ if (_plateNumber) {
18198
+ const siteCameras = [];
18199
+ let page = 1;
18200
+ let pages = 1;
18201
+ const limit = 20;
18202
+ do {
18203
+ const siteCameraReq = await _getAllSiteCameras({
18204
+ site,
18205
+ type: "anpr",
18206
+ direction: ["both", "entry"],
18207
+ page,
18208
+ limit
18209
+ });
18210
+ pages = siteCameraReq.pages || 1;
18211
+ siteCameras.push(...siteCameraReq.items);
18212
+ page++;
18213
+ } while (page < pages);
18214
+ if (!siteCameras.length) {
18215
+ throw new BadRequestError73("No site cameras found.");
18216
+ }
18217
+ for (const camera of siteCameras) {
18218
+ const { host, username, password } = camera;
18219
+ const removePlateNumber = {
18220
+ host,
18221
+ username,
18222
+ password,
18223
+ mode: _type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
18224
+ recno: _recNo
18225
+ };
18226
+ const responseForDeletion = await _removePlateNumber(
18227
+ removePlateNumber
18228
+ );
18229
+ if (responseForDeletion?.statusCode !== 200) {
18230
+ throw new BadRequestError73("Failed to delete plate number to ANPR");
18231
+ }
18232
+ const dahuaPayload = {
18233
+ host,
18234
+ username,
18235
+ password,
18236
+ plateNumber: _plateNumber,
18237
+ mode: "TrafficBlackList" /* TRAFFIC_BLACKLIST */,
18238
+ owner: _name,
18239
+ ...startDahua ? { start: startDahua } : {},
18240
+ ...endDahua ? { end: endDahua } : {}
18241
+ };
18242
+ const dahuaResponse = await _addPlateNumber(dahuaPayload);
18243
+ if (dahuaResponse?.statusCode !== 200) {
18244
+ throw new BadRequestError73("Failed to update plate number to ANPR");
18245
+ }
18246
+ const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
18247
+ value.recNo = responseData.split("=")[1]?.trim();
18248
+ const normalizedPlateNumber = _plateNumber;
18249
+ if (value.peopleId && value.recNo) {
18250
+ await _pushVehicleById(
18251
+ value.peopleId,
18252
+ {
18253
+ plateNumber: normalizedPlateNumber,
18254
+ recNo: value.recNo
18255
+ },
18256
+ session
18257
+ );
18258
+ }
18259
+ }
18260
+ }
18261
+ const formattedValue = {
18262
+ type: "blocklist" /* BLOCKLIST */,
18263
+ recNo: value.recNo
18264
+ };
18265
+ await _updateVehicleById(_id, formattedValue, session);
18266
+ await session.commitTransaction();
18267
+ } catch (error) {
18268
+ await session.abortTransaction();
18269
+ throw error;
18270
+ } finally {
18271
+ session.endSession();
18272
+ }
18273
+ }
18274
+ async function removeFromBlocklist(_id, value) {
18275
+ const session = useAtlas34.getClient()?.startSession();
18276
+ if (!session) {
18277
+ throw new Error("Unable to start session for vehicle service.");
18278
+ }
18279
+ try {
18280
+ session.startTransaction();
18281
+ const vehicle = await _getVehicleById(_id);
18282
+ const plate = vehicle.plates.find((p) => p._id.toString() === _id);
18283
+ const _plateNumber = plate?.plateNumber;
18284
+ const _recNo = plate.recNo;
18285
+ if (value.peopleId) {
18286
+ value.peopleId = new ObjectId46(value.peopleId);
18287
+ }
18288
+ const { site } = value;
18289
+ if (_plateNumber) {
18290
+ const siteCameras = [];
18291
+ let page = 1;
18292
+ let pages = 1;
18293
+ const limit = 20;
18294
+ do {
18295
+ const siteCameraReq = await _getAllSiteCameras({
18296
+ site,
18297
+ type: "anpr",
18298
+ direction: ["both", "entry"],
18299
+ page,
18300
+ limit
18301
+ });
18302
+ pages = siteCameraReq.pages || 1;
18303
+ siteCameras.push(...siteCameraReq.items);
18304
+ page++;
18305
+ } while (page < pages);
18306
+ if (!siteCameras.length) {
18307
+ throw new BadRequestError73("No site cameras found.");
18308
+ }
18309
+ for (const camera of siteCameras) {
18310
+ const { host, username, password } = camera;
18311
+ const removePlateNumber = {
18312
+ host,
18313
+ username,
18314
+ password,
18315
+ mode: "TrafficBlackList" /* TRAFFIC_BLACKLIST */,
18316
+ recno: _recNo
18317
+ };
18318
+ console.log(removePlateNumber);
18319
+ const responseForDeletion = await _removePlateNumber(
18320
+ removePlateNumber
18321
+ );
18322
+ if (responseForDeletion?.statusCode !== 200) {
18323
+ throw new BadRequestError73("Failed to delete plate number to ANPR");
18324
+ }
18325
+ }
18326
+ }
18327
+ await _deleteVehicle(_id, session);
18328
+ await session.commitTransaction();
18329
+ } catch (error) {
18330
+ await session.abortTransaction();
18331
+ throw error;
18332
+ } finally {
18333
+ session.endSession();
18334
+ }
18335
+ }
18112
18336
  return {
18113
18337
  add,
18114
18338
  deleteVehicle,
@@ -18116,7 +18340,9 @@ function useVehicleService() {
18116
18340
  processDeletingExpiredVehicles,
18117
18341
  reactivateVehicleById,
18118
18342
  updateVehicleById,
18119
- bulkUpsertVehicles
18343
+ bulkUpsertVehicles,
18344
+ blocklistVehicles,
18345
+ removeFromBlocklist
18120
18346
  };
18121
18347
  }
18122
18348
 
@@ -20486,7 +20712,7 @@ function useBuildingService() {
20486
20712
  getByBuildingLevel,
20487
20713
  updateLevelByBuildingLevel,
20488
20714
  updateByBuildingId,
20489
- add: _addBuildingUnit
20715
+ bulkAddBuildingUnits: _bulkAddBuildingUnits
20490
20716
  } = useBuildingUnitRepo();
20491
20717
  const { updateStatusById } = useFileRepo();
20492
20718
  const { deleteFile } = useFileService();
@@ -20675,15 +20901,16 @@ function useBuildingService() {
20675
20901
  companyName: "",
20676
20902
  companyRegistrationNumber: "",
20677
20903
  billing: [],
20678
- unitNumber: parseInt(unit.replace("Unit ", ""), 10) || null
20904
+ unitNumber: parseInt(unit.replace("Unit ", ""), 10) || null,
20905
+ createdAt: /* @__PURE__ */ new Date(),
20906
+ updatedAt: "",
20907
+ deletedAt: ""
20679
20908
  });
20680
20909
  });
20681
20910
  });
20682
20911
  }
20683
20912
  );
20684
- for (const buildingUnitPayload of buildingUnitPayloads) {
20685
- const result = await _addBuildingUnit(buildingUnitPayload);
20686
- }
20913
+ await _bulkAddBuildingUnits(buildingUnitPayloads);
20687
20914
  await session?.commitTransaction();
20688
20915
  return { buildingPayloads, buildingUnitPayloads };
20689
20916
  } catch (error) {
@@ -21429,7 +21656,9 @@ function useVehicleController() {
21429
21656
  approveVehicleById: _approveVehicleById,
21430
21657
  reactivateVehicleById: _reactivateVehicleById,
21431
21658
  updateVehicleById: _updateVehicleById,
21432
- bulkUpsertVehicles: _bulkUpsertVehicles
21659
+ bulkUpsertVehicles: _bulkUpsertVehicles,
21660
+ blocklistVehicles: _blocklistVehicles,
21661
+ removeFromBlocklist: _removeFromBlocklist
21433
21662
  } = useVehicleService();
21434
21663
  const {
21435
21664
  getSeasonPassTypes: _getSeasonPassTypes,
@@ -22006,6 +22235,68 @@ function useVehicleController() {
22006
22235
  return;
22007
22236
  }
22008
22237
  }
22238
+ async function blocklistVehicles(req, res, next) {
22239
+ try {
22240
+ const schema2 = Joi47.object({
22241
+ _id: Joi47.string().hex().length(24).required(),
22242
+ site: Joi47.string().hex().length(24).required(),
22243
+ peopleId: Joi47.string().hex().length(24).optional().allow(null, ""),
22244
+ remarks: Joi47.string().optional().allow("", null)
22245
+ });
22246
+ const { error, value } = schema2.validate(
22247
+ {
22248
+ _id: req.params.id,
22249
+ ...req.body
22250
+ },
22251
+ { abortEarly: false }
22252
+ );
22253
+ if (error) {
22254
+ const messages = error.details.map((d) => d.message).join(", ");
22255
+ logger66.log({ level: "error", message: messages });
22256
+ next(new BadRequestError85(messages));
22257
+ return;
22258
+ }
22259
+ const { _id, ...rest } = value;
22260
+ await _blocklistVehicles(_id, rest);
22261
+ res.json({ message: "Successfully blocked vehicle." });
22262
+ return;
22263
+ } catch (error) {
22264
+ logger66.log({ level: "error", message: error.message });
22265
+ next(error);
22266
+ return;
22267
+ }
22268
+ }
22269
+ async function removeFromBlocklist(req, res, next) {
22270
+ try {
22271
+ const schema2 = Joi47.object({
22272
+ _id: Joi47.string().hex().length(24).required(),
22273
+ site: Joi47.string().hex().length(24).required(),
22274
+ peopleId: Joi47.string().hex().length(24).optional().allow(null, ""),
22275
+ remarks: Joi47.string().optional().allow("", null)
22276
+ });
22277
+ const { error, value } = schema2.validate(
22278
+ {
22279
+ _id: req.params.id,
22280
+ ...req.body
22281
+ },
22282
+ { abortEarly: false }
22283
+ );
22284
+ if (error) {
22285
+ const messages = error.details.map((d) => d.message).join(", ");
22286
+ logger66.log({ level: "error", message: messages });
22287
+ next(new BadRequestError85(messages));
22288
+ return;
22289
+ }
22290
+ const { _id, ...rest } = value;
22291
+ await _removeFromBlocklist(_id, rest);
22292
+ res.json({ message: "Successfully removed vehicle from blocklist." });
22293
+ return;
22294
+ } catch (error) {
22295
+ logger66.log({ level: "error", message: error.message });
22296
+ next(error);
22297
+ return;
22298
+ }
22299
+ }
22009
22300
  return {
22010
22301
  add,
22011
22302
  getVehicles,
@@ -22019,7 +22310,9 @@ function useVehicleController() {
22019
22310
  getAllVehiclesByUnitId,
22020
22311
  uploadSpreadsheetVehicles,
22021
22312
  getSpecificVehicleById,
22022
- getBlocklistedVehicles
22313
+ getBlocklistedVehicles,
22314
+ blocklistVehicles,
22315
+ removeFromBlocklist
22023
22316
  };
22024
22317
  }
22025
22318
 
@@ -31651,6 +31944,18 @@ function MBulletinBoard(value) {
31651
31944
  throw new Error("Invalid org ID.");
31652
31945
  }
31653
31946
  }
31947
+ if (value.file && Array.isArray(value.file)) {
31948
+ value.file = value.file.map((f) => {
31949
+ if (f._id && typeof f._id === "string") {
31950
+ try {
31951
+ return { ...f, _id: new ObjectId78(f._id) };
31952
+ } catch {
31953
+ throw new Error("Invalid file ID.");
31954
+ }
31955
+ }
31956
+ return f;
31957
+ });
31958
+ }
31654
31959
  return {
31655
31960
  _id: value._id ?? new ObjectId78(),
31656
31961
  site: value.site ?? "",
@@ -31728,7 +32033,8 @@ function useBulletinBoardRepo() {
31728
32033
  sort = {},
31729
32034
  site = "",
31730
32035
  status = "active",
31731
- recipients = []
32036
+ recipients = [],
32037
+ expiration
31732
32038
  }, session) {
31733
32039
  page = page > 0 ? page - 1 : 0;
31734
32040
  try {
@@ -31739,8 +32045,13 @@ function useBulletinBoardRepo() {
31739
32045
  const query = {
31740
32046
  site,
31741
32047
  status,
31742
- ...search && { $text: { $search: search } },
31743
- ...recipients?.length && { recipients: { $in: recipients } }
32048
+ ...search && {
32049
+ $or: [{ title: { $regex: search, $options: "i" } }]
32050
+ },
32051
+ ...recipients?.length && { recipients: { $all: recipients } },
32052
+ ...expiration !== void 0 && {
32053
+ noExpiration: expiration === "yes"
32054
+ }
31744
32055
  };
31745
32056
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
31746
32057
  const cacheOptions = {
@@ -31750,7 +32061,8 @@ function useBulletinBoardRepo() {
31750
32061
  page,
31751
32062
  limit,
31752
32063
  ...search && { search },
31753
- ...recipients?.length && { recipients: recipients.sort().join(",") }
32064
+ ...recipients?.length && { recipients: recipients.sort().join(",") },
32065
+ ...expiration !== void 0 && { expiration }
31754
32066
  };
31755
32067
  const cacheKey = makeCacheKey39(
31756
32068
  bulletin_boards_namespace_collection,
@@ -31938,7 +32250,9 @@ function useBulletinBoardRepo() {
31938
32250
  { session }
31939
32251
  );
31940
32252
  if (res.matchedCount === 0) {
31941
- throw new NotFoundError30("No upcoming bulletin boards found to activate.");
32253
+ throw new NotFoundError30(
32254
+ "No upcoming bulletin boards found to activate."
32255
+ );
31942
32256
  }
31943
32257
  delNamespace().then(() => {
31944
32258
  logger105.info(
@@ -31968,7 +32282,7 @@ function useBulletinBoardRepo() {
31968
32282
  }
31969
32283
 
31970
32284
  // src/services/bulletin-board.service.ts
31971
- import { useAtlas as useAtlas67 } from "@7365admin1/node-server-utils";
32285
+ import { useAtlas as useAtlas67, NotFoundError as NotFoundError31 } from "@7365admin1/node-server-utils";
31972
32286
  function useBulletinBoardService() {
31973
32287
  const {
31974
32288
  add: _add,
@@ -31978,7 +32292,7 @@ function useBulletinBoardService() {
31978
32292
  deleteBulletinBoardById: _deleteBulletinBoardById,
31979
32293
  getBulletinBoardById: _getBulletinBoardById
31980
32294
  } = useBulletinBoardRepo();
31981
- const { deleteFileById: _deleteFileById } = useFileRepo();
32295
+ const { deleteFileById: _deleteFileById, updateStatusById } = useFileRepo();
31982
32296
  async function add(value) {
31983
32297
  const session = useAtlas67.getClient()?.startSession();
31984
32298
  session?.startTransaction();
@@ -31986,6 +32300,21 @@ function useBulletinBoardService() {
31986
32300
  value.status = "upcoming" /* UPCOMING */;
31987
32301
  }
31988
32302
  try {
32303
+ const bulletinFiles = value?.file ?? [];
32304
+ if (bulletinFiles.length > 0) {
32305
+ for (const bulletinFile of bulletinFiles) {
32306
+ if (!bulletinFile._id)
32307
+ continue;
32308
+ const file = await updateStatusById(
32309
+ bulletinFile._id.toString(),
32310
+ { status: "active" },
32311
+ session
32312
+ );
32313
+ if (!file) {
32314
+ throw new NotFoundError31("File not found.");
32315
+ }
32316
+ }
32317
+ }
31989
32318
  await _add(value, session);
31990
32319
  await session?.commitTransaction();
31991
32320
  return "Successfully added bulletin board.";
@@ -32109,32 +32438,35 @@ function useBulletinBoardController() {
32109
32438
  order: Joi77.string().valid(...Object.values(BulletinOrder)).default("desc" /* DESC */),
32110
32439
  site: Joi77.string().hex().length(24).required(),
32111
32440
  status: Joi77.string().valid(...Object.values(BulletinStatus)).optional().default("active" /* ACTIVE */),
32112
- recipients: Joi77.alternatives().try(
32113
- Joi77.array().items(
32114
- Joi77.string().valid(...Object.values(BulletinRecipient))
32115
- ),
32116
- Joi77.string().allow("")
32117
- ).optional().allow(null).custom((value2, helpers) => {
32118
- if (!value2 || value2 === "") {
32441
+ recipients: Joi77.any().optional().allow(null, "").custom((value2, helpers) => {
32442
+ if (!value2 || value2 === "")
32119
32443
  return [];
32120
- }
32121
- let parsed = [];
32444
+ let parsed;
32122
32445
  if (Array.isArray(value2)) {
32123
32446
  parsed = value2;
32124
- } else if (typeof value2 === "string") {
32125
- parsed = value2.split(",").map((v) => v.trim()).filter(Boolean);
32126
- }
32127
- for (const r of parsed) {
32128
- if (!Object.values(BulletinRecipient).includes(r)) {
32129
- return helpers.error("any.only");
32447
+ } else if (typeof value2 === "string" && value2.trim().startsWith("[")) {
32448
+ try {
32449
+ const result = JSON.parse(value2);
32450
+ parsed = Array.isArray(result) ? result : [value2];
32451
+ } catch {
32452
+ return helpers.error("any.invalid");
32130
32453
  }
32454
+ } else {
32455
+ parsed = [value2];
32131
32456
  }
32457
+ const validValues = Object.values(BulletinRecipient);
32458
+ const isValid = parsed.every(
32459
+ (r) => validValues.includes(r)
32460
+ );
32461
+ if (!isValid)
32462
+ return helpers.error("any.invalid");
32132
32463
  return parsed;
32133
32464
  }).messages({
32134
- "any.only": `Recipients must be one of: ${Object.values(
32465
+ "any.invalid": `Recipients must be one of: ${Object.values(
32135
32466
  BulletinRecipient
32136
32467
  ).join(", ")}`
32137
- })
32468
+ }),
32469
+ expiration: Joi77.string().valid("yes", "no").optional().allow("", null)
32138
32470
  });
32139
32471
  const { error, value } = validation.validate(req.query, {
32140
32472
  abortEarly: false
@@ -32145,7 +32477,17 @@ function useBulletinBoardController() {
32145
32477
  next(new BadRequestError128(messages));
32146
32478
  return;
32147
32479
  }
32148
- const { search, page, limit, site, status, recipients, sort, order } = value;
32480
+ const {
32481
+ search,
32482
+ page,
32483
+ limit,
32484
+ site,
32485
+ status,
32486
+ recipients,
32487
+ sort,
32488
+ order,
32489
+ expiration
32490
+ } = value;
32149
32491
  const sortObj = {
32150
32492
  [sort ? sort : "_id" /* ID */]: order === "asc" /* ASC */ ? 1 : -1
32151
32493
  };
@@ -32157,7 +32499,8 @@ function useBulletinBoardController() {
32157
32499
  sort: sortObj,
32158
32500
  site,
32159
32501
  status,
32160
- recipients
32502
+ recipients,
32503
+ expiration
32161
32504
  });
32162
32505
  res.status(200).json(data);
32163
32506
  return;
@@ -33617,7 +33960,7 @@ import {
33617
33960
  InternalServerError as InternalServerError45,
33618
33961
  logger as logger115,
33619
33962
  makeCacheKey as makeCacheKey42,
33620
- NotFoundError as NotFoundError33,
33963
+ NotFoundError as NotFoundError34,
33621
33964
  paginate as paginate37,
33622
33965
  useAtlas as useAtlas72,
33623
33966
  useCache as useCache44
@@ -33781,7 +34124,7 @@ function useEventManagementRepo() {
33781
34124
  try {
33782
34125
  const data = await collection.findOne({ _id }, { session });
33783
34126
  if (!data) {
33784
- throw new NotFoundError33("Event not found.");
34127
+ throw new NotFoundError34("Event not found.");
33785
34128
  }
33786
34129
  setCache(cacheKey, data, 15 * 60).then(() => {
33787
34130
  logger115.info(`Cache set for key: ${cacheKey}`);
@@ -33878,7 +34221,7 @@ function useEventManagementRepo() {
33878
34221
  { session }
33879
34222
  );
33880
34223
  if (res.matchedCount === 0) {
33881
- throw new NotFoundError33("No bulletin boards found to update.");
34224
+ throw new NotFoundError34("No bulletin boards found to update.");
33882
34225
  }
33883
34226
  delNamespace().then(() => {
33884
34227
  logger115.info(
@@ -37799,6 +38142,19 @@ function UseAccessManagementRepo() {
37799
38142
  await session?.endSession();
37800
38143
  }
37801
38144
  }
38145
+ async function uploadTemplateRepo({ site, id, name }) {
38146
+ site = new ObjectId90(site);
38147
+ id = new ObjectId90(id);
38148
+ try {
38149
+ const result = await collectionName("sites").updateOne(
38150
+ { _id: site },
38151
+ { $set: { "siteSettings.entryPass.settings.template": { id, name } } }
38152
+ );
38153
+ return result;
38154
+ } catch (error) {
38155
+ throw new Error(error.message);
38156
+ }
38157
+ }
37802
38158
  return {
37803
38159
  createIndexes,
37804
38160
  createIndexForEntrypass,
@@ -37833,7 +38189,8 @@ function UseAccessManagementRepo() {
37833
38189
  indexCombination,
37834
38190
  getTransactionsRepo,
37835
38191
  assignMultipleCardsRepo,
37836
- visitorCheckoutRepo
38192
+ visitorCheckoutRepo,
38193
+ uploadTemplateRepo
37837
38194
  };
37838
38195
  }
37839
38196
 
@@ -37876,7 +38233,8 @@ function useAccessManagementSvc() {
37876
38233
  getBlockLevelAndUnitListRepo,
37877
38234
  getTransactionsRepo,
37878
38235
  assignMultipleCardsRepo,
37879
- visitorCheckoutRepo
38236
+ visitorCheckoutRepo,
38237
+ uploadTemplateRepo
37880
38238
  } = UseAccessManagementRepo();
37881
38239
  const addPhysicalCardSvc = async (payload) => {
37882
38240
  try {
@@ -38189,7 +38547,15 @@ function useAccessManagementSvc() {
38189
38547
  const response = await visitorCheckoutRepo({ userId });
38190
38548
  return response;
38191
38549
  } catch (err) {
38192
- return Promise.reject("Server internal error.");
38550
+ throw new Error(err.message);
38551
+ }
38552
+ };
38553
+ const uploadTemplateSvc = async ({ site, id, name }) => {
38554
+ try {
38555
+ const response = await uploadTemplateRepo({ site, id, name });
38556
+ return response;
38557
+ } catch (err) {
38558
+ throw new Error(err.message);
38193
38559
  }
38194
38560
  };
38195
38561
  return {
@@ -38229,7 +38595,8 @@ function useAccessManagementSvc() {
38229
38595
  getBlockLevelAndUnitListSvc,
38230
38596
  getTransactionsSvc,
38231
38597
  assignMultipleCardsSvc,
38232
- visitorCheckoutSvc
38598
+ visitorCheckoutSvc,
38599
+ uploadTemplateSvc
38233
38600
  };
38234
38601
  }
38235
38602
 
@@ -38272,7 +38639,8 @@ function useAccessManagementController() {
38272
38639
  getBlockLevelAndUnitListSvc,
38273
38640
  getTransactionsSvc,
38274
38641
  assignMultipleCardsSvc,
38275
- visitorCheckoutSvc
38642
+ visitorCheckoutSvc,
38643
+ uploadTemplateSvc
38276
38644
  } = useAccessManagementSvc();
38277
38645
  const addPhysicalCard = async (req, res) => {
38278
38646
  try {
@@ -39089,7 +39457,32 @@ function useAccessManagementController() {
39089
39457
  const result = await visitorCheckoutSvc({ userId });
39090
39458
  return res.status(200).json({ message: "Success", data: result });
39091
39459
  } catch (error) {
39092
- return Promise.reject("Internal Server Error");
39460
+ return res.status(400).json({
39461
+ data: null,
39462
+ message: error.message
39463
+ });
39464
+ }
39465
+ };
39466
+ const uploadTemplate = async (req, res) => {
39467
+ try {
39468
+ const { site } = req.query;
39469
+ const { id, name } = req.body;
39470
+ const schema2 = Joi86.object({
39471
+ site: Joi86.string().hex().required(),
39472
+ id: Joi86.string().hex().required(),
39473
+ name: Joi86.string().required()
39474
+ });
39475
+ const { error } = schema2.validate({ site, id, name });
39476
+ if (error) {
39477
+ return res.status(400).json({ message: error.message });
39478
+ }
39479
+ const result = await uploadTemplateSvc({ site, id, name });
39480
+ return res.status(200).json({ message: "Success", data: result });
39481
+ } catch (error) {
39482
+ return res.status(400).json({
39483
+ data: null,
39484
+ message: error.message
39485
+ });
39093
39486
  }
39094
39487
  };
39095
39488
  return {
@@ -39127,7 +39520,8 @@ function useAccessManagementController() {
39127
39520
  getBlockLevelAndUnitList,
39128
39521
  getTransactions: getTransactions2,
39129
39522
  assignMultipleCards,
39130
- visitorCheckout
39523
+ visitorCheckout,
39524
+ uploadTemplate
39131
39525
  };
39132
39526
  }
39133
39527
 
@@ -39658,7 +40052,7 @@ import {
39658
40052
  InternalServerError as InternalServerError49,
39659
40053
  logger as logger124,
39660
40054
  makeCacheKey as makeCacheKey46,
39661
- NotFoundError as NotFoundError37,
40055
+ NotFoundError as NotFoundError38,
39662
40056
  paginate as paginate41,
39663
40057
  toObjectId as toObjectId14,
39664
40058
  useAtlas as useAtlas79,
@@ -39823,7 +40217,7 @@ function useOccurrenceBookRepo() {
39823
40217
  try {
39824
40218
  const data = await collection.findOne({ _id }, { session });
39825
40219
  if (!data) {
39826
- throw new NotFoundError37("Occurrence book not found.");
40220
+ throw new NotFoundError38("Occurrence book not found.");
39827
40221
  }
39828
40222
  setCache(cacheKey, data, 15 * 60).then(() => {
39829
40223
  logger124.info(`Cache set for key: ${cacheKey}`);
@@ -40320,7 +40714,7 @@ import {
40320
40714
  InternalServerError as InternalServerError50,
40321
40715
  logger as logger126,
40322
40716
  makeCacheKey as makeCacheKey47,
40323
- NotFoundError as NotFoundError38,
40717
+ NotFoundError as NotFoundError39,
40324
40718
  paginate as paginate42,
40325
40719
  useAtlas as useAtlas81,
40326
40720
  useCache as useCache49
@@ -40381,7 +40775,9 @@ function useBulletinVideoRepo() {
40381
40775
  page = 1,
40382
40776
  limit = 10,
40383
40777
  sort = {},
40384
- site = ""
40778
+ site = "",
40779
+ startDate,
40780
+ endDate
40385
40781
  }, session) {
40386
40782
  page = page > 0 ? page - 1 : 0;
40387
40783
  try {
@@ -40389,10 +40785,33 @@ function useBulletinVideoRepo() {
40389
40785
  } catch (error) {
40390
40786
  throw new BadRequestError150("Invalid site ID format.");
40391
40787
  }
40788
+ let dateExpr = {};
40789
+ if (startDate && endDate) {
40790
+ const startingDate = new Date(startDate);
40791
+ startingDate.setUTCHours(0, 0, 0, 0);
40792
+ const endingDate = new Date(endDate);
40793
+ endingDate.setUTCHours(23, 59, 59, 999);
40794
+ const parsedCreatedAt = {
40795
+ $dateFromString: {
40796
+ dateString: "$createdAt",
40797
+ onError: /* @__PURE__ */ new Date(0),
40798
+ onNull: /* @__PURE__ */ new Date(0)
40799
+ }
40800
+ };
40801
+ dateExpr = {
40802
+ $expr: {
40803
+ $and: [
40804
+ { $gte: [parsedCreatedAt, startingDate] },
40805
+ { $lte: [parsedCreatedAt, endingDate] }
40806
+ ]
40807
+ }
40808
+ };
40809
+ }
40392
40810
  const query = {
40393
40811
  site,
40394
40812
  status: { $ne: "deleted" },
40395
- ...search && { $text: { $search: search } }
40813
+ ...search && { $text: { $search: search } },
40814
+ ...dateExpr
40396
40815
  };
40397
40816
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
40398
40817
  const cacheOptions = {
@@ -40401,7 +40820,9 @@ function useBulletinVideoRepo() {
40401
40820
  page,
40402
40821
  limit,
40403
40822
  status: { $ne: "deleted" },
40404
- ...search && { search }
40823
+ ...search && { search },
40824
+ ...startDate && { startDate },
40825
+ ...endDate && { endDate }
40405
40826
  };
40406
40827
  if (search) {
40407
40828
  query.$or = [
@@ -40456,7 +40877,7 @@ function useBulletinVideoRepo() {
40456
40877
  { session }
40457
40878
  );
40458
40879
  if (!data) {
40459
- throw new NotFoundError38("Bulletin video not found.");
40880
+ throw new NotFoundError39("Bulletin video not found.");
40460
40881
  }
40461
40882
  setCache(cacheKey, data, 15 * 60).then(() => {
40462
40883
  logger126.info(`Cache set for key: ${cacheKey}`);
@@ -40549,7 +40970,7 @@ function useBulletinVideoRepo() {
40549
40970
  }
40550
40971
 
40551
40972
  // src/services/bulletin-video.service.ts
40552
- import { useAtlas as useAtlas82 } from "@7365admin1/node-server-utils";
40973
+ import { useAtlas as useAtlas82, NotFoundError as NotFoundError40 } from "@7365admin1/node-server-utils";
40553
40974
  function useBulletinVideoService() {
40554
40975
  const {
40555
40976
  add: _add,
@@ -40557,11 +40978,22 @@ function useBulletinVideoService() {
40557
40978
  deleteBulletinVideoById: _deleteBulletinVideoById,
40558
40979
  getBulletinVideoById: _getBulletinVideoById
40559
40980
  } = useBulletinVideoRepo();
40560
- const { deleteFileById: _deleteFileById } = useFileRepo();
40981
+ const { deleteFileById: _deleteFileById, updateStatusById } = useFileRepo();
40561
40982
  async function add(value) {
40562
40983
  const session = useAtlas82.getClient()?.startSession();
40563
40984
  session?.startTransaction();
40564
40985
  try {
40986
+ const bulletinVideo = value.file;
40987
+ if (bulletinVideo) {
40988
+ const file = await updateStatusById(
40989
+ bulletinVideo,
40990
+ { status: "active" },
40991
+ session
40992
+ );
40993
+ if (!file) {
40994
+ throw new NotFoundError40("File not found.");
40995
+ }
40996
+ }
40565
40997
  await _add(value, session);
40566
40998
  await session?.commitTransaction();
40567
40999
  return "Successfully added bulletin video.";
@@ -40649,7 +41081,9 @@ function useBulletinVideoController() {
40649
41081
  limit: Joi92.number().integer().min(1).max(100).allow("", null).default(10),
40650
41082
  sort: Joi92.string().valid(...Object.values(BulletinVideoSort)).default("_id" /* ID */),
40651
41083
  order: Joi92.string().valid(...Object.values(BulletinVideoOrder)).default("desc" /* DESC */),
40652
- site: Joi92.string().hex().length(24).required()
41084
+ site: Joi92.string().hex().length(24).required(),
41085
+ startDate: Joi92.string().optional().allow("", null),
41086
+ endDate: Joi92.string().optional().allow("", null)
40653
41087
  });
40654
41088
  const { error, value } = validation.validate(req.query, {
40655
41089
  abortEarly: false
@@ -40660,7 +41094,7 @@ function useBulletinVideoController() {
40660
41094
  next(new BadRequestError151(messages));
40661
41095
  return;
40662
41096
  }
40663
- const { search, page, limit, site, sort, order } = value;
41097
+ const { search, page, limit, site, sort, order, startDate, endDate } = value;
40664
41098
  const sortObj = {
40665
41099
  [sort ?? "_id" /* ID */]: order === "asc" /* ASC */ ? 1 : -1
40666
41100
  };
@@ -40670,7 +41104,9 @@ function useBulletinVideoController() {
40670
41104
  page,
40671
41105
  limit,
40672
41106
  sort: sortObj,
40673
- site
41107
+ site,
41108
+ startDate,
41109
+ endDate
40674
41110
  });
40675
41111
  res.status(200).json(data);
40676
41112
  return;
@@ -41898,7 +42334,7 @@ import {
41898
42334
  InternalServerError as InternalServerError52,
41899
42335
  logger as logger133,
41900
42336
  makeCacheKey as makeCacheKey49,
41901
- NotFoundError as NotFoundError40,
42337
+ NotFoundError as NotFoundError42,
41902
42338
  paginate as paginate44,
41903
42339
  useAtlas as useAtlas85,
41904
42340
  useCache as useCache51
@@ -42066,7 +42502,7 @@ function useEntryPassSettingsRepo() {
42066
42502
  }
42067
42503
  ]).toArray();
42068
42504
  if (!data || !data.length) {
42069
- throw new NotFoundError40("Entry Pass Settings not found.");
42505
+ throw new NotFoundError42("Entry Pass Settings not found.");
42070
42506
  }
42071
42507
  setCache(cacheKey, data[0], 15 * 60).then(() => {
42072
42508
  logger133.info(`Cache set for key: ${cacheKey}`);
@@ -42194,7 +42630,7 @@ function useEntryPassSettingsRepo() {
42194
42630
  }
42195
42631
  ]).toArray();
42196
42632
  if (!data || !data.length) {
42197
- throw new NotFoundError40("Entry Pass Settings not found.");
42633
+ throw new NotFoundError42("Entry Pass Settings not found.");
42198
42634
  }
42199
42635
  setCache(cacheKey, data[0], 15 * 60).then(() => {
42200
42636
  logger133.info(`Cache set for key: ${cacheKey}`);
@@ -42994,7 +43430,7 @@ function useNfcPatrolRouteService() {
42994
43430
  import {
42995
43431
  BadRequestError as BadRequestError163,
42996
43432
  logger as logger140,
42997
- NotFoundError as NotFoundError42
43433
+ NotFoundError as NotFoundError44
42998
43434
  } from "@7365admin1/node-server-utils";
42999
43435
  import Joi99 from "joi";
43000
43436
  function useNfcPatrolRouteController() {
@@ -43083,7 +43519,7 @@ function useNfcPatrolRouteController() {
43083
43519
  try {
43084
43520
  const nfcPatrolRoute = await _getById(value?.id, value?.isStart);
43085
43521
  if (!nfcPatrolRoute) {
43086
- throw new NotFoundError42("NFC Patrol Route not found.");
43522
+ throw new NotFoundError44("NFC Patrol Route not found.");
43087
43523
  }
43088
43524
  res.json({
43089
43525
  message: "Successfully retrieved nfc patrol route.",
@@ -43392,7 +43828,7 @@ function MIncidentReport(value) {
43392
43828
  import {
43393
43829
  useAtlas as useAtlas90,
43394
43830
  BadRequestError as BadRequestError165,
43395
- NotFoundError as NotFoundError44
43831
+ NotFoundError as NotFoundError46
43396
43832
  } from "@7365admin1/node-server-utils";
43397
43833
 
43398
43834
  // src/repositories/incident-report.repo.ts
@@ -43401,7 +43837,7 @@ import {
43401
43837
  InternalServerError as InternalServerError55,
43402
43838
  logger as logger141,
43403
43839
  makeCacheKey as makeCacheKey52,
43404
- NotFoundError as NotFoundError43,
43840
+ NotFoundError as NotFoundError45,
43405
43841
  paginate as paginate46,
43406
43842
  useAtlas as useAtlas89,
43407
43843
  useCache as useCache54
@@ -43659,7 +44095,7 @@ function useIncidentReportRepo() {
43659
44095
  { session }
43660
44096
  );
43661
44097
  if (!data) {
43662
- throw new NotFoundError43("Incident report not found.");
44098
+ throw new NotFoundError45("Incident report not found.");
43663
44099
  }
43664
44100
  setCache(cacheKey, data, 15 * 60).then(() => {
43665
44101
  logger141.info(`Cache set for key: ${cacheKey}`);
@@ -43856,7 +44292,7 @@ function useIncidentReportService() {
43856
44292
  session
43857
44293
  );
43858
44294
  if (!file) {
43859
- throw new NotFoundError44("File not found.");
44295
+ throw new NotFoundError46("File not found.");
43860
44296
  }
43861
44297
  }
43862
44298
  }
@@ -44326,7 +44762,7 @@ import {
44326
44762
  InternalServerError as InternalServerError56,
44327
44763
  logger as logger144,
44328
44764
  makeCacheKey as makeCacheKey53,
44329
- NotFoundError as NotFoundError45,
44765
+ NotFoundError as NotFoundError47,
44330
44766
  useAtlas as useAtlas91,
44331
44767
  useCache as useCache55
44332
44768
  } from "@7365admin1/node-server-utils";
@@ -44416,7 +44852,7 @@ function useNfcPatrolSettingsRepository() {
44416
44852
  { session }
44417
44853
  );
44418
44854
  if (res.matchedCount === 0) {
44419
- throw new NotFoundError45("NFC patrol settings not found for this site.");
44855
+ throw new NotFoundError47("NFC patrol settings not found for this site.");
44420
44856
  }
44421
44857
  delNamespace().then(() => {
44422
44858
  logger144.info(`Cache cleared for namespace: ${namespace_collection}`);
@@ -44581,7 +45017,7 @@ import {
44581
45017
  InternalServerError as InternalServerError57,
44582
45018
  logger as logger147,
44583
45019
  makeCacheKey as makeCacheKey54,
44584
- NotFoundError as NotFoundError46,
45020
+ NotFoundError as NotFoundError48,
44585
45021
  paginate as paginate47,
44586
45022
  useAtlas as useAtlas93,
44587
45023
  useCache as useCache56
@@ -44809,7 +45245,7 @@ function useOccurrenceSubjectRepo() {
44809
45245
  try {
44810
45246
  const data = await collection.findOne({ _id }, { session });
44811
45247
  if (!data) {
44812
- throw new NotFoundError46("Occurrence subject not found.");
45248
+ throw new NotFoundError48("Occurrence subject not found.");
44813
45249
  }
44814
45250
  setCache(cacheKey, data, 15 * 60).then(() => {
44815
45251
  logger147.info(`Cache set for key: ${cacheKey}`);
@@ -45267,7 +45703,7 @@ import {
45267
45703
  InternalServerError as InternalServerError58,
45268
45704
  logger as logger149,
45269
45705
  makeCacheKey as makeCacheKey55,
45270
- NotFoundError as NotFoundError47,
45706
+ NotFoundError as NotFoundError49,
45271
45707
  paginate as paginate48,
45272
45708
  useAtlas as useAtlas95,
45273
45709
  useCache as useCache57
@@ -45413,7 +45849,7 @@ function useOnlineFormRepo() {
45413
45849
  }
45414
45850
  ]).toArray();
45415
45851
  if (!data || !data.length) {
45416
- throw new NotFoundError47("Document not found.");
45852
+ throw new NotFoundError49("Document not found.");
45417
45853
  }
45418
45854
  setCache(cacheKey, data[0], 15 * 60).then(() => {
45419
45855
  logger149.info(`Cache set for key: ${cacheKey}`);
@@ -51292,7 +51728,7 @@ import {
51292
51728
  logger as logger178,
51293
51729
  getDirectory as getDirectory5,
51294
51730
  BadRequestError as BadRequestError200,
51295
- NotFoundError as NotFoundError51,
51731
+ NotFoundError as NotFoundError53,
51296
51732
  InternalServerError as InternalServerError69,
51297
51733
  useAtlas as useAtlas113,
51298
51734
  hashPassword as hashPassword4
@@ -51421,7 +51857,7 @@ function useVerificationServiceV2() {
51421
51857
  session?.startTransaction();
51422
51858
  const item = await _getByVerificationCode(verificationCode);
51423
51859
  if (!item) {
51424
- throw new NotFoundError51("Verification not found.");
51860
+ throw new NotFoundError53("Verification not found.");
51425
51861
  }
51426
51862
  switch (item.status) {
51427
51863
  case "expired" /* EXPIRED */:
@@ -51911,7 +52347,7 @@ import {
51911
52347
  BadRequestError as BadRequestError203,
51912
52348
  comparePassword as comparePassword3,
51913
52349
  InternalServerError as InternalServerError71,
51914
- NotFoundError as NotFoundError53,
52350
+ NotFoundError as NotFoundError55,
51915
52351
  useCache as useCache67
51916
52352
  } from "@7365admin1/node-server-utils";
51917
52353
  import { v4 as uuidv42 } from "uuid";
@@ -51924,7 +52360,7 @@ import {
51924
52360
  logger as logger180,
51925
52361
  BadRequestError as BadRequestError202,
51926
52362
  paginate as paginate58,
51927
- NotFoundError as NotFoundError52,
52363
+ NotFoundError as NotFoundError54,
51928
52364
  AppError as AppError28,
51929
52365
  useCache as useCache66,
51930
52366
  makeCacheKey as makeCacheKey64,
@@ -52057,7 +52493,7 @@ function useUserRepoV2() {
52057
52493
  ]).toArray();
52058
52494
  const data = results.length > 0 ? results[0] : null;
52059
52495
  if (!data)
52060
- throw new NotFoundError52("User not found.");
52496
+ throw new NotFoundError54("User not found.");
52061
52497
  setCache(cacheKey, data, 15 * 60).then(() => logger180.info(`Cache set for key: ${cacheKey}`)).catch(
52062
52498
  (err) => logger180.error(`Failed to set cache for key: ${cacheKey}`, err)
52063
52499
  );
@@ -52398,7 +52834,7 @@ function useAuthServiceV2() {
52398
52834
  try {
52399
52835
  const user = await getUserByEmail(email);
52400
52836
  if (!user) {
52401
- throw new NotFoundError53(
52837
+ throw new NotFoundError55(
52402
52838
  "Invalid user email. Please check your email and try again."
52403
52839
  );
52404
52840
  }
@@ -52468,7 +52904,7 @@ import {
52468
52904
  comparePassword as comparePassword4,
52469
52905
  hashPassword as hashPassword5,
52470
52906
  InternalServerError as InternalServerError72,
52471
- NotFoundError as NotFoundError54,
52907
+ NotFoundError as NotFoundError56,
52472
52908
  useAtlas as useAtlas115,
52473
52909
  useS3 as useS33
52474
52910
  } from "@7365admin1/node-server-utils";
@@ -52572,14 +53008,14 @@ function useUserServiceV2() {
52572
53008
  try {
52573
53009
  const otpDoc = await _getVerificationById(id);
52574
53010
  if (!otpDoc) {
52575
- throw new NotFoundError54("You are using an invalid reset link.");
53011
+ throw new NotFoundError56("You are using an invalid reset link.");
52576
53012
  }
52577
53013
  if (otpDoc.status === "complete" /* COMPLETE */) {
52578
53014
  throw new BadRequestError204("This link has already been invalidated.");
52579
53015
  }
52580
53016
  const user = await _getUserByEmail(otpDoc.email);
52581
53017
  if (!user) {
52582
- throw new NotFoundError54("User not found.");
53018
+ throw new NotFoundError56("User not found.");
52583
53019
  }
52584
53020
  if (!user._id) {
52585
53021
  throw new InternalServerError72("Invalid user ID.");