@7365admin1/core 2.61.0 → 2.62.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
@@ -18109,6 +18109,167 @@ function useVehicleService() {
18109
18109
  throw error;
18110
18110
  }
18111
18111
  }
18112
+ async function blocklistVehicles(_id, value) {
18113
+ const session = useAtlas34.getClient()?.startSession();
18114
+ if (!session) {
18115
+ throw new Error("Unable to start session for vehicle service.");
18116
+ }
18117
+ try {
18118
+ session.startTransaction();
18119
+ const vehicle = await _getVehicleById(_id);
18120
+ const plate = vehicle.plates.find((p) => p._id.toString() === _id);
18121
+ const _name = value.name ? value.name : vehicle.name;
18122
+ const _plateNumber = plate?.plateNumber;
18123
+ const _start = vehicle.start;
18124
+ const _end = vehicle.end;
18125
+ const _recNo = plate.recNo;
18126
+ const _type = plate.type;
18127
+ if (value.peopleId) {
18128
+ value.peopleId = new ObjectId46(value.peopleId);
18129
+ }
18130
+ const { site } = value;
18131
+ const startDahua = formatDahuaDate(_start);
18132
+ const endPlus24Hours = _end ? _end : new Date(new Date(_end).getTime() + 24 * 60 * 60 * 1e3);
18133
+ const endDahua = formatDahuaDate(endPlus24Hours);
18134
+ if (_plateNumber) {
18135
+ const siteCameras = [];
18136
+ let page = 1;
18137
+ let pages = 1;
18138
+ const limit = 20;
18139
+ do {
18140
+ const siteCameraReq = await _getAllSiteCameras({
18141
+ site,
18142
+ type: "anpr",
18143
+ direction: ["both", "entry"],
18144
+ page,
18145
+ limit
18146
+ });
18147
+ pages = siteCameraReq.pages || 1;
18148
+ siteCameras.push(...siteCameraReq.items);
18149
+ page++;
18150
+ } while (page < pages);
18151
+ if (!siteCameras.length) {
18152
+ throw new BadRequestError73("No site cameras found.");
18153
+ }
18154
+ for (const camera of siteCameras) {
18155
+ const { host, username, password } = camera;
18156
+ const removePlateNumber = {
18157
+ host,
18158
+ username,
18159
+ password,
18160
+ mode: _type === "blocklist" /* BLOCKLIST */ ? "TrafficBlackList" /* TRAFFIC_BLACKLIST */ : "TrafficRedList" /* TRAFFIC_REDLIST */,
18161
+ recno: _recNo
18162
+ };
18163
+ const responseForDeletion = await _removePlateNumber(
18164
+ removePlateNumber
18165
+ );
18166
+ if (responseForDeletion?.statusCode !== 200) {
18167
+ throw new BadRequestError73("Failed to delete plate number to ANPR");
18168
+ }
18169
+ const dahuaPayload = {
18170
+ host,
18171
+ username,
18172
+ password,
18173
+ plateNumber: _plateNumber,
18174
+ mode: "TrafficBlackList" /* TRAFFIC_BLACKLIST */,
18175
+ owner: _name,
18176
+ ...startDahua ? { start: startDahua } : {},
18177
+ ...endDahua ? { end: endDahua } : {}
18178
+ };
18179
+ const dahuaResponse = await _addPlateNumber(dahuaPayload);
18180
+ if (dahuaResponse?.statusCode !== 200) {
18181
+ throw new BadRequestError73("Failed to update plate number to ANPR");
18182
+ }
18183
+ const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
18184
+ value.recNo = responseData.split("=")[1]?.trim();
18185
+ const normalizedPlateNumber = _plateNumber;
18186
+ if (value.peopleId && value.recNo) {
18187
+ await _pushVehicleById(
18188
+ value.peopleId,
18189
+ {
18190
+ plateNumber: normalizedPlateNumber,
18191
+ recNo: value.recNo
18192
+ },
18193
+ session
18194
+ );
18195
+ }
18196
+ }
18197
+ }
18198
+ const formattedValue = {
18199
+ type: "blocklist" /* BLOCKLIST */,
18200
+ recNo: value.recNo
18201
+ };
18202
+ await _updateVehicleById(_id, formattedValue, session);
18203
+ await session.commitTransaction();
18204
+ } catch (error) {
18205
+ await session.abortTransaction();
18206
+ throw error;
18207
+ } finally {
18208
+ session.endSession();
18209
+ }
18210
+ }
18211
+ async function removeFromBlocklist(_id, value) {
18212
+ const session = useAtlas34.getClient()?.startSession();
18213
+ if (!session) {
18214
+ throw new Error("Unable to start session for vehicle service.");
18215
+ }
18216
+ try {
18217
+ session.startTransaction();
18218
+ const vehicle = await _getVehicleById(_id);
18219
+ const plate = vehicle.plates.find((p) => p._id.toString() === _id);
18220
+ const _plateNumber = plate?.plateNumber;
18221
+ const _recNo = plate.recNo;
18222
+ if (value.peopleId) {
18223
+ value.peopleId = new ObjectId46(value.peopleId);
18224
+ }
18225
+ const { site } = value;
18226
+ if (_plateNumber) {
18227
+ const siteCameras = [];
18228
+ let page = 1;
18229
+ let pages = 1;
18230
+ const limit = 20;
18231
+ do {
18232
+ const siteCameraReq = await _getAllSiteCameras({
18233
+ site,
18234
+ type: "anpr",
18235
+ direction: ["both", "entry"],
18236
+ page,
18237
+ limit
18238
+ });
18239
+ pages = siteCameraReq.pages || 1;
18240
+ siteCameras.push(...siteCameraReq.items);
18241
+ page++;
18242
+ } while (page < pages);
18243
+ if (!siteCameras.length) {
18244
+ throw new BadRequestError73("No site cameras found.");
18245
+ }
18246
+ for (const camera of siteCameras) {
18247
+ const { host, username, password } = camera;
18248
+ const removePlateNumber = {
18249
+ host,
18250
+ username,
18251
+ password,
18252
+ mode: "TrafficBlackList" /* TRAFFIC_BLACKLIST */,
18253
+ recno: _recNo
18254
+ };
18255
+ console.log(removePlateNumber);
18256
+ const responseForDeletion = await _removePlateNumber(
18257
+ removePlateNumber
18258
+ );
18259
+ if (responseForDeletion?.statusCode !== 200) {
18260
+ throw new BadRequestError73("Failed to delete plate number to ANPR");
18261
+ }
18262
+ }
18263
+ }
18264
+ await _deleteVehicle(_id, session);
18265
+ await session.commitTransaction();
18266
+ } catch (error) {
18267
+ await session.abortTransaction();
18268
+ throw error;
18269
+ } finally {
18270
+ session.endSession();
18271
+ }
18272
+ }
18112
18273
  return {
18113
18274
  add,
18114
18275
  deleteVehicle,
@@ -18116,7 +18277,9 @@ function useVehicleService() {
18116
18277
  processDeletingExpiredVehicles,
18117
18278
  reactivateVehicleById,
18118
18279
  updateVehicleById,
18119
- bulkUpsertVehicles
18280
+ bulkUpsertVehicles,
18281
+ blocklistVehicles,
18282
+ removeFromBlocklist
18120
18283
  };
18121
18284
  }
