@7365admin1/core 2.33.0 → 2.35.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
@@ -148,7 +148,8 @@ import {
148
148
  NotFoundError as NotFoundError4,
149
149
  AppError,
150
150
  useCache as useCache5,
151
- makeCacheKey as makeCacheKey5
151
+ makeCacheKey as makeCacheKey5,
152
+ toObjectId
152
153
  } from "@7365admin1/node-server-utils";
153
154
 
154
155
  // src/repositories/feedback.repo.ts
@@ -2210,20 +2211,9 @@ function useUserRepo() {
2210
2211
  }
2211
2212
  async function getUserByEmail(email) {
2212
2213
  try {
2213
- const cacheKey = makeCacheKey5(namespace_collection, { email });
2214
- const cachedData = await getCache(cacheKey);
2215
- if (cachedData) {
2216
- logger7.info(`Cache hit for key: ${cacheKey}`);
2217
- return cachedData;
2218
- }
2219
2214
  const data = await collection.findOne({
2220
2215
  email: { $regex: `^${email}$`, $options: "i" }
2221
2216
  });
2222
- setCache(cacheKey, data, 15 * 60).then(() => {
2223
- logger7.info(`Cache set for key: ${cacheKey}`);
2224
- }).catch((err) => {
2225
- logger7.error(`Failed to set cache for key: ${cacheKey}`, err);
2226
- });
2227
2217
  return data;
2228
2218
  } catch (error) {
2229
2219
  throw new InternalServerError5("Failed to get user by email.");
@@ -2530,6 +2520,39 @@ function useUserRepo() {
2530
2520
  throw new InternalServerError5("Failed to update user password.");
2531
2521
  }
2532
2522
  }
2523
+ async function resetPassword({
2524
+ _id,
2525
+ password,
2526
+ sid
2527
+ }, session) {
2528
+ try {
2529
+ _id = new ObjectId9(_id);
2530
+ } catch (error) {
2531
+ throw new BadRequestError9("Invalid user ID format.");
2532
+ }
2533
+ try {
2534
+ const result = await collection.updateOne(
2535
+ { _id },
2536
+ { $set: { password, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
2537
+ { session }
2538
+ );
2539
+ const cacheKey = makeCacheKey5(namespace_collection, { _id });
2540
+ delCache(cacheKey).then(() => {
2541
+ logger7.info(`Cache deleted for key: ${cacheKey}`);
2542
+ }).catch((err) => {
2543
+ logger7.error(`Failed to delete cache for key: ${cacheKey}`, err);
2544
+ });
2545
+ const authCacheKey = `sid:${sid}`;
2546
+ delCache(authCacheKey).then(() => {
2547
+ logger7.info(`Cache deleted for key: ${authCacheKey}`);
2548
+ }).catch((err) => {
2549
+ logger7.error(`Failed to delete cache for key: ${authCacheKey}`, err);
2550
+ });
2551
+ return result;
2552
+ } catch (error) {
2553
+ throw new InternalServerError5("Failed to update user password.");
2554
+ }
2555
+ }
2533
2556
  async function updateBirthday({
2534
2557
  _id,
2535
2558
  month,
@@ -2622,6 +2645,19 @@ function useUserRepo() {
2622
2645
  throw new InternalServerError5(`Failed to update user ${field}.`);
2623
2646
  }
2624
2647
  }
2648
+ async function updateUserSIDById(id, sid, session) {
2649
+ const _id = toObjectId(id);
2650
+ try {
2651
+ const result = await collection.updateOne(
2652
+ { _id },
2653
+ { $set: { sid, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
2654
+ { session }
2655
+ );
2656
+ return result;
2657
+ } catch (error) {
2658
+ throw new InternalServerError5("Failed to update user.");
2659
+ }
2660
+ }
2625
2661
  return {
2626
2662
  createIndex,
2627
2663
  createTextIndex,
@@ -2637,7 +2673,9 @@ function useUserRepo() {
2637
2673
  updateBirthday,
2638
2674
  updateUserFieldById,
2639
2675
  updateDefaultOrgByEmail,
2640
- getUserByEmailStatus
2676
+ getUserByEmailStatus,
2677
+ updateUserSIDById,
2678
+ resetPassword
2641
2679
  };
2642
2680
  }
2643
2681
 
@@ -3482,7 +3520,11 @@ function useMemberRepo() {
3482
3520
 
3483
3521
  // src/services/auth.service.ts
3484
3522
  function useAuthService() {
3485
- const { getUserByEmail, getUserById: _getUserById } = useUserRepo();
3523
+ const {
3524
+ getUserByEmail,
3525
+ getUserById: _getUserById,
3526
+ updateUserSIDById: _updateUserSIDById
3527
+ } = useUserRepo();
3486
3528
  const { getByToken, deleteByToken } = useSessionRepo();
3487
3529
  const expiresIn = "15m";
3488
3530
  const { setCache, delCache } = useCache7("sessions");
@@ -3520,7 +3562,9 @@ function useAuthService() {
3520
3562
  }
3521
3563
  const sid = uuidv4();
3522
3564
  const cacheKey = `sid:${sid}`;
3523
- setCache(cacheKey, user, 14400).then(() => {
3565
+ await _updateUserSIDById(user._id, sid);
3566
+ const updatedUser = await _getUserById(user._id);
3567
+ setCache(cacheKey, updatedUser, 14400).then(() => {
3524
3568
  console.log("Session ID cached successfully");
3525
3569
  }).catch((error) => {
3526
3570
  console.error("Error caching session ID:", error);
@@ -4351,7 +4395,7 @@ import {
4351
4395
  logger as logger12,
4352
4396
  makeCacheKey as makeCacheKey9,
4353
4397
  AppError as AppError4,
4354
- toObjectId as toObjectId2
4398
+ toObjectId as toObjectId3
4355
4399
  } from "@7365admin1/node-server-utils";
4356
4400
  import Joi10 from "joi";
4357
4401
  function useSiteRepo() {
@@ -4737,7 +4781,7 @@ function useSiteRepo() {
4737
4781
  }
4738
4782
  }
4739
4783
  async function updateSiteById(id, payload, session) {
4740
- const _id = toObjectId2(id);
4784
+ const _id = toObjectId3(id);
4741
4785
  payload.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
4742
4786
  try {
4743
4787
  const res = await collection.updateOne(
@@ -5547,6 +5591,7 @@ function useRoleRepo() {
5547
5591
  }).catch((err) => {
5548
5592
  logger14.error(`Failed to clear cache for namespace: dashboard`, err);
5549
5593
  });
5594
+ return "Successfully deleted role permission.";
5550
5595
  } catch (error) {
5551
5596
  throw new InternalServerError12("Failed to delete role.");
5552
5597
  }
@@ -5750,7 +5795,8 @@ function useUserService() {
5750
5795
  getUserById,
5751
5796
  getUserByEmail,
5752
5797
  updatePassword,
5753
- updateUserFieldById: _updateUserFieldById
5798
+ updateUserFieldById: _updateUserFieldById,
5799
+ resetPassword: _resetPassword
5754
5800
  } = useUserRepo();
5755
5801
  const { getRoleByName, addRole } = useRoleRepo();
5756
5802
  const { add: addMember } = useMemberRepo();
@@ -5926,8 +5972,12 @@ function useUserService() {
5926
5972
  throw new InternalServerError14("Invalid user ID.");
5927
5973
  }
5928
5974
  await updateStatusById(id, "complete", session);
5929
- await updatePassword(
5930
- { _id: user._id.toString(), password: hashedPassword },
5975
+ await _resetPassword(
5976
+ {
5977
+ _id: user._id.toString(),
5978
+ password: hashedPassword,
5979
+ sid: user.sid
5980
+ },
5931
5981
  session
5932
5982
  );
5933
5983
  await session?.commitTransaction();
@@ -8651,7 +8701,7 @@ import {
8651
8701
  import { z } from "zod";
8652
8702
  import { ObjectId as ObjectId26 } from "mongodb";
8653
8703
  import { BadRequestError as BadRequestError39 } from "@7365admin1/node-server-utils";
8654
- function toObjectId3(value) {
8704
+ function toObjectId4(value) {
8655
8705
  if (typeof value === "string") {
8656
8706
  if (!/^[a-fA-F0-9]{24}$/.test(value)) {
8657
8707
  throw new BadRequestError39(`Invalid ObjectId format: ${value}`);
@@ -8703,7 +8753,7 @@ var TInvoice = z.object({
8703
8753
  message: "Invalid ObjectId: Must be a 24-character hex string."
8704
8754
  }),
8705
8755
  z.instanceof(ObjectId26, { message: "Invalid ObjectId instance." })
8706
- ]).optional().transform((val) => val ? toObjectId3(val) : void 0),
8756
+ ]).optional().transform((val) => val ? toObjectId4(val) : void 0),
8707
8757
  invoiceNumber: z.string({ required_error: "Invoice number is required." }),
8708
8758
  type: TInvoiceType.default("other"),
8709
8759
  amount: z.number().min(0, { message: "Invoice amount must be at least 0." }),
@@ -12456,7 +12506,7 @@ import {
12456
12506
  logger as logger46,
12457
12507
  makeCacheKey as makeCacheKey21,
12458
12508
  paginate as paginate16,
12459
- toObjectId as toObjectId5,
12509
+ toObjectId as toObjectId6,
12460
12510
  useAtlas as useAtlas29,
12461
12511
  useCache as useCache22
12462
12512
  } from "@7365admin1/node-server-utils";
@@ -12684,7 +12734,7 @@ function useSiteCameraRepo() {
12684
12734
  });
12685
12735
  }
12686
12736
  async function getBySite(site, options = {}) {
12687
- const _site = toObjectId5(site);
12737
+ const _site = toObjectId6(site);
12688
12738
  const cacheKeyOptions = {
12689
12739
  site,
12690
12740
  tag: "get-by-site",
@@ -12918,7 +12968,7 @@ import {
12918
12968
  BadRequestError as BadRequestError66,
12919
12969
  InternalServerError as InternalServerError23,
12920
12970
  paginate as paginate17,
12921
- toObjectId as toObjectId6,
12971
+ toObjectId as toObjectId7,
12922
12972
  useAtlas as useAtlas30
12923
12973
  } from "@7365admin1/node-server-utils";
12924
12974
 
@@ -13560,7 +13610,7 @@ function useVisitorTransactionRepo() {
13560
13610
  }
13561
13611
  }
13562
13612
  async function getVisitorTransactionById(id) {
13563
- const _id = toObjectId6(id);
13613
+ const _id = toObjectId7(id);
13564
13614
  try {
13565
13615
  const basePipeline = [{ $match: { _id } }];
13566
13616
  const [result] = await collection.aggregate([
@@ -13602,7 +13652,7 @@ function useVisitorTransactionRepo() {
13602
13652
  }
13603
13653
  }
13604
13654
  async function getOpenByPlateNumber(plateNumber, site) {
13605
- const _site = typeof site === "string" ? toObjectId6(site) : site;
13655
+ const _site = typeof site === "string" ? toObjectId7(site) : site;
13606
13656
  const query = {
13607
13657
  plateNumber,
13608
13658
  site: _site,
@@ -13686,7 +13736,7 @@ function useVisitorTransactionRepo() {
13686
13736
  }
13687
13737
  }
13688
13738
  async function getExpiredCheckedOutTransactionsBySite(siteId) {
13689
- const site = toObjectId6(siteId);
13739
+ const site = toObjectId7(siteId);
13690
13740
  try {
13691
13741
  const now = (/* @__PURE__ */ new Date()).toISOString();
13692
13742
  const expiredTransactions = await collection.find({
@@ -13935,7 +13985,7 @@ import {
13935
13985
  logger as logger49,
13936
13986
  NotFoundError as NotFoundError17,
13937
13987
  paginate as paginate18,
13938
- toObjectId as toObjectId7,
13988
+ toObjectId as toObjectId8,
13939
13989
  useAtlas as useAtlas31
13940
13990
  } from "@7365admin1/node-server-utils";
13941
13991
  import { ObjectId as ObjectId42 } from "mongodb";
@@ -14534,7 +14584,7 @@ function useVehicleRepo() {
14534
14584
  page = page > 0 ? page - 1 : 0;
14535
14585
  const skip = page * limit;
14536
14586
  try {
14537
- const unit = toObjectId7(unitId);
14587
+ const unit = toObjectId8(unitId);
14538
14588
  const query = {
14539
14589
  unit
14540
14590
  };
@@ -14603,7 +14653,7 @@ import {
14603
14653
  useAtlas as useAtlas32,
14604
14654
  useCache as useCache25,
14605
14655
  AppError as AppError10,
14606
- toObjectId as toObjectId8
14656
+ toObjectId as toObjectId9
14607
14657
  } from "@7365admin1/node-server-utils";
14608
14658
  import { ObjectId as ObjectId43 } from "mongodb";
14609
14659
  var site_people_namespace_collection = "site.people";
@@ -15084,7 +15134,7 @@ function usePersonRepo() {
15084
15134
  async function pushVehicleById(id, plate, session) {
15085
15135
  const { plateNumber, recNo } = plate;
15086
15136
  const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
15087
- const _id = toObjectId8(id);
15137
+ const _id = toObjectId9(id);
15088
15138
  try {
15089
15139
  const updateExisting = await collection.updateOne(
15090
15140
  {
@@ -15142,7 +15192,7 @@ function usePersonRepo() {
15142
15192
  }
15143
15193
  }
15144
15194
  async function getByUserId(userId) {
15145
- const user = toObjectId8(userId);
15195
+ const user = toObjectId9(userId);
15146
15196
  const cacheKey = makeCacheKey24(site_people_namespace_collection, {
15147
15197
  user: userId
15148
15198
  });
@@ -17414,7 +17464,7 @@ import {
17414
17464
  logger as logger60,
17415
17465
  makeCacheKey as makeCacheKey26,
17416
17466
  paginate as paginate21,
17417
- toObjectId as toObjectId10,
17467
+ toObjectId as toObjectId11,
17418
17468
  useAtlas as useAtlas37,
17419
17469
  useCache as useCache28
17420
17470
  } from "@7365admin1/node-server-utils";
@@ -17579,8 +17629,8 @@ function useBuildingUnitRepo() {
17579
17629
  const query = {
17580
17630
  status,
17581
17631
  ...search && { $text: { $search: search } },
17582
- ...site && { site: toObjectId10(site) },
17583
- ...building && { building: toObjectId10(building) }
17632
+ ...site && { site: toObjectId11(site) },
17633
+ ...building && { building: toObjectId11(building) }
17584
17634
  };
17585
17635
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
17586
17636
  const cacheParams = {
@@ -19284,16 +19334,30 @@ function useCustomerSiteRepo() {
19284
19334
  return cachedData;
19285
19335
  }
19286
19336
  try {
19337
+ const distinctPipeline = [
19338
+ { $match: query },
19339
+ { $sort: sort },
19340
+ { $group: { _id: { name: "$name", site: "$site" }, doc: { $first: "$$ROOT" } } },
19341
+ { $replaceRoot: { newRoot: "$doc" } },
19342
+ { $sort: sort }
19343
+ ];
19287
19344
  const items = await collection.aggregate(
19288
19345
  [
19289
- { $match: query },
19290
- { $sort: sort },
19346
+ ...distinctPipeline,
19291
19347
  { $skip: page * limit },
19292
19348
  { $limit: limit }
19293
19349
  ],
19294
19350
  { session }
19295
19351
  ).toArray();
19296
- const length = await collection.countDocuments(query, { session });
19352
+ const countResult = await collection.aggregate(
19353
+ [
19354
+ { $match: query },
19355
+ { $group: { _id: { name: "$name", site: "$site" } } },
19356
+ { $count: "total" }
19357
+ ],
19358
+ { session }
19359
+ ).toArray();
19360
+ const length = countResult[0]?.total ?? 0;
19297
19361
  const data = paginate22(items, page, limit, length);
19298
19362
  setCache(cacheKey, data, 15 * 60).then(() => {
19299
19363
  logger67.info(`Cache set for key: ${cacheKey}`);
@@ -21410,7 +21474,8 @@ var KeyRepo = class {
21410
21474
  location: 1,
21411
21475
  prefix: 1,
21412
21476
  keyNo: 1,
21413
- parentId: 1
21477
+ parentId: 1,
21478
+ status: 1
21414
21479
  }
21415
21480
  }
21416
21481
  ]).toArray();
@@ -21653,7 +21718,8 @@ function useVisitorTransactionService() {
21653
21718
  add: _add,
21654
21719
  updateById: _updateVisitorTansactionById,
21655
21720
  getExpiredCheckedOutTransactionsBySite: _getExpiredCheckedOutTransactionsBySite,
21656
- updateManyDahuaSyncStatus: _updateManyDahuaSyncStatus
21721
+ updateManyDahuaSyncStatus: _updateManyDahuaSyncStatus,
21722
+ getVisitorTransactionById: _getVisitorTransactionById
21657
21723
  } = useVisitorTransactionRepo();
21658
21724
  const { getById } = useBuildingUnitRepo();
21659
21725
  const {
@@ -21672,6 +21738,70 @@ function useVisitorTransactionService() {
21672
21738
  const { getAllSites: _getAllSites } = useSiteRepo();
21673
21739
  const { getByUserId: _getByUserId } = usePersonRepo();
21674
21740
  const { add: addVehicle } = useVehicleRepo();
21741
+ function extractKeyId(item) {
21742
+ if (!item)
21743
+ return null;
21744
+ if (typeof item === "string") {
21745
+ return ObjectId58.isValid(item) ? item : null;
21746
+ }
21747
+ if (typeof item === "object" && item !== null) {
21748
+ if ("keyId" in item) {
21749
+ const keyId = String(item.keyId);
21750
+ return ObjectId58.isValid(keyId) ? keyId : null;
21751
+ }
21752
+ const value = String(item);
21753
+ return ObjectId58.isValid(value) ? value : null;
21754
+ }
21755
+ return null;
21756
+ }
21757
+ function normalizeKeyRefs(items) {
21758
+ if (!Array.isArray(items))
21759
+ return [];
21760
+ const seen = /* @__PURE__ */ new Set();
21761
+ const normalized = [];
21762
+ for (const item of items) {
21763
+ const keyId = extractKeyId(item);
21764
+ if (!keyId || seen.has(keyId))
21765
+ continue;
21766
+ seen.add(keyId);
21767
+ normalized.push({ keyId: new ObjectId58(keyId) });
21768
+ }
21769
+ return normalized;
21770
+ }
21771
+ async function syncTransactionKeys({
21772
+ current,
21773
+ incoming,
21774
+ site,
21775
+ session
21776
+ }) {
21777
+ const currentIds = current.map((item) => item.keyId.toString());
21778
+ const incomingIds = incoming.map((item) => item.keyId.toString());
21779
+ const currentSet = new Set(currentIds);
21780
+ const incomingSet = new Set(incomingIds);
21781
+ const removedIds = currentIds.filter((id) => !incomingSet.has(id));
21782
+ const addedIds = incomingIds.filter((id) => !currentSet.has(id));
21783
+ for (const keyId of removedIds) {
21784
+ const existingKey = await KeyRepo.getById(keyId);
21785
+ if (!existingKey)
21786
+ continue;
21787
+ if (existingKey.status === "In Use" /* IN_USE */) {
21788
+ await KeyRepo.updateKeyById(
21789
+ keyId,
21790
+ { status: "Available" /* AVAILABLE */ },
21791
+ site,
21792
+ session
21793
+ );
21794
+ }
21795
+ }
21796
+ for (const keyId of addedIds) {
21797
+ await KeyRepo.updateKeyById(
21798
+ keyId,
21799
+ { status: "In Use" /* IN_USE */ },
21800
+ site,
21801
+ session
21802
+ );
21803
+ }
21804
+ }
21675
21805
  async function add(value) {
21676
21806
  const session = useAtlas48.getClient()?.startSession();
21677
21807
  const allowedPersonTypes = [
@@ -21916,7 +22046,7 @@ function useVisitorTransactionService() {
21916
22046
  session?.endSession();
21917
22047
  }
21918
22048
  }
21919
- async function updateById(id, value) {
22049
+ async function updateVisitorTransactionById(id, value) {
21920
22050
  const session = useAtlas48.getClient()?.startSession();
21921
22051
  session?.startTransaction();
21922
22052
  try {
@@ -22092,18 +22222,70 @@ function useVisitorTransactionService() {
22092
22222
  await session?.commitTransaction();
22093
22223
  return result;
22094
22224
  } catch (error) {
22095
- logger77.error("Error in people service invite visitor:", error);
22225
+ logger77.error("Error in visitor transaction invite visitor:", error);
22096
22226
  await session.abortTransaction();
22097
22227
  throw error;
22098
22228
  } finally {
22099
22229
  session?.endSession();
22100
22230
  }
22101
22231
  }
22232
+ async function changeVisitorTransactionKeysById(id, visitorPass, passKeys) {
22233
+ const session = useAtlas48.getClient()?.startSession();
22234
+ if (!session) {
22235
+ throw new Error(
22236
+ "Unable to start session for visitor transaction service."
22237
+ );
22238
+ }
22239
+ try {
22240
+ session.startTransaction();
22241
+ const visitorTransaction = await _getVisitorTransactionById(id);
22242
+ if (!visitorTransaction) {
22243
+ throw new Error("Visitor transaction not found.");
22244
+ }
22245
+ const updatePayload = {};
22246
+ if (visitorPass !== void 0) {
22247
+ const currentVisitorPass = normalizeKeyRefs(
22248
+ visitorTransaction.visitorPass
22249
+ );
22250
+ const incomingVisitorPass = normalizeKeyRefs(visitorPass);
22251
+ await syncTransactionKeys({
22252
+ current: currentVisitorPass,
22253
+ incoming: incomingVisitorPass,
22254
+ site: visitorTransaction.site,
22255
+ session
22256
+ });
22257
+ updatePayload.visitorPass = incomingVisitorPass;
22258
+ }
22259
+ if (passKeys !== void 0) {
22260
+ const currentPassKeys = normalizeKeyRefs(visitorTransaction.passKeys);
22261
+ const incomingPassKeys = normalizeKeyRefs(passKeys);
22262
+ await syncTransactionKeys({
22263
+ current: currentPassKeys,
22264
+ incoming: incomingPassKeys,
22265
+ site: visitorTransaction.site,
22266
+ session
22267
+ });
22268
+ updatePayload.passKeys = incomingPassKeys;
22269
+ }
22270
+ if (Object.keys(updatePayload).length > 0) {
22271
+ await _updateVisitorTansactionById(id, updatePayload, session);
22272
+ }
22273
+ await session.commitTransaction();
22274
+ return "Successfully changed visitor transaction keys.";
22275
+ } catch (error) {
22276
+ await session.abortTransaction();
22277
+ logger77.error("Error in visitor transaction change keys by id:", error);
22278
+ throw error;
22279
+ } finally {
22280
+ session.endSession();
22281
+ }
22282
+ }
22102
22283
  return {
22103
22284
  add,
22104
- updateById,
22285
+ updateVisitorTransactionById,
22105
22286
  processTransactionDahuaStatus,
22106
- inviteVisitor
22287
+ inviteVisitor,
22288
+ changeVisitorTransactionKeysById
22107
22289
  };
22108
22290
  }
22109
22291
 
@@ -22113,8 +22295,9 @@ import { BadRequestError as BadRequestError97, logger as logger78 } from "@7365a
22113
22295
  function useVisitorTransactionController() {
22114
22296
  const {
22115
22297
  add: _add,
22116
- updateById: _updateVisitorTansactionById,
22117
- inviteVisitor: _inviteVisitor
22298
+ updateVisitorTransactionById: _updateVisitorTransactionById,
22299
+ inviteVisitor: _inviteVisitor,
22300
+ changeVisitorTransactionKeysById: _changeVisitorTransactionKeysById
22118
22301
  } = useVisitorTransactionService();
22119
22302
  const {
22120
22303
  getAll: _getAll,
@@ -22256,7 +22439,7 @@ function useVisitorTransactionController() {
22256
22439
  return;
22257
22440
  }
22258
22441
  try {
22259
- await _updateVisitorTansactionById(_id, req.body);
22442
+ await _updateVisitorTransactionById(_id, req.body);
22260
22443
  res.status(200).json({ message: "Successfully updated visitor transaction." });
22261
22444
  return;
22262
22445
  } catch (error2) {
@@ -22310,8 +22493,31 @@ function useVisitorTransactionController() {
22310
22493
  next(new BadRequestError97(messages));
22311
22494
  return;
22312
22495
  }
22313
- const { expectedCheckIn, arrivalTime, duration, name, contact, email, plateNumber, isOvernightParking, numberOfPassengers, purpose, inviterUserId } = value;
22314
- const rest = { expectedCheckIn, arrivalTime, duration, name, contact, email, plateNumber, isOvernightParking, numberOfPassengers, purpose };
22496
+ const {
22497
+ expectedCheckIn,
22498
+ arrivalTime,
22499
+ duration,
22500
+ name,
22501
+ contact,
22502
+ email,
22503
+ plateNumber,
22504
+ isOvernightParking,
22505
+ numberOfPassengers,
22506
+ purpose,
22507
+ inviterUserId
22508
+ } = value;
22509
+ const rest = {
22510
+ expectedCheckIn,
22511
+ arrivalTime,
22512
+ duration,
22513
+ name,
22514
+ contact,
22515
+ email,
22516
+ plateNumber,
22517
+ isOvernightParking,
22518
+ numberOfPassengers,
22519
+ purpose
22520
+ };
22315
22521
  try {
22316
22522
  const result = await _inviteVisitor(rest, inviterUserId);
22317
22523
  res.status(200).json({ insertedId: result });
@@ -22322,13 +22528,61 @@ function useVisitorTransactionController() {
22322
22528
  return;
22323
22529
  }
22324
22530
  }
22531
+ async function changeVisitorTransactionKeysById(req, res, next) {
22532
+ const idValidation = Joi55.string().hex().length(24).required();
22533
+ const bodyValidation = Joi55.object({
22534
+ visitorPass: Joi55.array().items(
22535
+ Joi55.object({
22536
+ keyId: Joi55.string().hex().length(24).required()
22537
+ })
22538
+ ).optional(),
22539
+ passKeys: Joi55.array().items(
22540
+ Joi55.object({
22541
+ keyId: Joi55.string().hex().length(24).required()
22542
+ })
22543
+ ).optional()
22544
+ }).or("visitorPass", "passKeys");
22545
+ const _id = req.params.id;
22546
+ const { error: idError } = idValidation.validate(_id);
22547
+ if (idError) {
22548
+ logger78.log({ level: "error", message: idError.message });
22549
+ next(new BadRequestError97(idError.message));
22550
+ return;
22551
+ }
22552
+ const { error, value } = bodyValidation.validate(req.body, {
22553
+ abortEarly: false
22554
+ });
22555
+ if (error) {
22556
+ const message = error.details.map((d) => d.message).join(", ");
22557
+ logger78.log({ level: "error", message });
22558
+ next(new BadRequestError97(message));
22559
+ return;
22560
+ }
22561
+ try {
22562
+ const { visitorPass, passKeys } = value;
22563
+ const result = await _changeVisitorTransactionKeysById(
22564
+ _id,
22565
+ visitorPass,
22566
+ passKeys
22567
+ );
22568
+ res.status(200).json({
22569
+ message: result || "Successfully changed visitor transaction keys."
22570
+ });
22571
+ return;
22572
+ } catch (error2) {
22573
+ logger78.log({ level: "error", message: error2.message });
22574
+ next(error2);
22575
+ return;
22576
+ }
22577
+ }
22325
22578
  return {
22326
22579
  add,
22327
22580
  getAll,
22328
22581
  updateVisitorTansactionById,
22329
22582
  deleteVisitorTransaction,
22330
22583
  inviteVisitor,
22331
- getVisitorTransactionById
22584
+ getVisitorTransactionById,
22585
+ changeVisitorTransactionKeysById
22332
22586
  };
22333
22587
  }
22334
22588
 
@@ -27010,7 +27264,7 @@ import {
27010
27264
  makeCacheKey as makeCacheKey37,
27011
27265
  NotFoundError as NotFoundError27,
27012
27266
  paginate as paginate31,
27013
- toObjectId as toObjectId11,
27267
+ toObjectId as toObjectId12,
27014
27268
  useAtlas as useAtlas61,
27015
27269
  useCache as useCache39
27016
27270
  } from "@7365admin1/node-server-utils";
@@ -27066,7 +27320,7 @@ function useSiteFacilityBookingRepo() {
27066
27320
  page = page > 0 ? page - 1 : 0;
27067
27321
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
27068
27322
  const skip = page * limit;
27069
- const siteId = toObjectId11(site);
27323
+ const siteId = toObjectId12(site);
27070
27324
  const query = {
27071
27325
  site: siteId,
27072
27326
  status,
@@ -27112,7 +27366,7 @@ function useSiteFacilityBookingRepo() {
27112
27366
  }
27113
27367
  }
27114
27368
  async function getSiteFacilityBookingById(id, session) {
27115
- const _id = toObjectId11(id);
27369
+ const _id = toObjectId12(id);
27116
27370
  const cacheKey = makeCacheKey37(facility_bookings_namespace_collection, {
27117
27371
  id
27118
27372
  });
@@ -27138,17 +27392,17 @@ function useSiteFacilityBookingRepo() {
27138
27392
  }
27139
27393
  async function updateSiteFacilityBookingById(id, value, session) {
27140
27394
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
27141
- const _id = toObjectId11(id);
27395
+ const _id = toObjectId12(id);
27142
27396
  if (value.site)
27143
- value.site = typeof value.site === "string" ? toObjectId11(value.site) : value.site;
27397
+ value.site = typeof value.site === "string" ? toObjectId12(value.site) : value.site;
27144
27398
  if (value.user)
27145
- value.user = typeof value.user === "string" ? toObjectId11(value.user) : value.user;
27399
+ value.user = typeof value.user === "string" ? toObjectId12(value.user) : value.user;
27146
27400
  if (value.date)
27147
27401
  value.date = value.date ? new Date(value.date).toISOString() : value.date;
27148
27402
  if (value.approvedBy)
27149
- value.approvedBy = typeof value.approvedBy === "string" ? toObjectId11(value.approvedBy) : value.approvedBy;
27403
+ value.approvedBy = typeof value.approvedBy === "string" ? toObjectId12(value.approvedBy) : value.approvedBy;
27150
27404
  if (value.createdBy)
27151
- value.createdBy = typeof value.createdBy === "string" ? toObjectId11(value.createdBy) : value.createdBy;
27405
+ value.createdBy = typeof value.createdBy === "string" ? toObjectId12(value.createdBy) : value.createdBy;
27152
27406
  try {
27153
27407
  const res = await collection.updateOne(
27154
27408
  { _id },
@@ -35431,7 +35685,7 @@ import {
35431
35685
  makeCacheKey as makeCacheKey46,
35432
35686
  NotFoundError as NotFoundError37,
35433
35687
  paginate as paginate40,
35434
- toObjectId as toObjectId12,
35688
+ toObjectId as toObjectId13,
35435
35689
  useAtlas as useAtlas78,
35436
35690
  useCache as useCache48
35437
35691
  } from "@7365admin1/node-server-utils";
@@ -35506,7 +35760,7 @@ function useOccurrenceBookRepo() {
35506
35760
  status = ""
35507
35761
  }, session) {
35508
35762
  page = page > 0 && !date ? page - 1 : 0;
35509
- const _site = toObjectId12(site);
35763
+ const _site = toObjectId13(site);
35510
35764
  const query = {
35511
35765
  site: _site,
35512
35766
  ...status && { status },
@@ -36525,6 +36779,10 @@ var schemaSOABillingItem = Joi92.object({
36525
36779
  taxPercentage: Joi92.number().optional().allow(null),
36526
36780
  taxAmount: Joi92.number().optional().allow(null)
36527
36781
  });
36782
+ var schemaApprovedBy = Joi92.object({
36783
+ _id: Joi92.string().hex().optional().allow(null, ""),
36784
+ name: Joi92.string().optional().allow(null, "")
36785
+ });
36528
36786
  var schemaStatementOfAccount = Joi92.object({
36529
36787
  _id: Joi92.string().hex().optional(),
36530
36788
  site: Joi92.string().hex().required(),
@@ -36538,6 +36796,7 @@ var schemaStatementOfAccount = Joi92.object({
36538
36796
  category: Joi92.string().optional().allow(null, ""),
36539
36797
  status: Joi92.string().valid("pending", "approved", "rejected", "deleted").optional().allow(null, ""),
36540
36798
  billing: Joi92.array().items(schemaSOABillingItem).optional().allow(null, ""),
36799
+ approvedBy: schemaApprovedBy.optional().allow(null, ""),
36541
36800
  createdBy: Joi92.string().hex().required(),
36542
36801
  createdByName: Joi92.string().optional().allow(null, ""),
36543
36802
  createdAt: Joi92.date().optional(),
@@ -36557,6 +36816,7 @@ var schemaUpdateStatementOfAccount = Joi92.object({
36557
36816
  category: Joi92.string().optional().allow(null, ""),
36558
36817
  status: Joi92.string().valid("pending", "approved", "rejected", "deleted").optional().allow(null, ""),
36559
36818
  billing: Joi92.array().items(schemaSOABillingItem).optional().allow(null, ""),
36819
+ approvedBy: schemaApprovedBy.optional().allow(null, ""),
36560
36820
  createdBy: Joi92.string().optional().allow(null, ""),
36561
36821
  createdByName: Joi92.string().optional().allow(null, "")
36562
36822
  });
@@ -36621,6 +36881,7 @@ function MStatementOfAccount(value) {
36621
36881
  status: value.status ?? "pending",
36622
36882
  createdBy: value.createdBy,
36623
36883
  createdByName: value.createdByName ?? "",
36884
+ approvedBy: value.approvedBy,
36624
36885
  createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
36625
36886
  updatedAt: value.updatedAt ?? "",
36626
36887
  deletedAt: value.deletedAt ?? ""
@@ -36959,6 +37220,35 @@ function useStatementOfAccountRepo() {
36959
37220
  });
36960
37221
  });
36961
37222
  }
37223
+ async function reviewSOA(_id, value, session) {
37224
+ value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
37225
+ try {
37226
+ _id = new ObjectId97(_id);
37227
+ } catch (error) {
37228
+ throw new BadRequestError151("Invalid ID format.");
37229
+ }
37230
+ try {
37231
+ const res = await collection.updateOne(
37232
+ { _id },
37233
+ { $set: value },
37234
+ { session }
37235
+ );
37236
+ if (res.modifiedCount === 0) {
37237
+ throw new InternalServerError50(`Unable to ${value.status} soa.`);
37238
+ }
37239
+ delNamespace().then(() => {
37240
+ logger128.info(`Cache cleared for namespace: ${namespace_collection}`);
37241
+ }).catch((err) => {
37242
+ logger128.error(
37243
+ `Failed to clear cache for namespace: ${namespace_collection}`,
37244
+ err
37245
+ );
37246
+ });
37247
+ return res;
37248
+ } catch (error) {
37249
+ throw error;
37250
+ }
37251
+ }
36962
37252
  return {
36963
37253
  createTextIndex,
36964
37254
  add,
@@ -36967,7 +37257,8 @@ function useStatementOfAccountRepo() {
36967
37257
  updateById,
36968
37258
  deleteById,
36969
37259
  updateStatusById,
36970
- getResidentUserSoa
37260
+ getResidentUserSoa,
37261
+ reviewSOA
36971
37262
  };
36972
37263
  }
36973
37264
 
@@ -36980,9 +37271,10 @@ import {
36980
37271
  logger as logger129,
36981
37272
  useAtlas as useAtlas83
36982
37273
  } from "@7365admin1/node-server-utils";
37274
+ import { ObjectId as ObjectId98 } from "mongodb";
36983
37275
  import { launch } from "puppeteer";
36984
37276
  function useStatementOfAccountService() {
36985
- const { add: _add } = useStatementOfAccountRepo();
37277
+ const { add: _add, reviewSOA: _reviewSOA } = useStatementOfAccountRepo();
36986
37278
  const { getUnitBillingBySite } = useSiteUnitBillingRepo();
36987
37279
  const { getUserById } = useUserRepo();
36988
37280
  async function add(value, dateFrom, dateTo) {
@@ -37110,9 +37402,31 @@ function useStatementOfAccountService() {
37110
37402
  throw error;
37111
37403
  }
37112
37404
  }
37405
+ async function reviewSOA(id, value) {
37406
+ const session = useAtlas83.getClient()?.startSession();
37407
+ session?.startTransaction();
37408
+ try {
37409
+ if (value?.approvedBy?._id) {
37410
+ const approvedBy = await getUserById(value?.approvedBy?._id);
37411
+ if (!approvedBy || !approvedBy.name)
37412
+ throw new BadRequestError152("Created by not found.");
37413
+ value.approvedBy.name = approvedBy.name;
37414
+ value.approvedBy._id = new ObjectId98(approvedBy._id);
37415
+ }
37416
+ await _reviewSOA(id, value, session);
37417
+ await session?.commitTransaction();
37418
+ return `Successfully ${value.status} soa.`;
37419
+ } catch (error) {
37420
+ await session?.abortTransaction();
37421
+ throw error;
37422
+ } finally {
37423
+ session?.endSession();
37424
+ }
37425
+ }
37113
37426
  return {
37114
37427
  add,
37115
- generatePDF
37428
+ generatePDF,
37429
+ reviewSOA
37116
37430
  };
37117
37431
  }
37118
37432
 
@@ -37127,7 +37441,11 @@ function useStatementOfAccountController() {
37127
37441
  updateStatusById: _updateStatusById,
37128
37442
  getResidentUserSoa: _getResidentUserSoa
37129
37443
  } = useStatementOfAccountRepo();
37130
- const { add: _add, generatePDF: _generatePDF } = useStatementOfAccountService();
37444
+ const {
37445
+ add: _add,
37446
+ generatePDF: _generatePDF,
37447
+ reviewSOA: _reviewSOA
37448
+ } = useStatementOfAccountService();
37131
37449
  async function add(req, res, next) {
37132
37450
  const cookies = req.headers.cookie?.split(";").map((cookie) => cookie.trim().split("=")).reduce(
37133
37451
  (acc, [key, value]) => ({ ...acc, [key]: value }),
@@ -37427,6 +37745,40 @@ function useStatementOfAccountController() {
37427
37745
  return;
37428
37746
  }
37429
37747
  }
37748
+ async function reviewSOA(req, res, next) {
37749
+ const cookies = req.headers.cookie?.split(";").map((cookie) => cookie.trim().split("=")).reduce(
37750
+ (acc, [key, value]) => ({ ...acc, [key]: value }),
37751
+ {}
37752
+ );
37753
+ req.body.approvedBy = {
37754
+ _id: "",
37755
+ name: ""
37756
+ };
37757
+ req.body.approvedBy._id = cookies?.["user"] ? cookies["user"].toString() : req.body.approvedBy._id;
37758
+ const _id = req.params.id;
37759
+ const payload = { _id, ...req.body };
37760
+ const schema2 = Joi93.object({
37761
+ _id: Joi93.string().hex().required(),
37762
+ status: Joi93.string().valid("approved", "rejected").required(),
37763
+ approvedBy: schemaApprovedBy
37764
+ });
37765
+ const { error } = schema2.validate(payload);
37766
+ if (error) {
37767
+ const messages = error.details.map((d) => d.message).join(", ");
37768
+ logger130.log({ level: "error", message: messages });
37769
+ next(new BadRequestError153(messages));
37770
+ return;
37771
+ }
37772
+ try {
37773
+ const result = await _reviewSOA(_id, req.body);
37774
+ res.status(200).json({ message: result });
37775
+ return;
37776
+ } catch (error2) {
37777
+ logger130.log({ level: "error", message: error2.message });
37778
+ next(error2);
37779
+ return;
37780
+ }
37781
+ }
37430
37782
  return {
37431
37783
  add,
37432
37784
  getAll,
@@ -37435,13 +37787,14 @@ function useStatementOfAccountController() {
37435
37787
  deleteById,
37436
37788
  generatePDF,
37437
37789
  updateStatusById,
37438
- getResidentUserSoa
37790
+ getResidentUserSoa,
37791
+ reviewSOA
37439
37792
  };
37440
37793
  }
37441
37794
 
37442
37795
  // src/models/site-entrypass-settings.model.ts
37443
37796
  import { BadRequestError as BadRequestError154, logger as logger131 } from "@7365admin1/node-server-utils";
37444
- import { ObjectId as ObjectId98 } from "mongodb";
37797
+ import { ObjectId as ObjectId99 } from "mongodb";
37445
37798
  import Joi94 from "joi";
37446
37799
  var schemaEntryPassSettings = Joi94.object({
37447
37800
  _id: Joi94.string().hex().optional().allow("", null),
@@ -37489,21 +37842,21 @@ function MEntryPassSettings(value) {
37489
37842
  }
37490
37843
  if (value._id && typeof value._id === "string") {
37491
37844
  try {
37492
- value._id = new ObjectId98(value._id);
37845
+ value._id = new ObjectId99(value._id);
37493
37846
  } catch {
37494
37847
  throw new BadRequestError154("Invalid _id format");
37495
37848
  }
37496
37849
  }
37497
37850
  if (value.site && typeof value.site === "string") {
37498
37851
  try {
37499
- value.site = new ObjectId98(value.site);
37852
+ value.site = new ObjectId99(value.site);
37500
37853
  } catch {
37501
37854
  throw new BadRequestError154("Invalid site format");
37502
37855
  }
37503
37856
  }
37504
37857
  if (value.org && typeof value.org === "string") {
37505
37858
  try {
37506
- value.org = new ObjectId98(value.org);
37859
+ value.org = new ObjectId99(value.org);
37507
37860
  } catch {
37508
37861
  throw new BadRequestError154("Invalid org format");
37509
37862
  }
@@ -37542,7 +37895,7 @@ import {
37542
37895
  useAtlas as useAtlas84,
37543
37896
  useCache as useCache51
37544
37897
  } from "@7365admin1/node-server-utils";
37545
- import { ObjectId as ObjectId99 } from "mongodb";
37898
+ import { ObjectId as ObjectId100 } from "mongodb";
37546
37899
  function useEntryPassSettingsRepo() {
37547
37900
  const db = useAtlas84.getDb();
37548
37901
  if (!db) {
@@ -37652,7 +38005,7 @@ function useEntryPassSettingsRepo() {
37652
38005
  }
37653
38006
  async function getEntryPassSettingsById(_id) {
37654
38007
  try {
37655
- _id = new ObjectId99(_id);
38008
+ _id = new ObjectId100(_id);
37656
38009
  } catch (error) {
37657
38010
  throw new BadRequestError155("Invalid entry pass settings ID format.");
37658
38011
  }
@@ -37719,7 +38072,7 @@ function useEntryPassSettingsRepo() {
37719
38072
  }
37720
38073
  async function updateEntryPassSettingsById(_id, value) {
37721
38074
  try {
37722
- _id = new ObjectId99(_id);
38075
+ _id = new ObjectId100(_id);
37723
38076
  } catch (error) {
37724
38077
  throw new BadRequestError155("Invalid entry pass settings ID format.");
37725
38078
  }
@@ -37747,7 +38100,7 @@ function useEntryPassSettingsRepo() {
37747
38100
  }
37748
38101
  async function deleteEntryPassSettingsById(_id, session) {
37749
38102
  try {
37750
- _id = new ObjectId99(_id);
38103
+ _id = new ObjectId100(_id);
37751
38104
  } catch (error) {
37752
38105
  throw new BadRequestError155("Invalid card ID format.");
37753
38106
  }
@@ -37780,7 +38133,7 @@ function useEntryPassSettingsRepo() {
37780
38133
  }
37781
38134
  async function getEntryPassSettingsBySiteId(site) {
37782
38135
  try {
37783
- site = new ObjectId99(site);
38136
+ site = new ObjectId100(site);
37784
38137
  } catch (error) {
37785
38138
  throw new BadRequestError155("Invalid entry pass settings ID format.");
37786
38139
  }
@@ -37847,7 +38200,7 @@ function useEntryPassSettingsRepo() {
37847
38200
  }
37848
38201
  async function updateEntryPassSettingsBySiteId(site, value) {
37849
38202
  try {
37850
- site = new ObjectId99(site);
38203
+ site = new ObjectId100(site);
37851
38204
  } catch (error) {
37852
38205
  throw new BadRequestError155("Invalid entry pass settings ID format.");
37853
38206
  }
@@ -38212,7 +38565,7 @@ function useDashboardController() {
38212
38565
  }
38213
38566
 
38214
38567
  // src/models/nfc-patrol-route.model.ts
38215
- import { ObjectId as ObjectId100 } from "mongodb";
38568
+ import { ObjectId as ObjectId101 } from "mongodb";
38216
38569
  import Joi97 from "joi";
38217
38570
  import { BadRequestError as BadRequestError158, logger as logger136 } from "@7365admin1/node-server-utils";
38218
38571
  var schemaNfcPatrolRoute = Joi97.object({
@@ -38248,23 +38601,23 @@ function MNfcPatrolRoute(value) {
38248
38601
  }
38249
38602
  if (value._id && typeof value._id === "string") {
38250
38603
  try {
38251
- value._id = new ObjectId100(value._id);
38604
+ value._id = new ObjectId101(value._id);
38252
38605
  } catch (error2) {
38253
38606
  throw new BadRequestError158("Invalid _id format");
38254
38607
  }
38255
38608
  }
38256
38609
  try {
38257
- value.site = new ObjectId100(value.site);
38610
+ value.site = new ObjectId101(value.site);
38258
38611
  } catch (error2) {
38259
38612
  throw new BadRequestError158("Invalid site format");
38260
38613
  }
38261
38614
  try {
38262
- value.createdBy = new ObjectId100(value.createdBy);
38615
+ value.createdBy = new ObjectId101(value.createdBy);
38263
38616
  } catch (error2) {
38264
38617
  throw new BadRequestError158("Invalid createdBy format");
38265
38618
  }
38266
38619
  return {
38267
- _id: value._id ?? new ObjectId100(),
38620
+ _id: value._id ?? new ObjectId101(),
38268
38621
  site: value.site,
38269
38622
  name: value.name,
38270
38623
  checkPointNumber: value.checkPointNumber,
@@ -38289,7 +38642,7 @@ import {
38289
38642
  useAtlas as useAtlas86,
38290
38643
  useCache as useCache53
38291
38644
  } from "@7365admin1/node-server-utils";
38292
- import { ObjectId as ObjectId101 } from "mongodb";
38645
+ import { ObjectId as ObjectId102 } from "mongodb";
38293
38646
  function useNfcPatrolRouteRepo() {
38294
38647
  const db = useAtlas86.getDb();
38295
38648
  if (!db) {
@@ -38333,7 +38686,7 @@ function useNfcPatrolRouteRepo() {
38333
38686
  }, session) {
38334
38687
  page = page > 0 ? page - 1 : 0;
38335
38688
  try {
38336
- site = new ObjectId101(site);
38689
+ site = new ObjectId102(site);
38337
38690
  } catch (error) {
38338
38691
  throw new BadRequestError159("Invalid site ID format.");
38339
38692
  }
@@ -38404,7 +38757,7 @@ function useNfcPatrolRouteRepo() {
38404
38757
  }
38405
38758
  async function getById(_id, isStart) {
38406
38759
  try {
38407
- _id = new ObjectId101(_id);
38760
+ _id = new ObjectId102(_id);
38408
38761
  } catch (error) {
38409
38762
  throw new BadRequestError159("Invalid ID.");
38410
38763
  }
@@ -38514,18 +38867,18 @@ function useNfcPatrolRouteRepo() {
38514
38867
  throw new BadRequestError159(error.message);
38515
38868
  }
38516
38869
  try {
38517
- _id = new ObjectId101(_id);
38870
+ _id = new ObjectId102(_id);
38518
38871
  } catch (error2) {
38519
38872
  throw new BadRequestError159("Invalid ID.");
38520
38873
  }
38521
38874
  try {
38522
- value.site = new ObjectId101(value.site);
38875
+ value.site = new ObjectId102(value.site);
38523
38876
  } catch (error2) {
38524
38877
  throw new BadRequestError159("Invalid site format");
38525
38878
  }
38526
38879
  if (value.updatedBy) {
38527
38880
  try {
38528
- value.updatedBy = new ObjectId101(value.updatedBy);
38881
+ value.updatedBy = new ObjectId102(value.updatedBy);
38529
38882
  } catch (error2) {
38530
38883
  throw new BadRequestError159("Invalid createdBy format");
38531
38884
  }
@@ -38758,7 +39111,7 @@ function useNfcPatrolRouteController() {
38758
39111
  }
38759
39112
 
38760
39113
  // src/models/incident-report.model.ts
38761
- import { ObjectId as ObjectId102 } from "mongodb";
39114
+ import { ObjectId as ObjectId103 } from "mongodb";
38762
39115
  import Joi99 from "joi";
38763
39116
  var residentSchema = Joi99.object({
38764
39117
  _id: Joi99.string().hex().optional().allow(null, ""),
@@ -38962,28 +39315,28 @@ var schemaUpdateIncidentReport = Joi99.object({
38962
39315
  function MIncidentReport(value) {
38963
39316
  if (value._id && typeof value._id === "string") {
38964
39317
  try {
38965
- value._id = new ObjectId102(value._id);
39318
+ value._id = new ObjectId103(value._id);
38966
39319
  } catch {
38967
39320
  throw new Error("Invalid incident report ID.");
38968
39321
  }
38969
39322
  }
38970
39323
  if (value.organization && typeof value.organization === "string") {
38971
39324
  try {
38972
- value.organization = new ObjectId102(value.organization);
39325
+ value.organization = new ObjectId103(value.organization);
38973
39326
  } catch {
38974
39327
  throw new Error("Invalid organization ID.");
38975
39328
  }
38976
39329
  }
38977
39330
  if (value.site && typeof value.site === "string") {
38978
39331
  try {
38979
- value.site = new ObjectId102(value.site);
39332
+ value.site = new ObjectId103(value.site);
38980
39333
  } catch {
38981
39334
  throw new Error("Invalid site ID.");
38982
39335
  }
38983
39336
  }
38984
39337
  if (value.approvedBy && typeof value.approvedBy === "string") {
38985
39338
  try {
38986
- value.approvedBy = new ObjectId102(value.approvedBy);
39339
+ value.approvedBy = new ObjectId103(value.approvedBy);
38987
39340
  } catch {
38988
39341
  throw new Error("Invalid approvedBy ID.");
38989
39342
  }
@@ -38991,7 +39344,7 @@ function MIncidentReport(value) {
38991
39344
  const { incidentInformation } = value;
38992
39345
  if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
38993
39346
  try {
38994
- incidentInformation.siteInfo.site = new ObjectId102(
39347
+ incidentInformation.siteInfo.site = new ObjectId103(
38995
39348
  incidentInformation.siteInfo.site
38996
39349
  );
38997
39350
  } catch {
@@ -39005,7 +39358,7 @@ function MIncidentReport(value) {
39005
39358
  incidentInformation.submissionForm.dateOfReport = incidentInformation.submissionForm.dateOfReport.toISOString();
39006
39359
  }
39007
39360
  return {
39008
- _id: value._id ?? new ObjectId102(),
39361
+ _id: value._id ?? new ObjectId103(),
39009
39362
  reportId: value.reportId,
39010
39363
  incidentInformation: value.incidentInformation,
39011
39364
  affectedEntities: value.affectedEntities,
@@ -39042,7 +39395,7 @@ import {
39042
39395
  useAtlas as useAtlas88,
39043
39396
  useCache as useCache54
39044
39397
  } from "@7365admin1/node-server-utils";
39045
- import { ObjectId as ObjectId103 } from "mongodb";
39398
+ import { ObjectId as ObjectId104 } from "mongodb";
39046
39399
  var incidents_namespace_collection = "incident-reports";
39047
39400
  function useIncidentReportRepo() {
39048
39401
  const db = useAtlas88.getDb();
@@ -39109,7 +39462,7 @@ function useIncidentReportRepo() {
39109
39462
  page = page > 0 ? page - 1 : 0;
39110
39463
  let dateExpr = {};
39111
39464
  try {
39112
- site = new ObjectId103(site);
39465
+ site = new ObjectId104(site);
39113
39466
  } catch (error) {
39114
39467
  throw new BadRequestError162("Invalid site ID format.");
39115
39468
  }
@@ -39210,7 +39563,7 @@ function useIncidentReportRepo() {
39210
39563
  page = page > 0 ? page - 1 : 0;
39211
39564
  let dateExpr = {};
39212
39565
  try {
39213
- site = new ObjectId103(site);
39566
+ site = new ObjectId104(site);
39214
39567
  } catch (error) {
39215
39568
  throw new BadRequestError162("Invalid site ID format.");
39216
39569
  }
@@ -39279,7 +39632,7 @@ function useIncidentReportRepo() {
39279
39632
  }
39280
39633
  async function getIncidentReportById(_id, session) {
39281
39634
  try {
39282
- _id = new ObjectId103(_id);
39635
+ _id = new ObjectId104(_id);
39283
39636
  } catch (error) {
39284
39637
  throw new BadRequestError162("Invalid incident report ID format.");
39285
39638
  }
@@ -39310,27 +39663,27 @@ function useIncidentReportRepo() {
39310
39663
  async function updateIncidentReportById(_id, value, session) {
39311
39664
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
39312
39665
  try {
39313
- _id = new ObjectId103(_id);
39666
+ _id = new ObjectId104(_id);
39314
39667
  } catch (error) {
39315
39668
  throw new BadRequestError162("Invalid ID format.");
39316
39669
  }
39317
39670
  if (value.organization && typeof value.organization === "string") {
39318
39671
  try {
39319
- value.organization = new ObjectId103(value.organization);
39672
+ value.organization = new ObjectId104(value.organization);
39320
39673
  } catch {
39321
39674
  throw new Error("Invalid organization ID.");
39322
39675
  }
39323
39676
  }
39324
39677
  if (value.site && typeof value.site === "string") {
39325
39678
  try {
39326
- value.site = new ObjectId103(value.site);
39679
+ value.site = new ObjectId104(value.site);
39327
39680
  } catch {
39328
39681
  throw new Error("Invalid site ID.");
39329
39682
  }
39330
39683
  }
39331
39684
  if (value.approvedBy && typeof value.approvedBy === "string") {
39332
39685
  try {
39333
- value.approvedBy = new ObjectId103(value.approvedBy);
39686
+ value.approvedBy = new ObjectId104(value.approvedBy);
39334
39687
  } catch {
39335
39688
  throw new Error("Invalid approvedBy ID.");
39336
39689
  }
@@ -39338,7 +39691,7 @@ function useIncidentReportRepo() {
39338
39691
  const { incidentInformation } = value;
39339
39692
  if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
39340
39693
  try {
39341
- incidentInformation.siteInfo.site = new ObjectId103(
39694
+ incidentInformation.siteInfo.site = new ObjectId104(
39342
39695
  incidentInformation.siteInfo.site
39343
39696
  );
39344
39697
  } catch {
@@ -39373,7 +39726,7 @@ function useIncidentReportRepo() {
39373
39726
  }
39374
39727
  async function deleteIncidentReportById(_id) {
39375
39728
  try {
39376
- _id = new ObjectId103(_id);
39729
+ _id = new ObjectId104(_id);
39377
39730
  } catch (error) {
39378
39731
  throw new BadRequestError162("Invalid occurrence subject ID format.");
39379
39732
  }
@@ -39405,7 +39758,7 @@ function useIncidentReportRepo() {
39405
39758
  async function reviewIncidentReport(_id, value, session) {
39406
39759
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
39407
39760
  try {
39408
- _id = new ObjectId103(_id);
39761
+ _id = new ObjectId104(_id);
39409
39762
  } catch (error) {
39410
39763
  throw new BadRequestError162("Invalid ID format.");
39411
39764
  }
@@ -39897,7 +40250,7 @@ function useIncidentReportController() {
39897
40250
  }
39898
40251
 
39899
40252
  // src/models/nfc-patrol-settings.model.ts
39900
- import { ObjectId as ObjectId104 } from "mongodb";
40253
+ import { ObjectId as ObjectId105 } from "mongodb";
39901
40254
  import Joi101 from "joi";
39902
40255
  import { BadRequestError as BadRequestError165, logger as logger142 } from "@7365admin1/node-server-utils";
39903
40256
  var objectId = Joi101.string().hex().length(24);
@@ -39923,7 +40276,7 @@ function MNfcPatrolSettings(value) {
39923
40276
  }
39924
40277
  if (value.site) {
39925
40278
  try {
39926
- value.site = new ObjectId104(value.site);
40279
+ value.site = new ObjectId105(value.site);
39927
40280
  } catch (error2) {
39928
40281
  throw new BadRequestError165("Invalid site ID format.");
39929
40282
  }
@@ -39943,7 +40296,7 @@ function MNfcPatrolSettingsUpdate(value) {
39943
40296
  }
39944
40297
  if (value.updatedBy) {
39945
40298
  try {
39946
- value.updatedBy = new ObjectId104(value.updatedBy);
40299
+ value.updatedBy = new ObjectId105(value.updatedBy);
39947
40300
  } catch (error2) {
39948
40301
  throw new BadRequestError165("Invalid updatedBy ID format.");
39949
40302
  }
@@ -39965,7 +40318,7 @@ import {
39965
40318
  useAtlas as useAtlas90,
39966
40319
  useCache as useCache55
39967
40320
  } from "@7365admin1/node-server-utils";
39968
- import { ObjectId as ObjectId105 } from "mongodb";
40321
+ import { ObjectId as ObjectId106 } from "mongodb";
39969
40322
  function useNfcPatrolSettingsRepository() {
39970
40323
  const db = useAtlas90.getDb();
39971
40324
  if (!db) {
@@ -39995,7 +40348,7 @@ function useNfcPatrolSettingsRepository() {
39995
40348
  }
39996
40349
  async function getNfcPatrolSettingsBySite(site, session) {
39997
40350
  try {
39998
- site = new ObjectId105(site);
40351
+ site = new ObjectId106(site);
39999
40352
  } catch (error) {
40000
40353
  throw new BadRequestError166("Invalid nfc patrol settings site ID format.");
40001
40354
  }
@@ -40039,7 +40392,7 @@ function useNfcPatrolSettingsRepository() {
40039
40392
  }
40040
40393
  async function updateNfcPatrolSettings(site, value, session) {
40041
40394
  try {
40042
- site = new ObjectId105(site);
40395
+ site = new ObjectId106(site);
40043
40396
  } catch (error) {
40044
40397
  throw new BadRequestError166("Invalid attendance settings ID format.");
40045
40398
  }
@@ -40208,7 +40561,7 @@ function useNfcPatrolSettingsController() {
40208
40561
 
40209
40562
  // src/services/occurrence-entry.service.ts
40210
40563
  import { useAtlas as useAtlas93 } from "@7365admin1/node-server-utils";
40211
- import { ObjectId as ObjectId108 } from "mongodb";
40564
+ import { ObjectId as ObjectId109 } from "mongodb";
40212
40565
 
40213
40566
  // src/repositories/occurrence-subject.repo.ts
40214
40567
  import {
@@ -40223,7 +40576,7 @@ import {
40223
40576
  } from "@7365admin1/node-server-utils";
40224
40577
 
40225
40578
  // src/models/occurrence-subject.model.ts
40226
- import { ObjectId as ObjectId106 } from "mongodb";
40579
+ import { ObjectId as ObjectId107 } from "mongodb";
40227
40580
  import Joi103 from "joi";
40228
40581
  var schemaOccurrenceSubject = Joi103.object({
40229
40582
  site: Joi103.string().hex().required(),
@@ -40237,27 +40590,27 @@ var schemaUpdateOccurrenceSubject = Joi103.object({
40237
40590
  function MOccurrenceSubject(value) {
40238
40591
  if (value._id && typeof value._id === "string") {
40239
40592
  try {
40240
- value._id = new ObjectId106(value._id);
40593
+ value._id = new ObjectId107(value._id);
40241
40594
  } catch {
40242
40595
  throw new Error("Invalid ID.");
40243
40596
  }
40244
40597
  }
40245
40598
  if (value.site && typeof value.site === "string") {
40246
40599
  try {
40247
- value.site = new ObjectId106(value.site);
40600
+ value.site = new ObjectId107(value.site);
40248
40601
  } catch {
40249
40602
  throw new Error("Invalid site ID.");
40250
40603
  }
40251
40604
  }
40252
40605
  if (value.addedBy && typeof value.addedBy === "string") {
40253
40606
  try {
40254
- value.addedBy = new ObjectId106(value.addedBy);
40607
+ value.addedBy = new ObjectId107(value.addedBy);
40255
40608
  } catch {
40256
40609
  throw new Error("Invalid addedBy ID.");
40257
40610
  }
40258
40611
  }
40259
40612
  return {
40260
- _id: value._id ?? new ObjectId106(),
40613
+ _id: value._id ?? new ObjectId107(),
40261
40614
  site: value.site,
40262
40615
  subject: value.subject,
40263
40616
  addedBy: value.addedBy ?? "",
@@ -40268,7 +40621,7 @@ function MOccurrenceSubject(value) {
40268
40621
  }
40269
40622
 
40270
40623
  // src/repositories/occurrence-subject.repo.ts
40271
- import { ObjectId as ObjectId107 } from "mongodb";
40624
+ import { ObjectId as ObjectId108 } from "mongodb";
40272
40625
  function useOccurrenceSubjectRepo() {
40273
40626
  const db = useAtlas92.getDb();
40274
40627
  if (!db) {
@@ -40327,7 +40680,7 @@ function useOccurrenceSubjectRepo() {
40327
40680
  }, session) {
40328
40681
  page = page > 0 ? page - 1 : 0;
40329
40682
  try {
40330
- site = new ObjectId107(site);
40683
+ site = new ObjectId108(site);
40331
40684
  } catch (error) {
40332
40685
  throw new BadRequestError169("Invalid site ID format.");
40333
40686
  }
@@ -40422,7 +40775,7 @@ function useOccurrenceSubjectRepo() {
40422
40775
  }
40423
40776
  async function getOccurrenceSubjectById(_id, session) {
40424
40777
  try {
40425
- _id = new ObjectId107(_id);
40778
+ _id = new ObjectId108(_id);
40426
40779
  } catch (error) {
40427
40780
  throw new BadRequestError169("Invalid occurrence subject ID format.");
40428
40781
  }
@@ -40439,7 +40792,7 @@ function useOccurrenceSubjectRepo() {
40439
40792
  async function updateOccurrenceSubjectById(_id, value, session) {
40440
40793
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
40441
40794
  try {
40442
- _id = new ObjectId107(_id);
40795
+ _id = new ObjectId108(_id);
40443
40796
  } catch (error) {
40444
40797
  throw new BadRequestError169("Invalid ID format.");
40445
40798
  }
@@ -40469,7 +40822,7 @@ function useOccurrenceSubjectRepo() {
40469
40822
  }
40470
40823
  async function deleteOccurrenceSubjectById(_id) {
40471
40824
  try {
40472
- _id = new ObjectId107(_id);
40825
+ _id = new ObjectId108(_id);
40473
40826
  } catch (error) {
40474
40827
  throw new BadRequestError169("Invalid occurrence subject ID format.");
40475
40828
  }
@@ -40581,8 +40934,8 @@ function useOccurrenceEntryService() {
40581
40934
  value.dailyOccurrenceBookId = occurrenceEntry.dailyOccurrenceBookId;
40582
40935
  value.bookEntryCount = value.bookEntryCount ? value.bookEntryCount : occurrenceEntry.bookEntryCount;
40583
40936
  value.occurrence = value.occurrence ? value.occurrence : occurrenceEntry.occurrence;
40584
- value.signature = value.signature ? new ObjectId108(value.signature) : occurrenceEntry.signature._id;
40585
- value.eSignature = value.eSignature ? new ObjectId108(value.eSignature) : occurrenceEntry.eSignature;
40937
+ value.signature = value.signature ? new ObjectId109(value.signature) : occurrenceEntry.signature._id;
40938
+ value.eSignature = value.eSignature ? new ObjectId109(value.eSignature) : occurrenceEntry.eSignature;
40586
40939
  value.createdAt = /* @__PURE__ */ new Date();
40587
40940
  value.date = value.date ? value.date : occurrenceEntry.date;
40588
40941
  value.userName = value.userName ? value.userName : occurrenceEntry.signature.name;
@@ -40782,7 +41135,7 @@ function useOccurrenceEntryController() {
40782
41135
 
40783
41136
  // src/models/online-form.model.ts
40784
41137
  import Joi105 from "joi";
40785
- import { ObjectId as ObjectId109 } from "mongodb";
41138
+ import { ObjectId as ObjectId110 } from "mongodb";
40786
41139
  var schemaOnlineForm = Joi105.object({
40787
41140
  _id: Joi105.string().hex().optional().allow("", null),
40788
41141
  name: Joi105.string().required(),
@@ -40830,21 +41183,21 @@ function MOnlineForm(value) {
40830
41183
  }
40831
41184
  if (value._id && typeof value._id === "string") {
40832
41185
  try {
40833
- value._id = new ObjectId109(value._id);
41186
+ value._id = new ObjectId110(value._id);
40834
41187
  } catch (error2) {
40835
41188
  throw new Error("Invalid ID.");
40836
41189
  }
40837
41190
  }
40838
41191
  if (value.org && typeof value.org === "string") {
40839
41192
  try {
40840
- value.org = new ObjectId109(value.org);
41193
+ value.org = new ObjectId110(value.org);
40841
41194
  } catch (error2) {
40842
41195
  throw new Error("Invalid org ID.");
40843
41196
  }
40844
41197
  }
40845
41198
  if (value.site && typeof value.site === "string") {
40846
41199
  try {
40847
- value.site = new ObjectId109(value.site);
41200
+ value.site = new ObjectId110(value.site);
40848
41201
  } catch (error2) {
40849
41202
  throw new Error("Invalid site ID.");
40850
41203
  }
@@ -40876,7 +41229,7 @@ import {
40876
41229
  useAtlas as useAtlas94,
40877
41230
  useCache as useCache57
40878
41231
  } from "@7365admin1/node-server-utils";
40879
- import { ObjectId as ObjectId110 } from "mongodb";
41232
+ import { ObjectId as ObjectId111 } from "mongodb";
40880
41233
  function useOnlineFormRepo() {
40881
41234
  const db = useAtlas94.getDb();
40882
41235
  if (!db) {
@@ -40928,7 +41281,7 @@ function useOnlineFormRepo() {
40928
41281
  }) {
40929
41282
  page = page > 0 ? page - 1 : 0;
40930
41283
  try {
40931
- site = new ObjectId110(site);
41284
+ site = new ObjectId111(site);
40932
41285
  } catch (error) {
40933
41286
  throw new BadRequestError171("Invalid site ID format.");
40934
41287
  }
@@ -40988,7 +41341,7 @@ function useOnlineFormRepo() {
40988
41341
  }
40989
41342
  async function getOnlineFormById(_id) {
40990
41343
  try {
40991
- _id = new ObjectId110(_id);
41344
+ _id = new ObjectId111(_id);
40992
41345
  } catch (error) {
40993
41346
  throw new BadRequestError171("Invalid online form ID format.");
40994
41347
  }
@@ -41031,7 +41384,7 @@ function useOnlineFormRepo() {
41031
41384
  }
41032
41385
  async function updateOnlineFormById(_id, value) {
41033
41386
  try {
41034
- _id = new ObjectId110(_id);
41387
+ _id = new ObjectId111(_id);
41035
41388
  } catch (error) {
41036
41389
  throw new BadRequestError171("Invalid online form ID format.");
41037
41390
  }
@@ -41059,7 +41412,7 @@ function useOnlineFormRepo() {
41059
41412
  }
41060
41413
  async function deleteOnlineFormById(_id, session) {
41061
41414
  try {
41062
- _id = new ObjectId110(_id);
41415
+ _id = new ObjectId111(_id);
41063
41416
  } catch (error) {
41064
41417
  throw new BadRequestError171("Invalid online form ID format.");
41065
41418
  }
@@ -41092,7 +41445,7 @@ function useOnlineFormRepo() {
41092
41445
  }
41093
41446
  async function getOnlineFormsBySiteId(site, { search = "", page = 1, limit = 10, status = "active" }) {
41094
41447
  try {
41095
- site = new ObjectId110(site);
41448
+ site = new ObjectId111(site);
41096
41449
  } catch (error) {
41097
41450
  throw new BadRequestError171(
41098
41451
  "Invalid online form configuration site ID format."
@@ -41533,7 +41886,7 @@ function useOccurrenceSubjectController() {
41533
41886
  }
41534
41887
 
41535
41888
  // src/models/nfc-patrol-log.model.ts
41536
- import { ObjectId as ObjectId111 } from "mongodb";
41889
+ import { ObjectId as ObjectId112 } from "mongodb";
41537
41890
  import Joi108 from "joi";
41538
41891
  import { BadRequestError as BadRequestError174, logger as logger151 } from "@7365admin1/node-server-utils";
41539
41892
  var schemaNfcPatrolLog = Joi108.object({
@@ -41585,32 +41938,32 @@ function MNfcPatrolLog(valueArg) {
41585
41938
  }
41586
41939
  if (value._id && typeof value._id === "string") {
41587
41940
  try {
41588
- value._id = new ObjectId111(value._id);
41941
+ value._id = new ObjectId112(value._id);
41589
41942
  } catch (error2) {
41590
41943
  throw new BadRequestError174("Invalid _id format");
41591
41944
  }
41592
41945
  }
41593
41946
  try {
41594
- value.site = new ObjectId111(value.site);
41947
+ value.site = new ObjectId112(value.site);
41595
41948
  } catch (error2) {
41596
41949
  throw new BadRequestError174("Invalid site format");
41597
41950
  }
41598
41951
  if (value?.createdBy) {
41599
41952
  try {
41600
- value.createdBy = new ObjectId111(value.createdBy);
41953
+ value.createdBy = new ObjectId112(value.createdBy);
41601
41954
  } catch (error2) {
41602
41955
  throw new BadRequestError174("Invalid createdBy format");
41603
41956
  }
41604
41957
  }
41605
41958
  if (value?.route?._id) {
41606
41959
  try {
41607
- value.route._id = new ObjectId111(value.route._id);
41960
+ value.route._id = new ObjectId112(value.route._id);
41608
41961
  } catch (error2) {
41609
41962
  throw new BadRequestError174("Invalid route _id format");
41610
41963
  }
41611
41964
  }
41612
41965
  return {
41613
- _id: value._id ?? new ObjectId111(),
41966
+ _id: value._id ?? new ObjectId112(),
41614
41967
  site: value.site,
41615
41968
  route: value.route,
41616
41969
  date: value.date,
@@ -41632,7 +41985,7 @@ import {
41632
41985
  useAtlas as useAtlas96,
41633
41986
  useCache as useCache58
41634
41987
  } from "@7365admin1/node-server-utils";
41635
- import { ObjectId as ObjectId112 } from "mongodb";
41988
+ import { ObjectId as ObjectId113 } from "mongodb";
41636
41989
  function useNfcPatrolLogRepo() {
41637
41990
  const db = useAtlas96.getDb();
41638
41991
  if (!db) {
@@ -41685,7 +42038,7 @@ function useNfcPatrolLogRepo() {
41685
42038
  const pageIndex = page > 0 ? page - 1 : 0;
41686
42039
  let siteId;
41687
42040
  try {
41688
- siteId = typeof site === "string" ? new ObjectId112(site) : site;
42041
+ siteId = typeof site === "string" ? new ObjectId113(site) : site;
41689
42042
  } catch {
41690
42043
  throw new BadRequestError175("Invalid site ID format.");
41691
42044
  }
@@ -41696,7 +42049,7 @@ function useNfcPatrolLogRepo() {
41696
42049
  query.date = date;
41697
42050
  }
41698
42051
  if (route?._id) {
41699
- query["route._id"] = typeof route._id === "string" ? new ObjectId112(route._id) : route._id;
42052
+ query["route._id"] = typeof route._id === "string" ? new ObjectId113(route._id) : route._id;
41700
42053
  }
41701
42054
  if (route?.startTime) {
41702
42055
  query["route.startTime"] = route.startTime;
@@ -41869,7 +42222,7 @@ import {
41869
42222
  InternalServerError as InternalServerError59,
41870
42223
  logger as logger155,
41871
42224
  makeCacheKey as makeCacheKey57,
41872
- toObjectId as toObjectId13,
42225
+ toObjectId as toObjectId14,
41873
42226
  useAtlas as useAtlas98,
41874
42227
  useCache as useCache59
41875
42228
  } from "@7365admin1/node-server-utils";
@@ -41961,7 +42314,7 @@ function useNewDashboardRepo() {
41961
42314
  securityDashboardCollection
41962
42315
  );
41963
42316
  async function getMetric(collectionString, siteId, period) {
41964
- const site = toObjectId13(siteId);
42317
+ const site = toObjectId14(siteId);
41965
42318
  const range = getPeriodRangeWithPrevious(period);
41966
42319
  const collection = db.collection(collectionString);
41967
42320
  const current = await collection.countDocuments({
@@ -42568,7 +42921,7 @@ function useNewDashboardController() {
42568
42921
 
42569
42922
  // src/models/manpower-monitoring.model.ts
42570
42923
  import Joi111 from "joi";
42571
- import { ObjectId as ObjectId113 } from "mongodb";
42924
+ import { ObjectId as ObjectId114 } from "mongodb";
42572
42925
  var shiftSchema = Joi111.object({
42573
42926
  name: Joi111.string().required(),
42574
42927
  checkIn: Joi111.string().optional().allow("", null),
@@ -42593,7 +42946,7 @@ var manpowerMonitoringSchema = Joi111.object({
42593
42946
  });
42594
42947
  var MManpowerMonitoring = class {
42595
42948
  constructor(data) {
42596
- this._id = new ObjectId113();
42949
+ this._id = new ObjectId114();
42597
42950
  this.serviceProviderId = data.serviceProviderId || "";
42598
42951
  this.siteId = data.siteId || "";
42599
42952
  this.siteName = data.siteName;
@@ -43063,7 +43416,7 @@ var hrmlabs_attendance_util_default = {
43063
43416
  };
43064
43417
 
43065
43418
  // src/repositories/manpower-monitoring.repo.ts
43066
- import { ObjectId as ObjectId114 } from "mongodb";
43419
+ import { ObjectId as ObjectId115 } from "mongodb";
43067
43420
  var { hrmLabsAuthentication: hrmLabsAuthentication2, fetchSites: fetchSites2 } = hrmlabs_attendance_util_default;
43068
43421
  function useManpowerMonitoringRepo() {
43069
43422
  const db = useAtlas99.getDb();
@@ -43077,11 +43430,11 @@ function useManpowerMonitoringRepo() {
43077
43430
  try {
43078
43431
  value = new MManpowerMonitoring(value);
43079
43432
  if (value.createdBy)
43080
- value.createdBy = new ObjectId114(value.createdBy);
43433
+ value.createdBy = new ObjectId115(value.createdBy);
43081
43434
  if (value.siteId)
43082
- value.siteId = new ObjectId114(value.siteId);
43435
+ value.siteId = new ObjectId115(value.siteId);
43083
43436
  if (value.serviceProviderId)
43084
- value.serviceProviderId = new ObjectId114(value.serviceProviderId);
43437
+ value.serviceProviderId = new ObjectId115(value.serviceProviderId);
43085
43438
  const result = await collection.insertOne(value, { session });
43086
43439
  return result;
43087
43440
  } catch (error) {
@@ -43122,8 +43475,8 @@ function useManpowerMonitoringRepo() {
43122
43475
  }
43123
43476
  async function getManpowerSettingsBySiteId(_id, serviceProviderId) {
43124
43477
  try {
43125
- _id = new ObjectId114(_id);
43126
- serviceProviderId = new ObjectId114(serviceProviderId);
43478
+ _id = new ObjectId115(_id);
43479
+ serviceProviderId = new ObjectId115(serviceProviderId);
43127
43480
  } catch (error) {
43128
43481
  throw new Error("Invalid Site ID format.");
43129
43482
  }
@@ -43139,7 +43492,7 @@ function useManpowerMonitoringRepo() {
43139
43492
  }
43140
43493
  async function updateManpowerMonitoringSettings(_id, value) {
43141
43494
  try {
43142
- _id = new ObjectId114(_id);
43495
+ _id = new ObjectId115(_id);
43143
43496
  } catch (error) {
43144
43497
  throw new BadRequestError180("Invalid ID format.");
43145
43498
  }
@@ -43166,7 +43519,7 @@ function useManpowerMonitoringRepo() {
43166
43519
  for (let item of value) {
43167
43520
  item = new MManpowerMonitoring(item);
43168
43521
  const data = await collection.findOne({
43169
- siteId: new ObjectId114(item.siteId)
43522
+ siteId: new ObjectId115(item.siteId)
43170
43523
  });
43171
43524
  if (data) {
43172
43525
  let updateValue;
@@ -43191,11 +43544,11 @@ function useManpowerMonitoringRepo() {
43191
43544
  }
43192
43545
  } else {
43193
43546
  if (item.createdBy)
43194
- item.createdBy = new ObjectId114(item.createdBy);
43547
+ item.createdBy = new ObjectId115(item.createdBy);
43195
43548
  if (item.siteId)
43196
- item.siteId = new ObjectId114(item.siteId);
43549
+ item.siteId = new ObjectId115(item.siteId);
43197
43550
  if (item.serviceProviderId)
43198
- item.serviceProviderId = new ObjectId114(item.serviceProviderId);
43551
+ item.serviceProviderId = new ObjectId115(item.serviceProviderId);
43199
43552
  const result = await collection.insertOne(item);
43200
43553
  if (result.insertedId) {
43201
43554
  results.inserted++;
@@ -43219,7 +43572,7 @@ function useManpowerMonitoringRepo() {
43219
43572
  const siteUrl = process.env.HRMLABS_SITE_URL;
43220
43573
  try {
43221
43574
  const serviceProvider = await serviceProviderCollection.findOne({
43222
- _id: new ObjectId114(serviceProviderId)
43575
+ _id: new ObjectId115(serviceProviderId)
43223
43576
  });
43224
43577
  if (!serviceProvider) {
43225
43578
  throw new Error("Service Provider not found.");
@@ -43269,7 +43622,7 @@ import {
43269
43622
 
43270
43623
  // src/models/manpower-remarks.model.ts
43271
43624
  import Joi112 from "joi";
43272
- import { ObjectId as ObjectId115 } from "mongodb";
43625
+ import { ObjectId as ObjectId116 } from "mongodb";
43273
43626
  var remarksSchema = Joi112.object({
43274
43627
  name: Joi112.string().required(),
43275
43628
  remark: Joi112.object({
@@ -43293,7 +43646,7 @@ var manpowerRemarksSchema = Joi112.object({
43293
43646
  });
43294
43647
  var MManpowerRemarks = class {
43295
43648
  constructor(data) {
43296
- this._id = new ObjectId115();
43649
+ this._id = new ObjectId116();
43297
43650
  this.serviceProviderId = data.serviceProviderId || "";
43298
43651
  this.siteId = data.siteId || "";
43299
43652
  this.siteName = data.siteName || "";
@@ -43311,7 +43664,7 @@ var MManpowerRemarks = class {
43311
43664
  };
43312
43665
 
43313
43666
  // src/repositories/manpower-remarks.repo.ts
43314
- import { ObjectId as ObjectId116 } from "mongodb";
43667
+ import { ObjectId as ObjectId117 } from "mongodb";
43315
43668
  import moment2 from "moment-timezone";
43316
43669
  function useManpowerRemarksRepo() {
43317
43670
  const db = useAtlas100.getDb();
@@ -43324,9 +43677,9 @@ function useManpowerRemarksRepo() {
43324
43677
  try {
43325
43678
  value = new MManpowerRemarks(value);
43326
43679
  if (value.siteId)
43327
- value.siteId = new ObjectId116(value.siteId);
43680
+ value.siteId = new ObjectId117(value.siteId);
43328
43681
  if (value.serviceProviderId)
43329
- value.serviceProviderId = new ObjectId116(value.serviceProviderId);
43682
+ value.serviceProviderId = new ObjectId117(value.serviceProviderId);
43330
43683
  const result = await collection.insertOne(value, { session });
43331
43684
  return result;
43332
43685
  } catch (error) {
@@ -43346,7 +43699,7 @@ function useManpowerRemarksRepo() {
43346
43699
  limit = limit || 10;
43347
43700
  const searchQuery = {};
43348
43701
  const nowSGT = moment2().tz("Asia/Singapore");
43349
- searchQuery.serviceProviderId = new ObjectId116(serviceProviderId);
43702
+ searchQuery.serviceProviderId = new ObjectId117(serviceProviderId);
43350
43703
  if (search != "") {
43351
43704
  searchQuery.siteName = { $regex: search, $options: "i" };
43352
43705
  }
@@ -43378,8 +43731,8 @@ function useManpowerRemarksRepo() {
43378
43731
  }
43379
43732
  async function getManpowerRemarksBySiteId(_id, date, serviceProviderId) {
43380
43733
  try {
43381
- _id = new ObjectId116(_id);
43382
- serviceProviderId = new ObjectId116(serviceProviderId);
43734
+ _id = new ObjectId117(_id);
43735
+ serviceProviderId = new ObjectId117(serviceProviderId);
43383
43736
  } catch (error) {
43384
43737
  throw new Error("Invalid Site ID format.");
43385
43738
  }
@@ -43396,13 +43749,13 @@ function useManpowerRemarksRepo() {
43396
43749
  }
43397
43750
  async function updateManpowerRemarks(_id, value) {
43398
43751
  try {
43399
- _id = new ObjectId116(_id);
43752
+ _id = new ObjectId117(_id);
43400
43753
  } catch (error) {
43401
43754
  throw new BadRequestError181("Invalid ID format.");
43402
43755
  }
43403
43756
  try {
43404
43757
  if (value.createdBy) {
43405
- value.createdBy = new ObjectId116(value.createdBy);
43758
+ value.createdBy = new ObjectId117(value.createdBy);
43406
43759
  }
43407
43760
  const updateValue = {
43408
43761
  ...value,
@@ -43419,7 +43772,7 @@ function useManpowerRemarksRepo() {
43419
43772
  }
43420
43773
  async function updateRemarksStatus(_id, value) {
43421
43774
  try {
43422
- _id = new ObjectId116(_id);
43775
+ _id = new ObjectId117(_id);
43423
43776
  } catch (error) {
43424
43777
  throw new BadRequestError181("Invalid ID format.");
43425
43778
  }
@@ -43691,7 +44044,7 @@ function useManpowerMonitoringCtrl() {
43691
44044
 
43692
44045
  // src/models/manpower-designations.model.ts
43693
44046
  import Joi114 from "joi";
43694
- import { ObjectId as ObjectId117 } from "mongodb";
44047
+ import { ObjectId as ObjectId118 } from "mongodb";
43695
44048
  var designationsSchema = Joi114.object({
43696
44049
  title: Joi114.string().required(),
43697
44050
  shifts: Joi114.object({
@@ -43710,7 +44063,7 @@ var manpowerDesignationsSchema = Joi114.object({
43710
44063
  });
43711
44064
  var MManpowerDesignations = class {
43712
44065
  constructor(data) {
43713
- this._id = new ObjectId117();
44066
+ this._id = new ObjectId118();
43714
44067
  this.siteId = data.siteId || "";
43715
44068
  this.siteName = data.siteName || "";
43716
44069
  this.serviceProviderId = data.serviceProviderId || "";
@@ -43726,7 +44079,7 @@ var MManpowerDesignations = class {
43726
44079
  import {
43727
44080
  useAtlas as useAtlas102
43728
44081
  } from "@7365admin1/node-server-utils";
43729
- import { ObjectId as ObjectId118 } from "mongodb";
44082
+ import { ObjectId as ObjectId119 } from "mongodb";
43730
44083
  function useManpowerDesignationRepo() {
43731
44084
  const db = useAtlas102.getDb();
43732
44085
  if (!db) {
@@ -43738,11 +44091,11 @@ function useManpowerDesignationRepo() {
43738
44091
  try {
43739
44092
  value = new MManpowerDesignations(value);
43740
44093
  if (value.createdBy)
43741
- value.createdBy = new ObjectId118(value.createdBy);
44094
+ value.createdBy = new ObjectId119(value.createdBy);
43742
44095
  if (value.siteId)
43743
- value.siteId = new ObjectId118(value.siteId);
44096
+ value.siteId = new ObjectId119(value.siteId);
43744
44097
  if (value.serviceProviderId)
43745
- value.serviceProviderId = new ObjectId118(value.serviceProviderId);
44098
+ value.serviceProviderId = new ObjectId119(value.serviceProviderId);
43746
44099
  const result = await collection.insertOne(value);
43747
44100
  return result;
43748
44101
  } catch (error) {
@@ -43751,8 +44104,8 @@ function useManpowerDesignationRepo() {
43751
44104
  }
43752
44105
  async function getManpowerDesignationsBySiteId(_id, serviceProviderId) {
43753
44106
  try {
43754
- _id = new ObjectId118(_id);
43755
- serviceProviderId = new ObjectId118(serviceProviderId);
44107
+ _id = new ObjectId119(_id);
44108
+ serviceProviderId = new ObjectId119(serviceProviderId);
43756
44109
  } catch (error) {
43757
44110
  throw new Error("Invalid Site ID format.");
43758
44111
  }
@@ -43768,7 +44121,7 @@ function useManpowerDesignationRepo() {
43768
44121
  }
43769
44122
  async function updateManpowerDesignations(_id, value) {
43770
44123
  try {
43771
- _id = new ObjectId118(_id);
44124
+ _id = new ObjectId119(_id);
43772
44125
  } catch (error) {
43773
44126
  throw new Error("Invalid ID format.");
43774
44127
  }
@@ -43871,7 +44224,7 @@ function useManpowerDesignationCtrl() {
43871
44224
 
43872
44225
  // src/models/overnight-parking.model.ts
43873
44226
  import Joi116 from "joi";
43874
- import { ObjectId as ObjectId119 } from "mongodb";
44227
+ import { ObjectId as ObjectId120 } from "mongodb";
43875
44228
  var dayScheduleSchema = Joi116.object({
43876
44229
  isEnabled: Joi116.boolean().required(),
43877
44230
  startTime: Joi116.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
@@ -43913,7 +44266,7 @@ function MOvernightParkingApprovalHours(value) {
43913
44266
  }
43914
44267
  if (value.site && typeof value.site === "string") {
43915
44268
  try {
43916
- value.site = new ObjectId119(value.site);
44269
+ value.site = new ObjectId120(value.site);
43917
44270
  } catch {
43918
44271
  throw new Error("Invalid site ID.");
43919
44272
  }
@@ -43939,7 +44292,7 @@ import {
43939
44292
  InternalServerError as InternalServerError63,
43940
44293
  logger as logger163,
43941
44294
  makeCacheKey as makeCacheKey61,
43942
- toObjectId as toObjectId14,
44295
+ toObjectId as toObjectId15,
43943
44296
  useAtlas as useAtlas103,
43944
44297
  useCache as useCache63
43945
44298
  } from "@7365admin1/node-server-utils";
@@ -44018,7 +44371,7 @@ function useOvernightParkingRepo() {
44018
44371
  }
44019
44372
  }
44020
44373
  async function getSiteOvernightParking(site) {
44021
- const siteId = toObjectId14(site);
44374
+ const siteId = toObjectId15(site);
44022
44375
  const cacheKey = makeCacheKey61(overnight_parking_namespace_collection, {
44023
44376
  site
44024
44377
  });
@@ -44114,7 +44467,7 @@ function useOvernightParkingController() {
44114
44467
 
44115
44468
  // src/models/overnight-parking-request.model.ts
44116
44469
  import Joi118 from "joi";
44117
- import { toObjectId as toObjectId15 } from "@7365admin1/node-server-utils";
44470
+ import { toObjectId as toObjectId16 } from "@7365admin1/node-server-utils";
44118
44471
  var OvernightParkingRequestStatus = /* @__PURE__ */ ((OvernightParkingRequestStatus2) => {
44119
44472
  OvernightParkingRequestStatus2["PENDING"] = "pending";
44120
44473
  OvernightParkingRequestStatus2["APPROVED"] = "approved";
@@ -44151,7 +44504,7 @@ function MOvernightParkingRequest(value) {
44151
44504
  throw new Error(error.details[0].message);
44152
44505
  }
44153
44506
  if (value.site && typeof value.site === "string")
44154
- value.site = toObjectId15(value.site);
44507
+ value.site = toObjectId16(value.site);
44155
44508
  const data = {
44156
44509
  ...value,
44157
44510
  createdAt: value.createdAt ? new Date(value.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
@@ -44168,7 +44521,7 @@ import {
44168
44521
  logger as logger165,
44169
44522
  makeCacheKey as makeCacheKey62,
44170
44523
  paginate as paginate54,
44171
- toObjectId as toObjectId16,
44524
+ toObjectId as toObjectId17,
44172
44525
  useAtlas as useAtlas104,
44173
44526
  useCache as useCache64
44174
44527
  } from "@7365admin1/node-server-utils";
@@ -44236,7 +44589,7 @@ function useOvernightParkingRequestRepo() {
44236
44589
  }) {
44237
44590
  page = page ? page - 1 : 0;
44238
44591
  const skip = page * limit;
44239
- const siteId = toObjectId16(site);
44592
+ const siteId = toObjectId17(site);
44240
44593
  const query = {
44241
44594
  site: siteId,
44242
44595
  ...status && { status }
@@ -44287,7 +44640,7 @@ function useOvernightParkingRequestRepo() {
44287
44640
  logger165.info(`Cache hit for key: ${cacheKey}`);
44288
44641
  return cachedData;
44289
44642
  }
44290
- const _id = toObjectId16(id);
44643
+ const _id = toObjectId17(id);
44291
44644
  const data = await collection.findOne({ _id });
44292
44645
  if (!data)
44293
44646
  throw new BadRequestError188("Overnight parking request not found.");
@@ -44303,7 +44656,7 @@ function useOvernightParkingRequestRepo() {
44303
44656
  }
44304
44657
  async function updateOvernightParkingRequestById(id, value, session) {
44305
44658
  try {
44306
- const _id = toObjectId16(id);
44659
+ const _id = toObjectId17(id);
44307
44660
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
44308
44661
  const data = await collection.updateOne(
44309
44662
  { _id },
@@ -44329,7 +44682,7 @@ function useOvernightParkingRequestRepo() {
44329
44682
  }
44330
44683
  async function deleteOvernightParkingRequestById(id, session) {
44331
44684
  try {
44332
- const _id = toObjectId16(id);
44685
+ const _id = toObjectId17(id);
44333
44686
  const value = {
44334
44687
  deletedAt: (/* @__PURE__ */ new Date()).toISOString(),
44335
44688
  status: "deleted" /* DELETED */
@@ -44358,7 +44711,7 @@ function useOvernightParkingRequestRepo() {
44358
44711
  }
44359
44712
  async function updateExpiredRequests(site, session) {
44360
44713
  try {
44361
- const _site = toObjectId16(site);
44714
+ const _site = toObjectId17(site);
44362
44715
  const value = {
44363
44716
  status: "expired" /* EXPIRED */
44364
44717
  };
@@ -45537,7 +45890,7 @@ function useManpowerRemarkCtrl() {
45537
45890
 
45538
45891
  // src/models/manpower-sites.model.ts
45539
45892
  import Joi122 from "joi";
45540
- import { ObjectId as ObjectId120 } from "mongodb";
45893
+ import { ObjectId as ObjectId121 } from "mongodb";
45541
45894
  var manpowerSitesSchema = Joi122.object({
45542
45895
  id: Joi122.string().hex().required(),
45543
45896
  text: Joi122.string().hex().optional().allow("", null),
@@ -45548,7 +45901,7 @@ var manpowerSitesSchema = Joi122.object({
45548
45901
  });
45549
45902
  var MManpowerSites = class {
45550
45903
  constructor(data) {
45551
- this._id = new ObjectId120();
45904
+ this._id = new ObjectId121();
45552
45905
  this.id = data.id || "";
45553
45906
  this.text = data.text || "";
45554
45907
  this.contractID = data.contractID || "";
@@ -45770,7 +46123,7 @@ import {
45770
46123
  getDirectory as getDirectory3,
45771
46124
  logger as logger174
45772
46125
  } from "@7365admin1/node-server-utils";
45773
- import { ObjectId as ObjectId121 } from "mongodb";
46126
+ import { ObjectId as ObjectId122 } from "mongodb";
45774
46127
  import moment4 from "moment-timezone";
45775
46128
  var createManpowerRemarksDaily = async () => {
45776
46129
  const db = useAtlas108.getDb();
@@ -45930,7 +46283,7 @@ var updateRemarksisAcknowledged = async () => {
45930
46283
  for (const id of updatedIds) {
45931
46284
  const doc = await remarks.findOne({ _id: id });
45932
46285
  const setting = await settings.findOne(
45933
- { siteId: new ObjectId121(doc?.siteId) },
46286
+ { siteId: new ObjectId122(doc?.siteId) },
45934
46287
  { projection: { emails: 1 } }
45935
46288
  );
45936
46289
  const payload = {
@@ -46016,7 +46369,7 @@ var updateRemarksStatusEod = async () => {
46016
46369
  for (const doc of docs) {
46017
46370
  let shiftsToCheck = [];
46018
46371
  const endShiftTime = await settings.findOne(
46019
- { siteId: new ObjectId121(doc.siteId) },
46372
+ { siteId: new ObjectId122(doc.siteId) },
46020
46373
  { projection: { shifts: 1, shiftType: 1 } }
46021
46374
  );
46022
46375
  if (doc.createdAtSGT === nowSGT) {
@@ -46122,7 +46475,7 @@ var isWithinHour = (alertTime, timeNow) => {
46122
46475
 
46123
46476
  // src/events/manpower.event.ts
46124
46477
  import { useAtlas as useAtlas109 } from "@7365admin1/node-server-utils";
46125
- import { ObjectId as ObjectId122 } from "mongodb";
46478
+ import { ObjectId as ObjectId123 } from "mongodb";
46126
46479
  import moment5 from "moment-timezone";
46127
46480
  async function manpowerEvents(io) {
46128
46481
  let intervalId = null;
@@ -46148,7 +46501,7 @@ async function manpowerEvents(io) {
46148
46501
  }).toArray();
46149
46502
  for (const doc of docs) {
46150
46503
  const siteSettings = await settings.findOne(
46151
- { siteId: new ObjectId122(doc.siteId), enabled: true },
46504
+ { siteId: new ObjectId123(doc.siteId), enabled: true },
46152
46505
  { projection: { shifts: 1, shiftType: 1 } }
46153
46506
  );
46154
46507
  const shiftType = siteSettings?.shiftType || "2-shifts";
@@ -46267,7 +46620,7 @@ function genericSignature(params, secretKey) {
46267
46620
  }
46268
46621
 
46269
46622
  // src/repositories/reddot-payment.repository.ts
46270
- import { ObjectId as ObjectId126 } from "mongodb";
46623
+ import { ObjectId as ObjectId127 } from "mongodb";
46271
46624
 
46272
46625
  // src/utils/date-format.util.ts
46273
46626
  import moment6 from "moment-timezone";
@@ -46292,11 +46645,11 @@ function formatDateString(today, format, dateRange) {
46292
46645
  }
46293
46646
 
46294
46647
  // src/models/credit-card.model.ts
46295
- import { ObjectId as ObjectId123 } from "mongodb";
46648
+ import { ObjectId as ObjectId124 } from "mongodb";
46296
46649
  var MCardInfo = class {
46297
46650
  // this is coming from RDP transaction
46298
46651
  constructor({
46299
- _id = new ObjectId123(),
46652
+ _id = new ObjectId124(),
46300
46653
  userId,
46301
46654
  cardType,
46302
46655
  cardNumber,
@@ -46331,11 +46684,11 @@ var MCardInfo = class {
46331
46684
  };
46332
46685
 
46333
46686
  // src/models/cart.model.ts
46334
- import { ObjectId as ObjectId124 } from "mongodb";
46687
+ import { ObjectId as ObjectId125 } from "mongodb";
46335
46688
  var MUnitBillings = class {
46336
46689
  // transaction response messages
46337
46690
  constructor({
46338
- _id = new ObjectId124(),
46691
+ _id = new ObjectId125(),
46339
46692
  unit,
46340
46693
  unitId,
46341
46694
  unitBill,
@@ -46376,7 +46729,7 @@ var MUnitBillings = class {
46376
46729
  };
46377
46730
 
46378
46731
  // src/repositories/payment.repository.ts
46379
- import { ObjectId as ObjectId125 } from "mongodb";
46732
+ import { ObjectId as ObjectId126 } from "mongodb";
46380
46733
  import {
46381
46734
  InternalServerError as InternalServerError66,
46382
46735
  useAtlas as useAtlas110
@@ -46413,7 +46766,7 @@ var PaymentBillRepo = () => {
46413
46766
  if (unitBillInfo?.status === "Inactive" /* inactive */) {
46414
46767
  throw new Error("This Bill is Inactive!");
46415
46768
  }
46416
- const billId = new ObjectId125(unitBillInfo?.billId);
46769
+ const billId = new ObjectId126(unitBillInfo?.billId);
46417
46770
  const billInfo = await billCollection().findOne({ _id: billId });
46418
46771
  if (!billInfo) {
46419
46772
  throw new Error("Bill info not found");
@@ -46452,13 +46805,13 @@ var PaymentBillRepo = () => {
46452
46805
  const saveCreditCardInfo = async (payload) => {
46453
46806
  try {
46454
46807
  if (payload.userId)
46455
- payload.userId = new ObjectId125(payload.userId);
46808
+ payload.userId = new ObjectId126(payload.userId);
46456
46809
  if (payload.site)
46457
- payload.site = new ObjectId125(payload.site);
46810
+ payload.site = new ObjectId126(payload.site);
46458
46811
  if (payload.organization)
46459
- payload.organization = new ObjectId125(payload.organization);
46812
+ payload.organization = new ObjectId126(payload.organization);
46460
46813
  if (payload.createdBy)
46461
- payload.createdBy = new ObjectId125(payload.createdBy);
46814
+ payload.createdBy = new ObjectId126(payload.createdBy);
46462
46815
  const createdAt = formatDateString(/* @__PURE__ */ new Date(), "mm-dd-yyyy");
46463
46816
  payload.createdAt = createdAt;
46464
46817
  const result = await creditCollection().insertOne(new MCardInfo(payload));
@@ -46470,19 +46823,19 @@ var PaymentBillRepo = () => {
46470
46823
  const checkOutUnitBills = async (payload) => {
46471
46824
  try {
46472
46825
  if (payload.unitId)
46473
- payload.unitId = new ObjectId125(payload.unitId);
46826
+ payload.unitId = new ObjectId126(payload.unitId);
46474
46827
  if (payload.site)
46475
- payload.site = new ObjectId125(payload.site);
46828
+ payload.site = new ObjectId126(payload.site);
46476
46829
  if (payload.organization)
46477
- payload.organization = new ObjectId125(payload.organization);
46830
+ payload.organization = new ObjectId126(payload.organization);
46478
46831
  payload.createdAt = await formatDateString(/* @__PURE__ */ new Date(), "mm-dd-yyyy");
46479
46832
  const addToCart = await cartCollection().insertOne(new MUnitBillings(payload));
46480
46833
  const unitId = payload.unitId;
46481
46834
  const dateFormatted = formatDateString(/* @__PURE__ */ new Date(), "for-ref");
46482
46835
  const unit = unitId?.toString().slice(-4);
46483
- const newId = new ObjectId125(addToCart?.insertedId).toString().slice(-4);
46836
+ const newId = new ObjectId126(addToCart?.insertedId).toString().slice(-4);
46484
46837
  const referenceNumber = `CRT${unit}${newId}${dateFormatted}`;
46485
- const result = await cartCollection().findOneAndUpdate({ _id: new ObjectId125(addToCart.insertedId) }, { $set: { referenceNumber } }, { returnDocument: "after" });
46838
+ const result = await cartCollection().findOneAndUpdate({ _id: new ObjectId126(addToCart.insertedId) }, { $set: { referenceNumber } }, { returnDocument: "after" });
46486
46839
  return result;
46487
46840
  } catch (error) {
46488
46841
  throw new Error(error.message || error || "Server Internal Error");
@@ -46513,7 +46866,7 @@ var PaymentBillRepo = () => {
46513
46866
  for (const ref of refNumber) {
46514
46867
  const unitBillInfo = await collection().findOne({ referenceNumber: ref });
46515
46868
  const billId = unitBillInfo?.billId;
46516
- const billInfo = await billCollection().findOne({ _id: new ObjectId125(billId) });
46869
+ const billInfo = await billCollection().findOne({ _id: new ObjectId126(billId) });
46517
46870
  const billAmount = billInfo?.price;
46518
46871
  payload.updatedAt = updatedAt;
46519
46872
  payload.amountPaid = billAmount;
@@ -46667,7 +47020,7 @@ var useRedDotPaymentRepo = () => {
46667
47020
  throw new Error("Failed to Add Merchant Details");
46668
47021
  }
46669
47022
  const merchantId = merchant?.insertedId;
46670
- const orgId = new ObjectId126(_id);
47023
+ const orgId = new ObjectId127(_id);
46671
47024
  const result = await orgCollection().findOneAndUpdate({ _id: orgId }, { $push: { merchant: merchantId } }, {
46672
47025
  returnDocument: "after"
46673
47026
  });
@@ -46696,7 +47049,7 @@ var useRedDotPaymentRepo = () => {
46696
47049
  const getMerchantDetailsById = async (_id) => {
46697
47050
  try {
46698
47051
  if (_id)
46699
- _id = new ObjectId126(_id);
47052
+ _id = new ObjectId127(_id);
46700
47053
  const result = await redDotMerchantCollection().aggregate([
46701
47054
  {
46702
47055
  $match: {
@@ -46956,11 +47309,11 @@ import {
46956
47309
  logger as logger175,
46957
47310
  makeCacheKey as makeCacheKey64,
46958
47311
  paginate as paginate57,
46959
- toObjectId as toObjectId17,
47312
+ toObjectId as toObjectId18,
46960
47313
  useAtlas as useAtlas112,
46961
47314
  useCache as useCache66
46962
47315
  } from "@7365admin1/node-server-utils";
46963
- import { ObjectId as ObjectId127 } from "mongodb";
47316
+ import { ObjectId as ObjectId128 } from "mongodb";
46964
47317
  function useVerificationRepoV2() {
46965
47318
  const db = useAtlas112.getDb();
46966
47319
  if (!db) {
@@ -47013,7 +47366,7 @@ function useVerificationRepoV2() {
47013
47366
  }
47014
47367
  async function updateVerificationStatusById(_id, status, session) {
47015
47368
  try {
47016
- _id = new ObjectId127(_id);
47369
+ _id = new ObjectId128(_id);
47017
47370
  } catch (error) {
47018
47371
  throw new BadRequestError195("Invalid verification ID format.");
47019
47372
  }
@@ -47063,7 +47416,7 @@ function useVerificationRepoV2() {
47063
47416
  }
47064
47417
  async function getVerificationById(id) {
47065
47418
  try {
47066
- const _id = toObjectId17(id);
47419
+ const _id = toObjectId18(id);
47067
47420
  const cacheKey = makeCacheKey64(namespace_collection, { id });
47068
47421
  const cachedData = await getCache(cacheKey);
47069
47422
  if (cachedData) {
@@ -47156,7 +47509,7 @@ function useVerificationRepoV2() {
47156
47509
  }
47157
47510
  async function updateStatusById(_id, status, session) {
47158
47511
  try {
47159
- _id = new ObjectId127(_id);
47512
+ _id = new ObjectId128(_id);
47160
47513
  } catch (error) {
47161
47514
  throw new BadRequestError195("Invalid verification ID format.");
47162
47515
  }
@@ -47758,7 +48111,7 @@ import {
47758
48111
  import { v4 as uuidv42 } from "uuid";
47759
48112
 
47760
48113
  // src/repositories/user-v2.repo.ts
47761
- import { ObjectId as ObjectId128 } from "mongodb";
48114
+ import { ObjectId as ObjectId129 } from "mongodb";
47762
48115
  import {
47763
48116
  useAtlas as useAtlas114,
47764
48117
  InternalServerError as InternalServerError70,
@@ -47769,7 +48122,7 @@ import {
47769
48122
  AppError as AppError27,
47770
48123
  useCache as useCache67,
47771
48124
  makeCacheKey as makeCacheKey65,
47772
- toObjectId as toObjectId18
48125
+ toObjectId as toObjectId19
47773
48126
  } from "@7365admin1/node-server-utils";
47774
48127
  function useUserRepoV2() {
47775
48128
  const { updateFeedbackCreatedByName } = useFeedbackRepo();
@@ -47870,7 +48223,7 @@ function useUserRepoV2() {
47870
48223
  }
47871
48224
  }
47872
48225
  async function getUserById(id) {
47873
- const _id = toObjectId18(id);
48226
+ const _id = toObjectId19(id);
47874
48227
  try {
47875
48228
  const cacheKey = makeCacheKey65(namespace_collection, { id });
47876
48229
  const cachedData = await getCache(cacheKey);
@@ -47970,7 +48323,7 @@ function useUserRepoV2() {
47970
48323
  }
47971
48324
  if (organization) {
47972
48325
  try {
47973
- query.defaultOrg = new ObjectId128(organization);
48326
+ query.defaultOrg = new ObjectId129(organization);
47974
48327
  cacheOptions.organization = organization.toString();
47975
48328
  } catch (error) {
47976
48329
  throw new BadRequestError198("Invalid organization ID format.");
@@ -48075,7 +48428,7 @@ function useUserRepoV2() {
48075
48428
  }
48076
48429
  async function updatePasswordById({ _id, password }, session) {
48077
48430
  const cacheKey = makeCacheKey65(namespace_collection, { _id });
48078
- _id = toObjectId18(_id);
48431
+ _id = toObjectId19(_id);
48079
48432
  try {
48080
48433
  const result = await collection.updateOne(
48081
48434
  { _id },
@@ -48109,13 +48462,13 @@ function useUserRepoV2() {
48109
48462
  );
48110
48463
  }
48111
48464
  try {
48112
- _id = new ObjectId128(_id);
48465
+ _id = new ObjectId129(_id);
48113
48466
  } catch (error) {
48114
48467
  throw new BadRequestError198("Invalid ID.");
48115
48468
  }
48116
48469
  if (field === "defaultOrg") {
48117
48470
  try {
48118
- value = new ObjectId128(value);
48471
+ value = new ObjectId129(value);
48119
48472
  } catch (error) {
48120
48473
  throw new BadRequestError198("Invalid organization ID.");
48121
48474
  }
@@ -48156,7 +48509,7 @@ function useUserRepoV2() {
48156
48509
  year
48157
48510
  }, session) {
48158
48511
  try {
48159
- _id = new ObjectId128(_id);
48512
+ _id = new ObjectId129(_id);
48160
48513
  } catch (error) {
48161
48514
  throw new BadRequestError198("Invalid user ID format.");
48162
48515
  }
@@ -48186,7 +48539,7 @@ function useUserRepoV2() {
48186
48539
  }
48187
48540
  async function updatePassword({ _id, password }, session) {
48188
48541
  try {
48189
- _id = new ObjectId128(_id);
48542
+ _id = new ObjectId129(_id);
48190
48543
  } catch (error) {
48191
48544
  throw new BadRequestError198("Invalid user ID format.");
48192
48545
  }
@@ -48281,9 +48634,25 @@ function useAuthServiceV2() {
48281
48634
  throw new InternalServerError71("Error deleting token");
48282
48635
  }
48283
48636
  }
48637
+ async function verifyPassword(_id, password) {
48638
+ try {
48639
+ const user = await _getUserById(_id);
48640
+ const isPasswordMatch = await comparePassword3(password, user.password);
48641
+ if (!isPasswordMatch) {
48642
+ throw new BadRequestError199("Invalid credentials");
48643
+ }
48644
+ return "Verification successful.";
48645
+ } catch (error) {
48646
+ if (error instanceof BadRequestError199) {
48647
+ throw error;
48648
+ }
48649
+ throw new InternalServerError71("Error during password verification");
48650
+ }
48651
+ }
48284
48652
  return {
48285
48653
  login,
48286
- logout
48654
+ logout,
48655
+ verifyPassword
48287
48656
  };
48288
48657
  }
48289
48658
 
@@ -48499,7 +48868,11 @@ function useUserServiceV2() {
48499
48868
  // src/controllers/auth-v2.controller.ts
48500
48869
  function useAuthControllerV2() {
48501
48870
  const { signUp: _signUp } = useVerificationServiceV2();
48502
- const { login: _login, logout: _logout } = useAuthServiceV2();
48871
+ const {
48872
+ login: _login,
48873
+ logout: _logout,
48874
+ verifyPassword: _verifyPassword
48875
+ } = useAuthServiceV2();
48503
48876
  const { resetPassword: _resetPassword } = useUserServiceV2();
48504
48877
  async function signUp(req, res, next) {
48505
48878
  try {
@@ -48613,11 +48986,38 @@ function useAuthControllerV2() {
48613
48986
  return;
48614
48987
  }
48615
48988
  }
48989
+ async function verifyPassword(req, res, next) {
48990
+ const schema2 = Joi127.object({
48991
+ _id: Joi127.string().hex().required(),
48992
+ password: Joi127.string().required().min(8)
48993
+ });
48994
+ const { error, value } = schema2.validate(
48995
+ { _id: req.params.id, ...req.body },
48996
+ { abortEarly: false }
48997
+ );
48998
+ if (error) {
48999
+ const messages = error.details.map((d) => d.message);
49000
+ logger180.log({ level: "error", message: messages.join(", ") });
49001
+ next(new BadRequestError201(messages.join(", ")));
49002
+ return;
49003
+ }
49004
+ const { _id, password } = value;
49005
+ try {
49006
+ const message = await _verifyPassword(_id, password);
49007
+ res.json({ message });
49008
+ return;
49009
+ } catch (error2) {
49010
+ logger180.log({ level: "error", message: error2.message });
49011
+ next(error2);
49012
+ return;
49013
+ }
49014
+ }
48616
49015
  return {
48617
49016
  signUp,
48618
49017
  login,
48619
49018
  logout,
48620
- resetPassword
49019
+ resetPassword,
49020
+ verifyPassword
48621
49021
  };
48622
49022
  }
48623
49023
 
@@ -49040,6 +49440,7 @@ export {
49040
49440
  remarksSchema,
49041
49441
  robotSchema,
49042
49442
  schema,
49443
+ schemaApprovedBy,
49043
49444
  schemaBilling,
49044
49445
  schemaBillingConfiguration,
49045
49446
  schemaBillingItem,