@7365admin1/core 2.31.0 → 2.31.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -7722,6 +7722,34 @@ function useOrgController() {
7722
7722
  return;
7723
7723
  }
7724
7724
  }
7725
+ async function addOnboardingOrg(req, res, next) {
7726
+ const validation = import_joi18.default.object({
7727
+ name: import_joi18.default.string().required(),
7728
+ type: import_joi18.default.string().required(),
7729
+ nature: import_joi18.default.string().valid(...allowedNatures).required(),
7730
+ email: import_joi18.default.string().email().optional().allow("", null),
7731
+ contact: import_joi18.default.string().optional().allow("", null)
7732
+ });
7733
+ const { error } = validation.validate(req.body);
7734
+ if (error) {
7735
+ import_node_server_utils34.logger.log({ level: "error", message: error.message });
7736
+ next(new import_node_server_utils34.BadRequestError(error.message));
7737
+ return;
7738
+ }
7739
+ try {
7740
+ const _id = await _add(req.body);
7741
+ const data = await _getById(_id);
7742
+ res.status(201).json({
7743
+ message: "Successfully created organization.",
7744
+ data
7745
+ });
7746
+ return;
7747
+ } catch (error2) {
7748
+ import_node_server_utils34.logger.log({ level: "error", message: error2.message });
7749
+ next(error2);
7750
+ return;
7751
+ }
7752
+ }
7725
7753
  async function getOrgsByUserId(req, res, next) {
7726
7754
  const validation = import_joi18.default.object({
7727
7755
  search: import_joi18.default.string().optional().allow("", null),
@@ -7820,6 +7848,7 @@ function useOrgController() {
7820
7848
  }
7821
7849
  return {
7822
7850
  add,
7851
+ addOnboardingOrg,
7823
7852
  getAll,
7824
7853
  getOrgsByUserId,
7825
7854
  getByName,
@@ -13314,7 +13343,7 @@ var schemaVisitorTransaction = import_joi36.default.object({
13314
13343
  arrivalTime: import_joi36.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
13315
13344
  "string.pattern.base": "arrivalTime must be in HH:mm format (e.g. 09:30, 18:45)"
13316
13345
  }),
13317
- duration: import_joi36.default.number().integer().optional().allow(null),
13346
+ duration: import_joi36.default.number().integer().optional().allow(null, ""),
13318
13347
  isOvernightParking: import_joi36.default.boolean().optional().default(false),
13319
13348
  email: import_joi36.default.string().email().optional().allow(null, ""),
13320
13349
  numberOfPassengers: import_joi36.default.number().integer().optional().allow(null, ""),
@@ -13331,7 +13360,8 @@ var schemaVisitorTransaction = import_joi36.default.object({
13331
13360
  checkInRemarks: import_joi36.default.string().optional().allow("", null),
13332
13361
  checkOutRemarks: import_joi36.default.string().optional().allow("", null),
13333
13362
  expectedCheckIn: import_joi36.default.string().isoDate().optional(),
13334
- purpose: import_joi36.default.string().optional().allow(null, "")
13363
+ purpose: import_joi36.default.string().optional().allow(null, ""),
13364
+ invitedId: import_joi36.default.any().optional().allow(null, "")
13335
13365
  });
13336
13366
  var schemaUpdateVisTrans = import_joi36.default.object({
13337
13367
  _id: import_joi36.default.string().hex().length(24).required(),
@@ -13475,7 +13505,17 @@ function MVisitorTransaction(value) {
13475
13505
  expiredAt: value.expiredAt ?? null,
13476
13506
  createdAt: value.createdAt ?? newDate,
13477
13507
  updatedAt: value.updatedAt ?? "",
13478
- deletedAt: value.deletedAt ?? ""
13508
+ deletedAt: value.deletedAt ?? "",
13509
+ purpose: value.purpose,
13510
+ numberOfPassengers: value.numberOfPassengers ?? null,
13511
+ email: value.email,
13512
+ isOvernightParking: value.isOvernightParking ?? false,
13513
+ invitedId: new import_mongodb39.ObjectId(String(value.invitedId)) ?? null,
13514
+ overnightParking: value.isOvernightParking == true ? {
13515
+ status: "pending approval",
13516
+ remarks: "",
13517
+ updatedBy: new import_mongodb39.ObjectId(String(value.invitedId)) ?? null
13518
+ } : null
13479
13519
  };
13480
13520
  }
13481
13521
 
@@ -13607,16 +13647,40 @@ function useVisitorTransactionRepo() {
13607
13647
  localField: "visitorPass.keyId",
13608
13648
  foreignField: "_id",
13609
13649
  pipeline: [
13650
+ {
13651
+ $lookup: {
13652
+ from: "qr-code-templates",
13653
+ localField: "template",
13654
+ foreignField: "_id",
13655
+ pipeline: [
13656
+ {
13657
+ $project: {
13658
+ _id: 1,
13659
+ prefixPass: 1,
13660
+ name: 1
13661
+ }
13662
+ }
13663
+ ],
13664
+ as: "template"
13665
+ }
13666
+ },
13610
13667
  {
13611
13668
  $project: {
13612
13669
  _id: 0,
13613
- // remove original _id
13614
13670
  keyId: "$_id",
13615
13671
  status: 1,
13616
13672
  description: 1,
13673
+ templatePrefixPass: {
13674
+ $arrayElemAt: ["$template.prefixPass", 0]
13675
+ },
13617
13676
  prefixAndName: {
13618
13677
  $concat: [
13619
- { $ifNull: ["$prefix", ""] },
13678
+ {
13679
+ $ifNull: [
13680
+ { $arrayElemAt: ["$template.prefixPass", 0] },
13681
+ ""
13682
+ ]
13683
+ },
13620
13684
  { $ifNull: ["$name", ""] }
13621
13685
  ]
13622
13686
  }
@@ -13629,145 +13693,50 @@ function useVisitorTransactionRepo() {
13629
13693
  {
13630
13694
  $lookup: {
13631
13695
  from: "keys",
13632
- localField: "visitorPass.keyId",
13696
+ localField: "passKeys.keyId",
13633
13697
  foreignField: "_id",
13634
13698
  pipeline: [
13635
13699
  {
13636
- $project: {
13637
- _id: 1,
13638
- prefix: 1,
13639
- name: 1,
13640
- description: 1,
13641
- createdAt: 1,
13642
- updatedAt: 1
13643
- }
13644
- }
13645
- ],
13646
- as: "visitorPassDetails"
13647
- }
13648
- },
13649
- {
13650
- $addFields: {
13651
- visitorPass: {
13652
- $map: {
13653
- input: "$visitorPass",
13654
- as: "vp",
13655
- in: {
13656
- $let: {
13657
- vars: {
13658
- matchedKey: {
13659
- $arrayElemAt: [
13660
- {
13661
- $filter: {
13662
- input: "$visitorPassDetails",
13663
- as: "kd",
13664
- cond: { $eq: ["$$kd._id", "$$vp.keyId"] }
13665
- }
13666
- },
13667
- 0
13668
- ]
13669
- }
13670
- },
13671
- in: {
13672
- keyId: "$$vp.keyId",
13673
- receivedDate: "$$vp.receivedDate",
13674
- status: "$$vp.status",
13675
- lastUpdate: {
13676
- $max: [
13677
- "$$matchedKey.createdAt",
13678
- "$$matchedKey.updatedAt"
13679
- ]
13680
- },
13681
- remarks: "$$vp.remarks",
13682
- description: "$$matchedKey.description",
13683
- prefixAndName: {
13684
- $concat: [
13685
- { $ifNull: ["$$matchedKey.prefix", ""] },
13686
- { $ifNull: ["$$matchedKey.name", ""] }
13687
- ]
13700
+ $lookup: {
13701
+ from: "qr-code-templates",
13702
+ localField: "template",
13703
+ foreignField: "_id",
13704
+ pipeline: [
13705
+ {
13706
+ $project: {
13707
+ _id: 1,
13708
+ prefixPass: 1,
13709
+ name: 1
13688
13710
  }
13689
13711
  }
13690
- }
13712
+ ],
13713
+ as: "template"
13691
13714
  }
13692
- }
13693
- }
13694
- }
13695
- },
13696
- {
13697
- $project: {
13698
- visitorPassDetails: 0
13699
- }
13700
- },
13701
- {
13702
- $lookup: {
13703
- from: "keys",
13704
- localField: "passKeys.keyId",
13705
- foreignField: "_id",
13706
- pipeline: [
13715
+ },
13707
13716
  {
13708
13717
  $project: {
13709
- _id: 1,
13710
- prefix: 1,
13711
- name: 1,
13718
+ _id: 0,
13719
+ keyId: "$_id",
13720
+ status: 1,
13712
13721
  description: 1,
13713
- createdAt: 1,
13714
- updatedAt: 1
13715
- }
13716
- }
13717
- ],
13718
- as: "passKeysDetails"
13719
- }
13720
- },
13721
- {
13722
- $addFields: {
13723
- passKeys: {
13724
- $map: {
13725
- input: "$passKeys",
13726
- as: "pk",
13727
- in: {
13728
- $let: {
13729
- vars: {
13730
- matchedKey: {
13731
- $arrayElemAt: [
13732
- {
13733
- $filter: {
13734
- input: "$passKeysDetails",
13735
- as: "kd",
13736
- cond: { $eq: ["$$kd._id", "$$pk.keyId"] }
13737
- }
13738
- },
13739
- 0
13740
- ]
13741
- }
13742
- },
13743
- in: {
13744
- keyId: "$$pk.keyId",
13745
- receivedDate: "$$pk.receivedDate",
13746
- status: "$$pk.status",
13747
- lastUpdate: {
13748
- $max: [
13749
- "$$matchedKey.createdAt",
13750
- "$$matchedKey.updatedAt"
13722
+ templatePrefixPass: {
13723
+ $arrayElemAt: ["$template.prefixPass", 0]
13724
+ },
13725
+ prefixAndName: {
13726
+ $concat: [
13727
+ {
13728
+ $ifNull: [
13729
+ { $arrayElemAt: ["$template.prefixPass", 0] },
13730
+ ""
13751
13731
  ]
13752
13732
  },
13753
- remarks: "$$pk.remarks",
13754
- description: "$$matchedKey.description",
13755
- prefixAndName: {
13756
- $concat: [
13757
- { $ifNull: ["$$matchedKey.prefix", ""] },
13758
- { $ifNull: ["$$matchedKey.name", ""] }
13759
- ]
13760
- }
13761
- }
13733
+ { $ifNull: ["$name", ""] }
13734
+ ]
13762
13735
  }
13763
13736
  }
13764
13737
  }
13765
- }
13766
- }
13767
- },
13768
- {
13769
- $project: {
13770
- passKeysDetails: 0
13738
+ ],
13739
+ as: "passKeys"
13771
13740
  }
13772
13741
  },
13773
13742
  { $sort: sort },
@@ -21776,6 +21745,7 @@ function useVisitorTransactionService() {
21776
21745
  getExpiredCheckedOutTransactionsBySite: _getExpiredCheckedOutTransactionsBySite,
21777
21746
  updateManyDahuaSyncStatus: _updateManyDahuaSyncStatus
21778
21747
  } = useVisitorTransactionRepo();
21748
+ const { getById } = useBuildingUnitRepo();
21779
21749
  const {
21780
21750
  add: _addPerson,
21781
21751
  getByNRIC,
@@ -22174,6 +22144,7 @@ function useVisitorTransactionService() {
22174
22144
  try {
22175
22145
  session.startTransaction();
22176
22146
  const inviter = await _getByUserId(userId);
22147
+ const unit = await getById(inviter?.unit);
22177
22148
  value.checkIn = null;
22178
22149
  const dir = __dirname;
22179
22150
  const filePath = (0, import_node_server_utils101.getDirectory)(dir, "./public/handlebars/visitor-invite");
@@ -22182,9 +22153,11 @@ function useVisitorTransactionService() {
22182
22153
  block: inviter?.block,
22183
22154
  level: inviter?.level,
22184
22155
  unit: inviter?.unit,
22156
+ unitName: unit?.name,
22185
22157
  org: inviter?.org.toString(),
22186
22158
  site: inviter?.site.toString(),
22187
- status: "pending" /* PENDING */
22159
+ status: "pending" /* PENDING */,
22160
+ invitedId: inviter?._id
22188
22161
  };
22189
22162
  const result = await _add(payload);
22190
22163
  const emailContent = (0, import_node_server_utils101.compileHandlebar)({
@@ -22407,7 +22380,7 @@ function useVisitorTransactionController() {
22407
22380
  arrivalTime: import_joi55.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
22408
22381
  "string.pattern.base": "arrivalTime must be in HH:mm format (e.g. 09:30, 18:45)"
22409
22382
  }),
22410
- duration: import_joi55.default.number().integer().optional().allow(null),
22383
+ duration: import_joi55.default.number().integer().optional().allow(null, ""),
22411
22384
  name: import_joi55.default.string().required(),
22412
22385
  contact: import_joi55.default.string().required(),
22413
22386
  email: import_joi55.default.string().email().required(),
@@ -22430,8 +22403,8 @@ function useVisitorTransactionController() {
22430
22403
  const { expectedCheckIn, arrivalTime, duration, name, contact, email, plateNumber, isOvernightParking, numberOfPassengers, purpose, inviterUserId } = value;
22431
22404
  const rest = { expectedCheckIn, arrivalTime, duration, name, contact, email, plateNumber, isOvernightParking, numberOfPassengers, purpose };
22432
22405
  try {
22433
- await _inviteVisitor(rest, inviterUserId);
22434
- res.status(200).json({ message: "Successfully invited visitor." });
22406
+ const result = await _inviteVisitor(rest, inviterUserId);
22407
+ res.status(200).json({ insertedId: result });
22435
22408
  return;
22436
22409
  } catch (error2) {
22437
22410
  import_node_server_utils102.logger.log({ level: "error", message: error2.message });
@@ -36773,6 +36746,81 @@ function useStatementOfAccountRepo() {
36773
36746
  throw new import_node_server_utils164.InternalServerError("Failed to update soa request.");
36774
36747
  }
36775
36748
  }
36749
+ async function getResidentUserSoa({
36750
+ search = "",
36751
+ page = 1,
36752
+ limit = 10,
36753
+ sort = {},
36754
+ status = "pending",
36755
+ site = "",
36756
+ dateFrom,
36757
+ dateTo,
36758
+ unitId,
36759
+ category
36760
+ }, session) {
36761
+ page = page > 0 ? page - 1 : 0;
36762
+ let dateExpr = {};
36763
+ if (dateFrom && dateTo) {
36764
+ let startDate = new Date(dateFrom);
36765
+ startDate.setHours(0, 0, 0, 0);
36766
+ let endDate = new Date(dateTo);
36767
+ endDate.setHours(23, 59, 59, 999);
36768
+ dateExpr = {
36769
+ $expr: {
36770
+ $and: [
36771
+ { $gte: ["$createdAt", startDate] },
36772
+ { $lte: ["$createdAt", endDate] }
36773
+ ]
36774
+ }
36775
+ };
36776
+ }
36777
+ const unitSearchRegex = search ? search.trim().replace(/\s+/g, "").replace(/\//g, "\\s*/\\s*") : null;
36778
+ const query = {
36779
+ ...status && status !== "all" && { status },
36780
+ ...search && {
36781
+ $or: [
36782
+ { unitOwner: { $regex: search, $options: "i" } },
36783
+ { unit: { $regex: unitSearchRegex, $options: "i" } },
36784
+ { email: { $regex: search, $options: "i" } },
36785
+ { category: { $regex: search, $options: "i" } }
36786
+ ]
36787
+ },
36788
+ ...import_mongodb97.ObjectId.isValid(site) && { site: new import_mongodb97.ObjectId(site) },
36789
+ ...dateExpr,
36790
+ ...import_mongodb97.ObjectId.isValid(unitId) && { unitId: new import_mongodb97.ObjectId(unitId) },
36791
+ ...category && { category }
36792
+ };
36793
+ sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
36794
+ try {
36795
+ const basePipeline = [
36796
+ { $match: query },
36797
+ {
36798
+ $addFields: {
36799
+ sortPriority: {
36800
+ $cond: [{ $eq: ["$status", "pending"] }, 1, 2]
36801
+ }
36802
+ }
36803
+ },
36804
+ {
36805
+ $sort: {
36806
+ sortPriority: 1,
36807
+ ...sort
36808
+ }
36809
+ },
36810
+ { $skip: page * limit },
36811
+ { $limit: limit }
36812
+ ];
36813
+ const [items, countResult] = await Promise.all([
36814
+ collection.aggregate(basePipeline, { session }).toArray(),
36815
+ collection.aggregate([{ $match: query }, { $count: "total" }], { session }).toArray()
36816
+ ]);
36817
+ const totalCount = countResult[0]?.total || 0;
36818
+ const data = (0, import_node_server_utils164.paginate)(items, page, limit, totalCount);
36819
+ return data;
36820
+ } catch (error) {
36821
+ throw error;
36822
+ }
36823
+ }
36776
36824
  function delCachedData() {
36777
36825
  delNamespace().then(() => {
36778
36826
  import_node_server_utils164.logger.log({
@@ -36793,7 +36841,8 @@ function useStatementOfAccountRepo() {
36793
36841
  getById,
36794
36842
  updateById,
36795
36843
  deleteById,
36796
- updateStatusById
36844
+ updateStatusById,
36845
+ getResidentUserSoa
36797
36846
  };
36798
36847
  }
36799
36848
 
@@ -36946,7 +36995,8 @@ function useStatementOfAccountController() {
36946
36995
  getById: _getById,
36947
36996
  updateById: _updateById,
36948
36997
  deleteById: _deleteById,
36949
- updateStatusById: _updateStatusById
36998
+ updateStatusById: _updateStatusById,
36999
+ getResidentUserSoa: _getResidentUserSoa
36950
37000
  } = useStatementOfAccountRepo();
36951
37001
  const { add: _add, generatePDF: _generatePDF } = useStatementOfAccountService();
36952
37002
  async function add(req, res, next) {
@@ -37197,6 +37247,57 @@ function useStatementOfAccountController() {
37197
37247
  return;
37198
37248
  }
37199
37249
  }
37250
+ async function getResidentUserSoa(req, res, next) {
37251
+ const validation = import_joi93.default.object({
37252
+ page: import_joi93.default.number().integer().min(1).allow("", null).default(1),
37253
+ limit: import_joi93.default.number().integer().min(1).max(100).allow("", null).default(10),
37254
+ status: import_joi93.default.string().optional().allow(null, ""),
37255
+ search: import_joi93.default.string().optional().allow(null, ""),
37256
+ site: import_joi93.default.string().required(),
37257
+ dateFrom: import_joi93.default.string().optional().allow(null, ""),
37258
+ dateTo: import_joi93.default.string().optional().allow(null, ""),
37259
+ unitId: import_joi93.default.string().required(),
37260
+ category: import_joi93.default.string().optional().allow(null, "")
37261
+ });
37262
+ const query = { ...req.query };
37263
+ const { error } = validation.validate(query, {
37264
+ abortEarly: false
37265
+ });
37266
+ if (error) {
37267
+ const messages = error.details.map((d) => d.message).join(", ");
37268
+ import_node_server_utils166.logger.log({ level: "error", message: messages });
37269
+ next(new import_node_server_utils166.BadRequestError(messages));
37270
+ return;
37271
+ }
37272
+ const search = req.query.search ?? "";
37273
+ const page = parseInt(req.query.page ?? "1");
37274
+ const limit = parseInt(req.query.limit ?? "10");
37275
+ const status = req.query.status ?? "active";
37276
+ const site = req.query.site;
37277
+ const dateFrom = req.query.dateFrom ?? "";
37278
+ const dateTo = req.query.dateTo ?? "";
37279
+ const unitId = req.query.unitId;
37280
+ const category = req.query.category ?? "";
37281
+ try {
37282
+ const data = await _getResidentUserSoa({
37283
+ search,
37284
+ page,
37285
+ limit,
37286
+ status,
37287
+ site,
37288
+ dateFrom,
37289
+ dateTo,
37290
+ unitId,
37291
+ category
37292
+ });
37293
+ res.status(200).json(data);
37294
+ return;
37295
+ } catch (error2) {
37296
+ import_node_server_utils166.logger.log({ level: "error", message: error2.message });
37297
+ next(error2);
37298
+ return;
37299
+ }
37300
+ }
37200
37301
  return {
37201
37302
  add,
37202
37303
  getAll,
@@ -37204,7 +37305,8 @@ function useStatementOfAccountController() {
37204
37305
  updateById,
37205
37306
  deleteById,
37206
37307
  generatePDF,
37207
- updateStatusById
37308
+ updateStatusById,
37309
+ getResidentUserSoa
37208
37310
  };
37209
37311
  }
37210
37312
 
@@ -39920,6 +40022,7 @@ function useNfcPatrolSettingsController() {
39920
40022
 
39921
40023
  // src/services/occurrence-entry.service.ts
39922
40024
  var import_node_server_utils184 = require("@7365admin1/node-server-utils");
40025
+ var import_mongodb108 = require("mongodb");
39923
40026
 
39924
40027
  // src/repositories/occurrence-subject.repo.ts
39925
40028
  var import_node_server_utils183 = require("@7365admin1/node-server-utils");
@@ -40128,22 +40231,11 @@ function useOccurrenceSubjectRepo() {
40128
40231
  } catch (error) {
40129
40232
  throw new import_node_server_utils183.BadRequestError("Invalid occurrence subject ID format.");
40130
40233
  }
40131
- const cacheKey = (0, import_node_server_utils183.makeCacheKey)(namespace_collection, { _id });
40132
- const cachedData = await getCache(cacheKey);
40133
- if (cachedData) {
40134
- import_node_server_utils183.logger.info(`Cache hit for key: ${cacheKey}`);
40135
- return cachedData;
40136
- }
40137
40234
  try {
40138
40235
  const data = await collection.findOne({ _id }, { session });
40139
40236
  if (!data) {
40140
40237
  throw new import_node_server_utils183.NotFoundError("Occurrence subject not found.");
40141
40238
  }
40142
- setCache(cacheKey, data, 15 * 60).then(() => {
40143
- import_node_server_utils183.logger.info(`Cache set for key: ${cacheKey}`);
40144
- }).catch((err) => {
40145
- import_node_server_utils183.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
40146
- });
40147
40239
  return data;
40148
40240
  } catch (error) {
40149
40241
  throw error;
@@ -40284,11 +40376,22 @@ function useOccurrenceEntryService() {
40284
40376
  const updatedSerialNumber = (entrySerialNumber + 0.1).toFixed(1);
40285
40377
  const dobId = occurrenceEntry.dailyOccurrenceBookId;
40286
40378
  const book = await _getOccurrenceBookById(dobId);
40287
- const subject = await _getOccurrenceSubjectById(value.subject);
40379
+ const subject = await _getOccurrenceSubjectById(
40380
+ occurrenceEntry.subject._id
40381
+ );
40382
+ value.subject = value.subject ? value.subject : occurrenceEntry.subject._id;
40383
+ value.subjectName = subject.subject;
40288
40384
  value.serialNumber = updatedSerialNumber;
40289
40385
  value.site = occurrenceEntry.site;
40290
40386
  value.dailyOccurrenceBookId = occurrenceEntry.dailyOccurrenceBookId;
40291
- value.subjectName = subject.subject;
40387
+ value.bookEntryCount = value.bookEntryCount ? value.bookEntryCount : occurrenceEntry.bookEntryCount;
40388
+ value.occurrence = value.occurrence ? value.occurrence : occurrenceEntry.occurrence;
40389
+ value.signature = value.signature ? new import_mongodb108.ObjectId(value.signature) : occurrenceEntry.signature._id;
40390
+ value.eSignature = value.eSignature ? new import_mongodb108.ObjectId(value.eSignature) : occurrenceEntry.eSignature;
40391
+ value.createdAt = /* @__PURE__ */ new Date();
40392
+ value.date = value.date ? value.date : occurrenceEntry.date;
40393
+ value.userName = value.userName ? value.userName : occurrenceEntry.signature.name;
40394
+ value.createdByName = value.createdByName ? value.createdByName : occurrenceEntry.createdByName;
40292
40395
  await _updateOccurrenceBookById(dobId, {
40293
40396
  totalInput: book.totalInput + 1
40294
40397
  });
@@ -40484,7 +40587,7 @@ function useOccurrenceEntryController() {
40484
40587
 
40485
40588
  // src/models/online-form.model.ts
40486
40589
  var import_joi105 = __toESM(require("joi"));
40487
- var import_mongodb108 = require("mongodb");
40590
+ var import_mongodb109 = require("mongodb");
40488
40591
  var schemaOnlineForm = import_joi105.default.object({
40489
40592
  _id: import_joi105.default.string().hex().optional().allow("", null),
40490
40593
  name: import_joi105.default.string().required(),
@@ -40532,21 +40635,21 @@ function MOnlineForm(value) {
40532
40635
  }
40533
40636
  if (value._id && typeof value._id === "string") {
40534
40637
  try {
40535
- value._id = new import_mongodb108.ObjectId(value._id);
40638
+ value._id = new import_mongodb109.ObjectId(value._id);
40536
40639
  } catch (error2) {
40537
40640
  throw new Error("Invalid ID.");
40538
40641
  }
40539
40642
  }
40540
40643
  if (value.org && typeof value.org === "string") {
40541
40644
  try {
40542
- value.org = new import_mongodb108.ObjectId(value.org);
40645
+ value.org = new import_mongodb109.ObjectId(value.org);
40543
40646
  } catch (error2) {
40544
40647
  throw new Error("Invalid org ID.");
40545
40648
  }
40546
40649
  }
40547
40650
  if (value.site && typeof value.site === "string") {
40548
40651
  try {
40549
- value.site = new import_mongodb108.ObjectId(value.site);
40652
+ value.site = new import_mongodb109.ObjectId(value.site);
40550
40653
  } catch (error2) {
40551
40654
  throw new Error("Invalid site ID.");
40552
40655
  }
@@ -40569,7 +40672,7 @@ function MOnlineForm(value) {
40569
40672
 
40570
40673
  // src/repositories/online-form.repo.ts
40571
40674
  var import_node_server_utils186 = require("@7365admin1/node-server-utils");
40572
- var import_mongodb109 = require("mongodb");
40675
+ var import_mongodb110 = require("mongodb");
40573
40676
  function useOnlineFormRepo() {
40574
40677
  const db = import_node_server_utils186.useAtlas.getDb();
40575
40678
  if (!db) {
@@ -40621,7 +40724,7 @@ function useOnlineFormRepo() {
40621
40724
  }) {
40622
40725
  page = page > 0 ? page - 1 : 0;
40623
40726
  try {
40624
- site = new import_mongodb109.ObjectId(site);
40727
+ site = new import_mongodb110.ObjectId(site);
40625
40728
  } catch (error) {
40626
40729
  throw new import_node_server_utils186.BadRequestError("Invalid site ID format.");
40627
40730
  }
@@ -40681,7 +40784,7 @@ function useOnlineFormRepo() {
40681
40784
  }
40682
40785
  async function getOnlineFormById(_id) {
40683
40786
  try {
40684
- _id = new import_mongodb109.ObjectId(_id);
40787
+ _id = new import_mongodb110.ObjectId(_id);
40685
40788
  } catch (error) {
40686
40789
  throw new import_node_server_utils186.BadRequestError("Invalid online form ID format.");
40687
40790
  }
@@ -40724,7 +40827,7 @@ function useOnlineFormRepo() {
40724
40827
  }
40725
40828
  async function updateOnlineFormById(_id, value) {
40726
40829
  try {
40727
- _id = new import_mongodb109.ObjectId(_id);
40830
+ _id = new import_mongodb110.ObjectId(_id);
40728
40831
  } catch (error) {
40729
40832
  throw new import_node_server_utils186.BadRequestError("Invalid online form ID format.");
40730
40833
  }
@@ -40752,7 +40855,7 @@ function useOnlineFormRepo() {
40752
40855
  }
40753
40856
  async function deleteOnlineFormById(_id, session) {
40754
40857
  try {
40755
- _id = new import_mongodb109.ObjectId(_id);
40858
+ _id = new import_mongodb110.ObjectId(_id);
40756
40859
  } catch (error) {
40757
40860
  throw new import_node_server_utils186.BadRequestError("Invalid online form ID format.");
40758
40861
  }
@@ -40785,7 +40888,7 @@ function useOnlineFormRepo() {
40785
40888
  }
40786
40889
  async function getOnlineFormsBySiteId(site, { search = "", page = 1, limit = 10, status = "active" }) {
40787
40890
  try {
40788
- site = new import_mongodb109.ObjectId(site);
40891
+ site = new import_mongodb110.ObjectId(site);
40789
40892
  } catch (error) {
40790
40893
  throw new import_node_server_utils186.BadRequestError(
40791
40894
  "Invalid online form configuration site ID format."
@@ -41226,7 +41329,7 @@ function useOccurrenceSubjectController() {
41226
41329
  }
41227
41330
 
41228
41331
  // src/models/nfc-patrol-log.model.ts
41229
- var import_mongodb110 = require("mongodb");
41332
+ var import_mongodb111 = require("mongodb");
41230
41333
  var import_joi108 = __toESM(require("joi"));
41231
41334
  var import_node_server_utils190 = require("@7365admin1/node-server-utils");
41232
41335
  var schemaNfcPatrolLog = import_joi108.default.object({
@@ -41278,32 +41381,32 @@ function MNfcPatrolLog(valueArg) {
41278
41381
  }
41279
41382
  if (value._id && typeof value._id === "string") {
41280
41383
  try {
41281
- value._id = new import_mongodb110.ObjectId(value._id);
41384
+ value._id = new import_mongodb111.ObjectId(value._id);
41282
41385
  } catch (error2) {
41283
41386
  throw new import_node_server_utils190.BadRequestError("Invalid _id format");
41284
41387
  }
41285
41388
  }
41286
41389
  try {
41287
- value.site = new import_mongodb110.ObjectId(value.site);
41390
+ value.site = new import_mongodb111.ObjectId(value.site);
41288
41391
  } catch (error2) {
41289
41392
  throw new import_node_server_utils190.BadRequestError("Invalid site format");
41290
41393
  }
41291
41394
  if (value?.createdBy) {
41292
41395
  try {
41293
- value.createdBy = new import_mongodb110.ObjectId(value.createdBy);
41396
+ value.createdBy = new import_mongodb111.ObjectId(value.createdBy);
41294
41397
  } catch (error2) {
41295
41398
  throw new import_node_server_utils190.BadRequestError("Invalid createdBy format");
41296
41399
  }
41297
41400
  }
41298
41401
  if (value?.route?._id) {
41299
41402
  try {
41300
- value.route._id = new import_mongodb110.ObjectId(value.route._id);
41403
+ value.route._id = new import_mongodb111.ObjectId(value.route._id);
41301
41404
  } catch (error2) {
41302
41405
  throw new import_node_server_utils190.BadRequestError("Invalid route _id format");
41303
41406
  }
41304
41407
  }
41305
41408
  return {
41306
- _id: value._id ?? new import_mongodb110.ObjectId(),
41409
+ _id: value._id ?? new import_mongodb111.ObjectId(),
41307
41410
  site: value.site,
41308
41411
  route: value.route,
41309
41412
  date: value.date,
@@ -41317,7 +41420,7 @@ function MNfcPatrolLog(valueArg) {
41317
41420
 
41318
41421
  // src/repositories/nfc-patrol-log.repository.ts
41319
41422
  var import_node_server_utils191 = require("@7365admin1/node-server-utils");
41320
- var import_mongodb111 = require("mongodb");
41423
+ var import_mongodb112 = require("mongodb");
41321
41424
  function useNfcPatrolLogRepo() {
41322
41425
  const db = import_node_server_utils191.useAtlas.getDb();
41323
41426
  if (!db) {
@@ -41370,7 +41473,7 @@ function useNfcPatrolLogRepo() {
41370
41473
  const pageIndex = page > 0 ? page - 1 : 0;
41371
41474
  let siteId;
41372
41475
  try {
41373
- siteId = typeof site === "string" ? new import_mongodb111.ObjectId(site) : site;
41476
+ siteId = typeof site === "string" ? new import_mongodb112.ObjectId(site) : site;
41374
41477
  } catch {
41375
41478
  throw new import_node_server_utils191.BadRequestError("Invalid site ID format.");
41376
41479
  }
@@ -41381,7 +41484,7 @@ function useNfcPatrolLogRepo() {
41381
41484
  query.date = date;
41382
41485
  }
41383
41486
  if (route?._id) {
41384
- query["route._id"] = typeof route._id === "string" ? new import_mongodb111.ObjectId(route._id) : route._id;
41487
+ query["route._id"] = typeof route._id === "string" ? new import_mongodb112.ObjectId(route._id) : route._id;
41385
41488
  }
41386
41489
  if (route?.startTime) {
41387
41490
  query["route.startTime"] = route.startTime;
@@ -42240,7 +42343,7 @@ function useNewDashboardController() {
42240
42343
 
42241
42344
  // src/models/manpower-monitoring.model.ts
42242
42345
  var import_joi111 = __toESM(require("joi"));
42243
- var import_mongodb112 = require("mongodb");
42346
+ var import_mongodb113 = require("mongodb");
42244
42347
  var shiftSchema = import_joi111.default.object({
42245
42348
  name: import_joi111.default.string().required(),
42246
42349
  checkIn: import_joi111.default.string().optional().allow("", null),
@@ -42265,7 +42368,7 @@ var manpowerMonitoringSchema = import_joi111.default.object({
42265
42368
  });
42266
42369
  var MManpowerMonitoring = class {
42267
42370
  constructor(data) {
42268
- this._id = new import_mongodb112.ObjectId();
42371
+ this._id = new import_mongodb113.ObjectId();
42269
42372
  this.serviceProviderId = data.serviceProviderId || "";
42270
42373
  this.siteId = data.siteId || "";
42271
42374
  this.siteName = data.siteName;
@@ -42731,7 +42834,7 @@ var hrmlabs_attendance_util_default = {
42731
42834
  };
42732
42835
 
42733
42836
  // src/repositories/manpower-monitoring.repo.ts
42734
- var import_mongodb113 = require("mongodb");
42837
+ var import_mongodb114 = require("mongodb");
42735
42838
  var { hrmLabsAuthentication: hrmLabsAuthentication2, fetchSites: fetchSites2 } = hrmlabs_attendance_util_default;
42736
42839
  function useManpowerMonitoringRepo() {
42737
42840
  const db = import_node_server_utils196.useAtlas.getDb();
@@ -42745,11 +42848,11 @@ function useManpowerMonitoringRepo() {
42745
42848
  try {
42746
42849
  value = new MManpowerMonitoring(value);
42747
42850
  if (value.createdBy)
42748
- value.createdBy = new import_mongodb113.ObjectId(value.createdBy);
42851
+ value.createdBy = new import_mongodb114.ObjectId(value.createdBy);
42749
42852
  if (value.siteId)
42750
- value.siteId = new import_mongodb113.ObjectId(value.siteId);
42853
+ value.siteId = new import_mongodb114.ObjectId(value.siteId);
42751
42854
  if (value.serviceProviderId)
42752
- value.serviceProviderId = new import_mongodb113.ObjectId(value.serviceProviderId);
42855
+ value.serviceProviderId = new import_mongodb114.ObjectId(value.serviceProviderId);
42753
42856
  const result = await collection.insertOne(value, { session });
42754
42857
  return result;
42755
42858
  } catch (error) {
@@ -42790,8 +42893,8 @@ function useManpowerMonitoringRepo() {
42790
42893
  }
42791
42894
  async function getManpowerSettingsBySiteId(_id, serviceProviderId) {
42792
42895
  try {
42793
- _id = new import_mongodb113.ObjectId(_id);
42794
- serviceProviderId = new import_mongodb113.ObjectId(serviceProviderId);
42896
+ _id = new import_mongodb114.ObjectId(_id);
42897
+ serviceProviderId = new import_mongodb114.ObjectId(serviceProviderId);
42795
42898
  } catch (error) {
42796
42899
  throw new Error("Invalid Site ID format.");
42797
42900
  }
@@ -42807,7 +42910,7 @@ function useManpowerMonitoringRepo() {
42807
42910
  }
42808
42911
  async function updateManpowerMonitoringSettings(_id, value) {
42809
42912
  try {
42810
- _id = new import_mongodb113.ObjectId(_id);
42913
+ _id = new import_mongodb114.ObjectId(_id);
42811
42914
  } catch (error) {
42812
42915
  throw new import_node_server_utils196.BadRequestError("Invalid ID format.");
42813
42916
  }
@@ -42834,7 +42937,7 @@ function useManpowerMonitoringRepo() {
42834
42937
  for (let item of value) {
42835
42938
  item = new MManpowerMonitoring(item);
42836
42939
  const data = await collection.findOne({
42837
- siteId: new import_mongodb113.ObjectId(item.siteId)
42940
+ siteId: new import_mongodb114.ObjectId(item.siteId)
42838
42941
  });
42839
42942
  if (data) {
42840
42943
  let updateValue;
@@ -42859,11 +42962,11 @@ function useManpowerMonitoringRepo() {
42859
42962
  }
42860
42963
  } else {
42861
42964
  if (item.createdBy)
42862
- item.createdBy = new import_mongodb113.ObjectId(item.createdBy);
42965
+ item.createdBy = new import_mongodb114.ObjectId(item.createdBy);
42863
42966
  if (item.siteId)
42864
- item.siteId = new import_mongodb113.ObjectId(item.siteId);
42967
+ item.siteId = new import_mongodb114.ObjectId(item.siteId);
42865
42968
  if (item.serviceProviderId)
42866
- item.serviceProviderId = new import_mongodb113.ObjectId(item.serviceProviderId);
42969
+ item.serviceProviderId = new import_mongodb114.ObjectId(item.serviceProviderId);
42867
42970
  const result = await collection.insertOne(item);
42868
42971
  if (result.insertedId) {
42869
42972
  results.inserted++;
@@ -42887,7 +42990,7 @@ function useManpowerMonitoringRepo() {
42887
42990
  const siteUrl = process.env.HRMLABS_SITE_URL;
42888
42991
  try {
42889
42992
  const serviceProvider = await serviceProviderCollection.findOne({
42890
- _id: new import_mongodb113.ObjectId(serviceProviderId)
42993
+ _id: new import_mongodb114.ObjectId(serviceProviderId)
42891
42994
  });
42892
42995
  if (!serviceProvider) {
42893
42996
  throw new Error("Service Provider not found.");
@@ -42929,7 +43032,7 @@ var import_node_server_utils197 = require("@7365admin1/node-server-utils");
42929
43032
 
42930
43033
  // src/models/manpower-remarks.model.ts
42931
43034
  var import_joi112 = __toESM(require("joi"));
42932
- var import_mongodb114 = require("mongodb");
43035
+ var import_mongodb115 = require("mongodb");
42933
43036
  var remarksSchema = import_joi112.default.object({
42934
43037
  name: import_joi112.default.string().required(),
42935
43038
  remark: import_joi112.default.object({
@@ -42953,7 +43056,7 @@ var manpowerRemarksSchema = import_joi112.default.object({
42953
43056
  });
42954
43057
  var MManpowerRemarks = class {
42955
43058
  constructor(data) {
42956
- this._id = new import_mongodb114.ObjectId();
43059
+ this._id = new import_mongodb115.ObjectId();
42957
43060
  this.serviceProviderId = data.serviceProviderId || "";
42958
43061
  this.siteId = data.siteId || "";
42959
43062
  this.siteName = data.siteName || "";
@@ -42971,7 +43074,7 @@ var MManpowerRemarks = class {
42971
43074
  };
42972
43075
 
42973
43076
  // src/repositories/manpower-remarks.repo.ts
42974
- var import_mongodb115 = require("mongodb");
43077
+ var import_mongodb116 = require("mongodb");
42975
43078
  var import_moment_timezone2 = __toESM(require("moment-timezone"));
42976
43079
  function useManpowerRemarksRepo() {
42977
43080
  const db = import_node_server_utils197.useAtlas.getDb();
@@ -42984,9 +43087,9 @@ function useManpowerRemarksRepo() {
42984
43087
  try {
42985
43088
  value = new MManpowerRemarks(value);
42986
43089
  if (value.siteId)
42987
- value.siteId = new import_mongodb115.ObjectId(value.siteId);
43090
+ value.siteId = new import_mongodb116.ObjectId(value.siteId);
42988
43091
  if (value.serviceProviderId)
42989
- value.serviceProviderId = new import_mongodb115.ObjectId(value.serviceProviderId);
43092
+ value.serviceProviderId = new import_mongodb116.ObjectId(value.serviceProviderId);
42990
43093
  const result = await collection.insertOne(value, { session });
42991
43094
  return result;
42992
43095
  } catch (error) {
@@ -43006,7 +43109,7 @@ function useManpowerRemarksRepo() {
43006
43109
  limit = limit || 10;
43007
43110
  const searchQuery = {};
43008
43111
  const nowSGT = (0, import_moment_timezone2.default)().tz("Asia/Singapore");
43009
- searchQuery.serviceProviderId = new import_mongodb115.ObjectId(serviceProviderId);
43112
+ searchQuery.serviceProviderId = new import_mongodb116.ObjectId(serviceProviderId);
43010
43113
  if (search != "") {
43011
43114
  searchQuery.siteName = { $regex: search, $options: "i" };
43012
43115
  }
@@ -43038,8 +43141,8 @@ function useManpowerRemarksRepo() {
43038
43141
  }
43039
43142
  async function getManpowerRemarksBySiteId(_id, date, serviceProviderId) {
43040
43143
  try {
43041
- _id = new import_mongodb115.ObjectId(_id);
43042
- serviceProviderId = new import_mongodb115.ObjectId(serviceProviderId);
43144
+ _id = new import_mongodb116.ObjectId(_id);
43145
+ serviceProviderId = new import_mongodb116.ObjectId(serviceProviderId);
43043
43146
  } catch (error) {
43044
43147
  throw new Error("Invalid Site ID format.");
43045
43148
  }
@@ -43056,13 +43159,13 @@ function useManpowerRemarksRepo() {
43056
43159
  }
43057
43160
  async function updateManpowerRemarks(_id, value) {
43058
43161
  try {
43059
- _id = new import_mongodb115.ObjectId(_id);
43162
+ _id = new import_mongodb116.ObjectId(_id);
43060
43163
  } catch (error) {
43061
43164
  throw new import_node_server_utils197.BadRequestError("Invalid ID format.");
43062
43165
  }
43063
43166
  try {
43064
43167
  if (value.createdBy) {
43065
- value.createdBy = new import_mongodb115.ObjectId(value.createdBy);
43168
+ value.createdBy = new import_mongodb116.ObjectId(value.createdBy);
43066
43169
  }
43067
43170
  const updateValue = {
43068
43171
  ...value,
@@ -43079,7 +43182,7 @@ function useManpowerRemarksRepo() {
43079
43182
  }
43080
43183
  async function updateRemarksStatus(_id, value) {
43081
43184
  try {
43082
- _id = new import_mongodb115.ObjectId(_id);
43185
+ _id = new import_mongodb116.ObjectId(_id);
43083
43186
  } catch (error) {
43084
43187
  throw new import_node_server_utils197.BadRequestError("Invalid ID format.");
43085
43188
  }
@@ -43351,7 +43454,7 @@ function useManpowerMonitoringCtrl() {
43351
43454
 
43352
43455
  // src/models/manpower-designations.model.ts
43353
43456
  var import_joi114 = __toESM(require("joi"));
43354
- var import_mongodb116 = require("mongodb");
43457
+ var import_mongodb117 = require("mongodb");
43355
43458
  var designationsSchema = import_joi114.default.object({
43356
43459
  title: import_joi114.default.string().required(),
43357
43460
  shifts: import_joi114.default.object({
@@ -43370,7 +43473,7 @@ var manpowerDesignationsSchema = import_joi114.default.object({
43370
43473
  });
43371
43474
  var MManpowerDesignations = class {
43372
43475
  constructor(data) {
43373
- this._id = new import_mongodb116.ObjectId();
43476
+ this._id = new import_mongodb117.ObjectId();
43374
43477
  this.siteId = data.siteId || "";
43375
43478
  this.siteName = data.siteName || "";
43376
43479
  this.serviceProviderId = data.serviceProviderId || "";
@@ -43384,7 +43487,7 @@ var MManpowerDesignations = class {
43384
43487
 
43385
43488
  // src/repositories/manpower-designations.repo.ts
43386
43489
  var import_node_server_utils200 = require("@7365admin1/node-server-utils");
43387
- var import_mongodb117 = require("mongodb");
43490
+ var import_mongodb118 = require("mongodb");
43388
43491
  function useManpowerDesignationRepo() {
43389
43492
  const db = import_node_server_utils200.useAtlas.getDb();
43390
43493
  if (!db) {
@@ -43396,11 +43499,11 @@ function useManpowerDesignationRepo() {
43396
43499
  try {
43397
43500
  value = new MManpowerDesignations(value);
43398
43501
  if (value.createdBy)
43399
- value.createdBy = new import_mongodb117.ObjectId(value.createdBy);
43502
+ value.createdBy = new import_mongodb118.ObjectId(value.createdBy);
43400
43503
  if (value.siteId)
43401
- value.siteId = new import_mongodb117.ObjectId(value.siteId);
43504
+ value.siteId = new import_mongodb118.ObjectId(value.siteId);
43402
43505
  if (value.serviceProviderId)
43403
- value.serviceProviderId = new import_mongodb117.ObjectId(value.serviceProviderId);
43506
+ value.serviceProviderId = new import_mongodb118.ObjectId(value.serviceProviderId);
43404
43507
  const result = await collection.insertOne(value);
43405
43508
  return result;
43406
43509
  } catch (error) {
@@ -43409,8 +43512,8 @@ function useManpowerDesignationRepo() {
43409
43512
  }
43410
43513
  async function getManpowerDesignationsBySiteId(_id, serviceProviderId) {
43411
43514
  try {
43412
- _id = new import_mongodb117.ObjectId(_id);
43413
- serviceProviderId = new import_mongodb117.ObjectId(serviceProviderId);
43515
+ _id = new import_mongodb118.ObjectId(_id);
43516
+ serviceProviderId = new import_mongodb118.ObjectId(serviceProviderId);
43414
43517
  } catch (error) {
43415
43518
  throw new Error("Invalid Site ID format.");
43416
43519
  }
@@ -43426,7 +43529,7 @@ function useManpowerDesignationRepo() {
43426
43529
  }
43427
43530
  async function updateManpowerDesignations(_id, value) {
43428
43531
  try {
43429
- _id = new import_mongodb117.ObjectId(_id);
43532
+ _id = new import_mongodb118.ObjectId(_id);
43430
43533
  } catch (error) {
43431
43534
  throw new Error("Invalid ID format.");
43432
43535
  }
@@ -43529,7 +43632,7 @@ function useManpowerDesignationCtrl() {
43529
43632
 
43530
43633
  // src/models/overnight-parking.model.ts
43531
43634
  var import_joi116 = __toESM(require("joi"));
43532
- var import_mongodb118 = require("mongodb");
43635
+ var import_mongodb119 = require("mongodb");
43533
43636
  var dayScheduleSchema = import_joi116.default.object({
43534
43637
  isEnabled: import_joi116.default.boolean().required(),
43535
43638
  startTime: import_joi116.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
@@ -43571,7 +43674,7 @@ function MOvernightParkingApprovalHours(value) {
43571
43674
  }
43572
43675
  if (value.site && typeof value.site === "string") {
43573
43676
  try {
43574
- value.site = new import_mongodb118.ObjectId(value.site);
43677
+ value.site = new import_mongodb119.ObjectId(value.site);
43575
43678
  } catch {
43576
43679
  throw new Error("Invalid site ID.");
43577
43680
  }
@@ -45176,7 +45279,7 @@ function useManpowerRemarkCtrl() {
45176
45279
 
45177
45280
  // src/models/manpower-sites.model.ts
45178
45281
  var import_joi122 = __toESM(require("joi"));
45179
- var import_mongodb119 = require("mongodb");
45282
+ var import_mongodb120 = require("mongodb");
45180
45283
  var manpowerSitesSchema = import_joi122.default.object({
45181
45284
  id: import_joi122.default.string().hex().required(),
45182
45285
  text: import_joi122.default.string().hex().optional().allow("", null),
@@ -45187,7 +45290,7 @@ var manpowerSitesSchema = import_joi122.default.object({
45187
45290
  });
45188
45291
  var MManpowerSites = class {
45189
45292
  constructor(data) {
45190
- this._id = new import_mongodb119.ObjectId();
45293
+ this._id = new import_mongodb120.ObjectId();
45191
45294
  this.id = data.id || "";
45192
45295
  this.text = data.text || "";
45193
45296
  this.contractID = data.contractID || "";
@@ -45397,7 +45500,7 @@ function useManpowerSitesCtrl() {
45397
45500
 
45398
45501
  // src/utils/cron.util.ts
45399
45502
  var import_node_server_utils214 = require("@7365admin1/node-server-utils");
45400
- var import_mongodb120 = require("mongodb");
45503
+ var import_mongodb121 = require("mongodb");
45401
45504
  var import_moment_timezone4 = __toESM(require("moment-timezone"));
45402
45505
  var createManpowerRemarksDaily = async () => {
45403
45506
  const db = import_node_server_utils214.useAtlas.getDb();
@@ -45557,7 +45660,7 @@ var updateRemarksisAcknowledged = async () => {
45557
45660
  for (const id of updatedIds) {
45558
45661
  const doc = await remarks.findOne({ _id: id });
45559
45662
  const setting = await settings.findOne(
45560
- { siteId: new import_mongodb120.ObjectId(doc?.siteId) },
45663
+ { siteId: new import_mongodb121.ObjectId(doc?.siteId) },
45561
45664
  { projection: { emails: 1 } }
45562
45665
  );
45563
45666
  const payload = {
@@ -45643,7 +45746,7 @@ var updateRemarksStatusEod = async () => {
45643
45746
  for (const doc of docs) {
45644
45747
  let shiftsToCheck = [];
45645
45748
  const endShiftTime = await settings.findOne(
45646
- { siteId: new import_mongodb120.ObjectId(doc.siteId) },
45749
+ { siteId: new import_mongodb121.ObjectId(doc.siteId) },
45647
45750
  { projection: { shifts: 1, shiftType: 1 } }
45648
45751
  );
45649
45752
  if (doc.createdAtSGT === nowSGT) {
@@ -45749,7 +45852,7 @@ var isWithinHour = (alertTime, timeNow) => {
45749
45852
 
45750
45853
  // src/events/manpower.event.ts
45751
45854
  var import_node_server_utils215 = require("@7365admin1/node-server-utils");
45752
- var import_mongodb121 = require("mongodb");
45855
+ var import_mongodb122 = require("mongodb");
45753
45856
  var import_moment_timezone5 = __toESM(require("moment-timezone"));
45754
45857
  async function manpowerEvents(io) {
45755
45858
  let intervalId = null;
@@ -45775,7 +45878,7 @@ async function manpowerEvents(io) {
45775
45878
  }).toArray();
45776
45879
  for (const doc of docs) {
45777
45880
  const siteSettings = await settings.findOne(
45778
- { siteId: new import_mongodb121.ObjectId(doc.siteId), enabled: true },
45881
+ { siteId: new import_mongodb122.ObjectId(doc.siteId), enabled: true },
45779
45882
  { projection: { shifts: 1, shiftType: 1 } }
45780
45883
  );
45781
45884
  const shiftType = siteSettings?.shiftType || "2-shifts";
@@ -45894,7 +45997,7 @@ function genericSignature(params, secretKey) {
45894
45997
  }
45895
45998
 
45896
45999
  // src/repositories/reddot-payment.repository.ts
45897
- var import_mongodb125 = require("mongodb");
46000
+ var import_mongodb126 = require("mongodb");
45898
46001
 
45899
46002
  // src/utils/date-format.util.ts
45900
46003
  var import_moment_timezone6 = __toESM(require("moment-timezone"));
@@ -45919,11 +46022,11 @@ function formatDateString(today, format, dateRange) {
45919
46022
  }
45920
46023
 
45921
46024
  // src/models/credit-card.model.ts
45922
- var import_mongodb122 = require("mongodb");
46025
+ var import_mongodb123 = require("mongodb");
45923
46026
  var MCardInfo = class {
45924
46027
  // this is coming from RDP transaction
45925
46028
  constructor({
45926
- _id = new import_mongodb122.ObjectId(),
46029
+ _id = new import_mongodb123.ObjectId(),
45927
46030
  userId,
45928
46031
  cardType,
45929
46032
  cardNumber,
@@ -45958,11 +46061,11 @@ var MCardInfo = class {
45958
46061
  };
45959
46062
 
45960
46063
  // src/models/cart.model.ts
45961
- var import_mongodb123 = require("mongodb");
46064
+ var import_mongodb124 = require("mongodb");
45962
46065
  var MUnitBillings = class {
45963
46066
  // transaction response messages
45964
46067
  constructor({
45965
- _id = new import_mongodb123.ObjectId(),
46068
+ _id = new import_mongodb124.ObjectId(),
45966
46069
  unit,
45967
46070
  unitId,
45968
46071
  unitBill,
@@ -46003,7 +46106,7 @@ var MUnitBillings = class {
46003
46106
  };
46004
46107
 
46005
46108
  // src/repositories/payment.repository.ts
46006
- var import_mongodb124 = require("mongodb");
46109
+ var import_mongodb125 = require("mongodb");
46007
46110
  var import_node_server_utils216 = require("@7365admin1/node-server-utils");
46008
46111
  var PaymentBillRepo = () => {
46009
46112
  const getDB2 = () => {
@@ -46037,7 +46140,7 @@ var PaymentBillRepo = () => {
46037
46140
  if (unitBillInfo?.status === "Inactive" /* inactive */) {
46038
46141
  throw new Error("This Bill is Inactive!");
46039
46142
  }
46040
- const billId = new import_mongodb124.ObjectId(unitBillInfo?.billId);
46143
+ const billId = new import_mongodb125.ObjectId(unitBillInfo?.billId);
46041
46144
  const billInfo = await billCollection().findOne({ _id: billId });
46042
46145
  if (!billInfo) {
46043
46146
  throw new Error("Bill info not found");
@@ -46076,13 +46179,13 @@ var PaymentBillRepo = () => {
46076
46179
  const saveCreditCardInfo = async (payload) => {
46077
46180
  try {
46078
46181
  if (payload.userId)
46079
- payload.userId = new import_mongodb124.ObjectId(payload.userId);
46182
+ payload.userId = new import_mongodb125.ObjectId(payload.userId);
46080
46183
  if (payload.site)
46081
- payload.site = new import_mongodb124.ObjectId(payload.site);
46184
+ payload.site = new import_mongodb125.ObjectId(payload.site);
46082
46185
  if (payload.organization)
46083
- payload.organization = new import_mongodb124.ObjectId(payload.organization);
46186
+ payload.organization = new import_mongodb125.ObjectId(payload.organization);
46084
46187
  if (payload.createdBy)
46085
- payload.createdBy = new import_mongodb124.ObjectId(payload.createdBy);
46188
+ payload.createdBy = new import_mongodb125.ObjectId(payload.createdBy);
46086
46189
  const createdAt = formatDateString(/* @__PURE__ */ new Date(), "mm-dd-yyyy");
46087
46190
  payload.createdAt = createdAt;
46088
46191
  const result = await creditCollection().insertOne(new MCardInfo(payload));
@@ -46094,19 +46197,19 @@ var PaymentBillRepo = () => {
46094
46197
  const checkOutUnitBills = async (payload) => {
46095
46198
  try {
46096
46199
  if (payload.unitId)
46097
- payload.unitId = new import_mongodb124.ObjectId(payload.unitId);
46200
+ payload.unitId = new import_mongodb125.ObjectId(payload.unitId);
46098
46201
  if (payload.site)
46099
- payload.site = new import_mongodb124.ObjectId(payload.site);
46202
+ payload.site = new import_mongodb125.ObjectId(payload.site);
46100
46203
  if (payload.organization)
46101
- payload.organization = new import_mongodb124.ObjectId(payload.organization);
46204
+ payload.organization = new import_mongodb125.ObjectId(payload.organization);
46102
46205
  payload.createdAt = await formatDateString(/* @__PURE__ */ new Date(), "mm-dd-yyyy");
46103
46206
  const addToCart = await cartCollection().insertOne(new MUnitBillings(payload));
46104
46207
  const unitId = payload.unitId;
46105
46208
  const dateFormatted = formatDateString(/* @__PURE__ */ new Date(), "for-ref");
46106
46209
  const unit = unitId?.toString().slice(-4);
46107
- const newId = new import_mongodb124.ObjectId(addToCart?.insertedId).toString().slice(-4);
46210
+ const newId = new import_mongodb125.ObjectId(addToCart?.insertedId).toString().slice(-4);
46108
46211
  const referenceNumber = `CRT${unit}${newId}${dateFormatted}`;
46109
- const result = await cartCollection().findOneAndUpdate({ _id: new import_mongodb124.ObjectId(addToCart.insertedId) }, { $set: { referenceNumber } }, { returnDocument: "after" });
46212
+ const result = await cartCollection().findOneAndUpdate({ _id: new import_mongodb125.ObjectId(addToCart.insertedId) }, { $set: { referenceNumber } }, { returnDocument: "after" });
46110
46213
  return result;
46111
46214
  } catch (error) {
46112
46215
  throw new Error(error.message || error || "Server Internal Error");
@@ -46137,7 +46240,7 @@ var PaymentBillRepo = () => {
46137
46240
  for (const ref of refNumber) {
46138
46241
  const unitBillInfo = await collection().findOne({ referenceNumber: ref });
46139
46242
  const billId = unitBillInfo?.billId;
46140
- const billInfo = await billCollection().findOne({ _id: new import_mongodb124.ObjectId(billId) });
46243
+ const billInfo = await billCollection().findOne({ _id: new import_mongodb125.ObjectId(billId) });
46141
46244
  const billAmount = billInfo?.price;
46142
46245
  payload.updatedAt = updatedAt;
46143
46246
  payload.amountPaid = billAmount;
@@ -46288,7 +46391,7 @@ var useRedDotPaymentRepo = () => {
46288
46391
  throw new Error("Failed to Add Merchant Details");
46289
46392
  }
46290
46393
  const merchantId = merchant?.insertedId;
46291
- const orgId = new import_mongodb125.ObjectId(_id);
46394
+ const orgId = new import_mongodb126.ObjectId(_id);
46292
46395
  const result = await orgCollection().findOneAndUpdate({ _id: orgId }, { $push: { merchant: merchantId } }, {
46293
46396
  returnDocument: "after"
46294
46397
  });
@@ -46317,7 +46420,7 @@ var useRedDotPaymentRepo = () => {
46317
46420
  const getMerchantDetailsById = async (_id) => {
46318
46421
  try {
46319
46422
  if (_id)
46320
- _id = new import_mongodb125.ObjectId(_id);
46423
+ _id = new import_mongodb126.ObjectId(_id);
46321
46424
  const result = await redDotMerchantCollection().aggregate([
46322
46425
  {
46323
46426
  $match: {
@@ -46572,7 +46675,7 @@ function useRedDotPaymentController() {
46572
46675
 
46573
46676
  // src/repositories/verification-v2.repo.ts
46574
46677
  var import_node_server_utils218 = require("@7365admin1/node-server-utils");
46575
- var import_mongodb126 = require("mongodb");
46678
+ var import_mongodb127 = require("mongodb");
46576
46679
  function useVerificationRepoV2() {
46577
46680
  const db = import_node_server_utils218.useAtlas.getDb();
46578
46681
  if (!db) {
@@ -46625,7 +46728,7 @@ function useVerificationRepoV2() {
46625
46728
  }
46626
46729
  async function updateVerificationStatusById(_id, status, session) {
46627
46730
  try {
46628
- _id = new import_mongodb126.ObjectId(_id);
46731
+ _id = new import_mongodb127.ObjectId(_id);
46629
46732
  } catch (error) {
46630
46733
  throw new import_node_server_utils218.BadRequestError("Invalid verification ID format.");
46631
46734
  }
@@ -46695,13 +46798,85 @@ function useVerificationRepoV2() {
46695
46798
  );
46696
46799
  }
46697
46800
  }
46801
+ async function getVerifications({
46802
+ search = "",
46803
+ page = 1,
46804
+ limit = 10,
46805
+ sort = {},
46806
+ status = "active",
46807
+ app = "",
46808
+ type = {},
46809
+ email = ""
46810
+ }) {
46811
+ page = page > 0 ? page - 1 : 0;
46812
+ const query = { status };
46813
+ const cacheOptions = {
46814
+ page,
46815
+ limit,
46816
+ status
46817
+ };
46818
+ sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
46819
+ cacheOptions.sort = JSON.stringify(sort);
46820
+ if (search) {
46821
+ query.$text = { $search: search };
46822
+ cacheOptions.search = search;
46823
+ }
46824
+ if (app) {
46825
+ query["metadata.app"] = app;
46826
+ cacheOptions["metadata.app"] = app;
46827
+ }
46828
+ if (type && Object.keys(type).length > 0) {
46829
+ query.type = { $in: Object.keys(type) };
46830
+ cacheOptions.type = JSON.stringify(type);
46831
+ }
46832
+ if (email) {
46833
+ query.email = email;
46834
+ cacheOptions.email = email;
46835
+ }
46836
+ const cacheKey = (0, import_node_server_utils218.makeCacheKey)(namespace_collection, cacheOptions);
46837
+ const cachedData = await getCache(cacheKey);
46838
+ if (cachedData) {
46839
+ import_node_server_utils218.logger.info(`Cache hit for key: ${cacheKey}`);
46840
+ return cachedData;
46841
+ }
46842
+ try {
46843
+ const items = await collection.aggregate([
46844
+ { $match: query },
46845
+ { $sort: sort },
46846
+ { $skip: page * limit },
46847
+ { $limit: limit },
46848
+ {
46849
+ $project: {
46850
+ _id: 1,
46851
+ createdAt: 1,
46852
+ email: 1,
46853
+ type: 1,
46854
+ metadata: 1,
46855
+ status: 1
46856
+ }
46857
+ }
46858
+ ]).toArray();
46859
+ const length = await collection.countDocuments(query);
46860
+ const data = (0, import_node_server_utils218.paginate)(items, page, limit, length);
46861
+ setCache(cacheKey, data, 15 * 60).then(() => {
46862
+ import_node_server_utils218.logger.info(`Cache set for key: ${cacheKey}`);
46863
+ }).catch((err) => {
46864
+ import_node_server_utils218.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
46865
+ });
46866
+ return data;
46867
+ } catch (error) {
46868
+ import_node_server_utils218.logger.log({ level: "error", message: `${error}` });
46869
+ throw error;
46870
+ }
46871
+ }
46698
46872
  return {
46699
46873
  createIndex,
46700
46874
  createTextIndex,
46701
46875
  add,
46702
46876
  updateVerificationStatusById,
46703
46877
  getByVerificationCode,
46704
- getVerificationById
46878
+ getVerificationById,
46879
+ getVerifications
46705
46880
  };
46706
46881
  }
46707
46882
 
@@ -47045,6 +47220,7 @@ function useVerificationControllerV2() {
47045
47220
  createServiceProviderInvite: _createServiceProviderInvite,
47046
47221
  createForgetPassword: _createForgetPassword
47047
47222
  } = useVerificationServiceV2();
47223
+ const { getVerifications: _getVerifications } = useVerificationRepoV2();
47048
47224
  async function verify(req, res, next) {
47049
47225
  try {
47050
47226
  const schema2 = import_joi126.default.object({ verificationCode: import_joi126.default.string().required() });
@@ -47160,11 +47336,49 @@ function useVerificationControllerV2() {
47160
47336
  return;
47161
47337
  }
47162
47338
  }
47339
+ async function getVerifications(req, res, next) {
47340
+ const schema2 = import_joi126.default.object({
47341
+ search: import_joi126.default.string().optional().allow("", null),
47342
+ page: import_joi126.default.number().integer().min(1).allow("", null).default(1),
47343
+ status: import_joi126.default.string().required(),
47344
+ app: import_joi126.default.string().optional().allow("", null),
47345
+ type: import_joi126.default.alternatives().try(
47346
+ import_joi126.default.array().items(import_joi126.default.string()),
47347
+ import_joi126.default.string().custom((value2) => value2.split(","))
47348
+ ).optional().allow("", null),
47349
+ email: import_joi126.default.string().optional().allow("", null)
47350
+ });
47351
+ const { error, value } = schema2.validate(req.query);
47352
+ if (error) {
47353
+ const messages = error.details.map((d) => d.message).join(", ");
47354
+ import_node_server_utils220.logger.log({ level: "error", message: messages });
47355
+ next(new import_node_server_utils220.BadRequestError(messages));
47356
+ return;
47357
+ }
47358
+ const { search, page, status, app, email, type } = value;
47359
+ try {
47360
+ const data = await _getVerifications({
47361
+ search,
47362
+ page,
47363
+ status,
47364
+ app,
47365
+ type,
47366
+ email
47367
+ });
47368
+ res.json(data);
47369
+ return;
47370
+ } catch (error2) {
47371
+ import_node_server_utils220.logger.log({ level: "error", message: `${error2.message}` });
47372
+ next(error2);
47373
+ return;
47374
+ }
47375
+ }
47163
47376
  return {
47164
47377
  verify,
47165
47378
  createUserInvite,
47166
47379
  createServiceProviderInvite,
47167
- createForgetPassword
47380
+ createForgetPassword,
47381
+ getVerifications
47168
47382
  };
47169
47383
  }
47170
47384
 
@@ -47177,7 +47391,7 @@ var import_node_server_utils222 = require("@7365admin1/node-server-utils");
47177
47391
  var import_uuid2 = require("uuid");
47178
47392
 
47179
47393
  // src/repositories/user-v2.repo.ts
47180
- var import_mongodb127 = require("mongodb");
47394
+ var import_mongodb128 = require("mongodb");
47181
47395
  var import_node_server_utils221 = require("@7365admin1/node-server-utils");
47182
47396
  function useUserRepoV2() {
47183
47397
  const { updateFeedbackCreatedByName } = useFeedbackRepo();
@@ -47378,7 +47592,7 @@ function useUserRepoV2() {
47378
47592
  }
47379
47593
  if (organization) {
47380
47594
  try {
47381
- query.defaultOrg = new import_mongodb127.ObjectId(organization);
47595
+ query.defaultOrg = new import_mongodb128.ObjectId(organization);
47382
47596
  cacheOptions.organization = organization.toString();
47383
47597
  } catch (error) {
47384
47598
  throw new import_node_server_utils221.BadRequestError("Invalid organization ID format.");
@@ -47517,13 +47731,13 @@ function useUserRepoV2() {
47517
47731
  );
47518
47732
  }
47519
47733
  try {
47520
- _id = new import_mongodb127.ObjectId(_id);
47734
+ _id = new import_mongodb128.ObjectId(_id);
47521
47735
  } catch (error) {
47522
47736
  throw new import_node_server_utils221.BadRequestError("Invalid ID.");
47523
47737
  }
47524
47738
  if (field === "defaultOrg") {
47525
47739
  try {
47526
- value = new import_mongodb127.ObjectId(value);
47740
+ value = new import_mongodb128.ObjectId(value);
47527
47741
  } catch (error) {
47528
47742
  throw new import_node_server_utils221.BadRequestError("Invalid organization ID.");
47529
47743
  }
@@ -47564,7 +47778,7 @@ function useUserRepoV2() {
47564
47778
  year
47565
47779
  }, session) {
47566
47780
  try {
47567
- _id = new import_mongodb127.ObjectId(_id);
47781
+ _id = new import_mongodb128.ObjectId(_id);
47568
47782
  } catch (error) {
47569
47783
  throw new import_node_server_utils221.BadRequestError("Invalid user ID format.");
47570
47784
  }
@@ -47594,7 +47808,7 @@ function useUserRepoV2() {
47594
47808
  }
47595
47809
  async function updatePassword({ _id, password }, session) {
47596
47810
  try {
47597
- _id = new import_mongodb127.ObjectId(_id);
47811
+ _id = new import_mongodb128.ObjectId(_id);
47598
47812
  } catch (error) {
47599
47813
  throw new import_node_server_utils221.BadRequestError("Invalid user ID format.");
47600
47814
  }