18122
18285
 
@@ -20486,7 +20649,7 @@ function useBuildingService() {
20486
20649
  getByBuildingLevel,
20487
20650
  updateLevelByBuildingLevel,
20488
20651
  updateByBuildingId,
20489
- add: _addBuildingUnit
20652
+ bulkAddBuildingUnits: _bulkAddBuildingUnits
20490
20653
  } = useBuildingUnitRepo();
20491
20654
  const { updateStatusById } = useFileRepo();
20492
20655
  const { deleteFile } = useFileService();
@@ -20675,15 +20838,16 @@ function useBuildingService() {
20675
20838
  companyName: "",
20676
20839
  companyRegistrationNumber: "",
20677
20840
  billing: [],
20678
- unitNumber: parseInt(unit.replace("Unit ", ""), 10) || null
20841
+ unitNumber: parseInt(unit.replace("Unit ", ""), 10) || null,
20842
+ createdAt: /* @__PURE__ */ new Date(),
20843
+ updatedAt: "",
20844
+ deletedAt: ""
20679
20845
  });
20680
20846
  });
20681
20847
  });
20682
20848
  }
20683
20849
  );
20684
- for (const buildingUnitPayload of buildingUnitPayloads) {
20685
- const result = await _addBuildingUnit(buildingUnitPayload);
20686
- }
20850
+ await _bulkAddBuildingUnits(buildingUnitPayloads);
20687
20851
  await session?.commitTransaction();
20688
20852
  return { buildingPayloads, buildingUnitPayloads };
20689
20853
  } catch (error) {
@@ -21429,7 +21593,9 @@ function useVehicleController() {
21429
21593
  approveVehicleById: _approveVehicleById,
21430
21594
  reactivateVehicleById: _reactivateVehicleById,
21431
21595
  updateVehicleById: _updateVehicleById,
21432
- bulkUpsertVehicles: _bulkUpsertVehicles
21596
+ bulkUpsertVehicles: _bulkUpsertVehicles,
21597
+ blocklistVehicles: _blocklistVehicles,
21598
+ removeFromBlocklist: _removeFromBlocklist
21433
21599
  } = useVehicleService();
21434
21600
  const {
21435
21601
  getSeasonPassTypes: _getSeasonPassTypes,
@@ -22006,6 +22172,68 @@ function useVehicleController() {
22006
22172
  return;
22007
22173
  }
22008
22174
  }
22175
+ async function blocklistVehicles(req, res, next) {
22176
+ try {
22177
+ const schema2 = Joi47.object({
22178
+ _id: Joi47.string().hex().length(24).required(),
22179
+ site: Joi47.string().hex().length(24).required(),
22180
+ peopleId: Joi47.string().hex().length(24).optional().allow(null, ""),
22181
+ remarks: Joi47.string().optional().allow("", null)
22182
+ });
22183
+ const { error, value } = schema2.validate(
22184
+ {
22185
+ _id: req.params.id,
22186
+ ...req.body
22187
+ },
22188
+ { abortEarly: false }
22189
+ );
22190
+ if (error) {
22191
+ const messages = error.details.map((d) => d.message).join(", ");
22192
+ logger66.log({ level: "error", message: messages });
22193
+ next(new BadRequestError85(messages));
22194
+ return;
22195
+ }
22196
+ const { _id, ...rest } = value;
22197
+ await _blocklistVehicles(_id, rest);
22198
+ res.json({ message: "Successfully blocked vehicle." });
22199
+ return;
22200
+ } catch (error) {
22201
+ logger66.log({ level: "error", message: error.message });
22202
+ next(error);
22203
+ return;
22204
+ }
22205
+ }
22206
+ async function removeFromBlocklist(req, res, next) {
22207
+ try {
22208
+ const schema2 = Joi47.object({
22209
+ _id: Joi47.string().hex().length(24).required(),
22210
+ site: Joi47.string().hex().length(24).required(),
22211
+ peopleId: Joi47.string().hex().length(24).optional().allow(null, ""),
22212
+ remarks: Joi47.string().optional().allow("", null)
22213
+ });
22214
+ const { error, value } = schema2.validate(
22215
+ {
22216
+ _id: req.params.id,
22217
+ ...req.body
22218
+ },
22219
+ { abortEarly: false }
22220
+ );
22221
+ if (error) {
22222
+ const messages = error.details.map((d) => d.message).join(", ");
22223
+ logger66.log({ level: "error", message: messages });
22224
+ next(new BadRequestError85(messages));
22225
+ return;
22226
+ }
22227
+ const { _id, ...rest } = value;
22228
+ await _removeFromBlocklist(_id, rest);
22229
+ res.json({ message: "Successfully removed vehicle from blocklist." });
22230
+ return;
22231
+ } catch (error) {
22232
+ logger66.log({ level: "error", message: error.message });
22233
+ next(error);
22234
+ return;
22235
+ }
22236
+ }
22009
22237
  return {
22010
22238
  add,
22011
22239
  getVehicles,
@@ -22019,7 +22247,9 @@ function useVehicleController() {
22019
22247
  getAllVehiclesByUnitId,
22020
22248
  uploadSpreadsheetVehicles,
22021
22249
  getSpecificVehicleById,
22022
- getBlocklistedVehicles
22250
+ getBlocklistedVehicles,
22251
+ blocklistVehicles,
22252
+ removeFromBlocklist
22023
22253
  };
22024
22254
  }
22025
22255
 
@@ -31651,6 +31881,18 @@ function MBulletinBoard(value) {
31651
31881
  throw new Error("Invalid org ID.");
31652
31882
  }
31653
31883
  }
31884
+ if (value.file && Array.isArray(value.file)) {
31885
+ value.file = value.file.map((f) => {
31886
+ if (f._id && typeof f._id === "string") {
31887
+ try {
31888
+ return { ...f, _id: new ObjectId78(f._id) };
31889
+ } catch {
31890
+ throw new Error("Invalid file ID.");
31891
+ }
31892
+ }
31893
+ return f;
31894
+ });
31895
+ }
31654
31896
  return {
31655
31897
  _id: value._id ?? new ObjectId78(),
31656
31898
  site: value.site ?? "",
@@ -31968,7 +32210,7 @@ function useBulletinBoardRepo() {
31968
32210
  }
31969
32211
 
31970
32212
  // src/services/bulletin-board.service.ts
31971
- import { useAtlas as useAtlas67 } from "@7365admin1/node-server-utils";
32213
+ import { useAtlas as useAtlas67, NotFoundError as NotFoundError31 } from "@7365admin1/node-server-utils";
31972
32214
  function useBulletinBoardService() {
31973
32215
  const {
31974
32216
  add: _add,
@@ -31978,7 +32220,7 @@ function useBulletinBoardService() {
31978
32220
  deleteBulletinBoardById: _deleteBulletinBoardById,
31979
32221
  getBulletinBoardById: _getBulletinBoardById
31980
32222
  } = useBulletinBoardRepo();
31981
- const { deleteFileById: _deleteFileById } = useFileRepo();
32223
+ const { deleteFileById: _deleteFileById, updateStatusById } = useFileRepo();
31982
32224
  async function add(value) {
31983
32225
  const session = useAtlas67.getClient()?.startSession();
31984
32226
  session?.startTransaction();
@@ -31986,6 +32228,21 @@ function useBulletinBoardService() {
31986
32228
  value.status = "upcoming" /* UPCOMING */;
31987
32229
  }
31988
32230
  try {
32231
+ const bulletinFiles = value?.file ?? [];
32232
+ if (bulletinFiles.length > 0) {
32233
+ for (const bulletinFile of bulletinFiles) {
32234
+ if (!bulletinFile._id)
32235
+ continue;
32236
+ const file = await updateStatusById(
32237
+ bulletinFile._id.toString(),
32238
+ { status: "active" },
32239
+ session
32240
+ );
32241
+ if (!file) {
32242
+ throw new NotFoundError31("File not found.");
32243
+ }
32244
+ }
32245
+ }
31989
32246
  await _add(value, session);
31990
32247
  await session?.commitTransaction();
31991
32248
  return "Successfully added bulletin board.";
@@ -33617,7 +33874,7 @@ import {
33617
33874
  InternalServerError as InternalServerError45,
33618
33875
  logger as logger115,
33619
33876
  makeCacheKey as makeCacheKey42,
33620
- NotFoundError as NotFoundError33,
33877
+ NotFoundError as NotFoundError34,
33621
33878
  paginate as paginate37,
33622
33879
  useAtlas as useAtlas72,
33623
33880
  useCache as useCache44
@@ -33781,7 +34038,7 @@ function useEventManagementRepo() {
33781
34038
  try {
33782
34039
  const data = await collection.findOne({ _id }, { session });
33783
34040
  if (!data) {
33784
- throw new NotFoundError33("Event not found.");
34041
+ throw new NotFoundError34("Event not found.");
33785
34042
  }
33786
34043
  setCache(cacheKey, data, 15 * 60).then(() => {
33787
34044
  logger115.info(`Cache set for key: ${cacheKey}`);
@@ -33878,7 +34135,7 @@ function useEventManagementRepo() {
33878
34135
  { session }
33879
34136
  );
33880
34137
  if (res.matchedCount === 0) {
33881
- throw new NotFoundError33("No bulletin boards found to update.");
34138
+ throw new NotFoundError34("No bulletin boards found to update.");
33882
34139
  }
33883
34140
  delNamespace().then(() => {
33884
34141
  logger115.info(
@@ -37799,6 +38056,19 @@ function UseAccessManagementRepo() {
37799
38056
  await session?.endSession();
37800
38057
  }
37801
38058
  }
38059
+ async function uploadTemplateRepo({ site, id, name }) {
38060
+ site = new ObjectId90(site);
38061
+ id = new ObjectId90(id);
38062
+ try {
38063
+ const result = await collectionName("sites").updateOne(
38064
+ { _id: site },
38065
+ { $set: { "siteSettings.entryPass.settings.template": { id, name } } }
38066
+ );
38067
+ return result;
38068
+ } catch (error) {
38069
+ throw new Error(error.message);
38070
+ }
38071
+ }
37802
38072
  return {
37803
38073
  createIndexes,
37804
38074
  createIndexForEntrypass,
@@ -37833,7 +38103,8 @@ function UseAccessManagementRepo() {
37833
38103
  indexCombination,
37834
38104
  getTransactionsRepo,
37835
38105
  assignMultipleCardsRepo,
37836
- visitorCheckoutRepo
38106
+ visitorCheckoutRepo,
38107
+ uploadTemplateRepo
37837
38108
  };
37838
38109
  }
37839
38110
 
@@ -37876,7 +38147,8 @@ function useAccessManagementSvc() {
37876
38147
  getBlockLevelAndUnitListRepo,
37877
38148
  getTransactionsRepo,
37878
38149
  assignMultipleCardsRepo,
37879
- visitorCheckoutRepo
38150
+ visitorCheckoutRepo,
38151
+ uploadTemplateRepo
37880
38152
  } = UseAccessManagementRepo();
37881
38153
  const addPhysicalCardSvc = async (payload) => {
37882
38154
  try {
@@ -38189,7 +38461,15 @@ function useAccessManagementSvc() {
38189
38461
  const response = await visitorCheckoutRepo({ userId });
38190
38462
  return response;
38191
38463
  } catch (err) {
38192
- return Promise.reject("Server internal error.");
38464
+ throw new Error(err.message);
38465
+ }
38466
+ };
38467
+ const uploadTemplateSvc = async ({ site, id, name }) => {
38468
+ try {
38469
+ const response = await uploadTemplateRepo({ site, id, name });
38470
+ return response;
38471
+ } catch (err) {
38472
+ throw new Error(err.message);
38193
38473
  }
38194
38474
  };
38195
38475
  return {
@@ -38229,7 +38509,8 @@ function useAccessManagementSvc() {
38229
38509
  getBlockLevelAndUnitListSvc,
38230
38510
  getTransactionsSvc,
38231
38511
  assignMultipleCardsSvc,
38232
- visitorCheckoutSvc
38512
+ visitorCheckoutSvc,
38513
+ uploadTemplateSvc
38233
38514
  };
38234
38515
  }
38235
38516
 
@@ -38272,7 +38553,8 @@ function useAccessManagementController() {
38272
38553
  getBlockLevelAndUnitListSvc,
38273
38554
  getTransactionsSvc,
38274
38555
  assignMultipleCardsSvc,
38275
- visitorCheckoutSvc
38556
+ visitorCheckoutSvc,
38557
+ uploadTemplateSvc
38276
38558
  } = useAccessManagementSvc();
38277
38559
  const addPhysicalCard = async (req, res) => {
38278
38560
  try {
@@ -39089,7 +39371,32 @@ function useAccessManagementController() {
39089
39371
  const result = await visitorCheckoutSvc({ userId });
39090
39372
  return res.status(200).json({ message: "Success", data: result });
39091
39373
  } catch (error) {
39092
- return Promise.reject("Internal Server Error");
39374
+ return res.status(400).json({
39375
+ data: null,
39376
+ message: error.message
39377
+ });
39378
+ }
39379
+ };
39380
+ const uploadTemplate = async (req, res) => {
39381
+ try {
39382
+ const { site } = req.query;
39383
+ const { id, name } = req.body;
39384
+ const schema2 = Joi86.object({
39385
+ site: Joi86.string().hex().required(),
39386
+ id: Joi86.string().hex().required(),
39387
+ name: Joi86.string().required()
39388
+ });
39389
+ const { error } = schema2.validate({ site, id, name });
39390
+ if (error) {
39391
+ return res.status(400).json({ message: error.message });
39392
+ }
39393
+ const result = await uploadTemplateSvc({ site, id, name });
39394
+ return res.status(200).json({ message: "Success", data: result });
39395
+ } catch (error) {
39396
+ return res.status(400).json({
39397
+ data: null,
39398
+ message: error.message
39399
+ });
39093
39400
  }
39094
39401
  };
39095
39402
  return {
@@ -39127,7 +39434,8 @@ function useAccessManagementController() {
39127
39434
  getBlockLevelAndUnitList,
39128
39435
  getTransactions: getTransactions2,
39129
39436
  assignMultipleCards,
39130
- visitorCheckout
39437
+ visitorCheckout,
39438
+ uploadTemplate
39131
39439
  };
39132
39440
  }
39133
39441
 
@@ -39658,7 +39966,7 @@ import {
39658
39966
  InternalServerError as InternalServerError49,
39659
39967
  logger as logger124,
39660
39968
  makeCacheKey as makeCacheKey46,
39661
- NotFoundError as NotFoundError37,
39969
+ NotFoundError as NotFoundError38,
39662
39970
  paginate as paginate41,
39663
39971
  toObjectId as toObjectId14,
39664
39972
  useAtlas as useAtlas79,
@@ -39823,7 +40131,7 @@ function useOccurrenceBookRepo() {
39823
40131
  try {
39824
40132
  const data = await collection.findOne({ _id }, { session });
39825
40133
  if (!data) {
39826
- throw new NotFoundError37("Occurrence book not found.");
40134
+ throw new NotFoundError38("Occurrence book not found.");
39827
40135
  }
39828
40136
  setCache(cacheKey, data, 15 * 60).then(() => {
39829
40137
  logger124.info(`Cache set for key: ${cacheKey}`);
@@ -40320,7 +40628,7 @@ import {
40320
40628
  InternalServerError as InternalServerError50,
40321
40629
  logger as logger126,
40322
40630
  makeCacheKey as makeCacheKey47,
40323
- NotFoundError as NotFoundError38,
40631
+ NotFoundError as NotFoundError39,
40324
40632
  paginate as paginate42,
40325
40633
  useAtlas as useAtlas81,
40326
40634
  useCache as useCache49
@@ -40456,7 +40764,7 @@ function useBulletinVideoRepo() {
40456
40764
  { session }
40457
40765
  );
40458
40766
  if (!data) {
40459
- throw new NotFoundError38("Bulletin video not found.");
40767
+ throw new NotFoundError39("Bulletin video not found.");
40460
40768
  }
40461
40769
  setCache(cacheKey, data, 15 * 60).then(() => {
40462
40770
  logger126.info(`Cache set for key: ${cacheKey}`);
@@ -40549,7 +40857,7 @@ function useBulletinVideoRepo() {
40549
40857
  }
40550
40858
 
40551
40859
  // src/services/bulletin-video.service.ts
40552
- import { useAtlas as useAtlas82 } from "@7365admin1/node-server-utils";
40860
+ import { useAtlas as useAtlas82, NotFoundError as NotFoundError40 } from "@7365admin1/node-server-utils";
40553
40861
  function useBulletinVideoService() {
40554
40862
  const {
40555
40863
  add: _add,
@@ -40557,11 +40865,22 @@ function useBulletinVideoService() {
40557
40865
  deleteBulletinVideoById: _deleteBulletinVideoById,
40558
40866
  getBulletinVideoById: _getBulletinVideoById
40559
40867
  } = useBulletinVideoRepo();
40560
- const { deleteFileById: _deleteFileById } = useFileRepo();
40868
+ const { deleteFileById: _deleteFileById, updateStatusById } = useFileRepo();
40561
40869
  async function add(value) {
40562
40870
  const session = useAtlas82.getClient()?.startSession();
40563
40871
  session?.startTransaction();
40564
40872
  try {
40873
+ const bulletinVideo = value.file;
40874
+ if (bulletinVideo) {
40875
+ const file = await updateStatusById(
40876
+ bulletinVideo,
40877
+ { status: "active" },
40878
+ session
40879
+ );
40880
+ if (!file) {
40881
+ throw new NotFoundError40("File not found.");
40882
+ }
40883
+ }
40565
40884
  await _add(value, session);
40566
40885
  await session?.commitTransaction();
40567
40886
  return "Successfully added bulletin video.";
@@ -41898,7 +42217,7 @@ import {
41898
42217
  InternalServerError as InternalServerError52,
41899
42218
  logger as logger133,
41900
42219
  makeCacheKey as makeCacheKey49,
41901
- NotFoundError as NotFoundError40,
42220
+ NotFoundError as NotFoundError42,
41902
42221
  paginate as paginate44,
41903
42222
  useAtlas as useAtlas85,
41904
42223
  useCache as useCache51
@@ -42066,7 +42385,7 @@ function useEntryPassSettingsRepo() {
42066
42385
  }
42067
42386
  ]).toArray();
42068
42387
  if (!data || !data.length) {
42069
- throw new NotFoundError40("Entry Pass Settings not found.");
42388
+ throw new NotFoundError42("Entry Pass Settings not found.");
42070
42389
  }
42071
42390
  setCache(cacheKey, data[0], 15 * 60).then(() => {
42072
42391
  logger133.info(`Cache set for key: ${cacheKey}`);
@@ -42194,7 +42513,7 @@ function useEntryPassSettingsRepo() {
42194
42513
  }
42195
42514
  ]).toArray();
42196
42515
  if (!data || !data.length) {
42197
- throw new NotFoundError40("Entry Pass Settings not found.");
42516
+ throw new NotFoundError42("Entry Pass Settings not found.");
42198
42517
  }
42199
42518
  setCache(cacheKey, data[0], 15 * 60).then(() => {
42200
42519
  logger133.info(`Cache set for key: ${cacheKey}`);
@@ -42994,7 +43313,7 @@ function useNfcPatrolRouteService() {
42994
43313
  import {
42995
43314
  BadRequestError as BadRequestError163,
42996
43315
  logger as logger140,
42997
- NotFoundError as NotFoundError42
43316
+ NotFoundError as NotFoundError44
42998
43317
  } from "@7365admin1/node-server-utils";
42999
43318
  import Joi99 from "joi";
43000
43319
  function useNfcPatrolRouteController() {
@@ -43083,7 +43402,7 @@ function useNfcPatrolRouteController() {
43083
43402
  try {
43084
43403
  const nfcPatrolRoute = await _getById(value?.id, value?.isStart);
43085
43404
  if (!nfcPatrolRoute) {
43086
- throw new NotFoundError42("NFC Patrol Route not found.");
43405
+ throw new NotFoundError44("NFC Patrol Route not found.");
43087
43406
  }
43088
43407
  res.json({
43089
43408
  message: "Successfully retrieved nfc patrol route.",
@@ -43392,7 +43711,7 @@ function MIncidentReport(value) {
43392
43711
  import {
43393
43712
  useAtlas as useAtlas90,
43394
43713
  BadRequestError as BadRequestError165,
43395
- NotFoundError as NotFoundError44
43714
+ NotFoundError as NotFoundError46
43396
43715
  } from "@7365admin1/node-server-utils";
43397
43716
 
43398
43717
  // src/repositories/incident-report.repo.ts
@@ -43401,7 +43720,7 @@ import {
43401
43720
  InternalServerError as InternalServerError55,
43402
43721
  logger as logger141,
43403
43722
  makeCacheKey as makeCacheKey52,
43404
- NotFoundError as NotFoundError43,
43723
+ NotFoundError as NotFoundError45,
43405
43724
  paginate as paginate46,
43406
43725
  useAtlas as useAtlas89,
43407
43726
  useCache as useCache54
@@ -43659,7 +43978,7 @@ function useIncidentReportRepo() {
43659
43978
  { session }
43660
43979
  );
43661
43980
  if (!data) {
43662
- throw new NotFoundError43("Incident report not found.");
43981
+ throw new NotFoundError45("Incident report not found.");
43663
43982
  }
43664
43983
  setCache(cacheKey, data, 15 * 60).then(() => {
43665
43984
  logger141.info(`Cache set for key: ${cacheKey}`);
@@ -43856,7 +44175,7 @@ function useIncidentReportService() {
43856
44175
  session
43857
44176
  );
43858
44177
  if (!file) {
43859
- throw new NotFoundError44("File not found.");
44178
+ throw new NotFoundError46("File not found.");
43860
44179
  }
43861
44180
  }
43862
44181
  }
@@ -44326,7 +44645,7 @@ import {
44326
44645
  InternalServerError as InternalServerError56,
44327
44646
  logger as logger144,
44328
44647
  makeCacheKey as makeCacheKey53,
44329
- NotFoundError as NotFoundError45,
44648
+ NotFoundError as NotFoundError47,
44330
44649
  useAtlas as useAtlas91,
44331
44650
  useCache as useCache55
44332
44651
  } from "@7365admin1/node-server-utils";
@@ -44416,7 +44735,7 @@ function useNfcPatrolSettingsRepository() {
44416
44735
  { session }
44417
44736
  );
44418
44737
  if (res.matchedCount === 0) {
44419
- throw new NotFoundError45("NFC patrol settings not found for this site.");
44738
+ throw new NotFoundError47("NFC patrol settings not found for this site.");
44420
44739
  }
44421
44740
  delNamespace().then(() => {
44422
44741
  logger144.info(`Cache cleared for namespace: ${namespace_collection}`);
@@ -44581,7 +44900,7 @@ import {
44581
44900
  InternalServerError as InternalServerError57,
44582
44901
  logger as logger147,
44583
44902
  makeCacheKey as makeCacheKey54,
44584
- NotFoundError as NotFoundError46,
44903
+ NotFoundError as NotFoundError48,
44585
44904
  paginate as paginate47,
44586
44905
  useAtlas as useAtlas93,
44587
44906
  useCache as useCache56
@@ -44809,7 +45128,7 @@ function useOccurrenceSubjectRepo() {
44809
45128
  try {
44810
45129
  const data = await collection.findOne({ _id }, { session });
44811
45130
  if (!data) {
44812
- throw new NotFoundError46("Occurrence subject not found.");
45131
+ throw new NotFoundError48("Occurrence subject not found.");
44813
45132
  }
44814
45133
  setCache(cacheKey, data, 15 * 60).then(() => {
44815
45134
  logger147.info(`Cache set for key: ${cacheKey}`);
@@ -45267,7 +45586,7 @@ import {
45267
45586
  InternalServerError as InternalServerError58,
45268
45587
  logger as logger149,
45269
45588
  makeCacheKey as makeCacheKey55,
45270
- NotFoundError as NotFoundError47,
45589
+ NotFoundError as NotFoundError49,
45271
45590
  paginate as paginate48,
45272
45591
  useAtlas as useAtlas95,
45273
45592
  useCache as useCache57
@@ -45413,7 +45732,7 @@ function useOnlineFormRepo() {
45413
45732
  }
45414
45733
  ]).toArray();
45415
45734
  if (!data || !data.length) {
45416
- throw new NotFoundError47("Document not found.");
45735
+ throw new NotFoundError49("Document not found.");
45417
45736
  }
45418
45737
  setCache(cacheKey, data[0], 15 * 60).then(() => {
45419
45738
  logger149.info(`Cache set for key: ${cacheKey}`);
@@ -51292,7 +51611,7 @@ import {
51292
51611
  logger as logger178,
51293
51612
  getDirectory as getDirectory5,
51294
51613
  BadRequestError as BadRequestError200,
51295
- NotFoundError as NotFoundError51,
51614
+ NotFoundError as NotFoundError53,
51296
51615
  InternalServerError as InternalServerError69,
51297
51616
  useAtlas as useAtlas113,
51298
51617
  hashPassword as hashPassword4
@@ -51421,7 +51740,7 @@ function useVerificationServiceV2() {
51421
51740
  session?.startTransaction();
51422
51741
  const item = await _getByVerificationCode(verificationCode);
51423
51742
  if (!item) {
51424
- throw new NotFoundError51("Verification not found.");
51743
+ throw new NotFoundError53("Verification not found.");
51425
51744
  }
51426
51745
  switch (item.status) {
51427
51746
  case "expired" /* EXPIRED */:
@@ -51911,7 +52230,7 @@ import {
51911
52230
  BadRequestError as BadRequestError203,
51912
52231
  comparePassword as comparePassword3,
51913
52232
  InternalServerError as InternalServerError71,
51914
- NotFoundError as NotFoundError53,
52233
+ NotFoundError as NotFoundError55,
51915
52234
  useCache as useCache67
51916
52235
  } from "@7365admin1/node-server-utils";
51917
52236
  import { v4 as uuidv42 } from "uuid";
@@ -51924,7 +52243,7 @@ import {
51924
52243
  logger as logger180,
51925
52244
  BadRequestError as BadRequestError202,
51926
52245
  paginate as paginate58,
51927
- NotFoundError as NotFoundError52,
52246
+ NotFoundError as NotFoundError54,
51928
52247
  AppError as AppError28,
51929
52248
  useCache as useCache66,
51930
52249
  makeCacheKey as makeCacheKey64,
@@ -52057,7 +52376,7 @@ function useUserRepoV2() {
52057
52376
  ]).toArray();
52058
52377
  const data = results.length > 0 ? results[0] : null;
52059
52378
  if (!data)
52060
- throw new NotFoundError52("User not found.");
52379
+ throw new NotFoundError54("User not found.");
52061
52380
  setCache(cacheKey, data, 15 * 60).then(() => logger180.info(`Cache set for key: ${cacheKey}`)).catch(
52062
52381
  (err) => logger180.error(`Failed to set cache for key: ${cacheKey}`, err)
52063
52382
  );
@@ -52398,7 +52717,7 @@ function useAuthServiceV2() {
52398
52717
  try {
52399
52718
  const user = await getUserByEmail(email);
52400
52719
  if (!user) {
52401
- throw new NotFoundError53(
52720
+ throw new NotFoundError55(
52402
52721
  "Invalid user email. Please check your email and try again."
52403
52722
  );
52404
52723
  }
@@ -52468,7 +52787,7 @@ import {
52468
52787
  comparePassword as comparePassword4,
52469
52788
  hashPassword as hashPassword5,
52470
52789
  InternalServerError as InternalServerError72,
52471
- NotFoundError as NotFoundError54,
52790
+ NotFoundError as NotFoundError56,
52472
52791
  useAtlas as useAtlas115,
52473
52792
  useS3 as useS33
52474
52793
  } from "@7365admin1/node-server-utils";
@@ -52572,14 +52891,14 @@ function useUserServiceV2() {
52572
52891
  try {
52573
52892
  const otpDoc = await _getVerificationById(id);
52574
52893
  if (!otpDoc) {
52575
- throw new NotFoundError54("You are using an invalid reset link.");
52894
+ throw new NotFoundError56("You are using an invalid reset link.");
52576
52895
  }
52577
52896
  if (otpDoc.status === "complete" /* COMPLETE */) {
52578
52897
  throw new BadRequestError204("This link has already been invalidated.");
52579
52898
  }
52580
52899
  const user = await _getUserByEmail(otpDoc.email);
52581
52900
  if (!user) {
52582
- throw new NotFoundError54("User not found.");
52901
+ throw new NotFoundError56("User not found.");
52583
52902
  }
52584
52903
  if (!user._id) {
52585
52904
  throw new InternalServerError72("Invalid user ID.");