@7365admin1/core 2.75.0 → 2.76.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.js CHANGED
@@ -3181,6 +3181,20 @@ function useUserRepo() {
3181
3181
  throw new import_node_server_utils10.InternalServerError("Failed to update user.");
3182
3182
  }
3183
3183
  }
3184
+ async function updateUserOrgById(id, org, session) {
3185
+ const _id = (0, import_node_server_utils10.toObjectId)(id);
3186
+ const orgId = (0, import_node_server_utils10.toObjectId)(org);
3187
+ try {
3188
+ await collection.updateOne(
3189
+ { _id },
3190
+ { $set: { defaultOrg: orgId, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
3191
+ { session }
3192
+ );
3193
+ return "Successfully updated user organization.";
3194
+ } catch (error) {
3195
+ throw new import_node_server_utils10.InternalServerError("Failed to update user organization.");
3196
+ }
3197
+ }
3184
3198
  return {
3185
3199
  createIndex,
3186
3200
  createTextIndex,
@@ -3198,7 +3212,8 @@ function useUserRepo() {
3198
3212
  updateDefaultOrgByEmail,
3199
3213
  getUserByEmailStatus,
3200
3214
  updateUserSIDById,
3201
- resetPassword
3215
+ resetPassword,
3216
+ updateUserOrgById
3202
3217
  };
3203
3218
  }
3204
3219
 
@@ -7897,7 +7912,8 @@ function useUserController() {
7897
7912
  "dateOfBirth",
7898
7913
  "profile",
7899
7914
  "gender",
7900
- "defaultOrg"
7915
+ "defaultOrg",
7916
+ "status"
7901
7917
  ).required(),
7902
7918
  value: import_joi13.default.when("field", {
7903
7919
  switch: [
@@ -27458,6 +27474,7 @@ var import_node_server_utils112 = require("@7365admin1/node-server-utils");
27458
27474
 
27459
27475
  // src/services/person.service.ts
27460
27476
  var import_node_server_utils111 = require("@7365admin1/node-server-utils");
27477
+ var import_mongodb64 = require("mongodb");
27461
27478
  function usePersonService() {
27462
27479
  const MailerConfig = {
27463
27480
  host: MAILER_TRANSPORT_HOST,
@@ -27479,7 +27496,8 @@ function usePersonService() {
27479
27496
  createUser: addUser,
27480
27497
  getUserByEmail,
27481
27498
  updateUserFieldById: _updateUserFieldById,
27482
- getUserById
27499
+ getUserById,
27500
+ updateUserOrgById: _updateUserOrgById
27483
27501
  } = useUserRepo();
27484
27502
  const { add: addMember } = useMemberRepo();
27485
27503
  const { getById: _getUnitById, updateById: updateUnitById } = useBuildingUnitRepo();
@@ -27570,8 +27588,27 @@ function usePersonService() {
27570
27588
  }
27571
27589
  await _add(value, session);
27572
27590
  await session.commitTransaction();
27591
+ if (value.email && isValidType && value.platform === "mobile") {
27592
+ const emailContent = (0, import_node_server_utils111.compileHandlebar)({
27593
+ context: { name: value.name },
27594
+ filePath: (0, import_node_server_utils111.getDirectory)(
27595
+ __dirname,
27596
+ "./public/handlebars/registration-pending"
27597
+ )
27598
+ });
27599
+ mailer.sendMail({
27600
+ to: value.email,
27601
+ subject: "Registration Received \u2013 Pending Review",
27602
+ html: emailContent,
27603
+ sender: "iService365"
27604
+ }).catch((error) => {
27605
+ import_node_server_utils111.logger.error(`Failed to send registration pending email: ${error}`);
27606
+ });
27607
+ }
27573
27608
  return "People added successfully.";
27574
27609
  } catch (error) {
27610
+ console.log("error message service", error);
27611
+ console.log("error message service", error.message);
27575
27612
  import_node_server_utils111.logger.error("Error in people service add:", error);
27576
27613
  await session.abortTransaction();
27577
27614
  throw error;
@@ -27592,7 +27629,21 @@ function usePersonService() {
27592
27629
  }
27593
27630
  const isNameUpdated = typeof value.name === "string" && value.name.trim() !== person.name;
27594
27631
  const isOwnerChanged = value.isOwner !== person.isOwner;
27632
+ if (value.org && typeof value.org === "string") {
27633
+ value.org = new import_mongodb64.ObjectId(value.org);
27634
+ }
27635
+ if (value.site && typeof value.site === "string") {
27636
+ value.site = new import_mongodb64.ObjectId(value.site);
27637
+ }
27638
+ const isOrgChanged = value.org && person.org?.toString() !== value.org.toString();
27595
27639
  await _updateById(_id, value, session);
27640
+ if (isOrgChanged && person.user) {
27641
+ await _updateUserOrgById(
27642
+ person.user.toString(),
27643
+ value.org,
27644
+ session
27645
+ );
27646
+ }
27596
27647
  if (value.unit && (isNameUpdated || isOwnerChanged || value.isOwner)) {
27597
27648
  const unit = await _getUnitById(value.unit.toString());
27598
27649
  if (unit) {
@@ -27614,7 +27665,11 @@ function usePersonService() {
27614
27665
  updatePayload.ownerName = value.name || "";
27615
27666
  }
27616
27667
  if (Object.keys(updatePayload).length > 0 && unit && unit._id) {
27617
- await updateUnitById(unit._id.toString(), updatePayload, session);
27668
+ await updateUnitById(
27669
+ unit._id.toString(),
27670
+ updatePayload,
27671
+ session
27672
+ );
27618
27673
  }
27619
27674
  }
27620
27675
  }
@@ -27704,13 +27759,13 @@ function usePersonService() {
27704
27759
  title = "We request resubmission for your application";
27705
27760
  hideLogin = false;
27706
27761
  statusLogo = `${statusIconPath}/resubmission-icon.png`;
27707
- message2 = `Hi ${person.name}, please resubmit your application with the required updates.`;
27762
+ message2 = `Hi ${person.name}, please resubmit your application with the required updates.${value.remarks ? ` Remarks: ${value.remarks}` : ""}`;
27708
27763
  break;
27709
27764
  case "rejected":
27710
27765
  userStatus = "rejected";
27711
- title = "Your account request for deletion has been rejected.";
27766
+ title = "Your account request for application has been rejected.";
27712
27767
  statusLogo = `${statusIconPath}/deleted-icon.png`;
27713
- message2 = `Hi ${person.name}, unfortunately your application has been rejected. Please contact support for more information.`;
27768
+ message2 = `Hi ${person.name}, unfortunately your application has been rejected.${value.remarks ? ` Remarks: ${value.remarks}` : " Please contact support for more information."}`;
27714
27769
  break;
27715
27770
  default:
27716
27771
  throw new Error("Invalid review status");
@@ -28147,7 +28202,7 @@ function usePersonController() {
28147
28202
  // src/models/robot.model.ts
28148
28203
  var import_node_server_utils113 = require("@7365admin1/node-server-utils");
28149
28204
  var import_joi61 = __toESM(require("joi"));
28150
- var import_mongodb64 = require("mongodb");
28205
+ var import_mongodb65 = require("mongodb");
28151
28206
  var metadataSchema4 = {
28152
28207
  orgId: import_joi61.default.string().hex().optional().allow("", null),
28153
28208
  siteId: import_joi61.default.string().hex().optional().allow("", null),
@@ -28172,21 +28227,21 @@ function MRobot(value) {
28172
28227
  }
28173
28228
  if (value.metadata?.orgId) {
28174
28229
  try {
28175
- value.metadata.orgId = new import_mongodb64.ObjectId(value.metadata.orgId);
28230
+ value.metadata.orgId = new import_mongodb65.ObjectId(value.metadata.orgId);
28176
28231
  } catch (error2) {
28177
28232
  throw new import_node_server_utils113.BadRequestError("Invalid organization ID format.");
28178
28233
  }
28179
28234
  }
28180
28235
  if (value.metadata?.siteId) {
28181
28236
  try {
28182
- value.metadata.siteId = new import_mongodb64.ObjectId(value.metadata.siteId);
28237
+ value.metadata.siteId = new import_mongodb65.ObjectId(value.metadata.siteId);
28183
28238
  } catch (error2) {
28184
28239
  throw new import_node_server_utils113.BadRequestError("Invalid site ID format.");
28185
28240
  }
28186
28241
  }
28187
28242
  if (value.metadata?.administratorId) {
28188
28243
  try {
28189
- value.metadata.administratorId = new import_mongodb64.ObjectId(
28244
+ value.metadata.administratorId = new import_mongodb65.ObjectId(
28190
28245
  value.metadata.administratorId
28191
28246
  );
28192
28247
  } catch (error2) {
@@ -28195,7 +28250,7 @@ function MRobot(value) {
28195
28250
  }
28196
28251
  if (value.createdBy) {
28197
28252
  try {
28198
- value.createdBy = new import_mongodb64.ObjectId(value.createdBy);
28253
+ value.createdBy = new import_mongodb65.ObjectId(value.createdBy);
28199
28254
  } catch (error2) {
28200
28255
  throw new import_node_server_utils113.BadRequestError("Invalid created by ID format.");
28201
28256
  }
@@ -28220,7 +28275,7 @@ function MRobot(value) {
28220
28275
  }
28221
28276
 
28222
28277
  // src/repositories/robot.repo.ts
28223
- var import_mongodb65 = require("mongodb");
28278
+ var import_mongodb66 = require("mongodb");
28224
28279
  var import_node_server_utils114 = require("@7365admin1/node-server-utils");
28225
28280
  function useRobotRepo() {
28226
28281
  const db = import_node_server_utils114.useAtlas.getDb();
@@ -28281,12 +28336,12 @@ function useRobotRepo() {
28281
28336
  }) {
28282
28337
  page = page > 0 ? page - 1 : 0;
28283
28338
  try {
28284
- organization = new import_mongodb65.ObjectId(organization);
28339
+ organization = new import_mongodb66.ObjectId(organization);
28285
28340
  } catch (error) {
28286
28341
  throw new import_node_server_utils114.BadRequestError("Invalid organization ID format.");
28287
28342
  }
28288
28343
  try {
28289
- site = new import_mongodb65.ObjectId(site);
28344
+ site = new import_mongodb66.ObjectId(site);
28290
28345
  } catch (error) {
28291
28346
  throw new import_node_server_utils114.BadRequestError("Invalid site ID format.");
28292
28347
  }
@@ -28509,7 +28564,7 @@ function useRobotController() {
28509
28564
 
28510
28565
  // src/models/patrol-question.model.ts
28511
28566
  var import_node_server_utils117 = require("@7365admin1/node-server-utils");
28512
- var import_mongodb66 = require("mongodb");
28567
+ var import_mongodb67 = require("mongodb");
28513
28568
  var import_joi63 = __toESM(require("joi"));
28514
28569
  var schemaPatrolQuestion = import_joi63.default.object({
28515
28570
  _id: import_joi63.default.string().hex().optional(),
@@ -28535,14 +28590,14 @@ function MPatrolQuestion(value) {
28535
28590
  }
28536
28591
  if (value._id && typeof value._id === "string") {
28537
28592
  try {
28538
- value._id = new import_mongodb66.ObjectId(value._id);
28593
+ value._id = new import_mongodb67.ObjectId(value._id);
28539
28594
  } catch {
28540
28595
  throw new import_node_server_utils117.BadRequestError("Invalid _id format");
28541
28596
  }
28542
28597
  }
28543
28598
  return {
28544
- _id: value._id ?? new import_mongodb66.ObjectId(),
28545
- site: new import_mongodb66.ObjectId(value.site),
28599
+ _id: value._id ?? new import_mongodb67.ObjectId(),
28600
+ site: new import_mongodb67.ObjectId(value.site),
28546
28601
  question: value.question,
28547
28602
  answers: value.answers,
28548
28603
  status: value.status ?? "active",
@@ -28554,7 +28609,7 @@ function MPatrolQuestion(value) {
28554
28609
 
28555
28610
  // src/repositories/patrol-question.repo.ts
28556
28611
  var import_node_server_utils118 = require("@7365admin1/node-server-utils");
28557
- var import_mongodb67 = require("mongodb");
28612
+ var import_mongodb68 = require("mongodb");
28558
28613
  function usePatrolQuestionRepo() {
28559
28614
  const db = import_node_server_utils118.useAtlas.getDb();
28560
28615
  if (!db) {
@@ -28633,7 +28688,7 @@ function usePatrolQuestionRepo() {
28633
28688
  { answers: { $regex: search, $options: "i" } }
28634
28689
  ]
28635
28690
  },
28636
- ...import_mongodb67.ObjectId.isValid(site) && { site: new import_mongodb67.ObjectId(site) }
28691
+ ...import_mongodb68.ObjectId.isValid(site) && { site: new import_mongodb68.ObjectId(site) }
28637
28692
  };
28638
28693
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
28639
28694
  const cacheOptions = {
@@ -28673,7 +28728,7 @@ function usePatrolQuestionRepo() {
28673
28728
  }
28674
28729
  async function updateById(_id, value, session) {
28675
28730
  try {
28676
- _id = new import_mongodb67.ObjectId(_id);
28731
+ _id = new import_mongodb68.ObjectId(_id);
28677
28732
  } catch (error) {
28678
28733
  throw new import_node_server_utils118.BadRequestError(
28679
28734
  "Invalid patrol question transaction ID format."
@@ -28694,7 +28749,7 @@ function usePatrolQuestionRepo() {
28694
28749
  }
28695
28750
  async function deleteById(_id) {
28696
28751
  try {
28697
- _id = new import_mongodb67.ObjectId(_id);
28752
+ _id = new import_mongodb68.ObjectId(_id);
28698
28753
  } catch (error) {
28699
28754
  throw new import_node_server_utils118.BadRequestError("Invalid customer ID format.");
28700
28755
  }
@@ -28716,7 +28771,7 @@ function usePatrolQuestionRepo() {
28716
28771
  }
28717
28772
  async function getById(_id, session) {
28718
28773
  try {
28719
- _id = new import_mongodb67.ObjectId(_id);
28774
+ _id = new import_mongodb68.ObjectId(_id);
28720
28775
  } catch (error) {
28721
28776
  throw new import_node_server_utils118.BadRequestError("Invalid patrol question ID format.");
28722
28777
  }
@@ -28891,7 +28946,7 @@ function usePatrolQuestionController() {
28891
28946
 
28892
28947
  // src/models/patrol-route.model.ts
28893
28948
  var import_node_server_utils120 = require("@7365admin1/node-server-utils");
28894
- var import_mongodb68 = require("mongodb");
28949
+ var import_mongodb69 = require("mongodb");
28895
28950
  var import_joi65 = __toESM(require("joi"));
28896
28951
  var schemeCamera = import_joi65.default.object({
28897
28952
  camera: import_joi65.default.string().hex().required(),
@@ -28939,14 +28994,14 @@ function MPatrolRoute(value) {
28939
28994
  }
28940
28995
  if (value._id && typeof value._id === "string") {
28941
28996
  try {
28942
- value._id = new import_mongodb68.ObjectId(value._id);
28997
+ value._id = new import_mongodb69.ObjectId(value._id);
28943
28998
  } catch {
28944
28999
  throw new import_node_server_utils120.BadRequestError("Invalid _id format");
28945
29000
  }
28946
29001
  }
28947
29002
  if (value.assignee && Array.isArray(value.assignee)) {
28948
29003
  try {
28949
- value.assignee = value.assignee.map((id) => new import_mongodb68.ObjectId(id));
29004
+ value.assignee = value.assignee.map((id) => new import_mongodb69.ObjectId(id));
28950
29005
  } catch {
28951
29006
  throw new import_node_server_utils120.BadRequestError("Invalid assignee id format");
28952
29007
  }
@@ -28955,7 +29010,7 @@ function MPatrolRoute(value) {
28955
29010
  value.cameras = value.cameras.map((camera) => {
28956
29011
  if (typeof camera.camera === "string") {
28957
29012
  try {
28958
- camera.camera = new import_mongodb68.ObjectId(camera.camera);
29013
+ camera.camera = new import_mongodb69.ObjectId(camera.camera);
28959
29014
  } catch {
28960
29015
  throw new import_node_server_utils120.BadRequestError("Invalid camera id format");
28961
29016
  }
@@ -28963,7 +29018,7 @@ function MPatrolRoute(value) {
28963
29018
  camera.questions = camera.questions.map((question) => {
28964
29019
  if (typeof question.questionId === "string") {
28965
29020
  try {
28966
- question.questionId = new import_mongodb68.ObjectId(question.questionId);
29021
+ question.questionId = new import_mongodb69.ObjectId(question.questionId);
28967
29022
  } catch {
28968
29023
  throw new import_node_server_utils120.BadRequestError("Invalid question id format");
28969
29024
  }
@@ -28974,8 +29029,8 @@ function MPatrolRoute(value) {
28974
29029
  });
28975
29030
  }
28976
29031
  return {
28977
- _id: value._id ?? new import_mongodb68.ObjectId(),
28978
- site: new import_mongodb68.ObjectId(value.site),
29032
+ _id: value._id ?? new import_mongodb69.ObjectId(),
29033
+ site: new import_mongodb69.ObjectId(value.site),
28979
29034
  name: value.name,
28980
29035
  assignee: value.assignee,
28981
29036
  start: value.start,
@@ -28992,7 +29047,7 @@ function MPatrolRoute(value) {
28992
29047
 
28993
29048
  // src/repositories/patrol-route.repo.ts
28994
29049
  var import_node_server_utils121 = require("@7365admin1/node-server-utils");
28995
- var import_mongodb69 = require("mongodb");
29050
+ var import_mongodb70 = require("mongodb");
28996
29051
  function usePatrolRouteRepo() {
28997
29052
  const db = import_node_server_utils121.useAtlas.getDb();
28998
29053
  if (!db) {
@@ -29068,7 +29123,7 @@ function usePatrolRouteRepo() {
29068
29123
  page = page > 0 ? page - 1 : 0;
29069
29124
  const query = {
29070
29125
  status,
29071
- ...import_mongodb69.ObjectId.isValid(site) && { site: new import_mongodb69.ObjectId(site) }
29126
+ ...import_mongodb70.ObjectId.isValid(site) && { site: new import_mongodb70.ObjectId(site) }
29072
29127
  };
29073
29128
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
29074
29129
  const cacheOptions = {
@@ -29151,20 +29206,20 @@ function usePatrolRouteRepo() {
29151
29206
  }
29152
29207
  async function updateById(_id, value, session) {
29153
29208
  try {
29154
- _id = new import_mongodb69.ObjectId(_id);
29209
+ _id = new import_mongodb70.ObjectId(_id);
29155
29210
  } catch (error) {
29156
29211
  throw new import_node_server_utils121.BadRequestError("Invalid patrol route transaction ID format.");
29157
29212
  }
29158
- if (value.site && import_mongodb69.ObjectId.isValid(value.site.toString())) {
29213
+ if (value.site && import_mongodb70.ObjectId.isValid(value.site.toString())) {
29159
29214
  try {
29160
- value.site = new import_mongodb69.ObjectId(value.site.toString());
29215
+ value.site = new import_mongodb70.ObjectId(value.site.toString());
29161
29216
  } catch {
29162
29217
  throw new import_node_server_utils121.BadRequestError("Invalid _id format");
29163
29218
  }
29164
29219
  }
29165
29220
  if (value.assignee && Array.isArray(value.assignee)) {
29166
29221
  try {
29167
- value.assignee = value.assignee.map((id) => new import_mongodb69.ObjectId(id));
29222
+ value.assignee = value.assignee.map((id) => new import_mongodb70.ObjectId(id));
29168
29223
  } catch {
29169
29224
  throw new import_node_server_utils121.BadRequestError("Invalid _id format");
29170
29225
  }
@@ -29184,7 +29239,7 @@ function usePatrolRouteRepo() {
29184
29239
  }
29185
29240
  async function deleteById(_id) {
29186
29241
  try {
29187
- _id = new import_mongodb69.ObjectId(_id);
29242
+ _id = new import_mongodb70.ObjectId(_id);
29188
29243
  } catch (error) {
29189
29244
  throw new import_node_server_utils121.BadRequestError("Invalid patrol route transaction ID format.");
29190
29245
  }
@@ -29233,7 +29288,7 @@ function usePatrolRouteRepo() {
29233
29288
  const query = {
29234
29289
  status,
29235
29290
  ...search && { $text: { $search: search } },
29236
- ...import_mongodb69.ObjectId.isValid(site) && { site: new import_mongodb69.ObjectId(site) }
29291
+ ...import_mongodb70.ObjectId.isValid(site) && { site: new import_mongodb70.ObjectId(site) }
29237
29292
  };
29238
29293
  if (day && start) {
29239
29294
  const [hour, minute] = start?.split(":") ?? ["0", "0"];
@@ -29316,7 +29371,7 @@ function usePatrolRouteRepo() {
29316
29371
  id: "$_id",
29317
29372
  start: startOfDay,
29318
29373
  end: endOfDay,
29319
- site: import_mongodb69.ObjectId.isValid(site) ? new import_mongodb69.ObjectId(site) : null
29374
+ site: import_mongodb70.ObjectId.isValid(site) ? new import_mongodb70.ObjectId(site) : null
29320
29375
  },
29321
29376
  pipeline: [
29322
29377
  {
@@ -29362,7 +29417,7 @@ function usePatrolRouteRepo() {
29362
29417
  }
29363
29418
  async function getById(_id, session) {
29364
29419
  try {
29365
- _id = new import_mongodb69.ObjectId(_id);
29420
+ _id = new import_mongodb70.ObjectId(_id);
29366
29421
  } catch (error) {
29367
29422
  throw new import_node_server_utils121.BadRequestError("Invalid patrol log ID format.");
29368
29423
  }
@@ -29607,7 +29662,7 @@ function usePatrolRouteController() {
29607
29662
 
29608
29663
  // src/models/patrol-log.model.ts
29609
29664
  var import_node_server_utils123 = require("@7365admin1/node-server-utils");
29610
- var import_mongodb70 = require("mongodb");
29665
+ var import_mongodb71 = require("mongodb");
29611
29666
  var import_joi67 = __toESM(require("joi"));
29612
29667
  var schemeLogCamera = import_joi67.default.object({
29613
29668
  camera: import_joi67.default.string().hex().required(),
@@ -29668,41 +29723,41 @@ function MPatrolLog(value) {
29668
29723
  }
29669
29724
  if (value._id && typeof value._id === "string") {
29670
29725
  try {
29671
- value._id = new import_mongodb70.ObjectId(value._id);
29726
+ value._id = new import_mongodb71.ObjectId(value._id);
29672
29727
  } catch {
29673
29728
  throw new import_node_server_utils123.BadRequestError("Invalid _id format");
29674
29729
  }
29675
29730
  }
29676
29731
  if (value.route && typeof value.route === "string") {
29677
29732
  try {
29678
- value.route = new import_mongodb70.ObjectId(value.route);
29733
+ value.route = new import_mongodb71.ObjectId(value.route);
29679
29734
  } catch {
29680
29735
  throw new import_node_server_utils123.BadRequestError("Invalid route id format");
29681
29736
  }
29682
29737
  }
29683
29738
  if (value.site && typeof value.site === "string") {
29684
29739
  try {
29685
- value.site = new import_mongodb70.ObjectId(value.site);
29740
+ value.site = new import_mongodb71.ObjectId(value.site);
29686
29741
  } catch {
29687
29742
  throw new import_node_server_utils123.BadRequestError("Invalid site id format");
29688
29743
  }
29689
29744
  }
29690
29745
  const assignee = (value.assignee || []).map((id) => {
29691
29746
  try {
29692
- return new import_mongodb70.ObjectId(id);
29747
+ return new import_mongodb71.ObjectId(id);
29693
29748
  } catch {
29694
29749
  throw new import_node_server_utils123.BadRequestError("Invalid assignee id format");
29695
29750
  }
29696
29751
  });
29697
29752
  if (value.incidentReport && typeof value.incidentReport.id === "string") {
29698
29753
  try {
29699
- value.incidentReport.id = new import_mongodb70.ObjectId(value.incidentReport.id);
29754
+ value.incidentReport.id = new import_mongodb71.ObjectId(value.incidentReport.id);
29700
29755
  } catch {
29701
29756
  throw new import_node_server_utils123.BadRequestError("Invalid incident report id format");
29702
29757
  }
29703
29758
  }
29704
29759
  return {
29705
- _id: value._id ?? new import_mongodb70.ObjectId(),
29760
+ _id: value._id ?? new import_mongodb71.ObjectId(),
29706
29761
  site: value.site,
29707
29762
  name: value.name,
29708
29763
  assignee,
@@ -29721,7 +29776,7 @@ function MPatrolLog(value) {
29721
29776
 
29722
29777
  // src/repositories/patrol-log.repo.ts
29723
29778
  var import_node_server_utils124 = require("@7365admin1/node-server-utils");
29724
- var import_mongodb71 = require("mongodb");
29779
+ var import_mongodb72 = require("mongodb");
29725
29780
  function usePatrolLogRepo() {
29726
29781
  const db = import_node_server_utils124.useAtlas.getDb();
29727
29782
  if (!db) {
@@ -29812,7 +29867,7 @@ function usePatrolLogRepo() {
29812
29867
  };
29813
29868
  }
29814
29869
  const query = {
29815
- ...import_mongodb71.ObjectId.isValid(site) && { site: new import_mongodb71.ObjectId(site) },
29870
+ ...import_mongodb72.ObjectId.isValid(site) && { site: new import_mongodb72.ObjectId(site) },
29816
29871
  ...dateExpr
29817
29872
  };
29818
29873
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
@@ -29952,7 +30007,7 @@ function usePatrolLogRepo() {
29952
30007
  }
29953
30008
  async function updateById(_id, value, session) {
29954
30009
  try {
29955
- _id = new import_mongodb71.ObjectId(_id);
30010
+ _id = new import_mongodb72.ObjectId(_id);
29956
30011
  } catch (error) {
29957
30012
  throw new import_node_server_utils124.BadRequestError("Invalid patrol log transaction ID format.");
29958
30013
  }
@@ -29971,7 +30026,7 @@ function usePatrolLogRepo() {
29971
30026
  }
29972
30027
  async function deleteById(_id, session) {
29973
30028
  try {
29974
- _id = new import_mongodb71.ObjectId(_id);
30029
+ _id = new import_mongodb72.ObjectId(_id);
29975
30030
  } catch (error) {
29976
30031
  throw new import_node_server_utils124.BadRequestError("Invalid patrol log ID format.");
29977
30032
  }
@@ -29985,7 +30040,7 @@ function usePatrolLogRepo() {
29985
30040
  }
29986
30041
  async function getById(_id, session) {
29987
30042
  try {
29988
- _id = new import_mongodb71.ObjectId(_id);
30043
+ _id = new import_mongodb72.ObjectId(_id);
29989
30044
  } catch (error) {
29990
30045
  throw new import_node_server_utils124.BadRequestError("Invalid patrol log ID format.");
29991
30046
  }
@@ -30233,7 +30288,7 @@ function usePatrolLogController() {
30233
30288
 
30234
30289
  // src/models/site-facility.model.ts
30235
30290
  var import_joi69 = __toESM(require("joi"));
30236
- var import_mongodb72 = require("mongodb");
30291
+ var import_mongodb73 = require("mongodb");
30237
30292
  var timeSlotSchema = import_joi69.default.array().items(
30238
30293
  import_joi69.default.object({
30239
30294
  start: import_joi69.default.string().optional().allow("", null),
@@ -30393,28 +30448,28 @@ function MSiteFacility(value) {
30393
30448
  throw new Error(error.details[0].message);
30394
30449
  if (value._id && typeof value._id === "string") {
30395
30450
  try {
30396
- value._id = new import_mongodb72.ObjectId(value._id);
30451
+ value._id = new import_mongodb73.ObjectId(value._id);
30397
30452
  } catch {
30398
30453
  throw new Error("Invalid _id.");
30399
30454
  }
30400
30455
  }
30401
30456
  if (value.site && typeof value.site === "string") {
30402
30457
  try {
30403
- value.site = new import_mongodb72.ObjectId(value.site);
30458
+ value.site = new import_mongodb73.ObjectId(value.site);
30404
30459
  } catch {
30405
30460
  throw new Error("Invalid _id.");
30406
30461
  }
30407
30462
  }
30408
30463
  if (value.featuredImage && typeof value.featuredImage === "string") {
30409
30464
  try {
30410
- value.featuredImage = new import_mongodb72.ObjectId(value.featuredImage);
30465
+ value.featuredImage = new import_mongodb73.ObjectId(value.featuredImage);
30411
30466
  } catch {
30412
30467
  throw new Error("Invalid featuredImage ID.");
30413
30468
  }
30414
30469
  }
30415
30470
  if (Array.isArray(value.gallery)) {
30416
30471
  try {
30417
- value.gallery = value.gallery.map((id) => new import_mongodb72.ObjectId(id));
30472
+ value.gallery = value.gallery.map((id) => new import_mongodb73.ObjectId(id));
30418
30473
  } catch {
30419
30474
  throw new Error("Invalid ID in gallery array.");
30420
30475
  }
@@ -30498,7 +30553,7 @@ function MSiteFacility(value) {
30498
30553
 
30499
30554
  // src/repositories/site-facility.repo.ts
30500
30555
  var import_node_server_utils127 = require("@7365admin1/node-server-utils");
30501
- var import_mongodb73 = require("mongodb");
30556
+ var import_mongodb74 = require("mongodb");
30502
30557
  function useSiteFacilityRepo() {
30503
30558
  const db = import_node_server_utils127.useAtlas.getDb();
30504
30559
  if (!db) {
@@ -30566,7 +30621,7 @@ function useSiteFacilityRepo() {
30566
30621
  };
30567
30622
  if (site) {
30568
30623
  try {
30569
- site = new import_mongodb73.ObjectId(site);
30624
+ site = new import_mongodb74.ObjectId(site);
30570
30625
  query.site = site;
30571
30626
  cacheOptions.site = site.toString();
30572
30627
  } catch (error) {
@@ -30611,7 +30666,7 @@ function useSiteFacilityRepo() {
30611
30666
  }
30612
30667
  async function getSiteFacilityById(_id, session) {
30613
30668
  try {
30614
- _id = new import_mongodb73.ObjectId(_id);
30669
+ _id = new import_mongodb74.ObjectId(_id);
30615
30670
  } catch (error) {
30616
30671
  throw new import_node_server_utils127.BadRequestError("Invalid site facility ID format.");
30617
30672
  }
@@ -30639,20 +30694,20 @@ function useSiteFacilityRepo() {
30639
30694
  async function updateSiteFacilityById(_id, value, session) {
30640
30695
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
30641
30696
  try {
30642
- _id = new import_mongodb73.ObjectId(_id);
30697
+ _id = new import_mongodb74.ObjectId(_id);
30643
30698
  } catch (error) {
30644
30699
  throw new import_node_server_utils127.BadRequestError("Invalid ID format.");
30645
30700
  }
30646
30701
  if (value.featuredImage) {
30647
30702
  try {
30648
- value.featuredImage = new import_mongodb73.ObjectId(value.featuredImage);
30703
+ value.featuredImage = new import_mongodb74.ObjectId(value.featuredImage);
30649
30704
  } catch (error) {
30650
30705
  throw new import_node_server_utils127.BadRequestError("Invalid ID format for featured image.");
30651
30706
  }
30652
30707
  }
30653
30708
  if (Array.isArray(value.gallery)) {
30654
30709
  try {
30655
- value.gallery = value.gallery.map((id) => new import_mongodb73.ObjectId(id));
30710
+ value.gallery = value.gallery.map((id) => new import_mongodb74.ObjectId(id));
30656
30711
  } catch {
30657
30712
  throw new Error("Invalid ID in gallery array.");
30658
30713
  }
@@ -30698,7 +30753,7 @@ function useSiteFacilityRepo() {
30698
30753
  }
30699
30754
  async function deleteSiteFacilityById(_id) {
30700
30755
  try {
30701
- _id = new import_mongodb73.ObjectId(_id);
30756
+ _id = new import_mongodb74.ObjectId(_id);
30702
30757
  } catch (error) {
30703
30758
  throw new import_node_server_utils127.BadRequestError("Invalid site facility ID format.");
30704
30759
  }
@@ -30727,12 +30782,12 @@ function useSiteFacilityRepo() {
30727
30782
  }
30728
30783
  async function getSiteFacilityTimeSlotById(_id, site, session) {
30729
30784
  try {
30730
- _id = new import_mongodb73.ObjectId(_id);
30785
+ _id = new import_mongodb74.ObjectId(_id);
30731
30786
  } catch (error) {
30732
30787
  throw new import_node_server_utils127.BadRequestError("Invalid facility ID format.");
30733
30788
  }
30734
30789
  try {
30735
- site = new import_mongodb73.ObjectId(site);
30790
+ site = new import_mongodb74.ObjectId(site);
30736
30791
  } catch (error) {
30737
30792
  throw new import_node_server_utils127.BadRequestError("Invalid site ID format.");
30738
30793
  }
@@ -31075,7 +31130,7 @@ function useSiteFacilityController() {
31075
31130
 
31076
31131
  // src/models/service-provider-billing.model.ts
31077
31132
  var import_joi71 = __toESM(require("joi"));
31078
- var import_mongodb74 = require("mongodb");
31133
+ var import_mongodb75 = require("mongodb");
31079
31134
  var schemaServiceProviderBilling = import_joi71.default.object({
31080
31135
  _id: import_joi71.default.string().hex().optional().allow("", null),
31081
31136
  attachments: import_joi71.default.array().items(import_joi71.default.string().hex()).required(),
@@ -31109,7 +31164,7 @@ function MServiceProviderBilling(value) {
31109
31164
  }
31110
31165
  if (value._id && typeof value._id === "string") {
31111
31166
  try {
31112
- value._id = new import_mongodb74.ObjectId(value._id);
31167
+ value._id = new import_mongodb75.ObjectId(value._id);
31113
31168
  } catch {
31114
31169
  throw new Error("Invalid ID.");
31115
31170
  }
@@ -31118,7 +31173,7 @@ function MServiceProviderBilling(value) {
31118
31173
  value.acknowledgedBy = value.acknowledgedBy.map((item) => {
31119
31174
  if (item.user && typeof item.user === "string") {
31120
31175
  try {
31121
- item.user = new import_mongodb74.ObjectId(item.user);
31176
+ item.user = new import_mongodb75.ObjectId(item.user);
31122
31177
  } catch (error2) {
31123
31178
  throw new Error("Invalid ID format for acknowledgedBy.user.");
31124
31179
  }
@@ -31128,13 +31183,13 @@ function MServiceProviderBilling(value) {
31128
31183
  }
31129
31184
  if (value.orgId && typeof value.orgId === "string") {
31130
31185
  try {
31131
- value.orgId = new import_mongodb74.ObjectId(value.orgId);
31186
+ value.orgId = new import_mongodb75.ObjectId(value.orgId);
31132
31187
  } catch {
31133
31188
  throw new Error("Invalid org ID.");
31134
31189
  }
31135
31190
  }
31136
31191
  return {
31137
- _id: value._id ?? new import_mongodb74.ObjectId(),
31192
+ _id: value._id ?? new import_mongodb75.ObjectId(),
31138
31193
  attachments: value.attachments,
31139
31194
  acknowledgedBy: value.acknowledgedBy || [],
31140
31195
  status: value.status,
@@ -31147,7 +31202,7 @@ function MServiceProviderBilling(value) {
31147
31202
 
31148
31203
  // src/repositories/service-provider-billing.repo.ts
31149
31204
  var import_node_server_utils130 = require("@7365admin1/node-server-utils");
31150
- var import_mongodb75 = require("mongodb");
31205
+ var import_mongodb76 = require("mongodb");
31151
31206
  function useServiceProviderBillingRepo() {
31152
31207
  const db = import_node_server_utils130.useAtlas.getDb();
31153
31208
  if (!db) {
@@ -31194,7 +31249,7 @@ function useServiceProviderBillingRepo() {
31194
31249
  }, session) {
31195
31250
  page = page > 0 ? page - 1 : 0;
31196
31251
  try {
31197
- org = new import_mongodb75.ObjectId(org);
31252
+ org = new import_mongodb76.ObjectId(org);
31198
31253
  } catch (error) {
31199
31254
  throw new import_node_server_utils130.BadRequestError("Invalid org ID format.");
31200
31255
  }
@@ -31244,7 +31299,7 @@ function useServiceProviderBillingRepo() {
31244
31299
  }
31245
31300
  async function getSiteServiceProviderBillingById(_id, session) {
31246
31301
  try {
31247
- _id = new import_mongodb75.ObjectId(_id);
31302
+ _id = new import_mongodb76.ObjectId(_id);
31248
31303
  } catch (error) {
31249
31304
  throw new import_node_server_utils130.BadRequestError("Invalid service provider billing ID format.");
31250
31305
  }
@@ -31272,7 +31327,7 @@ function useServiceProviderBillingRepo() {
31272
31327
  async function updateServiceProviderBillingById(_id, value, session) {
31273
31328
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
31274
31329
  try {
31275
- _id = new import_mongodb75.ObjectId(_id);
31330
+ _id = new import_mongodb76.ObjectId(_id);
31276
31331
  } catch (error) {
31277
31332
  throw new import_node_server_utils130.BadRequestError("Invalid ID format.");
31278
31333
  }
@@ -31280,7 +31335,7 @@ function useServiceProviderBillingRepo() {
31280
31335
  value.acknowledgedBy = value.acknowledgedBy.map((item) => {
31281
31336
  if (item.user && typeof item.user === "string") {
31282
31337
  try {
31283
- item.user = new import_mongodb75.ObjectId(item.user);
31338
+ item.user = new import_mongodb76.ObjectId(item.user);
31284
31339
  } catch (error) {
31285
31340
  throw new Error("Invalid ID format for acknowledgedBy.user.");
31286
31341
  }
@@ -31314,7 +31369,7 @@ function useServiceProviderBillingRepo() {
31314
31369
  }
31315
31370
  async function deleteServiceProviderBillingById(_id) {
31316
31371
  try {
31317
- _id = new import_mongodb75.ObjectId(_id);
31372
+ _id = new import_mongodb76.ObjectId(_id);
31318
31373
  } catch (error) {
31319
31374
  throw new import_node_server_utils130.BadRequestError("Invalid service provider billing ID format.");
31320
31375
  }
@@ -31552,7 +31607,7 @@ function useServiceProviderBillingController() {
31552
31607
 
31553
31608
  // src/models/site-facility-booking.model.ts
31554
31609
  var import_joi73 = __toESM(require("joi"));
31555
- var import_mongodb76 = require("mongodb");
31610
+ var import_mongodb77 = require("mongodb");
31556
31611
  var FacilitySort = /* @__PURE__ */ ((FacilitySort2) => {
31557
31612
  FacilitySort2["CREATED_AT"] = "createdAt";
31558
31613
  FacilitySort2["NAME"] = "name";
@@ -31662,48 +31717,48 @@ function MSiteFacilityBooking(value) {
31662
31717
  }
31663
31718
  if (value._id && typeof value._id === "string") {
31664
31719
  try {
31665
- value._id = new import_mongodb76.ObjectId(value._id);
31720
+ value._id = new import_mongodb77.ObjectId(value._id);
31666
31721
  } catch {
31667
31722
  throw new Error("Invalid ID.");
31668
31723
  }
31669
31724
  }
31670
31725
  if (value.site && typeof value.site === "string") {
31671
31726
  try {
31672
- value.site = new import_mongodb76.ObjectId(value.site);
31727
+ value.site = new import_mongodb77.ObjectId(value.site);
31673
31728
  } catch {
31674
31729
  throw new Error("Invalid site ID.");
31675
31730
  }
31676
31731
  }
31677
31732
  if (value.user && typeof value.user === "string") {
31678
31733
  try {
31679
- value.user = new import_mongodb76.ObjectId(value.user);
31734
+ value.user = new import_mongodb77.ObjectId(value.user);
31680
31735
  } catch {
31681
31736
  throw new Error("Invalid user ID.");
31682
31737
  }
31683
31738
  }
31684
31739
  if (value.approvedBy && typeof value.approvedBy === "string") {
31685
31740
  try {
31686
- value.approvedBy = new import_mongodb76.ObjectId(value.approvedBy);
31741
+ value.approvedBy = new import_mongodb77.ObjectId(value.approvedBy);
31687
31742
  } catch {
31688
31743
  throw new Error("Invalid approved by ID.");
31689
31744
  }
31690
31745
  }
31691
31746
  if (value.createdBy && typeof value.createdBy === "string") {
31692
31747
  try {
31693
- value.createdBy = new import_mongodb76.ObjectId(value.createdBy);
31748
+ value.createdBy = new import_mongodb77.ObjectId(value.createdBy);
31694
31749
  } catch {
31695
31750
  throw new Error("Invalid created by ID.");
31696
31751
  }
31697
31752
  }
31698
31753
  if (value.updatedBy && typeof value.updatedBy === "string") {
31699
31754
  try {
31700
- value.updatedBy = new import_mongodb76.ObjectId(value.updatedBy);
31755
+ value.updatedBy = new import_mongodb77.ObjectId(value.updatedBy);
31701
31756
  } catch {
31702
31757
  throw new Error("Invalid updated by ID.");
31703
31758
  }
31704
31759
  }
31705
31760
  return {
31706
- _id: value._id ?? new import_mongodb76.ObjectId(),
31761
+ _id: value._id ?? new import_mongodb77.ObjectId(),
31707
31762
  facility: value.facility ?? "",
31708
31763
  slot: value.slot ?? "",
31709
31764
  slotName: value.slotName ?? "",
@@ -31789,7 +31844,7 @@ function MSiteFacilityBooking(value) {
31789
31844
 
31790
31845
  // src/repositories/site-facility-booking.repo.ts
31791
31846
  var import_node_server_utils133 = require("@7365admin1/node-server-utils");
31792
- var import_mongodb77 = require("mongodb");
31847
+ var import_mongodb78 = require("mongodb");
31793
31848
  var facility_bookings_namespace_collection = "site.facilty-booking";
31794
31849
  function useSiteFacilityBookingRepo() {
31795
31850
  const db = import_node_server_utils133.useAtlas.getDb();
@@ -31952,7 +32007,7 @@ function useSiteFacilityBookingRepo() {
31952
32007
  }
31953
32008
  async function deleteSiteFacilityBookingById(_id) {
31954
32009
  try {
31955
- _id = new import_mongodb77.ObjectId(_id);
32010
+ _id = new import_mongodb78.ObjectId(_id);
31956
32011
  } catch (error) {
31957
32012
  throw new import_node_server_utils133.BadRequestError("Invalid site facility booking ID format.");
31958
32013
  }
@@ -32189,7 +32244,7 @@ function useSiteFacilityBookingController() {
32189
32244
 
32190
32245
  // src/models/document-management.model.ts
32191
32246
  var import_joi75 = __toESM(require("joi"));
32192
- var import_mongodb78 = require("mongodb");
32247
+ var import_mongodb79 = require("mongodb");
32193
32248
  var schemaDocumentManagement = import_joi75.default.object({
32194
32249
  _id: import_joi75.default.string().hex().optional().allow("", null),
32195
32250
  name: import_joi75.default.string().required(),
@@ -32227,28 +32282,28 @@ function MDocumentManagement(value) {
32227
32282
  }
32228
32283
  if (value._id && typeof value._id === "string") {
32229
32284
  try {
32230
- value._id = new import_mongodb78.ObjectId(value._id);
32285
+ value._id = new import_mongodb79.ObjectId(value._id);
32231
32286
  } catch (error2) {
32232
32287
  throw new Error("Invalid ID.");
32233
32288
  }
32234
32289
  }
32235
32290
  if (value.org && typeof value.org === "string") {
32236
32291
  try {
32237
- value.org = new import_mongodb78.ObjectId(value.org);
32292
+ value.org = new import_mongodb79.ObjectId(value.org);
32238
32293
  } catch (error2) {
32239
32294
  throw new Error("Invalid org ID.");
32240
32295
  }
32241
32296
  }
32242
32297
  if (value.site && typeof value.site === "string") {
32243
32298
  try {
32244
- value.site = new import_mongodb78.ObjectId(value.site);
32299
+ value.site = new import_mongodb79.ObjectId(value.site);
32245
32300
  } catch (error2) {
32246
32301
  throw new Error("Invalid site ID.");
32247
32302
  }
32248
32303
  }
32249
32304
  if (value.parentId && typeof value.parentId === "string") {
32250
32305
  try {
32251
- value.parentId = new import_mongodb78.ObjectId(value.parentId);
32306
+ value.parentId = new import_mongodb79.ObjectId(value.parentId);
32252
32307
  } catch (error2) {
32253
32308
  throw new Error("Invalid parentId.");
32254
32309
  }
@@ -32273,7 +32328,7 @@ function MDocumentManagement(value) {
32273
32328
 
32274
32329
  // src/repositories/document-management.repo.ts
32275
32330
  var import_node_server_utils136 = require("@7365admin1/node-server-utils");
32276
- var import_mongodb79 = require("mongodb");
32331
+ var import_mongodb80 = require("mongodb");
32277
32332
  function useDocumentManagementRepo() {
32278
32333
  const db = import_node_server_utils136.useAtlas.getDb();
32279
32334
  if (!db) {
@@ -32335,7 +32390,7 @@ function useDocumentManagementRepo() {
32335
32390
  }) {
32336
32391
  page = page > 0 ? page - 1 : 0;
32337
32392
  try {
32338
- site = new import_mongodb79.ObjectId(site);
32393
+ site = new import_mongodb80.ObjectId(site);
32339
32394
  } catch (error) {
32340
32395
  throw new import_node_server_utils136.BadRequestError("Invalid site ID format.");
32341
32396
  }
@@ -32352,12 +32407,12 @@ function useDocumentManagementRepo() {
32352
32407
  cacheOptions.type = type;
32353
32408
  }
32354
32409
  if (org) {
32355
- query.org = new import_mongodb79.ObjectId(org);
32410
+ query.org = new import_mongodb80.ObjectId(org);
32356
32411
  cacheOptions.org = org.toString();
32357
32412
  }
32358
32413
  if (parentId) {
32359
32414
  try {
32360
- query.parentId = new import_mongodb79.ObjectId(parentId);
32415
+ query.parentId = new import_mongodb80.ObjectId(parentId);
32361
32416
  cacheOptions.parentId = parentId.toString();
32362
32417
  } catch (error) {
32363
32418
  throw new import_node_server_utils136.BadRequestError("Invalid parentId format.");
@@ -32411,7 +32466,7 @@ function useDocumentManagementRepo() {
32411
32466
  }
32412
32467
  async function getDocumentById(_id) {
32413
32468
  try {
32414
- _id = new import_mongodb79.ObjectId(_id);
32469
+ _id = new import_mongodb80.ObjectId(_id);
32415
32470
  } catch (error) {
32416
32471
  throw new import_node_server_utils136.BadRequestError("Invalid document ID format.");
32417
32472
  }
@@ -32456,7 +32511,7 @@ function useDocumentManagementRepo() {
32456
32511
  }
32457
32512
  async function updateDocumentById(_id, value) {
32458
32513
  try {
32459
- _id = new import_mongodb79.ObjectId(_id);
32514
+ _id = new import_mongodb80.ObjectId(_id);
32460
32515
  } catch (error) {
32461
32516
  throw new import_node_server_utils136.BadRequestError("Invalid document ID format.");
32462
32517
  }
@@ -32484,7 +32539,7 @@ function useDocumentManagementRepo() {
32484
32539
  }
32485
32540
  async function deleteDocumentById(_id, session) {
32486
32541
  try {
32487
- _id = new import_mongodb79.ObjectId(_id);
32542
+ _id = new import_mongodb80.ObjectId(_id);
32488
32543
  } catch (error) {
32489
32544
  throw new import_node_server_utils136.BadRequestError("Invalid document ID format.");
32490
32545
  }
@@ -32517,7 +32572,7 @@ function useDocumentManagementRepo() {
32517
32572
  }
32518
32573
  async function getDocumentManagementBySiteId(site, type) {
32519
32574
  try {
32520
- site = new import_mongodb79.ObjectId(site);
32575
+ site = new import_mongodb80.ObjectId(site);
32521
32576
  } catch (error) {
32522
32577
  throw new import_node_server_utils136.BadRequestError("Invalid document management site ID format.");
32523
32578
  }
@@ -32843,7 +32898,7 @@ function useDocumentManagementController() {
32843
32898
 
32844
32899
  // src/models/bulletin-board.model.ts
32845
32900
  var import_joi77 = __toESM(require("joi"));
32846
- var import_mongodb80 = require("mongodb");
32901
+ var import_mongodb81 = require("mongodb");
32847
32902
  var BulletinRecipient = /* @__PURE__ */ ((BulletinRecipient2) => {
32848
32903
  BulletinRecipient2["RESIDENT"] = "resident";
32849
32904
  BulletinRecipient2["SECURITY_AGENCY"] = "security_agency";
@@ -32923,21 +32978,21 @@ function MBulletinBoard(value) {
32923
32978
  }
32924
32979
  if (value._id && typeof value._id === "string") {
32925
32980
  try {
32926
- value._id = new import_mongodb80.ObjectId(value._id);
32981
+ value._id = new import_mongodb81.ObjectId(value._id);
32927
32982
  } catch {
32928
32983
  throw new Error("Invalid ID.");
32929
32984
  }
32930
32985
  }
32931
32986
  if (value.site && typeof value.site === "string") {
32932
32987
  try {
32933
- value.site = new import_mongodb80.ObjectId(value.site);
32988
+ value.site = new import_mongodb81.ObjectId(value.site);
32934
32989
  } catch {
32935
32990
  throw new Error("Invalid site ID.");
32936
32991
  }
32937
32992
  }
32938
32993
  if (value.orgId && typeof value.orgId === "string") {
32939
32994
  try {
32940
- value.orgId = new import_mongodb80.ObjectId(value.orgId);
32995
+ value.orgId = new import_mongodb81.ObjectId(value.orgId);
32941
32996
  } catch {
32942
32997
  throw new Error("Invalid org ID.");
32943
32998
  }
@@ -32946,7 +33001,7 @@ function MBulletinBoard(value) {
32946
33001
  value.file = value.file.map((f) => {
32947
33002
  if (f._id && typeof f._id === "string") {
32948
33003
  try {
32949
- return { ...f, _id: new import_mongodb80.ObjectId(f._id) };
33004
+ return { ...f, _id: new import_mongodb81.ObjectId(f._id) };
32950
33005
  } catch {
32951
33006
  throw new Error("Invalid file ID.");
32952
33007
  }
@@ -32955,7 +33010,7 @@ function MBulletinBoard(value) {
32955
33010
  });
32956
33011
  }
32957
33012
  return {
32958
- _id: value._id ?? new import_mongodb80.ObjectId(),
33013
+ _id: value._id ?? new import_mongodb81.ObjectId(),
32959
33014
  site: value.site ?? "",
32960
33015
  orgId: value.orgId ?? "",
32961
33016
  recipients: value.recipients ?? [],
@@ -32974,7 +33029,7 @@ function MBulletinBoard(value) {
32974
33029
 
32975
33030
  // src/repositories/bulletin-board.repo.ts
32976
33031
  var import_node_server_utils139 = require("@7365admin1/node-server-utils");
32977
- var import_mongodb81 = require("mongodb");
33032
+ var import_mongodb82 = require("mongodb");
32978
33033
  var bulletin_boards_namespace_collection = "bulletin-boards";
32979
33034
  function useBulletinBoardRepo() {
32980
33035
  const db = import_node_server_utils139.useAtlas.getDb();
@@ -33027,7 +33082,7 @@ function useBulletinBoardRepo() {
33027
33082
  }, session) {
33028
33083
  page = page > 0 ? page - 1 : 0;
33029
33084
  try {
33030
- site = new import_mongodb81.ObjectId(site);
33085
+ site = new import_mongodb82.ObjectId(site);
33031
33086
  } catch (error) {
33032
33087
  throw new import_node_server_utils139.BadRequestError("Invalid site ID format.");
33033
33088
  }
@@ -33086,7 +33141,7 @@ function useBulletinBoardRepo() {
33086
33141
  }
33087
33142
  async function getBulletinBoardById(_id, session) {
33088
33143
  try {
33089
- _id = new import_mongodb81.ObjectId(_id);
33144
+ _id = new import_mongodb82.ObjectId(_id);
33090
33145
  } catch (error) {
33091
33146
  throw new import_node_server_utils139.BadRequestError("Invalid bulletin board ID format.");
33092
33147
  }
@@ -33116,13 +33171,13 @@ function useBulletinBoardRepo() {
33116
33171
  async function updateBulletinBoardById(_id, value, session) {
33117
33172
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
33118
33173
  try {
33119
- _id = new import_mongodb81.ObjectId(_id);
33174
+ _id = new import_mongodb82.ObjectId(_id);
33120
33175
  } catch (error) {
33121
33176
  throw new import_node_server_utils139.BadRequestError("Invalid ID format.");
33122
33177
  }
33123
33178
  if (value.site && typeof value.site === "string") {
33124
33179
  try {
33125
- value.site = new import_mongodb81.ObjectId(value.site);
33180
+ value.site = new import_mongodb82.ObjectId(value.site);
33126
33181
  } catch {
33127
33182
  throw new Error("Invalid site ID.");
33128
33183
  }
@@ -33153,7 +33208,7 @@ function useBulletinBoardRepo() {
33153
33208
  }
33154
33209
  async function deleteBulletinBoardById(_id, session) {
33155
33210
  try {
33156
- _id = new import_mongodb81.ObjectId(_id);
33211
+ _id = new import_mongodb82.ObjectId(_id);
33157
33212
  } catch (error) {
33158
33213
  throw new import_node_server_utils139.BadRequestError("Invalid bulletin board ID format.");
33159
33214
  }
@@ -33587,7 +33642,7 @@ function useBulletinBoardController() {
33587
33642
 
33588
33643
  // src/models/site-billing-item.model.ts
33589
33644
  var import_node_server_utils142 = require("@7365admin1/node-server-utils");
33590
- var import_mongodb82 = require("mongodb");
33645
+ var import_mongodb83 = require("mongodb");
33591
33646
  var import_joi79 = __toESM(require("joi"));
33592
33647
 
33593
33648
  // src/types/enums/billing-frequency.enum.ts
@@ -33658,21 +33713,21 @@ function MBillingItem(value) {
33658
33713
  }
33659
33714
  if (value._id && typeof value._id === "string") {
33660
33715
  try {
33661
- value._id = new import_mongodb82.ObjectId(value._id);
33716
+ value._id = new import_mongodb83.ObjectId(value._id);
33662
33717
  } catch {
33663
33718
  throw new import_node_server_utils142.BadRequestError("Invalid _id format");
33664
33719
  }
33665
33720
  }
33666
33721
  if (value.site && typeof value.site === "string") {
33667
33722
  try {
33668
- value.site = new import_mongodb82.ObjectId(value.site);
33723
+ value.site = new import_mongodb83.ObjectId(value.site);
33669
33724
  } catch {
33670
33725
  throw new import_node_server_utils142.BadRequestError("Invalid site id format");
33671
33726
  }
33672
33727
  }
33673
33728
  if (value.org && typeof value.org === "string") {
33674
33729
  try {
33675
- value.org = new import_mongodb82.ObjectId(value.org);
33730
+ value.org = new import_mongodb83.ObjectId(value.org);
33676
33731
  } catch {
33677
33732
  throw new import_node_server_utils142.BadRequestError("Invalid org id format");
33678
33733
  }
@@ -33681,7 +33736,7 @@ function MBillingItem(value) {
33681
33736
  value.units = value.units.map((unit) => {
33682
33737
  if (unit._id && typeof unit._id === "string") {
33683
33738
  try {
33684
- unit._id = new import_mongodb82.ObjectId(unit._id);
33739
+ unit._id = new import_mongodb83.ObjectId(unit._id);
33685
33740
  } catch {
33686
33741
  throw new import_node_server_utils142.BadRequestError("Invalid unit id format");
33687
33742
  }
@@ -33690,7 +33745,7 @@ function MBillingItem(value) {
33690
33745
  });
33691
33746
  }
33692
33747
  return {
33693
- _id: value._id ?? new import_mongodb82.ObjectId(),
33748
+ _id: value._id ?? new import_mongodb83.ObjectId(),
33694
33749
  site: value.site,
33695
33750
  org: value.org,
33696
33751
  name: value.name,
@@ -33718,7 +33773,7 @@ function MBillingItem(value) {
33718
33773
 
33719
33774
  // src/repositories/site-billing-item.repo.ts
33720
33775
  var import_node_server_utils143 = require("@7365admin1/node-server-utils");
33721
- var import_mongodb83 = require("mongodb");
33776
+ var import_mongodb84 = require("mongodb");
33722
33777
  function useSiteBillingItemRepo() {
33723
33778
  const db = import_node_server_utils143.useAtlas.getDb();
33724
33779
  if (!db) {
@@ -33805,7 +33860,7 @@ function useSiteBillingItemRepo() {
33805
33860
  }
33806
33861
  ]
33807
33862
  },
33808
- ...import_mongodb83.ObjectId.isValid(site) && { site: new import_mongodb83.ObjectId(site) }
33863
+ ...import_mongodb84.ObjectId.isValid(site) && { site: new import_mongodb84.ObjectId(site) }
33809
33864
  };
33810
33865
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
33811
33866
  const cacheOptions = {
@@ -33845,7 +33900,7 @@ function useSiteBillingItemRepo() {
33845
33900
  }
33846
33901
  async function getById(_id, session) {
33847
33902
  try {
33848
- _id = new import_mongodb83.ObjectId(_id);
33903
+ _id = new import_mongodb84.ObjectId(_id);
33849
33904
  } catch (error) {
33850
33905
  throw new import_node_server_utils143.BadRequestError("Invalid ID.");
33851
33906
  }
@@ -33884,22 +33939,22 @@ function useSiteBillingItemRepo() {
33884
33939
  }
33885
33940
  async function updateById(_id, value, session) {
33886
33941
  try {
33887
- _id = new import_mongodb83.ObjectId(_id);
33942
+ _id = new import_mongodb84.ObjectId(_id);
33888
33943
  } catch (error) {
33889
33944
  throw new import_node_server_utils143.BadRequestError(
33890
33945
  "Invalid site billing item transaction ID format."
33891
33946
  );
33892
33947
  }
33893
- if (value.site && import_mongodb83.ObjectId.isValid(value.site.toString())) {
33948
+ if (value.site && import_mongodb84.ObjectId.isValid(value.site.toString())) {
33894
33949
  try {
33895
- value.site = new import_mongodb83.ObjectId(value.site.toString());
33950
+ value.site = new import_mongodb84.ObjectId(value.site.toString());
33896
33951
  } catch {
33897
33952
  throw new import_node_server_utils143.BadRequestError("Invalid _id format");
33898
33953
  }
33899
33954
  }
33900
- if (value.org && import_mongodb83.ObjectId.isValid(value.org.toString())) {
33955
+ if (value.org && import_mongodb84.ObjectId.isValid(value.org.toString())) {
33901
33956
  try {
33902
- value.org = new import_mongodb83.ObjectId(value.org.toString());
33957
+ value.org = new import_mongodb84.ObjectId(value.org.toString());
33903
33958
  } catch {
33904
33959
  throw new import_node_server_utils143.BadRequestError("Invalid _id format");
33905
33960
  }
@@ -33919,7 +33974,7 @@ function useSiteBillingItemRepo() {
33919
33974
  }
33920
33975
  async function deleteById(_id) {
33921
33976
  try {
33922
- _id = new import_mongodb83.ObjectId(_id);
33977
+ _id = new import_mongodb84.ObjectId(_id);
33923
33978
  } catch (error) {
33924
33979
  throw new import_node_server_utils143.BadRequestError(
33925
33980
  "Invalid site billing item transaction ID format."
@@ -33976,7 +34031,7 @@ var import_node_server_utils145 = require("@7365admin1/node-server-utils");
33976
34031
 
33977
34032
  // src/models/site-billing-configuration.model.ts
33978
34033
  var import_node_server_utils144 = require("@7365admin1/node-server-utils");
33979
- var import_mongodb84 = require("mongodb");
34034
+ var import_mongodb85 = require("mongodb");
33980
34035
  var import_joi80 = __toESM(require("joi"));
33981
34036
  var schemaBillingConfiguration = import_joi80.default.object({
33982
34037
  _id: import_joi80.default.string().hex().optional(),
@@ -34037,34 +34092,34 @@ function MBillingConfiguration(value) {
34037
34092
  }
34038
34093
  if (value._id && typeof value._id === "string") {
34039
34094
  try {
34040
- value._id = new import_mongodb84.ObjectId(value._id);
34095
+ value._id = new import_mongodb85.ObjectId(value._id);
34041
34096
  } catch {
34042
34097
  throw new import_node_server_utils144.BadRequestError("Invalid _id format");
34043
34098
  }
34044
34099
  }
34045
34100
  if (value.site && typeof value.site === "string") {
34046
34101
  try {
34047
- value.site = new import_mongodb84.ObjectId(value.site);
34102
+ value.site = new import_mongodb85.ObjectId(value.site);
34048
34103
  } catch {
34049
34104
  throw new import_node_server_utils144.BadRequestError("Invalid site id format");
34050
34105
  }
34051
34106
  }
34052
34107
  if (value.org && typeof value.org === "string") {
34053
34108
  try {
34054
- value.org = new import_mongodb84.ObjectId(value.org);
34109
+ value.org = new import_mongodb85.ObjectId(value.org);
34055
34110
  } catch {
34056
34111
  throw new import_node_server_utils144.BadRequestError("Invalid org id format");
34057
34112
  }
34058
34113
  }
34059
34114
  if (value.createdBy && typeof value.createdBy === "string") {
34060
34115
  try {
34061
- value.createdBy = new import_mongodb84.ObjectId(value.createdBy);
34116
+ value.createdBy = new import_mongodb85.ObjectId(value.createdBy);
34062
34117
  } catch {
34063
34118
  throw new import_node_server_utils144.BadRequestError("Invalid createdBy id format");
34064
34119
  }
34065
34120
  }
34066
34121
  return {
34067
- _id: value._id ?? new import_mongodb84.ObjectId(),
34122
+ _id: value._id ?? new import_mongodb85.ObjectId(),
34068
34123
  site: value.site,
34069
34124
  org: value.org,
34070
34125
  siteName: value.siteName,
@@ -34093,7 +34148,7 @@ function MBillingConfiguration(value) {
34093
34148
  }
34094
34149
 
34095
34150
  // src/repositories/site-billing-configuration.repo.ts
34096
- var import_mongodb85 = require("mongodb");
34151
+ var import_mongodb86 = require("mongodb");
34097
34152
  function useSiteBillingConfigurationRepo() {
34098
34153
  const db = import_node_server_utils145.useAtlas.getDb();
34099
34154
  if (!db) {
@@ -34166,7 +34221,7 @@ function useSiteBillingConfigurationRepo() {
34166
34221
  const query = {
34167
34222
  status,
34168
34223
  ...search && { $text: { $search: search } },
34169
- ...import_mongodb85.ObjectId.isValid(site) && { site: new import_mongodb85.ObjectId(site) }
34224
+ ...import_mongodb86.ObjectId.isValid(site) && { site: new import_mongodb86.ObjectId(site) }
34170
34225
  };
34171
34226
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
34172
34227
  const cacheOptions = {
@@ -34206,7 +34261,7 @@ function useSiteBillingConfigurationRepo() {
34206
34261
  }
34207
34262
  async function getById(_id) {
34208
34263
  try {
34209
- _id = new import_mongodb85.ObjectId(_id);
34264
+ _id = new import_mongodb86.ObjectId(_id);
34210
34265
  } catch (error) {
34211
34266
  throw new import_node_server_utils145.BadRequestError("Invalid ID.");
34212
34267
  }
@@ -34247,22 +34302,22 @@ function useSiteBillingConfigurationRepo() {
34247
34302
  }
34248
34303
  async function updateById(_id, value, session) {
34249
34304
  try {
34250
- _id = new import_mongodb85.ObjectId(_id);
34305
+ _id = new import_mongodb86.ObjectId(_id);
34251
34306
  } catch (error) {
34252
34307
  throw new import_node_server_utils145.BadRequestError(
34253
34308
  "Invalid site billing configuration transaction ID format."
34254
34309
  );
34255
34310
  }
34256
- if (value.site && import_mongodb85.ObjectId.isValid(value.site.toString())) {
34311
+ if (value.site && import_mongodb86.ObjectId.isValid(value.site.toString())) {
34257
34312
  try {
34258
- value.site = new import_mongodb85.ObjectId(value.site.toString());
34313
+ value.site = new import_mongodb86.ObjectId(value.site.toString());
34259
34314
  } catch {
34260
34315
  throw new import_node_server_utils145.BadRequestError("Invalid _id format");
34261
34316
  }
34262
34317
  }
34263
- if (value.org && import_mongodb85.ObjectId.isValid(value.org.toString())) {
34318
+ if (value.org && import_mongodb86.ObjectId.isValid(value.org.toString())) {
34264
34319
  try {
34265
- value.org = new import_mongodb85.ObjectId(value.org.toString());
34320
+ value.org = new import_mongodb86.ObjectId(value.org.toString());
34266
34321
  } catch {
34267
34322
  throw new import_node_server_utils145.BadRequestError("Invalid _id format");
34268
34323
  }
@@ -34282,7 +34337,7 @@ function useSiteBillingConfigurationRepo() {
34282
34337
  }
34283
34338
  async function deleteById(_id) {
34284
34339
  try {
34285
- _id = new import_mongodb85.ObjectId(_id);
34340
+ _id = new import_mongodb86.ObjectId(_id);
34286
34341
  } catch (error) {
34287
34342
  throw new import_node_server_utils145.BadRequestError(
34288
34343
  "Invalid site billing configuration transaction ID format."
@@ -34860,7 +34915,7 @@ function useSiteBillingConfigurationController() {
34860
34915
  }
34861
34916
 
34862
34917
  // src/models/event-management.model.ts
34863
- var import_mongodb86 = require("mongodb");
34918
+ var import_mongodb87 = require("mongodb");
34864
34919
  var import_joi83 = __toESM(require("joi"));
34865
34920
  var EventStatus = /* @__PURE__ */ ((EventStatus2) => {
34866
34921
  EventStatus2["PLANNED"] = "planned";
@@ -34904,20 +34959,20 @@ var schemaUpdateEventManagement = import_joi83.default.object({
34904
34959
  function MEventManagement(value) {
34905
34960
  if (value._id && typeof value._id === "string") {
34906
34961
  try {
34907
- value._id = new import_mongodb86.ObjectId(value._id);
34962
+ value._id = new import_mongodb87.ObjectId(value._id);
34908
34963
  } catch {
34909
34964
  throw new Error("Invalid ID.");
34910
34965
  }
34911
34966
  }
34912
34967
  if (value.site && typeof value.site === "string") {
34913
34968
  try {
34914
- value.site = new import_mongodb86.ObjectId(value.site);
34969
+ value.site = new import_mongodb87.ObjectId(value.site);
34915
34970
  } catch {
34916
34971
  throw new Error("Invalid site ID.");
34917
34972
  }
34918
34973
  }
34919
34974
  return {
34920
- _id: value._id ?? new import_mongodb86.ObjectId(),
34975
+ _id: value._id ?? new import_mongodb87.ObjectId(),
34921
34976
  site: value.site,
34922
34977
  title: value.title,
34923
34978
  description: value.description ?? "",
@@ -34932,7 +34987,7 @@ function MEventManagement(value) {
34932
34987
 
34933
34988
  // src/repositories/event-management.repo.ts
34934
34989
  var import_node_server_utils150 = require("@7365admin1/node-server-utils");
34935
- var import_mongodb87 = require("mongodb");
34990
+ var import_mongodb88 = require("mongodb");
34936
34991
  var events_namespace_collection = "event-management";
34937
34992
  function useEventManagementRepo() {
34938
34993
  const db = import_node_server_utils150.useAtlas.getDb();
@@ -35000,7 +35055,7 @@ function useEventManagementRepo() {
35000
35055
  }, session) {
35001
35056
  page = page > 0 ? page - 1 : 0;
35002
35057
  try {
35003
- site = new import_mongodb87.ObjectId(site);
35058
+ site = new import_mongodb88.ObjectId(site);
35004
35059
  } catch (error) {
35005
35060
  throw new import_node_server_utils150.BadRequestError("Invalid site ID format.");
35006
35061
  }
@@ -35088,7 +35143,7 @@ function useEventManagementRepo() {
35088
35143
  }
35089
35144
  async function getEventManagementById(_id, session) {
35090
35145
  try {
35091
- _id = new import_mongodb87.ObjectId(_id);
35146
+ _id = new import_mongodb88.ObjectId(_id);
35092
35147
  } catch (error) {
35093
35148
  throw new import_node_server_utils150.BadRequestError("Invalid event ID format.");
35094
35149
  }
@@ -35116,13 +35171,13 @@ function useEventManagementRepo() {
35116
35171
  async function updateEventManagementById(_id, value, session) {
35117
35172
  value.updatedAt = /* @__PURE__ */ new Date();
35118
35173
  try {
35119
- _id = new import_mongodb87.ObjectId(_id);
35174
+ _id = new import_mongodb88.ObjectId(_id);
35120
35175
  } catch (error) {
35121
35176
  throw new import_node_server_utils150.BadRequestError("Invalid ID format.");
35122
35177
  }
35123
35178
  if (value.site && typeof value.site === "string") {
35124
35179
  try {
35125
- value.site = new import_mongodb87.ObjectId(value.site);
35180
+ value.site = new import_mongodb88.ObjectId(value.site);
35126
35181
  } catch {
35127
35182
  throw new Error("Invalid site ID.");
35128
35183
  }
@@ -35153,7 +35208,7 @@ function useEventManagementRepo() {
35153
35208
  }
35154
35209
  async function deleteEventManagementById(_id) {
35155
35210
  try {
35156
- _id = new import_mongodb87.ObjectId(_id);
35211
+ _id = new import_mongodb88.ObjectId(_id);
35157
35212
  } catch (error) {
35158
35213
  throw new import_node_server_utils150.BadRequestError("Invalid event ID format.");
35159
35214
  }
@@ -35441,7 +35496,7 @@ function useEventManagementController() {
35441
35496
 
35442
35497
  // src/models/site-unit-billing.model.ts
35443
35498
  var import_node_server_utils153 = require("@7365admin1/node-server-utils");
35444
- var import_mongodb88 = require("mongodb");
35499
+ var import_mongodb89 = require("mongodb");
35445
35500
  var import_joi85 = __toESM(require("joi"));
35446
35501
  var Status = /* @__PURE__ */ ((Status2) => {
35447
35502
  Status2["PENDING"] = "pending";
@@ -35536,48 +35591,48 @@ function MUnitBilling(value) {
35536
35591
  }
35537
35592
  if (value._id && typeof value._id === "string") {
35538
35593
  try {
35539
- value._id = new import_mongodb88.ObjectId(value._id);
35594
+ value._id = new import_mongodb89.ObjectId(value._id);
35540
35595
  } catch {
35541
35596
  throw new import_node_server_utils153.BadRequestError("Invalid _id format");
35542
35597
  }
35543
35598
  }
35544
35599
  if (value.site && typeof value.site === "string") {
35545
35600
  try {
35546
- value.site = new import_mongodb88.ObjectId(value.site);
35601
+ value.site = new import_mongodb89.ObjectId(value.site);
35547
35602
  } catch {
35548
35603
  throw new import_node_server_utils153.BadRequestError("Invalid site id format");
35549
35604
  }
35550
35605
  }
35551
35606
  if (value.org && typeof value.org === "string") {
35552
35607
  try {
35553
- value.org = new import_mongodb88.ObjectId(value.org);
35608
+ value.org = new import_mongodb89.ObjectId(value.org);
35554
35609
  } catch {
35555
35610
  throw new import_node_server_utils153.BadRequestError("Invalid org id format");
35556
35611
  }
35557
35612
  }
35558
35613
  if (value.paidBy && typeof value.paidBy === "string") {
35559
35614
  try {
35560
- value.paidBy = new import_mongodb88.ObjectId(value.paidBy);
35615
+ value.paidBy = new import_mongodb89.ObjectId(value.paidBy);
35561
35616
  } catch {
35562
35617
  throw new import_node_server_utils153.BadRequestError("Invalid paidBy id format");
35563
35618
  }
35564
35619
  }
35565
35620
  if (value.billItem && typeof value.billItem === "string") {
35566
35621
  try {
35567
- value.billItem = new import_mongodb88.ObjectId(value.billItem);
35622
+ value.billItem = new import_mongodb89.ObjectId(value.billItem);
35568
35623
  } catch {
35569
35624
  throw new import_node_server_utils153.BadRequestError("Invalid billItem id format");
35570
35625
  }
35571
35626
  }
35572
35627
  if (value.unitId && typeof value.unitId === "string") {
35573
35628
  try {
35574
- value.unitId = new import_mongodb88.ObjectId(value.unitId);
35629
+ value.unitId = new import_mongodb89.ObjectId(value.unitId);
35575
35630
  } catch {
35576
35631
  throw new import_node_server_utils153.BadRequestError("Invalid unitId id format");
35577
35632
  }
35578
35633
  }
35579
35634
  return {
35580
- _id: value._id ?? new import_mongodb88.ObjectId(),
35635
+ _id: value._id ?? new import_mongodb89.ObjectId(),
35581
35636
  site: value.site ?? "",
35582
35637
  org: value.org ?? "",
35583
35638
  billItem: value.billItem ?? "",
@@ -35613,7 +35668,7 @@ function MUnitBilling(value) {
35613
35668
 
35614
35669
  // src/repositories/site-unit-billing.repo.ts
35615
35670
  var import_node_server_utils154 = require("@7365admin1/node-server-utils");
35616
- var import_mongodb89 = require("mongodb");
35671
+ var import_mongodb90 = require("mongodb");
35617
35672
  function useSiteUnitBillingRepo() {
35618
35673
  const db = import_node_server_utils154.useAtlas.getDb();
35619
35674
  if (!db) {
@@ -35663,7 +35718,7 @@ function useSiteUnitBillingRepo() {
35663
35718
  const res = await collection.insertOne(value, { session });
35664
35719
  const acronym = createAcronym(value.billName || "NA");
35665
35720
  const dateFormatted = formatDateString(/* @__PURE__ */ new Date());
35666
- const newId = new import_mongodb89.ObjectId(res.insertedId).toString().slice(-6);
35721
+ const newId = new import_mongodb90.ObjectId(res.insertedId).toString().slice(-6);
35667
35722
  const referenceNumber = `${acronym}${newId}${dateFormatted}`;
35668
35723
  await collection.updateOne(
35669
35724
  { _id: res.insertedId },
@@ -35741,7 +35796,7 @@ function useSiteUnitBillingRepo() {
35741
35796
  }
35742
35797
  ]
35743
35798
  },
35744
- ...import_mongodb89.ObjectId.isValid(site) && { site: new import_mongodb89.ObjectId(site) },
35799
+ ...import_mongodb90.ObjectId.isValid(site) && { site: new import_mongodb90.ObjectId(site) },
35745
35800
  ...dateExpr
35746
35801
  };
35747
35802
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
@@ -35807,7 +35862,7 @@ function useSiteUnitBillingRepo() {
35807
35862
  }
35808
35863
  async function getById(_id) {
35809
35864
  try {
35810
- _id = new import_mongodb89.ObjectId(_id);
35865
+ _id = new import_mongodb90.ObjectId(_id);
35811
35866
  } catch (error) {
35812
35867
  throw new import_node_server_utils154.BadRequestError("Invalid ID.");
35813
35868
  }
@@ -35866,8 +35921,8 @@ function useSiteUnitBillingRepo() {
35866
35921
  }
35867
35922
  const query = {
35868
35923
  status,
35869
- ...unitId && import_mongodb89.ObjectId.isValid(unitId) && { unitId: new import_mongodb89.ObjectId(unitId) },
35870
- ...site && import_mongodb89.ObjectId.isValid(site) && { site: new import_mongodb89.ObjectId(site) },
35924
+ ...unitId && import_mongodb90.ObjectId.isValid(unitId) && { unitId: new import_mongodb90.ObjectId(unitId) },
35925
+ ...site && import_mongodb90.ObjectId.isValid(site) && { site: new import_mongodb90.ObjectId(site) },
35871
35926
  ...dateExpr
35872
35927
  };
35873
35928
  try {
@@ -35905,43 +35960,43 @@ function useSiteUnitBillingRepo() {
35905
35960
  }
35906
35961
  async function updateById(_id, value, session) {
35907
35962
  try {
35908
- _id = new import_mongodb89.ObjectId(_id);
35963
+ _id = new import_mongodb90.ObjectId(_id);
35909
35964
  } catch (error) {
35910
35965
  throw new import_node_server_utils154.BadRequestError(
35911
35966
  "Invalid site unit billing transaction ID format."
35912
35967
  );
35913
35968
  }
35914
- if (value.site && import_mongodb89.ObjectId.isValid(value.site.toString())) {
35969
+ if (value.site && import_mongodb90.ObjectId.isValid(value.site.toString())) {
35915
35970
  try {
35916
- value.site = new import_mongodb89.ObjectId(value.site.toString());
35971
+ value.site = new import_mongodb90.ObjectId(value.site.toString());
35917
35972
  } catch {
35918
35973
  throw new import_node_server_utils154.BadRequestError("Invalid _id format");
35919
35974
  }
35920
35975
  }
35921
- if (value.org && import_mongodb89.ObjectId.isValid(value.org.toString())) {
35976
+ if (value.org && import_mongodb90.ObjectId.isValid(value.org.toString())) {
35922
35977
  try {
35923
- value.org = new import_mongodb89.ObjectId(value.org.toString());
35978
+ value.org = new import_mongodb90.ObjectId(value.org.toString());
35924
35979
  } catch {
35925
35980
  throw new import_node_server_utils154.BadRequestError("Invalid _id format");
35926
35981
  }
35927
35982
  }
35928
- if (value.paidBy && import_mongodb89.ObjectId.isValid(value.paidBy.toString())) {
35983
+ if (value.paidBy && import_mongodb90.ObjectId.isValid(value.paidBy.toString())) {
35929
35984
  try {
35930
- value.org = new import_mongodb89.ObjectId(value.paidBy.toString());
35985
+ value.org = new import_mongodb90.ObjectId(value.paidBy.toString());
35931
35986
  } catch {
35932
35987
  throw new import_node_server_utils154.BadRequestError("Invalid _id format");
35933
35988
  }
35934
35989
  }
35935
- if (value.billItem && import_mongodb89.ObjectId.isValid(value.billItem.toString())) {
35990
+ if (value.billItem && import_mongodb90.ObjectId.isValid(value.billItem.toString())) {
35936
35991
  try {
35937
- value.billItem = new import_mongodb89.ObjectId(value.billItem.toString());
35992
+ value.billItem = new import_mongodb90.ObjectId(value.billItem.toString());
35938
35993
  } catch {
35939
35994
  throw new import_node_server_utils154.BadRequestError("Invalid _id format");
35940
35995
  }
35941
35996
  }
35942
- if (value.unitId && import_mongodb89.ObjectId.isValid(value.unitId.toString())) {
35997
+ if (value.unitId && import_mongodb90.ObjectId.isValid(value.unitId.toString())) {
35943
35998
  try {
35944
- value.unitId = new import_mongodb89.ObjectId(value.unitId.toString());
35999
+ value.unitId = new import_mongodb90.ObjectId(value.unitId.toString());
35945
36000
  } catch {
35946
36001
  throw new import_node_server_utils154.BadRequestError("Invalid _id format");
35947
36002
  }
@@ -35961,7 +36016,7 @@ function useSiteUnitBillingRepo() {
35961
36016
  }
35962
36017
  async function deleteById(_id) {
35963
36018
  try {
35964
- _id = new import_mongodb89.ObjectId(_id);
36019
+ _id = new import_mongodb90.ObjectId(_id);
35965
36020
  } catch (error) {
35966
36021
  throw new import_node_server_utils154.BadRequestError(
35967
36022
  "Invalid site unit billing transaction ID format."
@@ -36027,9 +36082,9 @@ function useSiteUnitBillingRepo() {
36027
36082
  }
36028
36083
  ]
36029
36084
  },
36030
- ...import_mongodb89.ObjectId.isValid(site) && { site: new import_mongodb89.ObjectId(site) },
36085
+ ...import_mongodb90.ObjectId.isValid(site) && { site: new import_mongodb90.ObjectId(site) },
36031
36086
  ...dateExpr,
36032
- ...import_mongodb89.ObjectId.isValid(unitId) && { unitId: new import_mongodb89.ObjectId(unitId) }
36087
+ ...import_mongodb90.ObjectId.isValid(unitId) && { unitId: new import_mongodb90.ObjectId(unitId) }
36033
36088
  };
36034
36089
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
36035
36090
  try {
@@ -36116,9 +36171,9 @@ function useSiteUnitBillingRepo() {
36116
36171
  }
36117
36172
  ]
36118
36173
  },
36119
- ...import_mongodb89.ObjectId.isValid(site) && { site: new import_mongodb89.ObjectId(site) },
36174
+ ...import_mongodb90.ObjectId.isValid(site) && { site: new import_mongodb90.ObjectId(site) },
36120
36175
  ...dateExpr,
36121
- ...import_mongodb89.ObjectId.isValid(unitId) && { unitId: new import_mongodb89.ObjectId(unitId) }
36176
+ ...import_mongodb90.ObjectId.isValid(unitId) && { unitId: new import_mongodb90.ObjectId(unitId) }
36122
36177
  };
36123
36178
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
36124
36179
  try {
@@ -36201,7 +36256,7 @@ function useSiteUnitBillingRepo() {
36201
36256
 
36202
36257
  // src/services/site-unit-billing.service.ts
36203
36258
  var import_node_server_utils155 = require("@7365admin1/node-server-utils");
36204
- var import_mongodb90 = require("mongodb");
36259
+ var import_mongodb91 = require("mongodb");
36205
36260
  function useSiteUnitBillingService() {
36206
36261
  const {
36207
36262
  add: _add,
@@ -36358,7 +36413,7 @@ function useSiteUnitBillingService() {
36358
36413
  return unitsWithOwner || [];
36359
36414
  } else {
36360
36415
  if (units && units.length > 0) {
36361
- const unitIds = units.map((unit) => new import_mongodb90.ObjectId(unit._id));
36416
+ const unitIds = units.map((unit) => new import_mongodb91.ObjectId(unit._id));
36362
36417
  const specificUnitsWithOwner = await _getBuildingUnitsWithOwner(
36363
36418
  site || "",
36364
36419
  unitIds
@@ -36639,7 +36694,7 @@ function useSiteUnitBillingController() {
36639
36694
  }
36640
36695
 
36641
36696
  // src/models/access-management.model.ts
36642
- var import_mongodb91 = require("mongodb");
36697
+ var import_mongodb92 = require("mongodb");
36643
36698
  var EAccessCardTypes = /* @__PURE__ */ ((EAccessCardTypes2) => {
36644
36699
  EAccessCardTypes2["NFC"] = "NFC";
36645
36700
  EAccessCardTypes2["QR"] = "QRCODE";
@@ -36661,7 +36716,7 @@ var AccessTypeProps = /* @__PURE__ */ ((AccessTypeProps2) => {
36661
36716
  })(AccessTypeProps || {});
36662
36717
  var MAccessCardTransaction = class {
36663
36718
  constructor({
36664
- _id = new import_mongodb91.ObjectId(),
36719
+ _id = new import_mongodb92.ObjectId(),
36665
36720
  index,
36666
36721
  site,
36667
36722
  cardNo,
@@ -36688,7 +36743,7 @@ var MAccessCardTransaction = class {
36688
36743
  };
36689
36744
  var MAccessCard = class {
36690
36745
  constructor({
36691
- _id = new import_mongodb91.ObjectId(),
36746
+ _id = new import_mongodb92.ObjectId(),
36692
36747
  userId,
36693
36748
  site,
36694
36749
  staffNo = null,
@@ -36746,7 +36801,7 @@ var MAccessCard = class {
36746
36801
 
36747
36802
  // src/repositories/access-management.repo.ts
36748
36803
  var import_node_server_utils157 = require("@7365admin1/node-server-utils");
36749
- var import_mongodb92 = require("mongodb");
36804
+ var import_mongodb93 = require("mongodb");
36750
36805
 
36751
36806
  // src/utils/access-management.ts
36752
36807
  var import_fs4 = __toESM(require("fs"));
@@ -37056,12 +37111,12 @@ function UseAccessManagementRepo() {
37056
37111
  payload
37057
37112
  }) {
37058
37113
  try {
37059
- payload.site = new import_mongodb92.ObjectId(payload.site);
37114
+ payload.site = new import_mongodb93.ObjectId(payload.site);
37060
37115
  payload.startDate = new Date(payload.startDate);
37061
37116
  payload.endDate = new Date(payload.endDate);
37062
37117
  payload.createdAt = new Date(payload.createdAt);
37063
37118
  payload.updatedAt = new Date(payload.updatedAt);
37064
- payload.assignedUnit = payload.unit?.map((id) => new import_mongodb92.ObjectId(id));
37119
+ payload.assignedUnit = payload.unit?.map((id) => new import_mongodb93.ObjectId(id));
37065
37120
  delete payload.unit;
37066
37121
  const accessCardObj = new MAccessCard(payload);
37067
37122
  const result = await collection().insertOne(accessCardObj);
@@ -37100,7 +37155,7 @@ function UseAccessManagementRepo() {
37100
37155
  async function addNonPhysicalCardRepo(params) {
37101
37156
  try {
37102
37157
  const MAX_RETRIES = 3;
37103
- const site = new import_mongodb92.ObjectId(params.site);
37158
+ const site = new import_mongodb93.ObjectId(params.site);
37104
37159
  const date = /* @__PURE__ */ new Date();
37105
37160
  const endDate = new Date(date.setFullYear(date.getFullYear() + 10));
37106
37161
  const countPerUnit = params.quantity;
@@ -37132,7 +37187,7 @@ function UseAccessManagementRepo() {
37132
37187
  userType: params.userType,
37133
37188
  doorName: params.doorName,
37134
37189
  liftName: params.liftName,
37135
- assignedUnit: new import_mongodb92.ObjectId(units[i]),
37190
+ assignedUnit: new import_mongodb93.ObjectId(units[i]),
37136
37191
  createdAt: new Date(params.createdAt),
37137
37192
  updatedAt: new Date(params.updatedAt),
37138
37193
  isWinsland: params.isWinsland
@@ -37218,7 +37273,7 @@ function UseAccessManagementRepo() {
37218
37273
  }
37219
37274
  async function accessManagementSettingsRepo(params) {
37220
37275
  try {
37221
- params.site = new import_mongodb92.ObjectId(params.site);
37276
+ params.site = new import_mongodb93.ObjectId(params.site);
37222
37277
  const result = collectionName("entrypass-settings").updateOne(
37223
37278
  { site: params.site },
37224
37279
  {
@@ -37240,7 +37295,7 @@ function UseAccessManagementRepo() {
37240
37295
  }
37241
37296
  async function allAccessCardsCountsRepo(params) {
37242
37297
  try {
37243
- const site = new import_mongodb92.ObjectId(params.site);
37298
+ const site = new import_mongodb93.ObjectId(params.site);
37244
37299
  const userType = params.userType;
37245
37300
  const result = await collection().aggregate([
37246
37301
  {
@@ -37300,7 +37355,7 @@ function UseAccessManagementRepo() {
37300
37355
  }
37301
37356
  async function availableAccessCardsRepo(params) {
37302
37357
  try {
37303
- const site = new import_mongodb92.ObjectId(params.site);
37358
+ const site = new import_mongodb93.ObjectId(params.site);
37304
37359
  const userType = params.userType;
37305
37360
  const type = params.type;
37306
37361
  const query = {
@@ -37415,7 +37470,7 @@ function UseAccessManagementRepo() {
37415
37470
  }
37416
37471
  async function userTypeAccessCardsRepo(params) {
37417
37472
  try {
37418
- const site = new import_mongodb92.ObjectId(params.site);
37473
+ const site = new import_mongodb93.ObjectId(params.site);
37419
37474
  const userType = params.userType;
37420
37475
  const page = params.page ? Number(params.page) - 1 : 0;
37421
37476
  const limit = Number(params.limit) || 10;
@@ -37814,7 +37869,7 @@ function UseAccessManagementRepo() {
37814
37869
  }
37815
37870
  async function assignedAccessCardsRepo(params) {
37816
37871
  try {
37817
- const site = new import_mongodb92.ObjectId(params.site);
37872
+ const site = new import_mongodb93.ObjectId(params.site);
37818
37873
  const userType = params.userType;
37819
37874
  const type = params.type;
37820
37875
  const search = params.search;
@@ -37989,12 +38044,12 @@ function UseAccessManagementRepo() {
37989
38044
  session?.startTransaction();
37990
38045
  const { userId, cardId, site } = params;
37991
38046
  const allUserId = await Promise.all(
37992
- userId.map(async (id) => new import_mongodb92.ObjectId(id))
38047
+ userId.map(async (id) => new import_mongodb93.ObjectId(id))
37993
38048
  );
37994
38049
  const allCardId = await Promise.all(
37995
- cardId.map(async (id) => new import_mongodb92.ObjectId(id))
38050
+ cardId.map(async (id) => new import_mongodb93.ObjectId(id))
37996
38051
  );
37997
- const siteId = new import_mongodb92.ObjectId(site);
38052
+ const siteId = new import_mongodb93.ObjectId(site);
37998
38053
  const result = await collection().updateMany(
37999
38054
  {
38000
38055
  $or: [
@@ -38025,7 +38080,7 @@ function UseAccessManagementRepo() {
38025
38080
  async function accessandLiftCardsRepo(params) {
38026
38081
  try {
38027
38082
  const { accessLevel, liftAccessLevel, site, userType, type } = params;
38028
- const siteId = new import_mongodb92.ObjectId(site);
38083
+ const siteId = new import_mongodb93.ObjectId(site);
38029
38084
  const query = {
38030
38085
  site: { $in: [siteId] },
38031
38086
  userType,
@@ -38058,9 +38113,9 @@ function UseAccessManagementRepo() {
38058
38113
  const session = import_node_server_utils157.useAtlas.getClient()?.startSession();
38059
38114
  try {
38060
38115
  session?.startTransaction();
38061
- const siteId = new import_mongodb92.ObjectId(params.site);
38062
- const userId = new import_mongodb92.ObjectId(params.userId);
38063
- const cardId = new import_mongodb92.ObjectId(params.cardId);
38116
+ const siteId = new import_mongodb93.ObjectId(params.site);
38117
+ const userId = new import_mongodb93.ObjectId(params.userId);
38118
+ const cardId = new import_mongodb93.ObjectId(params.cardId);
38064
38119
  const quantity = 1;
38065
38120
  const cardCredentials = await collection().findOneAndUpdate(
38066
38121
  { _id: cardId },
@@ -38086,7 +38141,7 @@ function UseAccessManagementRepo() {
38086
38141
  (no) => no.toString().padStart(10, "0")
38087
38142
  );
38088
38143
  const accessCards = [];
38089
- const convertedUnits = unit.map((obj) => new import_mongodb92.ObjectId(obj));
38144
+ const convertedUnits = unit.map((obj) => new import_mongodb93.ObjectId(obj));
38090
38145
  for (let j = 0; j < (unit.length > 0 ? unit.length : quantity); j++) {
38091
38146
  accessCards.push(
38092
38147
  new MAccessCard({
@@ -38175,7 +38230,7 @@ function UseAccessManagementRepo() {
38175
38230
  session?.startTransaction();
38176
38231
  const results = [];
38177
38232
  for (let nfc of params.nfcList) {
38178
- nfc._id = new import_mongodb92.ObjectId(nfc._id);
38233
+ nfc._id = new import_mongodb93.ObjectId(nfc._id);
38179
38234
  const card = await collection().findOne({ _id: nfc._id }, { session });
38180
38235
  if (card) {
38181
38236
  const updateFields = {
@@ -38209,7 +38264,7 @@ function UseAccessManagementRepo() {
38209
38264
  async function doorAndLiftDropdownRepo(params) {
38210
38265
  try {
38211
38266
  const { site, type, userType } = params;
38212
- const id = new import_mongodb92.ObjectId(site);
38267
+ const id = new import_mongodb93.ObjectId(site);
38213
38268
  const res = collection().aggregate([
38214
38269
  {
38215
38270
  $match: {
@@ -38296,10 +38351,10 @@ function UseAccessManagementRepo() {
38296
38351
  const session = import_node_server_utils157.useAtlas.getClient()?.startSession();
38297
38352
  try {
38298
38353
  const { cardId, remarks, issuedCardId, unitId, userId } = params;
38299
- const id = new import_mongodb92.ObjectId(cardId);
38300
- const newCardId = new import_mongodb92.ObjectId(issuedCardId);
38301
- const unit = new import_mongodb92.ObjectId(unitId);
38302
- const user = new import_mongodb92.ObjectId(userId);
38354
+ const id = new import_mongodb93.ObjectId(cardId);
38355
+ const newCardId = new import_mongodb93.ObjectId(issuedCardId);
38356
+ const unit = new import_mongodb93.ObjectId(unitId);
38357
+ const user = new import_mongodb93.ObjectId(userId);
38303
38358
  session?.startTransaction();
38304
38359
  const sessionResult = await Promise.all([
38305
38360
  await collection().findOneAndUpdate(
@@ -38332,7 +38387,7 @@ function UseAccessManagementRepo() {
38332
38387
  async function visitorAccessCardsRepo(params) {
38333
38388
  try {
38334
38389
  const page = params.page ? params.page - 1 : 0;
38335
- const siteId = new import_mongodb92.ObjectId(params.site);
38390
+ const siteId = new import_mongodb93.ObjectId(params.site);
38336
38391
  const search = params.search;
38337
38392
  const type = params.type;
38338
38393
  const limit = Number(params.limit);
@@ -38400,7 +38455,7 @@ function UseAccessManagementRepo() {
38400
38455
  }
38401
38456
  async function getCardReplacementRepo(params) {
38402
38457
  try {
38403
- const site = new import_mongodb92.ObjectId(params.site);
38458
+ const site = new import_mongodb93.ObjectId(params.site);
38404
38459
  const search = params.search;
38405
38460
  const statusFilter = params.statusFilter;
38406
38461
  const dateFrom = params.dateFrom;
@@ -38572,7 +38627,7 @@ function UseAccessManagementRepo() {
38572
38627
  async function getAccessManagementSettingsRepo(params) {
38573
38628
  try {
38574
38629
  const { site } = params;
38575
- const siteId = new import_mongodb92.ObjectId(site);
38630
+ const siteId = new import_mongodb93.ObjectId(site);
38576
38631
  const res = await collectionName("entrypass-settings").findOne(
38577
38632
  { site: siteId },
38578
38633
  { allowDiskUse: true }
@@ -38606,7 +38661,7 @@ function UseAccessManagementRepo() {
38606
38661
  const rawAccessGroup = item["accessGroup (value ex. Full Access, No Access)"];
38607
38662
  const accessGroup = typeof rawAccessGroup === "string" ? rawAccessGroup.split(",").map((v) => v.trim()).filter((v) => v !== "") : [];
38608
38663
  return new MAccessCard({
38609
- site: new import_mongodb92.ObjectId(site),
38664
+ site: new import_mongodb93.ObjectId(site),
38610
38665
  type: "NFC" /* NFC */,
38611
38666
  staffNo: null,
38612
38667
  accessLevel,
@@ -38657,8 +38712,8 @@ function UseAccessManagementRepo() {
38657
38712
  liftAccessLevel
38658
38713
  } = params;
38659
38714
  const [convertedUnits, convertedSite] = await Promise.all([
38660
- Promise.all(units.map((id) => new import_mongodb92.ObjectId(id))),
38661
- new import_mongodb92.ObjectId(site)
38715
+ Promise.all(units.map((id) => new import_mongodb93.ObjectId(id))),
38716
+ new import_mongodb93.ObjectId(site)
38662
38717
  ]);
38663
38718
  const totalRequired = quantity * convertedUnits.length;
38664
38719
  const availableCards = await collection().find({
@@ -38710,7 +38765,7 @@ function UseAccessManagementRepo() {
38710
38765
  async function deleteCardRepo(params) {
38711
38766
  try {
38712
38767
  const { cardId, remarks } = params;
38713
- const id = new import_mongodb92.ObjectId(cardId);
38768
+ const id = new import_mongodb93.ObjectId(cardId);
38714
38769
  const result = await collection().findOneAndUpdate(
38715
38770
  { _id: id },
38716
38771
  {
@@ -38731,8 +38786,8 @@ function UseAccessManagementRepo() {
38731
38786
  async function getCardDetailsRepo(params) {
38732
38787
  try {
38733
38788
  const { siteId, cardId } = params;
38734
- const convertedSiteId = new import_mongodb92.ObjectId(siteId);
38735
- const convertedCardId = new import_mongodb92.ObjectId(cardId);
38789
+ const convertedSiteId = new import_mongodb93.ObjectId(siteId);
38790
+ const convertedCardId = new import_mongodb93.ObjectId(cardId);
38736
38791
  const card = await collection().findOne(
38737
38792
  {
38738
38793
  _id: convertedCardId,
@@ -38781,7 +38836,7 @@ function UseAccessManagementRepo() {
38781
38836
  async function addQrTagRepo(params) {
38782
38837
  try {
38783
38838
  const { site, payload } = params;
38784
- const id = new import_mongodb92.ObjectId(site);
38839
+ const id = new import_mongodb93.ObjectId(site);
38785
38840
  const highestCardNo = await collection().aggregate([
38786
38841
  {
38787
38842
  $match: {
@@ -38815,7 +38870,7 @@ function UseAccessManagementRepo() {
38815
38870
  );
38816
38871
  const bulkOps = await Promise.all(
38817
38872
  payload.map(async (doc, index) => {
38818
- const id2 = new import_mongodb92.ObjectId(doc._id);
38873
+ const id2 = new import_mongodb93.ObjectId(doc._id);
38819
38874
  return {
38820
38875
  updateOne: {
38821
38876
  filter: { _id: id2 },
@@ -38838,7 +38893,7 @@ function UseAccessManagementRepo() {
38838
38893
  async function allQrTagRepo(params) {
38839
38894
  try {
38840
38895
  const { site } = params;
38841
- const siteId = new import_mongodb92.ObjectId(site);
38896
+ const siteId = new import_mongodb93.ObjectId(site);
38842
38897
  const query = {
38843
38898
  site: siteId,
38844
38899
  assignedUnit: { $ne: null },
@@ -38887,8 +38942,8 @@ function UseAccessManagementRepo() {
38887
38942
  }
38888
38943
  async function availableCardContractorsRepo(params) {
38889
38944
  try {
38890
- const siteId = new import_mongodb92.ObjectId(params.siteId);
38891
- const unitId = new import_mongodb92.ObjectId(params.unitId);
38945
+ const siteId = new import_mongodb93.ObjectId(params.siteId);
38946
+ const unitId = new import_mongodb93.ObjectId(params.unitId);
38892
38947
  const page = Number(params.page) - 1;
38893
38948
  const limit = Number(params.limit) || 10;
38894
38949
  const type = params.type;
@@ -38989,8 +39044,8 @@ function UseAccessManagementRepo() {
38989
39044
  }
38990
39045
  async function vmsgenerateQrCodesRepo(params) {
38991
39046
  try {
38992
- const site = new import_mongodb92.ObjectId(params.site);
38993
- const unitId = new import_mongodb92.ObjectId(params.unitId);
39047
+ const site = new import_mongodb93.ObjectId(params.site);
39048
+ const unitId = new import_mongodb93.ObjectId(params.unitId);
38994
39049
  const quantity = Number(params.quantity);
38995
39050
  const normalizedUnitId = params.normalizedUnitId;
38996
39051
  const date = /* @__PURE__ */ new Date();
@@ -39045,11 +39100,11 @@ function UseAccessManagementRepo() {
39045
39100
  let isAborted = false;
39046
39101
  try {
39047
39102
  await session?.startTransaction();
39048
- const siteId = new import_mongodb92.ObjectId(params.site);
39049
- const unitId = new import_mongodb92.ObjectId(params.unitId);
39103
+ const siteId = new import_mongodb93.ObjectId(params.site);
39104
+ const unitId = new import_mongodb93.ObjectId(params.unitId);
39050
39105
  const quantity = params.quantity;
39051
39106
  const type = params.type;
39052
- const visitorId = new import_mongodb92.ObjectId(params.visitorId);
39107
+ const visitorId = new import_mongodb93.ObjectId(params.visitorId);
39053
39108
  const nfcCards = params.nfcCards;
39054
39109
  const acm_url = params.acm_url;
39055
39110
  let cards = [];
@@ -39071,7 +39126,7 @@ function UseAccessManagementRepo() {
39071
39126
  } else if (type === "NFC" /* NFC */) {
39072
39127
  if (nfcCards && nfcCards.length > 0) {
39073
39128
  const objectIds = nfcCards.map(
39074
- (card) => new import_mongodb92.ObjectId(card._id)
39129
+ (card) => new import_mongodb93.ObjectId(card._id)
39075
39130
  );
39076
39131
  cards = await collection().find({ _id: { $in: objectIds } }).toArray();
39077
39132
  const nfcList = objectIds.map((card) => ({
@@ -39178,7 +39233,7 @@ function UseAccessManagementRepo() {
39178
39233
  }
39179
39234
  async function signQrCodeRepo(params) {
39180
39235
  try {
39181
- const cardId = new import_mongodb92.ObjectId(params.cardId);
39236
+ const cardId = new import_mongodb93.ObjectId(params.cardId);
39182
39237
  const purpose = params.purpose;
39183
39238
  let validity = 5;
39184
39239
  const card = await collection().findOne({ _id: cardId });
@@ -39203,7 +39258,7 @@ function UseAccessManagementRepo() {
39203
39258
  const session = import_node_server_utils157.useAtlas.getClient()?.startSession();
39204
39259
  try {
39205
39260
  await session?.startTransaction();
39206
- const userId = new import_mongodb92.ObjectId(params.userId);
39261
+ const userId = new import_mongodb93.ObjectId(params.userId);
39207
39262
  const result = await collection().updateMany(
39208
39263
  { userId },
39209
39264
  { $set: { userId: null, status: "Available", updatedAt: /* @__PURE__ */ new Date() } }
@@ -39218,7 +39273,7 @@ function UseAccessManagementRepo() {
39218
39273
  }
39219
39274
  }
39220
39275
  async function getBlockLevelAndUnitListRepo(params) {
39221
- const site = new import_mongodb92.ObjectId(params.site);
39276
+ const site = new import_mongodb93.ObjectId(params.site);
39222
39277
  try {
39223
39278
  const blocks = await collectionName("buildings").aggregate([
39224
39279
  {
@@ -39288,7 +39343,7 @@ function UseAccessManagementRepo() {
39288
39343
  url
39289
39344
  }) {
39290
39345
  page = page ? page - 1 : 0;
39291
- site = new import_mongodb92.ObjectId(site);
39346
+ site = new import_mongodb93.ObjectId(site);
39292
39347
  try {
39293
39348
  let index = await collectionName("access-card-transactions").findOne(
39294
39349
  {},
@@ -39423,9 +39478,9 @@ function UseAccessManagementRepo() {
39423
39478
  throw new Error("No user to Assign.");
39424
39479
  }
39425
39480
  assignees = assignees.map(
39426
- (data) => new import_mongodb92.ObjectId(data)
39481
+ (data) => new import_mongodb93.ObjectId(data)
39427
39482
  );
39428
- unit = new import_mongodb92.ObjectId(unit);
39483
+ unit = new import_mongodb93.ObjectId(unit);
39429
39484
  let availableCards = [];
39430
39485
  let update = [];
39431
39486
  let cards = [];
@@ -39458,13 +39513,13 @@ function UseAccessManagementRepo() {
39458
39513
  throw new Error(`Not enough ${type} cards available.`);
39459
39514
  }
39460
39515
  cards = availableCards?.slice(0, assignees.length).map((card, index) => {
39461
- const userId = new import_mongodb92.ObjectId(assignees[index].toString());
39516
+ const userId = new import_mongodb93.ObjectId(assignees[index].toString());
39462
39517
  card.staffNo = userId.toString().slice(-10);
39463
39518
  return card;
39464
39519
  });
39465
39520
  update = availableCards.slice(0, assignees.length).map((card, index) => ({
39466
39521
  _id: card._id,
39467
- userId: new import_mongodb92.ObjectId(assignees[index])
39522
+ userId: new import_mongodb93.ObjectId(assignees[index])
39468
39523
  }));
39469
39524
  const commands = cards.map((item, index) => {
39470
39525
  let ag = null;
@@ -39530,7 +39585,7 @@ function UseAccessManagementRepo() {
39530
39585
  const session = import_node_server_utils157.useAtlas.getClient()?.startSession();
39531
39586
  try {
39532
39587
  session?.startTransaction();
39533
- const id = new import_mongodb92.ObjectId(userId);
39588
+ const id = new import_mongodb93.ObjectId(userId);
39534
39589
  await collection().updateMany(
39535
39590
  { userId: id },
39536
39591
  { $set: { userId: null, status: "Available" } },
@@ -39550,8 +39605,8 @@ function UseAccessManagementRepo() {
39550
39605
  id,
39551
39606
  name
39552
39607
  }) {
39553
- site = new import_mongodb92.ObjectId(site);
39554
- id = new import_mongodb92.ObjectId(id);
39608
+ site = new import_mongodb93.ObjectId(site);
39609
+ id = new import_mongodb93.ObjectId(id);
39555
39610
  try {
39556
39611
  const result = await collectionName("sites").updateOne(
39557
39612
  { _id: site },
@@ -39568,9 +39623,9 @@ function UseAccessManagementRepo() {
39568
39623
  unitId
39569
39624
  }) {
39570
39625
  try {
39571
- orgId = new import_mongodb92.ObjectId(orgId);
39572
- siteId = new import_mongodb92.ObjectId(siteId);
39573
- unitId = new import_mongodb92.ObjectId(unitId);
39626
+ orgId = new import_mongodb93.ObjectId(orgId);
39627
+ siteId = new import_mongodb93.ObjectId(siteId);
39628
+ unitId = new import_mongodb93.ObjectId(unitId);
39574
39629
  const result = await collectionName("users").aggregate([
39575
39630
  {
39576
39631
  $match: {
@@ -39608,8 +39663,8 @@ function UseAccessManagementRepo() {
39608
39663
  isLiftCard
39609
39664
  }) {
39610
39665
  try {
39611
- siteId = new import_mongodb92.ObjectId(siteId);
39612
- userId = new import_mongodb92.ObjectId(userId);
39666
+ siteId = new import_mongodb93.ObjectId(siteId);
39667
+ userId = new import_mongodb93.ObjectId(userId);
39613
39668
  const query = {
39614
39669
  site: siteId,
39615
39670
  userId,
@@ -39630,7 +39685,7 @@ function UseAccessManagementRepo() {
39630
39685
  }
39631
39686
  }
39632
39687
  async function removeTemplateRepo({ site }) {
39633
- site = new import_mongodb92.ObjectId(site);
39688
+ site = new import_mongodb93.ObjectId(site);
39634
39689
  try {
39635
39690
  const result = await collectionName("entrypass-settings").updateOne({ _id: site }, { $set: { "settings.template": {} } });
39636
39691
  return result;
@@ -39643,8 +39698,8 @@ function UseAccessManagementRepo() {
39643
39698
  page = page ? page - 1 : 0;
39644
39699
  let defaultQuery = {};
39645
39700
  let searchQuery = {};
39646
- site = new import_mongodb92.ObjectId(site);
39647
- userId = new import_mongodb92.ObjectId(userId);
39701
+ site = new import_mongodb93.ObjectId(site);
39702
+ userId = new import_mongodb93.ObjectId(userId);
39648
39703
  if (search) {
39649
39704
  searchQuery = {
39650
39705
  $or: [{ fullName: { $regex: search, $options: "i" } }, { cardNo: { $regex: search, $options: "i" } }]
@@ -41390,7 +41445,7 @@ function useAccessManagementController() {
41390
41445
  }
41391
41446
 
41392
41447
  // src/models/nfc-patrol-tag.model.ts
41393
- var import_mongodb93 = require("mongodb");
41448
+ var import_mongodb94 = require("mongodb");
41394
41449
  var import_joi88 = __toESM(require("joi"));
41395
41450
  var import_node_server_utils158 = require("@7365admin1/node-server-utils");
41396
41451
  var DEVICE_STATUS = {
@@ -41417,27 +41472,27 @@ var schemaNfcPatrolTag = import_joi88.default.object({
41417
41472
  function MNfcPatrolTag(value) {
41418
41473
  if (value._id && typeof value._id === "string") {
41419
41474
  try {
41420
- value._id = new import_mongodb93.ObjectId(value._id);
41475
+ value._id = new import_mongodb94.ObjectId(value._id);
41421
41476
  } catch {
41422
41477
  throw new import_node_server_utils158.BadRequestError("Invalid ID.");
41423
41478
  }
41424
41479
  }
41425
41480
  if (value.site && typeof value.site === "string") {
41426
41481
  try {
41427
- value.site = new import_mongodb93.ObjectId(value.site);
41482
+ value.site = new import_mongodb94.ObjectId(value.site);
41428
41483
  } catch {
41429
41484
  throw new import_node_server_utils158.BadRequestError("Invalid site ID.");
41430
41485
  }
41431
41486
  }
41432
41487
  if (value.createdBy && typeof value.createdBy === "string") {
41433
41488
  try {
41434
- value.createdBy = new import_mongodb93.ObjectId(value.createdBy);
41489
+ value.createdBy = new import_mongodb94.ObjectId(value.createdBy);
41435
41490
  } catch {
41436
41491
  throw new import_node_server_utils158.BadRequestError("Invalid Created By ID.");
41437
41492
  }
41438
41493
  }
41439
41494
  return {
41440
- _id: value._id ?? new import_mongodb93.ObjectId(),
41495
+ _id: value._id ?? new import_mongodb94.ObjectId(),
41441
41496
  site: value.site,
41442
41497
  tagID: value.tagID,
41443
41498
  name: value.name,
@@ -41449,7 +41504,7 @@ function MNfcPatrolTag(value) {
41449
41504
 
41450
41505
  // src/repositories/nfc-patrol-tag.repository.ts
41451
41506
  var import_node_server_utils159 = require("@7365admin1/node-server-utils");
41452
- var import_mongodb94 = require("mongodb");
41507
+ var import_mongodb95 = require("mongodb");
41453
41508
  function useNfcPatrolTagRepo() {
41454
41509
  const db = import_node_server_utils159.useAtlas.getDb();
41455
41510
  if (!db) {
@@ -41503,7 +41558,7 @@ function useNfcPatrolTagRepo() {
41503
41558
  }, session) {
41504
41559
  page = page > 0 ? page - 1 : 0;
41505
41560
  try {
41506
- site = new import_mongodb94.ObjectId(site);
41561
+ site = new import_mongodb95.ObjectId(site);
41507
41562
  } catch (error) {
41508
41563
  throw new import_node_server_utils159.BadRequestError("Invalid site ID format.");
41509
41564
  }
@@ -41547,19 +41602,19 @@ function useNfcPatrolTagRepo() {
41547
41602
  const [updateType, findObject, setData, session] = args;
41548
41603
  if (findObject?.site && typeof findObject.site === "string") {
41549
41604
  try {
41550
- findObject.site = new import_mongodb94.ObjectId(findObject.site);
41605
+ findObject.site = new import_mongodb95.ObjectId(findObject.site);
41551
41606
  } catch {
41552
41607
  throw new import_node_server_utils159.BadRequestError("Invalid site ID.");
41553
41608
  }
41554
41609
  }
41555
41610
  if (updateType == "Edit" && findObject?._id && typeof findObject._id === "string") {
41556
41611
  try {
41557
- findObject._id = new import_mongodb94.ObjectId(findObject._id);
41612
+ findObject._id = new import_mongodb95.ObjectId(findObject._id);
41558
41613
  } catch {
41559
41614
  throw new import_node_server_utils159.BadRequestError("Invalid nfc patrol tag document ID.");
41560
41615
  }
41561
41616
  try {
41562
- setData.updatedBy = new import_mongodb94.ObjectId(setData.updatedBy);
41617
+ setData.updatedBy = new import_mongodb95.ObjectId(setData.updatedBy);
41563
41618
  } catch {
41564
41619
  throw new import_node_server_utils159.BadRequestError("Invalid updatedBy ID.");
41565
41620
  }
@@ -41850,7 +41905,7 @@ function useNfcPatrolTagController() {
41850
41905
  }
41851
41906
 
41852
41907
  // src/models/occurrence-book.model.ts
41853
- var import_mongodb95 = require("mongodb");
41908
+ var import_mongodb96 = require("mongodb");
41854
41909
  var import_joi90 = __toESM(require("joi"));
41855
41910
  var DOBStatus = /* @__PURE__ */ ((DOBStatus3) => {
41856
41911
  DOBStatus3["OPEN"] = "open";
@@ -41876,20 +41931,20 @@ var schemaUpdateOccurrenceBook = import_joi90.default.object({
41876
41931
  function MOccurrenceBook(value) {
41877
41932
  if (value._id && typeof value._id === "string") {
41878
41933
  try {
41879
- value._id = new import_mongodb95.ObjectId(value._id);
41934
+ value._id = new import_mongodb96.ObjectId(value._id);
41880
41935
  } catch {
41881
41936
  throw new Error("Invalid ID.");
41882
41937
  }
41883
41938
  }
41884
41939
  if (value.site && typeof value.site === "string") {
41885
41940
  try {
41886
- value.site = new import_mongodb95.ObjectId(value.site);
41941
+ value.site = new import_mongodb96.ObjectId(value.site);
41887
41942
  } catch {
41888
41943
  throw new Error("Invalid site ID.");
41889
41944
  }
41890
41945
  }
41891
41946
  return {
41892
- _id: value._id ?? new import_mongodb95.ObjectId(),
41947
+ _id: value._id ?? new import_mongodb96.ObjectId(),
41893
41948
  site: value.site,
41894
41949
  date: value.date ?? "",
41895
41950
  totalInput: value.totalInput ?? 0,
@@ -41904,7 +41959,7 @@ function MOccurrenceBook(value) {
41904
41959
 
41905
41960
  // src/repositories/occurrence-book.repo.ts
41906
41961
  var import_node_server_utils162 = require("@7365admin1/node-server-utils");
41907
- var import_mongodb96 = require("mongodb");
41962
+ var import_mongodb97 = require("mongodb");
41908
41963
  var occurrence_book_namespace_collection = "occurrence-books";
41909
41964
  function useOccurrenceBookRepo() {
41910
41965
  const db = import_node_server_utils162.useAtlas.getDb();
@@ -42048,7 +42103,7 @@ function useOccurrenceBookRepo() {
42048
42103
  }
42049
42104
  async function getOccurrenceBookById(_id, session) {
42050
42105
  try {
42051
- _id = new import_mongodb96.ObjectId(_id);
42106
+ _id = new import_mongodb97.ObjectId(_id);
42052
42107
  } catch (error) {
42053
42108
  throw new import_node_server_utils162.BadRequestError("Invalid occurrence book ID format.");
42054
42109
  }
@@ -42078,7 +42133,7 @@ function useOccurrenceBookRepo() {
42078
42133
  async function updateOccurrenceBookById(_id, value, session) {
42079
42134
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
42080
42135
  try {
42081
- _id = new import_mongodb96.ObjectId(_id);
42136
+ _id = new import_mongodb97.ObjectId(_id);
42082
42137
  } catch (error) {
42083
42138
  throw new import_node_server_utils162.BadRequestError("Invalid ID format.");
42084
42139
  }
@@ -42110,7 +42165,7 @@ function useOccurrenceBookRepo() {
42110
42165
  }
42111
42166
  async function deleteOccurrenceBookById(_id) {
42112
42167
  try {
42113
- _id = new import_mongodb96.ObjectId(_id);
42168
+ _id = new import_mongodb97.ObjectId(_id);
42114
42169
  } catch (error) {
42115
42170
  throw new import_node_server_utils162.BadRequestError("Invalid occurrence book ID format.");
42116
42171
  }
@@ -42495,7 +42550,7 @@ function useOccurrenceBookController() {
42495
42550
  }
42496
42551
 
42497
42552
  // src/models/bulletin-video.model.ts
42498
- var import_mongodb97 = require("mongodb");
42553
+ var import_mongodb98 = require("mongodb");
42499
42554
  var import_joi92 = __toESM(require("joi"));
42500
42555
  var BulletinVideoSort = /* @__PURE__ */ ((BulletinVideoSort2) => {
42501
42556
  BulletinVideoSort2["CREATED_AT"] = "createdAt";
@@ -42523,27 +42578,27 @@ var schemaUpdateBulletinVideo = import_joi92.default.object({
42523
42578
  function MBulletinVideo(value) {
42524
42579
  if (value._id && typeof value._id === "string") {
42525
42580
  try {
42526
- value._id = new import_mongodb97.ObjectId(value._id);
42581
+ value._id = new import_mongodb98.ObjectId(value._id);
42527
42582
  } catch {
42528
42583
  throw new Error("Invalid ID.");
42529
42584
  }
42530
42585
  }
42531
42586
  if (value.site && typeof value.site === "string") {
42532
42587
  try {
42533
- value.site = new import_mongodb97.ObjectId(value.site);
42588
+ value.site = new import_mongodb98.ObjectId(value.site);
42534
42589
  } catch {
42535
42590
  throw new Error("Invalid site ID.");
42536
42591
  }
42537
42592
  }
42538
42593
  if (value.file && typeof value.file === "string") {
42539
42594
  try {
42540
- value.file = new import_mongodb97.ObjectId(value.file);
42595
+ value.file = new import_mongodb98.ObjectId(value.file);
42541
42596
  } catch {
42542
42597
  throw new Error("Invalid file ID.");
42543
42598
  }
42544
42599
  }
42545
42600
  return {
42546
- _id: value._id ?? new import_mongodb97.ObjectId(),
42601
+ _id: value._id ?? new import_mongodb98.ObjectId(),
42547
42602
  site: value.site,
42548
42603
  title: value.title ?? "",
42549
42604
  description: value.description ?? "",
@@ -42556,7 +42611,7 @@ function MBulletinVideo(value) {
42556
42611
 
42557
42612
  // src/repositories/bulletin-video.repo.ts
42558
42613
  var import_node_server_utils165 = require("@7365admin1/node-server-utils");
42559
- var import_mongodb98 = require("mongodb");
42614
+ var import_mongodb99 = require("mongodb");
42560
42615
  function useBulletinVideoRepo() {
42561
42616
  const db = import_node_server_utils165.useAtlas.getDb();
42562
42617
  if (!db) {
@@ -42618,7 +42673,7 @@ function useBulletinVideoRepo() {
42618
42673
  }, session) {
42619
42674
  page = page > 0 ? page - 1 : 0;
42620
42675
  try {
42621
- site = new import_mongodb98.ObjectId(site);
42676
+ site = new import_mongodb99.ObjectId(site);
42622
42677
  } catch (error) {
42623
42678
  throw new import_node_server_utils165.BadRequestError("Invalid site ID format.");
42624
42679
  }
@@ -42698,7 +42753,7 @@ function useBulletinVideoRepo() {
42698
42753
  }
42699
42754
  async function getBulletinVideoById(_id, session) {
42700
42755
  try {
42701
- _id = new import_mongodb98.ObjectId(_id);
42756
+ _id = new import_mongodb99.ObjectId(_id);
42702
42757
  } catch (error) {
42703
42758
  throw new import_node_server_utils165.BadRequestError("Invalid bulletin video ID format.");
42704
42759
  }
@@ -42729,13 +42784,13 @@ function useBulletinVideoRepo() {
42729
42784
  async function updateBulletinVideoById(_id, value, session) {
42730
42785
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
42731
42786
  try {
42732
- _id = new import_mongodb98.ObjectId(_id);
42787
+ _id = new import_mongodb99.ObjectId(_id);
42733
42788
  } catch (error) {
42734
42789
  throw new import_node_server_utils165.BadRequestError("Invalid ID format.");
42735
42790
  }
42736
42791
  if (value.file && typeof value.file === "string") {
42737
42792
  try {
42738
- value.file = new import_mongodb98.ObjectId(value.file);
42793
+ value.file = new import_mongodb99.ObjectId(value.file);
42739
42794
  } catch {
42740
42795
  throw new Error("Invalid file ID.");
42741
42796
  }
@@ -42764,7 +42819,7 @@ function useBulletinVideoRepo() {
42764
42819
  }
42765
42820
  async function deleteBulletinVideoById(_id, session) {
42766
42821
  try {
42767
- _id = new import_mongodb98.ObjectId(_id);
42822
+ _id = new import_mongodb99.ObjectId(_id);
42768
42823
  } catch (error) {
42769
42824
  throw new import_node_server_utils165.BadRequestError("Invalid bulletin video ID format.");
42770
42825
  }
@@ -43028,7 +43083,7 @@ function useBulletinVideoController() {
43028
43083
 
43029
43084
  // src/models/site-soa.model.ts
43030
43085
  var import_node_server_utils168 = require("@7365admin1/node-server-utils");
43031
- var import_mongodb99 = require("mongodb");
43086
+ var import_mongodb100 = require("mongodb");
43032
43087
  var import_joi94 = __toESM(require("joi"));
43033
43088
  var schemaSOABillingItem = import_joi94.default.object({
43034
43089
  _id: import_joi94.default.string().required(),
@@ -43096,28 +43151,28 @@ function MStatementOfAccount(value) {
43096
43151
  }
43097
43152
  if (value._id && typeof value._id === "string") {
43098
43153
  try {
43099
- value._id = new import_mongodb99.ObjectId(value._id);
43154
+ value._id = new import_mongodb100.ObjectId(value._id);
43100
43155
  } catch {
43101
43156
  throw new import_node_server_utils168.BadRequestError("Invalid _id format");
43102
43157
  }
43103
43158
  }
43104
43159
  if (value.site && typeof value.site === "string") {
43105
43160
  try {
43106
- value.site = new import_mongodb99.ObjectId(value.site);
43161
+ value.site = new import_mongodb100.ObjectId(value.site);
43107
43162
  } catch {
43108
43163
  throw new import_node_server_utils168.BadRequestError("Invalid site format");
43109
43164
  }
43110
43165
  }
43111
43166
  if (value.createdBy && typeof value.createdBy === "string") {
43112
43167
  try {
43113
- value.createdBy = new import_mongodb99.ObjectId(value.createdBy);
43168
+ value.createdBy = new import_mongodb100.ObjectId(value.createdBy);
43114
43169
  } catch {
43115
43170
  throw new import_node_server_utils168.BadRequestError("Invalid createBy format");
43116
43171
  }
43117
43172
  }
43118
43173
  if (value.unitId && typeof value.unitId === "string") {
43119
43174
  try {
43120
- value.unitId = new import_mongodb99.ObjectId(value.unitId);
43175
+ value.unitId = new import_mongodb100.ObjectId(value.unitId);
43121
43176
  } catch {
43122
43177
  throw new import_node_server_utils168.BadRequestError("Invalid unitId format");
43123
43178
  }
@@ -43126,7 +43181,7 @@ function MStatementOfAccount(value) {
43126
43181
  value.billing = value.billing.map((bill) => {
43127
43182
  if (bill._id && typeof bill._id === "string") {
43128
43183
  try {
43129
- bill._id = new import_mongodb99.ObjectId(bill._id);
43184
+ bill._id = new import_mongodb100.ObjectId(bill._id);
43130
43185
  } catch {
43131
43186
  throw new import_node_server_utils168.BadRequestError("Invalid billing id format");
43132
43187
  }
@@ -43135,7 +43190,7 @@ function MStatementOfAccount(value) {
43135
43190
  });
43136
43191
  }
43137
43192
  return {
43138
- _id: value._id ?? new import_mongodb99.ObjectId(),
43193
+ _id: value._id ?? new import_mongodb100.ObjectId(),
43139
43194
  site: value.site,
43140
43195
  unitId: value.unitId ?? "",
43141
43196
  unit: value.unit ?? "",
@@ -43158,7 +43213,7 @@ function MStatementOfAccount(value) {
43158
43213
 
43159
43214
  // src/repositories/site-soa.repo.ts
43160
43215
  var import_node_server_utils169 = require("@7365admin1/node-server-utils");
43161
- var import_mongodb100 = require("mongodb");
43216
+ var import_mongodb101 = require("mongodb");
43162
43217
  function useStatementOfAccountRepo() {
43163
43218
  const db = import_node_server_utils169.useAtlas.getDb();
43164
43219
  if (!db) {
@@ -43256,7 +43311,7 @@ function useStatementOfAccountRepo() {
43256
43311
  { category: { $regex: search, $options: "i" } }
43257
43312
  ]
43258
43313
  },
43259
- ...import_mongodb100.ObjectId.isValid(site) && { site: new import_mongodb100.ObjectId(site) },
43314
+ ...import_mongodb101.ObjectId.isValid(site) && { site: new import_mongodb101.ObjectId(site) },
43260
43315
  ...dateExpr
43261
43316
  };
43262
43317
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
@@ -43311,7 +43366,7 @@ function useStatementOfAccountRepo() {
43311
43366
  }
43312
43367
  async function getById(_id) {
43313
43368
  try {
43314
- _id = new import_mongodb100.ObjectId(_id);
43369
+ _id = new import_mongodb101.ObjectId(_id);
43315
43370
  } catch (error) {
43316
43371
  throw new import_node_server_utils169.BadRequestError("Invalid ID.");
43317
43372
  }
@@ -43350,7 +43405,7 @@ function useStatementOfAccountRepo() {
43350
43405
  }
43351
43406
  async function updateById(_id, value, session) {
43352
43407
  try {
43353
- _id = new import_mongodb100.ObjectId(_id);
43408
+ _id = new import_mongodb101.ObjectId(_id);
43354
43409
  } catch (error) {
43355
43410
  throw new import_node_server_utils169.BadRequestError("Invalid site SOA transaction ID format.");
43356
43411
  }
@@ -43369,7 +43424,7 @@ function useStatementOfAccountRepo() {
43369
43424
  }
43370
43425
  async function deleteById(_id) {
43371
43426
  try {
43372
- _id = new import_mongodb100.ObjectId(_id);
43427
+ _id = new import_mongodb101.ObjectId(_id);
43373
43428
  } catch (error) {
43374
43429
  throw new import_node_server_utils169.BadRequestError("Invalid site SOA transaction ID format.");
43375
43430
  }
@@ -43391,7 +43446,7 @@ function useStatementOfAccountRepo() {
43391
43446
  }
43392
43447
  async function updateStatusById(_id, value, session) {
43393
43448
  try {
43394
- _id = new import_mongodb100.ObjectId(_id);
43449
+ _id = new import_mongodb101.ObjectId(_id);
43395
43450
  } catch (error) {
43396
43451
  throw new import_node_server_utils169.BadRequestError("Invalid file ID format.");
43397
43452
  }
@@ -43446,9 +43501,9 @@ function useStatementOfAccountRepo() {
43446
43501
  { category: { $regex: search, $options: "i" } }
43447
43502
  ]
43448
43503
  },
43449
- ...import_mongodb100.ObjectId.isValid(site) && { site: new import_mongodb100.ObjectId(site) },
43504
+ ...import_mongodb101.ObjectId.isValid(site) && { site: new import_mongodb101.ObjectId(site) },
43450
43505
  ...dateExpr,
43451
- ...import_mongodb100.ObjectId.isValid(unitId) && { unitId: new import_mongodb100.ObjectId(unitId) },
43506
+ ...import_mongodb101.ObjectId.isValid(unitId) && { unitId: new import_mongodb101.ObjectId(unitId) },
43452
43507
  ...category && { category }
43453
43508
  };
43454
43509
  sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
@@ -43498,7 +43553,7 @@ function useStatementOfAccountRepo() {
43498
43553
  async function reviewSOA(_id, value, session) {
43499
43554
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
43500
43555
  try {
43501
- _id = new import_mongodb100.ObjectId(_id);
43556
+ _id = new import_mongodb101.ObjectId(_id);
43502
43557
  } catch (error) {
43503
43558
  throw new import_node_server_utils169.BadRequestError("Invalid ID format.");
43504
43559
  }
@@ -43543,7 +43598,7 @@ var import_node_server_utils171 = require("@7365admin1/node-server-utils");
43543
43598
 
43544
43599
  // src/services/site-soa.service.ts
43545
43600
  var import_node_server_utils170 = require("@7365admin1/node-server-utils");
43546
- var import_mongodb101 = require("mongodb");
43601
+ var import_mongodb102 = require("mongodb");
43547
43602
  var import_puppeteer = require("puppeteer");
43548
43603
  function useStatementOfAccountService() {
43549
43604
  const { add: _add, reviewSOA: _reviewSOA } = useStatementOfAccountRepo();
@@ -43680,7 +43735,7 @@ function useStatementOfAccountService() {
43680
43735
  if (!approvedBy || !approvedBy.name)
43681
43736
  throw new import_node_server_utils170.BadRequestError("Created by not found.");
43682
43737
  value.approvedBy.name = approvedBy.name;
43683
- value.approvedBy._id = new import_mongodb101.ObjectId(approvedBy._id);
43738
+ value.approvedBy._id = new import_mongodb102.ObjectId(approvedBy._id);
43684
43739
  }
43685
43740
  await _reviewSOA(id, value, session);
43686
43741
  await session?.commitTransaction();
@@ -44062,7 +44117,7 @@ function useStatementOfAccountController() {
44062
44117
 
44063
44118
  // src/models/site-entrypass-settings.model.ts
44064
44119
  var import_node_server_utils172 = require("@7365admin1/node-server-utils");
44065
- var import_mongodb102 = require("mongodb");
44120
+ var import_mongodb103 = require("mongodb");
44066
44121
  var import_joi96 = __toESM(require("joi"));
44067
44122
  var schemaEntryPassSettings = import_joi96.default.object({
44068
44123
  _id: import_joi96.default.string().hex().optional().allow("", null),
@@ -44110,21 +44165,21 @@ function MEntryPassSettings(value) {
44110
44165
  }
44111
44166
  if (value._id && typeof value._id === "string") {
44112
44167
  try {
44113
- value._id = new import_mongodb102.ObjectId(value._id);
44168
+ value._id = new import_mongodb103.ObjectId(value._id);
44114
44169
  } catch {
44115
44170
  throw new import_node_server_utils172.BadRequestError("Invalid _id format");
44116
44171
  }
44117
44172
  }
44118
44173
  if (value.site && typeof value.site === "string") {
44119
44174
  try {
44120
- value.site = new import_mongodb102.ObjectId(value.site);
44175
+ value.site = new import_mongodb103.ObjectId(value.site);
44121
44176
  } catch {
44122
44177
  throw new import_node_server_utils172.BadRequestError("Invalid site format");
44123
44178
  }
44124
44179
  }
44125
44180
  if (value.org && typeof value.org === "string") {
44126
44181
  try {
44127
- value.org = new import_mongodb102.ObjectId(value.org);
44182
+ value.org = new import_mongodb103.ObjectId(value.org);
44128
44183
  } catch {
44129
44184
  throw new import_node_server_utils172.BadRequestError("Invalid org format");
44130
44185
  }
@@ -44154,7 +44209,7 @@ function MEntryPassSettings(value) {
44154
44209
 
44155
44210
  // src/repositories/site-entrypass-settings.repo.ts
44156
44211
  var import_node_server_utils173 = require("@7365admin1/node-server-utils");
44157
- var import_mongodb103 = require("mongodb");
44212
+ var import_mongodb104 = require("mongodb");
44158
44213
  function useEntryPassSettingsRepo() {
44159
44214
  const db = import_node_server_utils173.useAtlas.getDb();
44160
44215
  if (!db) {
@@ -44264,7 +44319,7 @@ function useEntryPassSettingsRepo() {
44264
44319
  }
44265
44320
  async function getEntryPassSettingsById(_id) {
44266
44321
  try {
44267
- _id = new import_mongodb103.ObjectId(_id);
44322
+ _id = new import_mongodb104.ObjectId(_id);
44268
44323
  } catch (error) {
44269
44324
  throw new import_node_server_utils173.BadRequestError("Invalid entry pass settings ID format.");
44270
44325
  }
@@ -44331,7 +44386,7 @@ function useEntryPassSettingsRepo() {
44331
44386
  }
44332
44387
  async function updateEntryPassSettingsById(_id, value) {
44333
44388
  try {
44334
- _id = new import_mongodb103.ObjectId(_id);
44389
+ _id = new import_mongodb104.ObjectId(_id);
44335
44390
  } catch (error) {
44336
44391
  throw new import_node_server_utils173.BadRequestError("Invalid entry pass settings ID format.");
44337
44392
  }
@@ -44359,7 +44414,7 @@ function useEntryPassSettingsRepo() {
44359
44414
  }
44360
44415
  async function deleteEntryPassSettingsById(_id, session) {
44361
44416
  try {
44362
- _id = new import_mongodb103.ObjectId(_id);
44417
+ _id = new import_mongodb104.ObjectId(_id);
44363
44418
  } catch (error) {
44364
44419
  throw new import_node_server_utils173.BadRequestError("Invalid card ID format.");
44365
44420
  }
@@ -44392,7 +44447,7 @@ function useEntryPassSettingsRepo() {
44392
44447
  }
44393
44448
  async function getEntryPassSettingsBySiteId(site) {
44394
44449
  try {
44395
- site = new import_mongodb103.ObjectId(site);
44450
+ site = new import_mongodb104.ObjectId(site);
44396
44451
  } catch (error) {
44397
44452
  throw new import_node_server_utils173.BadRequestError("Invalid entry pass settings ID format.");
44398
44453
  }
@@ -44459,7 +44514,7 @@ function useEntryPassSettingsRepo() {
44459
44514
  }
44460
44515
  async function updateEntryPassSettingsBySiteId(site, value) {
44461
44516
  try {
44462
- site = new import_mongodb103.ObjectId(site);
44517
+ site = new import_mongodb104.ObjectId(site);
44463
44518
  } catch (error) {
44464
44519
  throw new import_node_server_utils173.BadRequestError("Invalid entry pass settings ID format.");
44465
44520
  }
@@ -44818,7 +44873,7 @@ function useDashboardController() {
44818
44873
  }
44819
44874
 
44820
44875
  // src/models/nfc-patrol-route.model.ts
44821
- var import_mongodb104 = require("mongodb");
44876
+ var import_mongodb105 = require("mongodb");
44822
44877
  var import_joi99 = __toESM(require("joi"));
44823
44878
  var import_node_server_utils177 = require("@7365admin1/node-server-utils");
44824
44879
  var schemaNfcPatrolRoute = import_joi99.default.object({
@@ -44854,23 +44909,23 @@ function MNfcPatrolRoute(value) {
44854
44909
  }
44855
44910
  if (value._id && typeof value._id === "string") {
44856
44911
  try {
44857
- value._id = new import_mongodb104.ObjectId(value._id);
44912
+ value._id = new import_mongodb105.ObjectId(value._id);
44858
44913
  } catch (error2) {
44859
44914
  throw new import_node_server_utils177.BadRequestError("Invalid _id format");
44860
44915
  }
44861
44916
  }
44862
44917
  try {
44863
- value.site = new import_mongodb104.ObjectId(value.site);
44918
+ value.site = new import_mongodb105.ObjectId(value.site);
44864
44919
  } catch (error2) {
44865
44920
  throw new import_node_server_utils177.BadRequestError("Invalid site format");
44866
44921
  }
44867
44922
  try {
44868
- value.createdBy = new import_mongodb104.ObjectId(value.createdBy);
44923
+ value.createdBy = new import_mongodb105.ObjectId(value.createdBy);
44869
44924
  } catch (error2) {
44870
44925
  throw new import_node_server_utils177.BadRequestError("Invalid createdBy format");
44871
44926
  }
44872
44927
  return {
44873
- _id: value._id ?? new import_mongodb104.ObjectId(),
44928
+ _id: value._id ?? new import_mongodb105.ObjectId(),
44874
44929
  site: value.site,
44875
44930
  name: value.name,
44876
44931
  checkPointNumber: value.checkPointNumber,
@@ -44886,7 +44941,7 @@ function MNfcPatrolRoute(value) {
44886
44941
 
44887
44942
  // src/repositories/nfc-patrol-route.repository.ts
44888
44943
  var import_node_server_utils178 = require("@7365admin1/node-server-utils");
44889
- var import_mongodb105 = require("mongodb");
44944
+ var import_mongodb106 = require("mongodb");
44890
44945
  function useNfcPatrolRouteRepo() {
44891
44946
  const db = import_node_server_utils178.useAtlas.getDb();
44892
44947
  if (!db) {
@@ -44930,7 +44985,7 @@ function useNfcPatrolRouteRepo() {
44930
44985
  }, session) {
44931
44986
  page = page > 0 ? page - 1 : 0;
44932
44987
  try {
44933
- site = new import_mongodb105.ObjectId(site);
44988
+ site = new import_mongodb106.ObjectId(site);
44934
44989
  } catch (error) {
44935
44990
  throw new import_node_server_utils178.BadRequestError("Invalid site ID format.");
44936
44991
  }
@@ -45001,7 +45056,7 @@ function useNfcPatrolRouteRepo() {
45001
45056
  }
45002
45057
  async function getById(_id, isStart) {
45003
45058
  try {
45004
- _id = new import_mongodb105.ObjectId(_id);
45059
+ _id = new import_mongodb106.ObjectId(_id);
45005
45060
  } catch (error) {
45006
45061
  throw new import_node_server_utils178.BadRequestError("Invalid ID.");
45007
45062
  }
@@ -45111,18 +45166,18 @@ function useNfcPatrolRouteRepo() {
45111
45166
  throw new import_node_server_utils178.BadRequestError(error.message);
45112
45167
  }
45113
45168
  try {
45114
- _id = new import_mongodb105.ObjectId(_id);
45169
+ _id = new import_mongodb106.ObjectId(_id);
45115
45170
  } catch (error2) {
45116
45171
  throw new import_node_server_utils178.BadRequestError("Invalid ID.");
45117
45172
  }
45118
45173
  try {
45119
- value.site = new import_mongodb105.ObjectId(value.site);
45174
+ value.site = new import_mongodb106.ObjectId(value.site);
45120
45175
  } catch (error2) {
45121
45176
  throw new import_node_server_utils178.BadRequestError("Invalid site format");
45122
45177
  }
45123
45178
  if (value.updatedBy) {
45124
45179
  try {
45125
- value.updatedBy = new import_mongodb105.ObjectId(value.updatedBy);
45180
+ value.updatedBy = new import_mongodb106.ObjectId(value.updatedBy);
45126
45181
  } catch (error2) {
45127
45182
  throw new import_node_server_utils178.BadRequestError("Invalid createdBy format");
45128
45183
  }
@@ -45347,7 +45402,7 @@ function useNfcPatrolRouteController() {
45347
45402
  }
45348
45403
 
45349
45404
  // src/models/incident-report.model.ts
45350
- var import_mongodb106 = require("mongodb");
45405
+ var import_mongodb107 = require("mongodb");
45351
45406
  var import_joi101 = __toESM(require("joi"));
45352
45407
  var residentSchema = import_joi101.default.object({
45353
45408
  _id: import_joi101.default.string().hex().optional().allow(null, ""),
@@ -45553,28 +45608,28 @@ var schemaUpdateIncidentReport = import_joi101.default.object({
45553
45608
  function MIncidentReport(value) {
45554
45609
  if (value._id && typeof value._id === "string") {
45555
45610
  try {
45556
- value._id = new import_mongodb106.ObjectId(value._id);
45611
+ value._id = new import_mongodb107.ObjectId(value._id);
45557
45612
  } catch {
45558
45613
  throw new Error("Invalid incident report ID.");
45559
45614
  }
45560
45615
  }
45561
45616
  if (value.organization && typeof value.organization === "string") {
45562
45617
  try {
45563
- value.organization = new import_mongodb106.ObjectId(value.organization);
45618
+ value.organization = new import_mongodb107.ObjectId(value.organization);
45564
45619
  } catch {
45565
45620
  throw new Error("Invalid organization ID.");
45566
45621
  }
45567
45622
  }
45568
45623
  if (value.site && typeof value.site === "string") {
45569
45624
  try {
45570
- value.site = new import_mongodb106.ObjectId(value.site);
45625
+ value.site = new import_mongodb107.ObjectId(value.site);
45571
45626
  } catch {
45572
45627
  throw new Error("Invalid site ID.");
45573
45628
  }
45574
45629
  }
45575
45630
  if (value.approvedBy && typeof value.approvedBy === "string") {
45576
45631
  try {
45577
- value.approvedBy = new import_mongodb106.ObjectId(value.approvedBy);
45632
+ value.approvedBy = new import_mongodb107.ObjectId(value.approvedBy);
45578
45633
  } catch {
45579
45634
  throw new Error("Invalid approvedBy ID.");
45580
45635
  }
@@ -45582,7 +45637,7 @@ function MIncidentReport(value) {
45582
45637
  const { incidentInformation } = value;
45583
45638
  if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
45584
45639
  try {
45585
- incidentInformation.siteInfo.site = new import_mongodb106.ObjectId(
45640
+ incidentInformation.siteInfo.site = new import_mongodb107.ObjectId(
45586
45641
  incidentInformation.siteInfo.site
45587
45642
  );
45588
45643
  } catch {
@@ -45596,7 +45651,7 @@ function MIncidentReport(value) {
45596
45651
  incidentInformation.submissionForm.dateOfReport = incidentInformation.submissionForm.dateOfReport.toISOString();
45597
45652
  }
45598
45653
  return {
45599
- _id: value._id ?? new import_mongodb106.ObjectId(),
45654
+ _id: value._id ?? new import_mongodb107.ObjectId(),
45600
45655
  reportId: value.reportId,
45601
45656
  incidentInformation: value.incidentInformation,
45602
45657
  affectedEntities: value.affectedEntities,
@@ -45621,7 +45676,7 @@ var import_node_server_utils182 = require("@7365admin1/node-server-utils");
45621
45676
 
45622
45677
  // src/repositories/incident-report.repo.ts
45623
45678
  var import_node_server_utils181 = require("@7365admin1/node-server-utils");
45624
- var import_mongodb107 = require("mongodb");
45679
+ var import_mongodb108 = require("mongodb");
45625
45680
  var incidents_namespace_collection = "incident-reports";
45626
45681
  function useIncidentReportRepo() {
45627
45682
  const db = import_node_server_utils181.useAtlas.getDb();
@@ -45688,7 +45743,7 @@ function useIncidentReportRepo() {
45688
45743
  page = page > 0 ? page - 1 : 0;
45689
45744
  let dateExpr = {};
45690
45745
  try {
45691
- site = new import_mongodb107.ObjectId(site);
45746
+ site = new import_mongodb108.ObjectId(site);
45692
45747
  } catch (error) {
45693
45748
  throw new import_node_server_utils181.BadRequestError("Invalid site ID format.");
45694
45749
  }
@@ -45789,7 +45844,7 @@ function useIncidentReportRepo() {
45789
45844
  page = page > 0 ? page - 1 : 0;
45790
45845
  let dateExpr = {};
45791
45846
  try {
45792
- site = new import_mongodb107.ObjectId(site);
45847
+ site = new import_mongodb108.ObjectId(site);
45793
45848
  } catch (error) {
45794
45849
  throw new import_node_server_utils181.BadRequestError("Invalid site ID format.");
45795
45850
  }
@@ -45858,7 +45913,7 @@ function useIncidentReportRepo() {
45858
45913
  }
45859
45914
  async function getIncidentReportById(_id, session) {
45860
45915
  try {
45861
- _id = new import_mongodb107.ObjectId(_id);
45916
+ _id = new import_mongodb108.ObjectId(_id);
45862
45917
  } catch (error) {
45863
45918
  throw new import_node_server_utils181.BadRequestError("Invalid incident report ID format.");
45864
45919
  }
@@ -45889,27 +45944,27 @@ function useIncidentReportRepo() {
45889
45944
  async function updateIncidentReportById(_id, value, session) {
45890
45945
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
45891
45946
  try {
45892
- _id = new import_mongodb107.ObjectId(_id);
45947
+ _id = new import_mongodb108.ObjectId(_id);
45893
45948
  } catch (error) {
45894
45949
  throw new import_node_server_utils181.BadRequestError("Invalid ID format.");
45895
45950
  }
45896
45951
  if (value.organization && typeof value.organization === "string") {
45897
45952
  try {
45898
- value.organization = new import_mongodb107.ObjectId(value.organization);
45953
+ value.organization = new import_mongodb108.ObjectId(value.organization);
45899
45954
  } catch {
45900
45955
  throw new Error("Invalid organization ID.");
45901
45956
  }
45902
45957
  }
45903
45958
  if (value.site && typeof value.site === "string") {
45904
45959
  try {
45905
- value.site = new import_mongodb107.ObjectId(value.site);
45960
+ value.site = new import_mongodb108.ObjectId(value.site);
45906
45961
  } catch {
45907
45962
  throw new Error("Invalid site ID.");
45908
45963
  }
45909
45964
  }
45910
45965
  if (value.approvedBy && typeof value.approvedBy === "string") {
45911
45966
  try {
45912
- value.approvedBy = new import_mongodb107.ObjectId(value.approvedBy);
45967
+ value.approvedBy = new import_mongodb108.ObjectId(value.approvedBy);
45913
45968
  } catch {
45914
45969
  throw new Error("Invalid approvedBy ID.");
45915
45970
  }
@@ -45917,7 +45972,7 @@ function useIncidentReportRepo() {
45917
45972
  const { incidentInformation } = value;
45918
45973
  if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
45919
45974
  try {
45920
- incidentInformation.siteInfo.site = new import_mongodb107.ObjectId(
45975
+ incidentInformation.siteInfo.site = new import_mongodb108.ObjectId(
45921
45976
  incidentInformation.siteInfo.site
45922
45977
  );
45923
45978
  } catch {
@@ -45952,7 +46007,7 @@ function useIncidentReportRepo() {
45952
46007
  }
45953
46008
  async function deleteIncidentReportById(_id) {
45954
46009
  try {
45955
- _id = new import_mongodb107.ObjectId(_id);
46010
+ _id = new import_mongodb108.ObjectId(_id);
45956
46011
  } catch (error) {
45957
46012
  throw new import_node_server_utils181.BadRequestError("Invalid occurrence subject ID format.");
45958
46013
  }
@@ -45984,7 +46039,7 @@ function useIncidentReportRepo() {
45984
46039
  async function reviewIncidentReport(_id, value, session) {
45985
46040
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
45986
46041
  try {
45987
- _id = new import_mongodb107.ObjectId(_id);
46042
+ _id = new import_mongodb108.ObjectId(_id);
45988
46043
  } catch (error) {
45989
46044
  throw new import_node_server_utils181.BadRequestError("Invalid ID format.");
45990
46045
  }
@@ -46477,7 +46532,7 @@ function useIncidentReportController() {
46477
46532
  }
46478
46533
 
46479
46534
  // src/models/nfc-patrol-settings.model.ts
46480
- var import_mongodb108 = require("mongodb");
46535
+ var import_mongodb109 = require("mongodb");
46481
46536
  var import_joi103 = __toESM(require("joi"));
46482
46537
  var import_node_server_utils184 = require("@7365admin1/node-server-utils");
46483
46538
  var objectId = import_joi103.default.string().hex().length(24);
@@ -46503,7 +46558,7 @@ function MNfcPatrolSettings(value) {
46503
46558
  }
46504
46559
  if (value.site) {
46505
46560
  try {
46506
- value.site = new import_mongodb108.ObjectId(value.site);
46561
+ value.site = new import_mongodb109.ObjectId(value.site);
46507
46562
  } catch (error2) {
46508
46563
  throw new import_node_server_utils184.BadRequestError("Invalid site ID format.");
46509
46564
  }
@@ -46523,7 +46578,7 @@ function MNfcPatrolSettingsUpdate(value) {
46523
46578
  }
46524
46579
  if (value.updatedBy) {
46525
46580
  try {
46526
- value.updatedBy = new import_mongodb108.ObjectId(value.updatedBy);
46581
+ value.updatedBy = new import_mongodb109.ObjectId(value.updatedBy);
46527
46582
  } catch (error2) {
46528
46583
  throw new import_node_server_utils184.BadRequestError("Invalid updatedBy ID format.");
46529
46584
  }
@@ -46537,7 +46592,7 @@ function MNfcPatrolSettingsUpdate(value) {
46537
46592
 
46538
46593
  // src/repositories/nfc-patrol-settings.repository.ts
46539
46594
  var import_node_server_utils185 = require("@7365admin1/node-server-utils");
46540
- var import_mongodb109 = require("mongodb");
46595
+ var import_mongodb110 = require("mongodb");
46541
46596
  function useNfcPatrolSettingsRepository() {
46542
46597
  const db = import_node_server_utils185.useAtlas.getDb();
46543
46598
  if (!db) {
@@ -46567,7 +46622,7 @@ function useNfcPatrolSettingsRepository() {
46567
46622
  }
46568
46623
  async function getNfcPatrolSettingsBySite(site, session) {
46569
46624
  try {
46570
- site = new import_mongodb109.ObjectId(site);
46625
+ site = new import_mongodb110.ObjectId(site);
46571
46626
  } catch (error) {
46572
46627
  throw new import_node_server_utils185.BadRequestError("Invalid nfc patrol settings site ID format.");
46573
46628
  }
@@ -46611,7 +46666,7 @@ function useNfcPatrolSettingsRepository() {
46611
46666
  }
46612
46667
  async function updateNfcPatrolSettings(site, value, session) {
46613
46668
  try {
46614
- site = new import_mongodb109.ObjectId(site);
46669
+ site = new import_mongodb110.ObjectId(site);
46615
46670
  } catch (error) {
46616
46671
  throw new import_node_server_utils185.BadRequestError("Invalid attendance settings ID format.");
46617
46672
  }
@@ -46776,13 +46831,13 @@ function useNfcPatrolSettingsController() {
46776
46831
 
46777
46832
  // src/services/occurrence-entry.service.ts
46778
46833
  var import_node_server_utils189 = require("@7365admin1/node-server-utils");
46779
- var import_mongodb112 = require("mongodb");
46834
+ var import_mongodb113 = require("mongodb");
46780
46835
 
46781
46836
  // src/repositories/occurrence-subject.repo.ts
46782
46837
  var import_node_server_utils188 = require("@7365admin1/node-server-utils");
46783
46838
 
46784
46839
  // src/models/occurrence-subject.model.ts
46785
- var import_mongodb110 = require("mongodb");
46840
+ var import_mongodb111 = require("mongodb");
46786
46841
  var import_joi105 = __toESM(require("joi"));
46787
46842
  var SubjectSort = /* @__PURE__ */ ((SubjectSort2) => {
46788
46843
  SubjectSort2["CREATED_AT"] = "createdAt";
@@ -46807,27 +46862,27 @@ var schemaUpdateOccurrenceSubject = import_joi105.default.object({
46807
46862
  function MOccurrenceSubject(value) {
46808
46863
  if (value._id && typeof value._id === "string") {
46809
46864
  try {
46810
- value._id = new import_mongodb110.ObjectId(value._id);
46865
+ value._id = new import_mongodb111.ObjectId(value._id);
46811
46866
  } catch {
46812
46867
  throw new Error("Invalid ID.");
46813
46868
  }
46814
46869
  }
46815
46870
  if (value.site && typeof value.site === "string") {
46816
46871
  try {
46817
- value.site = new import_mongodb110.ObjectId(value.site);
46872
+ value.site = new import_mongodb111.ObjectId(value.site);
46818
46873
  } catch {
46819
46874
  throw new Error("Invalid site ID.");
46820
46875
  }
46821
46876
  }
46822
46877
  if (value.addedBy && typeof value.addedBy === "string") {
46823
46878
  try {
46824
- value.addedBy = new import_mongodb110.ObjectId(value.addedBy);
46879
+ value.addedBy = new import_mongodb111.ObjectId(value.addedBy);
46825
46880
  } catch {
46826
46881
  throw new Error("Invalid addedBy ID.");
46827
46882
  }
46828
46883
  }
46829
46884
  return {
46830
- _id: value._id ?? new import_mongodb110.ObjectId(),
46885
+ _id: value._id ?? new import_mongodb111.ObjectId(),
46831
46886
  site: value.site,
46832
46887
  subject: value.subject,
46833
46888
  addedBy: value.addedBy ?? "",
@@ -46838,7 +46893,7 @@ function MOccurrenceSubject(value) {
46838
46893
  }
46839
46894
 
46840
46895
  // src/repositories/occurrence-subject.repo.ts
46841
- var import_mongodb111 = require("mongodb");
46896
+ var import_mongodb112 = require("mongodb");
46842
46897
  function useOccurrenceSubjectRepo() {
46843
46898
  const db = import_node_server_utils188.useAtlas.getDb();
46844
46899
  if (!db) {
@@ -46897,7 +46952,7 @@ function useOccurrenceSubjectRepo() {
46897
46952
  }, session) {
46898
46953
  page = page > 0 ? page - 1 : 0;
46899
46954
  try {
46900
- site = new import_mongodb111.ObjectId(site);
46955
+ site = new import_mongodb112.ObjectId(site);
46901
46956
  } catch (error) {
46902
46957
  throw new import_node_server_utils188.BadRequestError("Invalid site ID format.");
46903
46958
  }
@@ -46990,7 +47045,7 @@ function useOccurrenceSubjectRepo() {
46990
47045
  }
46991
47046
  async function getOccurrenceSubjectById(_id, session) {
46992
47047
  try {
46993
- _id = new import_mongodb111.ObjectId(_id);
47048
+ _id = new import_mongodb112.ObjectId(_id);
46994
47049
  } catch (error) {
46995
47050
  throw new import_node_server_utils188.BadRequestError("Invalid occurrence subject ID format.");
46996
47051
  }
@@ -47018,7 +47073,7 @@ function useOccurrenceSubjectRepo() {
47018
47073
  async function updateOccurrenceSubjectById(_id, value, session) {
47019
47074
  value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
47020
47075
  try {
47021
- _id = new import_mongodb111.ObjectId(_id);
47076
+ _id = new import_mongodb112.ObjectId(_id);
47022
47077
  } catch (error) {
47023
47078
  throw new import_node_server_utils188.BadRequestError("Invalid ID format.");
47024
47079
  }
@@ -47048,7 +47103,7 @@ function useOccurrenceSubjectRepo() {
47048
47103
  }
47049
47104
  async function deleteOccurrenceSubjectById(_id) {
47050
47105
  try {
47051
- _id = new import_mongodb111.ObjectId(_id);
47106
+ _id = new import_mongodb112.ObjectId(_id);
47052
47107
  } catch (error) {
47053
47108
  throw new import_node_server_utils188.BadRequestError("Invalid occurrence subject ID format.");
47054
47109
  }
@@ -47179,8 +47234,8 @@ function useOccurrenceEntryService() {
47179
47234
  value.dailyOccurrenceBookId = occurrenceEntry.dailyOccurrenceBookId;
47180
47235
  value.bookEntryCount = value.bookEntryCount ? value.bookEntryCount : occurrenceEntry.bookEntryCount;
47181
47236
  value.occurrence = value.occurrence ? value.occurrence : occurrenceEntry.occurrence;
47182
- value.signature = value.signature ? new import_mongodb112.ObjectId(value.signature) : occurrenceEntry.signature._id;
47183
- value.eSignature = value.eSignature ? new import_mongodb112.ObjectId(value.eSignature) : occurrenceEntry.eSignature;
47237
+ value.signature = value.signature ? new import_mongodb113.ObjectId(value.signature) : occurrenceEntry.signature._id;
47238
+ value.eSignature = value.eSignature ? new import_mongodb113.ObjectId(value.eSignature) : occurrenceEntry.eSignature;
47184
47239
  value.createdAt = /* @__PURE__ */ new Date();
47185
47240
  value.date = value.date ? value.date : occurrenceEntry.date;
47186
47241
  value.userName = value.userName ? value.userName : occurrenceEntry.signature.name;
@@ -47372,7 +47427,7 @@ function useOccurrenceEntryController() {
47372
47427
 
47373
47428
  // src/models/online-form.model.ts
47374
47429
  var import_joi107 = __toESM(require("joi"));
47375
- var import_mongodb113 = require("mongodb");
47430
+ var import_mongodb114 = require("mongodb");
47376
47431
  var schemaOnlineForm = import_joi107.default.object({
47377
47432
  _id: import_joi107.default.string().hex().optional().allow("", null),
47378
47433
  name: import_joi107.default.string().required(),
@@ -47420,21 +47475,21 @@ function MOnlineForm(value) {
47420
47475
  }
47421
47476
  if (value._id && typeof value._id === "string") {
47422
47477
  try {
47423
- value._id = new import_mongodb113.ObjectId(value._id);
47478
+ value._id = new import_mongodb114.ObjectId(value._id);
47424
47479
  } catch (error2) {
47425
47480
  throw new Error("Invalid ID.");
47426
47481
  }
47427
47482
  }
47428
47483
  if (value.org && typeof value.org === "string") {
47429
47484
  try {
47430
- value.org = new import_mongodb113.ObjectId(value.org);
47485
+ value.org = new import_mongodb114.ObjectId(value.org);
47431
47486
  } catch (error2) {
47432
47487
  throw new Error("Invalid org ID.");
47433
47488
  }
47434
47489
  }
47435
47490
  if (value.site && typeof value.site === "string") {
47436
47491
  try {
47437
- value.site = new import_mongodb113.ObjectId(value.site);
47492
+ value.site = new import_mongodb114.ObjectId(value.site);
47438
47493
  } catch (error2) {
47439
47494
  throw new Error("Invalid site ID.");
47440
47495
  }
@@ -47457,7 +47512,7 @@ function MOnlineForm(value) {
47457
47512
 
47458
47513
  // src/repositories/online-form.repo.ts
47459
47514
  var import_node_server_utils191 = require("@7365admin1/node-server-utils");
47460
- var import_mongodb114 = require("mongodb");
47515
+ var import_mongodb115 = require("mongodb");
47461
47516
  function useOnlineFormRepo() {
47462
47517
  const db = import_node_server_utils191.useAtlas.getDb();
47463
47518
  if (!db) {
@@ -47509,7 +47564,7 @@ function useOnlineFormRepo() {
47509
47564
  }) {
47510
47565
  page = page > 0 ? page - 1 : 0;
47511
47566
  try {
47512
- site = new import_mongodb114.ObjectId(site);
47567
+ site = new import_mongodb115.ObjectId(site);
47513
47568
  } catch (error) {
47514
47569
  throw new import_node_server_utils191.BadRequestError("Invalid site ID format.");
47515
47570
  }
@@ -47569,7 +47624,7 @@ function useOnlineFormRepo() {
47569
47624
  }
47570
47625
  async function getOnlineFormById(_id) {
47571
47626
  try {
47572
- _id = new import_mongodb114.ObjectId(_id);
47627
+ _id = new import_mongodb115.ObjectId(_id);
47573
47628
  } catch (error) {
47574
47629
  throw new import_node_server_utils191.BadRequestError("Invalid online form ID format.");
47575
47630
  }
@@ -47612,7 +47667,7 @@ function useOnlineFormRepo() {
47612
47667
  }
47613
47668
  async function updateOnlineFormById(_id, value) {
47614
47669
  try {
47615
- _id = new import_mongodb114.ObjectId(_id);
47670
+ _id = new import_mongodb115.ObjectId(_id);
47616
47671
  } catch (error) {
47617
47672
  throw new import_node_server_utils191.BadRequestError("Invalid online form ID format.");
47618
47673
  }
@@ -47640,7 +47695,7 @@ function useOnlineFormRepo() {
47640
47695
  }
47641
47696
  async function deleteOnlineFormById(_id, session) {
47642
47697
  try {
47643
- _id = new import_mongodb114.ObjectId(_id);
47698
+ _id = new import_mongodb115.ObjectId(_id);
47644
47699
  } catch (error) {
47645
47700
  throw new import_node_server_utils191.BadRequestError("Invalid online form ID format.");
47646
47701
  }
@@ -47673,7 +47728,7 @@ function useOnlineFormRepo() {
47673
47728
  }
47674
47729
  async function getOnlineFormsBySiteId(site, { search = "", page = 1, limit = 10, status = "active" }) {
47675
47730
  try {
47676
- site = new import_mongodb114.ObjectId(site);
47731
+ site = new import_mongodb115.ObjectId(site);
47677
47732
  } catch (error) {
47678
47733
  throw new import_node_server_utils191.BadRequestError(
47679
47734
  "Invalid online form configuration site ID format."
@@ -48105,7 +48160,7 @@ function useOccurrenceSubjectController() {
48105
48160
  }
48106
48161
 
48107
48162
  // src/models/nfc-patrol-log.model.ts
48108
- var import_mongodb115 = require("mongodb");
48163
+ var import_mongodb116 = require("mongodb");
48109
48164
  var import_joi110 = __toESM(require("joi"));
48110
48165
  var import_node_server_utils195 = require("@7365admin1/node-server-utils");
48111
48166
  var schemaNfcPatrolLog = import_joi110.default.object({
@@ -48157,32 +48212,32 @@ function MNfcPatrolLog(valueArg) {
48157
48212
  }
48158
48213
  if (value._id && typeof value._id === "string") {
48159
48214
  try {
48160
- value._id = new import_mongodb115.ObjectId(value._id);
48215
+ value._id = new import_mongodb116.ObjectId(value._id);
48161
48216
  } catch (error2) {
48162
48217
  throw new import_node_server_utils195.BadRequestError("Invalid _id format");
48163
48218
  }
48164
48219
  }
48165
48220
  try {
48166
- value.site = new import_mongodb115.ObjectId(value.site);
48221
+ value.site = new import_mongodb116.ObjectId(value.site);
48167
48222
  } catch (error2) {
48168
48223
  throw new import_node_server_utils195.BadRequestError("Invalid site format");
48169
48224
  }
48170
48225
  if (value?.createdBy) {
48171
48226
  try {
48172
- value.createdBy = new import_mongodb115.ObjectId(value.createdBy);
48227
+ value.createdBy = new import_mongodb116.ObjectId(value.createdBy);
48173
48228
  } catch (error2) {
48174
48229
  throw new import_node_server_utils195.BadRequestError("Invalid createdBy format");
48175
48230
  }
48176
48231
  }
48177
48232
  if (value?.route?._id) {
48178
48233
  try {
48179
- value.route._id = new import_mongodb115.ObjectId(value.route._id);
48234
+ value.route._id = new import_mongodb116.ObjectId(value.route._id);
48180
48235
  } catch (error2) {
48181
48236
  throw new import_node_server_utils195.BadRequestError("Invalid route _id format");
48182
48237
  }
48183
48238
  }
48184
48239
  return {
48185
- _id: value._id ?? new import_mongodb115.ObjectId(),
48240
+ _id: value._id ?? new import_mongodb116.ObjectId(),
48186
48241
  site: value.site,
48187
48242
  route: value.route,
48188
48243
  date: value.date,
@@ -48196,7 +48251,7 @@ function MNfcPatrolLog(valueArg) {
48196
48251
 
48197
48252
  // src/repositories/nfc-patrol-log.repository.ts
48198
48253
  var import_node_server_utils196 = require("@7365admin1/node-server-utils");
48199
- var import_mongodb116 = require("mongodb");
48254
+ var import_mongodb117 = require("mongodb");
48200
48255
  function useNfcPatrolLogRepo() {
48201
48256
  const db = import_node_server_utils196.useAtlas.getDb();
48202
48257
  if (!db) {
@@ -48249,7 +48304,7 @@ function useNfcPatrolLogRepo() {
48249
48304
  const pageIndex = page > 0 ? page - 1 : 0;
48250
48305
  let siteId;
48251
48306
  try {
48252
- siteId = typeof site === "string" ? new import_mongodb116.ObjectId(site) : site;
48307
+ siteId = typeof site === "string" ? new import_mongodb117.ObjectId(site) : site;
48253
48308
  } catch {
48254
48309
  throw new import_node_server_utils196.BadRequestError("Invalid site ID format.");
48255
48310
  }
@@ -48260,7 +48315,7 @@ function useNfcPatrolLogRepo() {
48260
48315
  query.date = date;
48261
48316
  }
48262
48317
  if (route?._id) {
48263
- query["route._id"] = typeof route._id === "string" ? new import_mongodb116.ObjectId(route._id) : route._id;
48318
+ query["route._id"] = typeof route._id === "string" ? new import_mongodb117.ObjectId(route._id) : route._id;
48264
48319
  }
48265
48320
  if (route?.startTime) {
48266
48321
  query["route.startTime"] = route.startTime;
@@ -49119,7 +49174,7 @@ function useNewDashboardController() {
49119
49174
 
49120
49175
  // src/models/manpower-monitoring.model.ts
49121
49176
  var import_joi113 = __toESM(require("joi"));
49122
- var import_mongodb117 = require("mongodb");
49177
+ var import_mongodb118 = require("mongodb");
49123
49178
  var shiftSchema = import_joi113.default.object({
49124
49179
  name: import_joi113.default.string().required(),
49125
49180
  checkIn: import_joi113.default.string().optional().allow("", null),
@@ -49144,7 +49199,7 @@ var manpowerMonitoringSchema = import_joi113.default.object({
49144
49199
  });
49145
49200
  var MManpowerMonitoring = class {
49146
49201
  constructor(data) {
49147
- this._id = new import_mongodb117.ObjectId();
49202
+ this._id = new import_mongodb118.ObjectId();
49148
49203
  this.serviceProviderId = data.serviceProviderId || "";
49149
49204
  this.siteId = data.siteId || "";
49150
49205
  this.siteName = data.siteName;
@@ -49611,7 +49666,7 @@ var hrmlabs_attendance_util_default = {
49611
49666
  };
49612
49667
 
49613
49668
  // src/repositories/manpower-monitoring.repo.ts
49614
- var import_mongodb118 = require("mongodb");
49669
+ var import_mongodb119 = require("mongodb");
49615
49670
  var { hrmLabsAuthentication: hrmLabsAuthentication2, fetchSites: fetchSites2 } = hrmlabs_attendance_util_default;
49616
49671
  function useManpowerMonitoringRepo() {
49617
49672
  const db = import_node_server_utils201.useAtlas.getDb();
@@ -49646,11 +49701,11 @@ function useManpowerMonitoringRepo() {
49646
49701
  try {
49647
49702
  value = new MManpowerMonitoring(value);
49648
49703
  if (value.createdBy)
49649
- value.createdBy = new import_mongodb118.ObjectId(value.createdBy);
49704
+ value.createdBy = new import_mongodb119.ObjectId(value.createdBy);
49650
49705
  if (value.siteId)
49651
- value.siteId = new import_mongodb118.ObjectId(value.siteId);
49706
+ value.siteId = new import_mongodb119.ObjectId(value.siteId);
49652
49707
  if (value.serviceProviderId)
49653
- value.serviceProviderId = new import_mongodb118.ObjectId(value.serviceProviderId);
49708
+ value.serviceProviderId = new import_mongodb119.ObjectId(value.serviceProviderId);
49654
49709
  const result = await collection.insertOne(value, { session });
49655
49710
  return result;
49656
49711
  } catch (error) {
@@ -49691,8 +49746,8 @@ function useManpowerMonitoringRepo() {
49691
49746
  }
49692
49747
  async function getManpowerSettingsBySiteId(_id, serviceProviderId) {
49693
49748
  try {
49694
- _id = new import_mongodb118.ObjectId(_id);
49695
- serviceProviderId = new import_mongodb118.ObjectId(serviceProviderId);
49749
+ _id = new import_mongodb119.ObjectId(_id);
49750
+ serviceProviderId = new import_mongodb119.ObjectId(serviceProviderId);
49696
49751
  } catch (error) {
49697
49752
  throw new Error("Invalid Site ID format.");
49698
49753
  }
@@ -49708,7 +49763,7 @@ function useManpowerMonitoringRepo() {
49708
49763
  }
49709
49764
  async function updateManpowerMonitoringSettings(_id, value) {
49710
49765
  try {
49711
- _id = new import_mongodb118.ObjectId(_id);
49766
+ _id = new import_mongodb119.ObjectId(_id);
49712
49767
  } catch (error) {
49713
49768
  throw new import_node_server_utils201.BadRequestError("Invalid ID format.");
49714
49769
  }
@@ -49735,7 +49790,7 @@ function useManpowerMonitoringRepo() {
49735
49790
  for (let item of value) {
49736
49791
  item = new MManpowerMonitoring(item);
49737
49792
  const data = await collection.findOne({
49738
- siteId: new import_mongodb118.ObjectId(item.siteId)
49793
+ siteId: new import_mongodb119.ObjectId(item.siteId)
49739
49794
  });
49740
49795
  if (data) {
49741
49796
  let updateValue;
@@ -49760,11 +49815,11 @@ function useManpowerMonitoringRepo() {
49760
49815
  }
49761
49816
  } else {
49762
49817
  if (item.createdBy)
49763
- item.createdBy = new import_mongodb118.ObjectId(item.createdBy);
49818
+ item.createdBy = new import_mongodb119.ObjectId(item.createdBy);
49764
49819
  if (item.siteId)
49765
- item.siteId = new import_mongodb118.ObjectId(item.siteId);
49820
+ item.siteId = new import_mongodb119.ObjectId(item.siteId);
49766
49821
  if (item.serviceProviderId)
49767
- item.serviceProviderId = new import_mongodb118.ObjectId(item.serviceProviderId);
49822
+ item.serviceProviderId = new import_mongodb119.ObjectId(item.serviceProviderId);
49768
49823
  const result = await collection.insertOne(item);
49769
49824
  if (result.insertedId) {
49770
49825
  results.inserted++;
@@ -49788,7 +49843,7 @@ function useManpowerMonitoringRepo() {
49788
49843
  const siteUrl = process.env.HRMLABS_SITE_URL;
49789
49844
  try {
49790
49845
  const serviceProvider = await serviceProviderCollection.findOne({
49791
- _id: new import_mongodb118.ObjectId(serviceProviderId)
49846
+ _id: new import_mongodb119.ObjectId(serviceProviderId)
49792
49847
  });
49793
49848
  if (!serviceProvider) {
49794
49849
  throw new Error("Service Provider not found.");
@@ -49831,7 +49886,7 @@ var import_node_server_utils202 = require("@7365admin1/node-server-utils");
49831
49886
 
49832
49887
  // src/models/manpower-remarks.model.ts
49833
49888
  var import_joi114 = __toESM(require("joi"));
49834
- var import_mongodb119 = require("mongodb");
49889
+ var import_mongodb120 = require("mongodb");
49835
49890
  var remarksSchema = import_joi114.default.object({
49836
49891
  name: import_joi114.default.string().required(),
49837
49892
  remark: import_joi114.default.object({
@@ -49855,7 +49910,7 @@ var manpowerRemarksSchema = import_joi114.default.object({
49855
49910
  });
49856
49911
  var MManpowerRemarks = class {
49857
49912
  constructor(data) {
49858
- this._id = new import_mongodb119.ObjectId();
49913
+ this._id = new import_mongodb120.ObjectId();
49859
49914
  this.serviceProviderId = data.serviceProviderId || "";
49860
49915
  this.siteId = data.siteId || "";
49861
49916
  this.siteName = data.siteName || "";
@@ -49873,7 +49928,7 @@ var MManpowerRemarks = class {
49873
49928
  };
49874
49929
 
49875
49930
  // src/repositories/manpower-remarks.repo.ts
49876
- var import_mongodb120 = require("mongodb");
49931
+ var import_mongodb121 = require("mongodb");
49877
49932
  var import_moment_timezone2 = __toESM(require("moment-timezone"));
49878
49933
  function useManpowerRemarksRepo() {
49879
49934
  const db = import_node_server_utils202.useAtlas.getDb();
@@ -49907,9 +49962,9 @@ function useManpowerRemarksRepo() {
49907
49962
  try {
49908
49963
  value = new MManpowerRemarks(value);
49909
49964
  if (value.siteId)
49910
- value.siteId = new import_mongodb120.ObjectId(value.siteId);
49965
+ value.siteId = new import_mongodb121.ObjectId(value.siteId);
49911
49966
  if (value.serviceProviderId)
49912
- value.serviceProviderId = new import_mongodb120.ObjectId(value.serviceProviderId);
49967
+ value.serviceProviderId = new import_mongodb121.ObjectId(value.serviceProviderId);
49913
49968
  const result = await collection.insertOne(value, { session });
49914
49969
  return result;
49915
49970
  } catch (error) {
@@ -49929,7 +49984,7 @@ function useManpowerRemarksRepo() {
49929
49984
  limit = limit || 10;
49930
49985
  const searchQuery = {};
49931
49986
  const nowSGT = (0, import_moment_timezone2.default)().tz("Asia/Singapore");
49932
- searchQuery.serviceProviderId = new import_mongodb120.ObjectId(serviceProviderId);
49987
+ searchQuery.serviceProviderId = new import_mongodb121.ObjectId(serviceProviderId);
49933
49988
  if (search != "") {
49934
49989
  searchQuery.siteName = { $regex: search, $options: "i" };
49935
49990
  }
@@ -49961,8 +50016,8 @@ function useManpowerRemarksRepo() {
49961
50016
  }
49962
50017
  async function getManpowerRemarksBySiteId(_id, date, serviceProviderId) {
49963
50018
  try {
49964
- _id = new import_mongodb120.ObjectId(_id);
49965
- serviceProviderId = new import_mongodb120.ObjectId(serviceProviderId);
50019
+ _id = new import_mongodb121.ObjectId(_id);
50020
+ serviceProviderId = new import_mongodb121.ObjectId(serviceProviderId);
49966
50021
  } catch (error) {
49967
50022
  throw new Error("Invalid Site ID format.");
49968
50023
  }
@@ -49979,13 +50034,13 @@ function useManpowerRemarksRepo() {
49979
50034
  }
49980
50035
  async function updateManpowerRemarks(_id, value) {
49981
50036
  try {
49982
- _id = new import_mongodb120.ObjectId(_id);
50037
+ _id = new import_mongodb121.ObjectId(_id);
49983
50038
  } catch (error) {
49984
50039
  throw new import_node_server_utils202.BadRequestError("Invalid ID format.");
49985
50040
  }
49986
50041
  try {
49987
50042
  if (value.createdBy) {
49988
- value.createdBy = new import_mongodb120.ObjectId(value.createdBy);
50043
+ value.createdBy = new import_mongodb121.ObjectId(value.createdBy);
49989
50044
  }
49990
50045
  const updateValue = {
49991
50046
  ...value,
@@ -50002,7 +50057,7 @@ function useManpowerRemarksRepo() {
50002
50057
  }
50003
50058
  async function updateRemarksStatus(_id, value) {
50004
50059
  try {
50005
- _id = new import_mongodb120.ObjectId(_id);
50060
+ _id = new import_mongodb121.ObjectId(_id);
50006
50061
  } catch (error) {
50007
50062
  throw new import_node_server_utils202.BadRequestError("Invalid ID format.");
50008
50063
  }
@@ -50272,7 +50327,7 @@ function useManpowerMonitoringCtrl() {
50272
50327
 
50273
50328
  // src/models/manpower-designations.model.ts
50274
50329
  var import_joi116 = __toESM(require("joi"));
50275
- var import_mongodb121 = require("mongodb");
50330
+ var import_mongodb122 = require("mongodb");
50276
50331
  var designationsSchema = import_joi116.default.object({
50277
50332
  title: import_joi116.default.string().required(),
50278
50333
  shifts: import_joi116.default.object({
@@ -50291,7 +50346,7 @@ var manpowerDesignationsSchema = import_joi116.default.object({
50291
50346
  });
50292
50347
  var MManpowerDesignations = class {
50293
50348
  constructor(data) {
50294
- this._id = new import_mongodb121.ObjectId();
50349
+ this._id = new import_mongodb122.ObjectId();
50295
50350
  this.siteId = data.siteId || "";
50296
50351
  this.siteName = data.siteName || "";
50297
50352
  this.serviceProviderId = data.serviceProviderId || "";
@@ -50305,7 +50360,7 @@ var MManpowerDesignations = class {
50305
50360
 
50306
50361
  // src/repositories/manpower-designations.repo.ts
50307
50362
  var import_node_server_utils205 = require("@7365admin1/node-server-utils");
50308
- var import_mongodb122 = require("mongodb");
50363
+ var import_mongodb123 = require("mongodb");
50309
50364
  function useManpowerDesignationRepo() {
50310
50365
  const db = import_node_server_utils205.useAtlas.getDb();
50311
50366
  if (!db) {
@@ -50337,11 +50392,11 @@ function useManpowerDesignationRepo() {
50337
50392
  try {
50338
50393
  value = new MManpowerDesignations(value);
50339
50394
  if (value.createdBy)
50340
- value.createdBy = new import_mongodb122.ObjectId(value.createdBy);
50395
+ value.createdBy = new import_mongodb123.ObjectId(value.createdBy);
50341
50396
  if (value.siteId)
50342
- value.siteId = new import_mongodb122.ObjectId(value.siteId);
50397
+ value.siteId = new import_mongodb123.ObjectId(value.siteId);
50343
50398
  if (value.serviceProviderId)
50344
- value.serviceProviderId = new import_mongodb122.ObjectId(value.serviceProviderId);
50399
+ value.serviceProviderId = new import_mongodb123.ObjectId(value.serviceProviderId);
50345
50400
  const result = await collection.insertOne(value);
50346
50401
  return result;
50347
50402
  } catch (error) {
@@ -50350,8 +50405,8 @@ function useManpowerDesignationRepo() {
50350
50405
  }
50351
50406
  async function getManpowerDesignationsBySiteId(_id, serviceProviderId) {
50352
50407
  try {
50353
- _id = new import_mongodb122.ObjectId(_id);
50354
- serviceProviderId = new import_mongodb122.ObjectId(serviceProviderId);
50408
+ _id = new import_mongodb123.ObjectId(_id);
50409
+ serviceProviderId = new import_mongodb123.ObjectId(serviceProviderId);
50355
50410
  } catch (error) {
50356
50411
  throw new Error("Invalid Site ID format.");
50357
50412
  }
@@ -50367,7 +50422,7 @@ function useManpowerDesignationRepo() {
50367
50422
  }
50368
50423
  async function updateManpowerDesignations(_id, value) {
50369
50424
  try {
50370
- _id = new import_mongodb122.ObjectId(_id);
50425
+ _id = new import_mongodb123.ObjectId(_id);
50371
50426
  } catch (error) {
50372
50427
  throw new Error("Invalid ID format.");
50373
50428
  }
@@ -50471,7 +50526,7 @@ function useManpowerDesignationCtrl() {
50471
50526
 
50472
50527
  // src/models/overnight-parking.model.ts
50473
50528
  var import_joi118 = __toESM(require("joi"));
50474
- var import_mongodb123 = require("mongodb");
50529
+ var import_mongodb124 = require("mongodb");
50475
50530
  var dayScheduleSchema = import_joi118.default.object({
50476
50531
  isEnabled: import_joi118.default.boolean().required(),
50477
50532
  startTime: import_joi118.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
@@ -50513,7 +50568,7 @@ function MOvernightParkingApprovalHours(value) {
50513
50568
  }
50514
50569
  if (value.site && typeof value.site === "string") {
50515
50570
  try {
50516
- value.site = new import_mongodb123.ObjectId(value.site);
50571
+ value.site = new import_mongodb124.ObjectId(value.site);
50517
50572
  } catch {
50518
50573
  throw new Error("Invalid site ID.");
50519
50574
  }
@@ -52118,7 +52173,7 @@ function useManpowerRemarkCtrl() {
52118
52173
 
52119
52174
  // src/models/manpower-sites.model.ts
52120
52175
  var import_joi124 = __toESM(require("joi"));
52121
- var import_mongodb124 = require("mongodb");
52176
+ var import_mongodb125 = require("mongodb");
52122
52177
  var manpowerSitesSchema = import_joi124.default.object({
52123
52178
  id: import_joi124.default.string().hex().required(),
52124
52179
  text: import_joi124.default.string().hex().optional().allow("", null),
@@ -52129,7 +52184,7 @@ var manpowerSitesSchema = import_joi124.default.object({
52129
52184
  });
52130
52185
  var MManpowerSites = class {
52131
52186
  constructor(data) {
52132
- this._id = new import_mongodb124.ObjectId();
52187
+ this._id = new import_mongodb125.ObjectId();
52133
52188
  this.id = data.id || "";
52134
52189
  this.text = data.text || "";
52135
52190
  this.contractID = data.contractID || "";
@@ -52339,7 +52394,7 @@ function useManpowerSitesCtrl() {
52339
52394
 
52340
52395
  // src/utils/cron.util.ts
52341
52396
  var import_node_server_utils219 = require("@7365admin1/node-server-utils");
52342
- var import_mongodb125 = require("mongodb");
52397
+ var import_mongodb126 = require("mongodb");
52343
52398
  var import_moment_timezone4 = __toESM(require("moment-timezone"));
52344
52399
  var createManpowerRemarksDaily = async () => {
52345
52400
  const db = import_node_server_utils219.useAtlas.getDb();
@@ -52499,7 +52554,7 @@ var updateRemarksisAcknowledged = async () => {
52499
52554
  for (const id of updatedIds) {
52500
52555
  const doc = await remarks.findOne({ _id: id });
52501
52556
  const setting = await settings.findOne(
52502
- { siteId: new import_mongodb125.ObjectId(doc?.siteId) },
52557
+ { siteId: new import_mongodb126.ObjectId(doc?.siteId) },
52503
52558
  { projection: { emails: 1 } }
52504
52559
  );
52505
52560
  const payload = {
@@ -52585,7 +52640,7 @@ var updateRemarksStatusEod = async () => {
52585
52640
  for (const doc of docs) {
52586
52641
  let shiftsToCheck = [];
52587
52642
  const endShiftTime = await settings.findOne(
52588
- { siteId: new import_mongodb125.ObjectId(doc.siteId) },
52643
+ { siteId: new import_mongodb126.ObjectId(doc.siteId) },
52589
52644
  { projection: { shifts: 1, shiftType: 1 } }
52590
52645
  );
52591
52646
  if (doc.createdAtSGT === nowSGT) {
@@ -52691,7 +52746,7 @@ var isWithinHour = (alertTime, timeNow) => {
52691
52746
 
52692
52747
  // src/events/manpower.event.ts
52693
52748
  var import_node_server_utils220 = require("@7365admin1/node-server-utils");
52694
- var import_mongodb126 = require("mongodb");
52749
+ var import_mongodb127 = require("mongodb");
52695
52750
  var import_moment_timezone5 = __toESM(require("moment-timezone"));
52696
52751
  async function manpowerEvents(io) {
52697
52752
  let intervalId = null;
@@ -52717,7 +52772,7 @@ async function manpowerEvents(io) {
52717
52772
  }).toArray();
52718
52773
  for (const doc of docs) {
52719
52774
  const siteSettings = await settings.findOne(
52720
- { siteId: new import_mongodb126.ObjectId(doc.siteId), enabled: true },
52775
+ { siteId: new import_mongodb127.ObjectId(doc.siteId), enabled: true },
52721
52776
  { projection: { shifts: 1, shiftType: 1 } }
52722
52777
  );
52723
52778
  const shiftType = siteSettings?.shiftType || "2-shifts";
@@ -52836,11 +52891,11 @@ function genericSignature(params, secretKey) {
52836
52891
  }
52837
52892
 
52838
52893
  // src/repositories/reddot-payment.repository.ts
52839
- var import_mongodb128 = require("mongodb");
52894
+ var import_mongodb129 = require("mongodb");
52840
52895
 
52841
52896
  // src/models/billing-payments.model.ts
52842
52897
  var import_node_server_utils221 = require("@7365admin1/node-server-utils");
52843
- var import_mongodb127 = require("mongodb");
52898
+ var import_mongodb128 = require("mongodb");
52844
52899
  var import_joi126 = __toESM(require("joi"));
52845
52900
  var schemaBillingItems = import_joi126.default.object({
52846
52901
  _id: import_joi126.default.string().hex().optional(),
@@ -52874,21 +52929,21 @@ function MBillingItems(value) {
52874
52929
  }
52875
52930
  if (value._id && typeof value._id === "string") {
52876
52931
  try {
52877
- value._id = new import_mongodb127.ObjectId(value._id);
52932
+ value._id = new import_mongodb128.ObjectId(value._id);
52878
52933
  } catch {
52879
52934
  throw new import_node_server_utils221.BadRequestError("Invalid _id format");
52880
52935
  }
52881
52936
  }
52882
52937
  if (value.unitId && typeof value.unitId === "string") {
52883
52938
  try {
52884
- value.unitId = new import_mongodb127.ObjectId(value.unitId);
52939
+ value.unitId = new import_mongodb128.ObjectId(value.unitId);
52885
52940
  } catch {
52886
52941
  throw new import_node_server_utils221.BadRequestError("Invalid unitId id format");
52887
52942
  }
52888
52943
  }
52889
52944
  if (value.paidBy && typeof value.paidBy === "string") {
52890
52945
  try {
52891
- value.paidBy = new import_mongodb127.ObjectId(value.paidBy);
52946
+ value.paidBy = new import_mongodb128.ObjectId(value.paidBy);
52892
52947
  } catch {
52893
52948
  throw new import_node_server_utils221.BadRequestError("Invalid paidBy id format");
52894
52949
  }
@@ -52898,7 +52953,7 @@ function MBillingItems(value) {
52898
52953
  value.unitBillingItems = value.unitBillingItems.map((unitBillingItem) => {
52899
52954
  if (typeof unitBillingItem._id === "string") {
52900
52955
  try {
52901
- unitBillingItem._id = new import_mongodb127.ObjectId(unitBillingItem._id);
52956
+ unitBillingItem._id = new import_mongodb128.ObjectId(unitBillingItem._id);
52902
52957
  } catch {
52903
52958
  throw new import_node_server_utils221.BadRequestError("Invalid unit billing id format");
52904
52959
  }
@@ -52910,7 +52965,7 @@ function MBillingItems(value) {
52910
52965
  }
52911
52966
  }
52912
52967
  return {
52913
- _id: value._id ?? new import_mongodb127.ObjectId(),
52968
+ _id: value._id ?? new import_mongodb128.ObjectId(),
52914
52969
  unitBillingItems: value.unitBillingItems ?? [],
52915
52970
  unitId: value.unitId ?? "",
52916
52971
  unitOwner: value.unitOwner ?? "",
@@ -52978,7 +53033,7 @@ var useRedDotPaymentRepo = () => {
52978
53033
  const res = await paymentCollection().insertOne(payload, { session });
52979
53034
  const unit = payload.unitId?.toString().slice(-4);
52980
53035
  const dateFormatted = formatDateString(/* @__PURE__ */ new Date());
52981
- const newId = new import_mongodb128.ObjectId(res.insertedId).toString().slice(-6);
53036
+ const newId = new import_mongodb129.ObjectId(res.insertedId).toString().slice(-6);
52982
53037
  const referenceNumber = `${unit}${newId}${dateFormatted}`;
52983
53038
  await paymentCollection().updateOne(
52984
53039
  { _id: res.insertedId },
@@ -54078,7 +54133,7 @@ var import_node_server_utils228 = require("@7365admin1/node-server-utils");
54078
54133
  var import_uuid2 = require("uuid");
54079
54134
 
54080
54135
  // src/repositories/user-v2.repo.ts
54081
- var import_mongodb129 = require("mongodb");
54136
+ var import_mongodb130 = require("mongodb");
54082
54137
  var import_node_server_utils227 = require("@7365admin1/node-server-utils");
54083
54138
  function useUserRepoV2() {
54084
54139
  const { updateFeedbackCreatedByName } = useFeedbackRepo();
@@ -54279,7 +54334,7 @@ function useUserRepoV2() {
54279
54334
  }
54280
54335
  if (organization) {
54281
54336
  try {
54282
- query.defaultOrg = new import_mongodb129.ObjectId(organization);
54337
+ query.defaultOrg = new import_mongodb130.ObjectId(organization);
54283
54338
  cacheOptions.organization = organization.toString();
54284
54339
  } catch (error) {
54285
54340
  throw new import_node_server_utils227.BadRequestError("Invalid organization ID format.");
@@ -54418,13 +54473,13 @@ function useUserRepoV2() {
54418
54473
  );
54419
54474
  }
54420
54475
  try {
54421
- _id = new import_mongodb129.ObjectId(_id);
54476
+ _id = new import_mongodb130.ObjectId(_id);
54422
54477
  } catch (error) {
54423
54478
  throw new import_node_server_utils227.BadRequestError("Invalid ID.");
54424
54479
  }
54425
54480
  if (field === "defaultOrg") {
54426
54481
  try {
54427
- value = new import_mongodb129.ObjectId(value);
54482
+ value = new import_mongodb130.ObjectId(value);
54428
54483
  } catch (error) {
54429
54484
  throw new import_node_server_utils227.BadRequestError("Invalid organization ID.");
54430
54485
  }
@@ -54465,7 +54520,7 @@ function useUserRepoV2() {
54465
54520
  year
54466
54521
  }, session) {
54467
54522
  try {
54468
- _id = new import_mongodb129.ObjectId(_id);
54523
+ _id = new import_mongodb130.ObjectId(_id);
54469
54524
  } catch (error) {
54470
54525
  throw new import_node_server_utils227.BadRequestError("Invalid user ID format.");
54471
54526
  }
@@ -54495,7 +54550,7 @@ function useUserRepoV2() {
54495
54550
  }
54496
54551
  async function updatePassword({ _id, password }, session) {
54497
54552
  try {
54498
- _id = new import_mongodb129.ObjectId(_id);
54553
+ _id = new import_mongodb130.ObjectId(_id);
54499
54554
  } catch (error) {
54500
54555
  throw new import_node_server_utils227.BadRequestError("Invalid user ID format.");
54501
54556
  }
@@ -55250,38 +55305,38 @@ function useUserControllerV2() {
55250
55305
 
55251
55306
  // src/models/role-v2.model.ts
55252
55307
  var import_node_server_utils232 = require("@7365admin1/node-server-utils");
55253
- var import_mongodb130 = require("mongodb");
55308
+ var import_mongodb131 = require("mongodb");
55254
55309
  var MRoleV2 = class {
55255
55310
  constructor(value) {
55256
55311
  if (typeof value._id === "string") {
55257
55312
  try {
55258
- value._id = new import_mongodb130.ObjectId(value._id);
55313
+ value._id = new import_mongodb131.ObjectId(value._id);
55259
55314
  } catch (error) {
55260
55315
  throw new import_node_server_utils232.BadRequestError("Invalid role-v2 ID format.");
55261
55316
  }
55262
55317
  }
55263
55318
  if (typeof value.site === "string" && value.site.length === 24) {
55264
55319
  try {
55265
- value.site = new import_mongodb130.ObjectId(value.site);
55320
+ value.site = new import_mongodb131.ObjectId(value.site);
55266
55321
  } catch (error) {
55267
55322
  throw new import_node_server_utils232.BadRequestError("Invalid site ID format.");
55268
55323
  }
55269
55324
  }
55270
55325
  if (typeof value.org === "string" && value.org.length === 24) {
55271
55326
  try {
55272
- value.org = new import_mongodb130.ObjectId(value.org);
55327
+ value.org = new import_mongodb131.ObjectId(value.org);
55273
55328
  } catch (error) {
55274
55329
  throw new import_node_server_utils232.BadRequestError("Invalid org ID format.");
55275
55330
  }
55276
55331
  }
55277
55332
  if (value.createdBy) {
55278
55333
  try {
55279
- value.createdBy = new import_mongodb130.ObjectId(value.createdBy);
55334
+ value.createdBy = new import_mongodb131.ObjectId(value.createdBy);
55280
55335
  } catch (error) {
55281
55336
  throw new import_node_server_utils232.BadRequestError("Invalid created by ID format.");
55282
55337
  }
55283
55338
  }
55284
- this._id = value._id ?? new import_mongodb130.ObjectId();
55339
+ this._id = value._id ?? new import_mongodb131.ObjectId();
55285
55340
  this.name = value.name ?? "";
55286
55341
  this.permissions = value.permissions ?? [];
55287
55342
  this.site = value.site ?? "";
@@ -55416,7 +55471,7 @@ function useRoleControllerV2() {
55416
55471
 
55417
55472
  // src/models/post-preloved.model.ts
55418
55473
  var import_joi133 = __toESM(require("joi"));
55419
- var import_mongodb131 = require("mongodb");
55474
+ var import_mongodb132 = require("mongodb");
55420
55475
  var PostStatus = /* @__PURE__ */ ((PostStatus2) => {
55421
55476
  PostStatus2["PUBLISHED"] = "published";
55422
55477
  PostStatus2["RESERVED"] = "reserved";
@@ -55472,28 +55527,28 @@ function MPost(value) {
55472
55527
  }
55473
55528
  if (value._id && typeof value._id === "string") {
55474
55529
  try {
55475
- value._id = new import_mongodb131.ObjectId(value._id);
55530
+ value._id = new import_mongodb132.ObjectId(value._id);
55476
55531
  } catch {
55477
55532
  throw new Error("Invalid ID.");
55478
55533
  }
55479
55534
  }
55480
55535
  if (value.site && typeof value.site === "string") {
55481
55536
  try {
55482
- value.site = new import_mongodb131.ObjectId(value.site);
55537
+ value.site = new import_mongodb132.ObjectId(value.site);
55483
55538
  } catch {
55484
55539
  throw new Error("Invalid site ID.");
55485
55540
  }
55486
55541
  }
55487
55542
  if (value.createdBy && typeof value.createdBy === "string") {
55488
55543
  try {
55489
- value.createdBy = new import_mongodb131.ObjectId(value.createdBy);
55544
+ value.createdBy = new import_mongodb132.ObjectId(value.createdBy);
55490
55545
  } catch {
55491
55546
  throw new Error("Invalid createdBy ID.");
55492
55547
  }
55493
55548
  }
55494
55549
  if (value.reserverId && typeof value.reserverId === "string") {
55495
55550
  try {
55496
- value.reserverId = new import_mongodb131.ObjectId(value.reserverId);
55551
+ value.reserverId = new import_mongodb132.ObjectId(value.reserverId);
55497
55552
  } catch {
55498
55553
  throw new Error("Invalid reserver ID.");
55499
55554
  }
@@ -55502,7 +55557,7 @@ function MPost(value) {
55502
55557
  value.attachments = value.attachments.map((id) => {
55503
55558
  if (typeof id === "string") {
55504
55559
  try {
55505
- return new import_mongodb131.ObjectId(id);
55560
+ return new import_mongodb132.ObjectId(id);
55506
55561
  } catch {
55507
55562
  throw new Error("Invalid attachment ID.");
55508
55563
  }
@@ -55512,20 +55567,20 @@ function MPost(value) {
55512
55567
  }
55513
55568
  if (value.category && typeof value.category === "string") {
55514
55569
  try {
55515
- value.category = new import_mongodb131.ObjectId(value.category);
55570
+ value.category = new import_mongodb132.ObjectId(value.category);
55516
55571
  } catch {
55517
55572
  throw new Error("Invalid category ID.");
55518
55573
  }
55519
55574
  }
55520
55575
  if (value.subcategory && typeof value.subcategory === "string") {
55521
55576
  try {
55522
- value.subcategory = new import_mongodb131.ObjectId(value.subcategory);
55577
+ value.subcategory = new import_mongodb132.ObjectId(value.subcategory);
55523
55578
  } catch {
55524
55579
  throw new Error("Invalid subcategory ID.");
55525
55580
  }
55526
55581
  }
55527
55582
  return {
55528
- _id: value._id ?? new import_mongodb131.ObjectId(),
55583
+ _id: value._id ?? new import_mongodb132.ObjectId(),
55529
55584
  title: value.title ?? "",
55530
55585
  description: value.description ?? "",
55531
55586
  attachments: value.attachments ?? [],
@@ -55545,7 +55600,7 @@ function MPost(value) {
55545
55600
 
55546
55601
  // src/repositories/post-preloved.repo.ts
55547
55602
  var import_node_server_utils235 = require("@7365admin1/node-server-utils");
55548
- var import_mongodb132 = require("mongodb");
55603
+ var import_mongodb133 = require("mongodb");
55549
55604
  function usePostPrelovedRepo() {
55550
55605
  const db = import_node_server_utils235.useAtlas.getDb();
55551
55606
  if (!db) {
@@ -55609,7 +55664,7 @@ function usePostPrelovedRepo() {
55609
55664
  }
55610
55665
  async function getById(_id) {
55611
55666
  try {
55612
- _id = new import_mongodb132.ObjectId(_id);
55667
+ _id = new import_mongodb133.ObjectId(_id);
55613
55668
  } catch {
55614
55669
  throw new import_node_server_utils235.BadRequestError("Invalid post ID format.");
55615
55670
  }
@@ -55642,7 +55697,7 @@ function usePostPrelovedRepo() {
55642
55697
  page = page > 0 ? page - 1 : 0;
55643
55698
  if (site) {
55644
55699
  try {
55645
- site = new import_mongodb132.ObjectId(site);
55700
+ site = new import_mongodb133.ObjectId(site);
55646
55701
  } catch {
55647
55702
  throw new import_node_server_utils235.BadRequestError("Invalid site ID format.");
55648
55703
  }
@@ -55651,14 +55706,14 @@ function usePostPrelovedRepo() {
55651
55706
  let subcategoryIds = null;
55652
55707
  if (category && subcategory) {
55653
55708
  try {
55654
- categoryId = new import_mongodb132.ObjectId(category);
55709
+ categoryId = new import_mongodb133.ObjectId(category);
55655
55710
  } catch {
55656
55711
  throw new import_node_server_utils235.BadRequestError("Invalid category ID format.");
55657
55712
  }
55658
55713
  if (subcategory.length > 0) {
55659
55714
  subcategoryIds = subcategory.map((id) => {
55660
55715
  try {
55661
- return new import_mongodb132.ObjectId(id);
55716
+ return new import_mongodb133.ObjectId(id);
55662
55717
  } catch {
55663
55718
  throw new import_node_server_utils235.BadRequestError("Invalid subcategory ID format.");
55664
55719
  }
@@ -55683,7 +55738,7 @@ function usePostPrelovedRepo() {
55683
55738
  let userObjectId = null;
55684
55739
  if (userId) {
55685
55740
  try {
55686
- userObjectId = new import_mongodb132.ObjectId(userId);
55741
+ userObjectId = new import_mongodb133.ObjectId(userId);
55687
55742
  } catch {
55688
55743
  throw new import_node_server_utils235.BadRequestError("Invalid user ID format.");
55689
55744
  }
@@ -55732,7 +55787,7 @@ function usePostPrelovedRepo() {
55732
55787
  }
55733
55788
  async function updateById(_id, value, session) {
55734
55789
  try {
55735
- _id = new import_mongodb132.ObjectId(_id);
55790
+ _id = new import_mongodb133.ObjectId(_id);
55736
55791
  } catch {
55737
55792
  throw new import_node_server_utils235.BadRequestError("Invalid post ID format.");
55738
55793
  }
@@ -55753,7 +55808,7 @@ function usePostPrelovedRepo() {
55753
55808
  }
55754
55809
  async function deleteById(_id, session) {
55755
55810
  try {
55756
- _id = new import_mongodb132.ObjectId(_id);
55811
+ _id = new import_mongodb133.ObjectId(_id);
55757
55812
  } catch {
55758
55813
  throw new import_node_server_utils235.BadRequestError("Invalid post ID format.");
55759
55814
  }
@@ -55779,7 +55834,7 @@ function usePostPrelovedRepo() {
55779
55834
  }
55780
55835
  async function updateStatus(_id, status, session) {
55781
55836
  try {
55782
- _id = new import_mongodb132.ObjectId(_id);
55837
+ _id = new import_mongodb133.ObjectId(_id);
55783
55838
  } catch {
55784
55839
  throw new import_node_server_utils235.BadRequestError("Invalid post ID format.");
55785
55840
  }
@@ -55991,7 +56046,7 @@ function usePostPrelovedController() {
55991
56046
 
55992
56047
  // src/models/post-favorite.model.ts
55993
56048
  var import_joi135 = __toESM(require("joi"));
55994
- var import_mongodb133 = require("mongodb");
56049
+ var import_mongodb134 = require("mongodb");
55995
56050
  var schemaUpdatePostFavorite = import_joi135.default.object({
55996
56051
  userId: import_joi135.default.string().hex().length(24).required()
55997
56052
  });
@@ -56009,14 +56064,14 @@ function MPostFavorite(value) {
56009
56064
  }
56010
56065
  if (value._id && typeof value._id === "string") {
56011
56066
  try {
56012
- value._id = new import_mongodb133.ObjectId(value._id);
56067
+ value._id = new import_mongodb134.ObjectId(value._id);
56013
56068
  } catch {
56014
56069
  throw new Error("Invalid ID.");
56015
56070
  }
56016
56071
  }
56017
56072
  if (value.postId && typeof value.postId === "string") {
56018
56073
  try {
56019
- value.postId = new import_mongodb133.ObjectId(value.postId);
56074
+ value.postId = new import_mongodb134.ObjectId(value.postId);
56020
56075
  } catch {
56021
56076
  throw new Error("Invalid post ID.");
56022
56077
  }
@@ -56025,7 +56080,7 @@ function MPostFavorite(value) {
56025
56080
  value.userIds = value.userIds.map((id) => {
56026
56081
  if (typeof id === "string") {
56027
56082
  try {
56028
- return new import_mongodb133.ObjectId(id);
56083
+ return new import_mongodb134.ObjectId(id);
56029
56084
  } catch {
56030
56085
  throw new Error("Invalid user ID.");
56031
56086
  }
@@ -56034,7 +56089,7 @@ function MPostFavorite(value) {
56034
56089
  });
56035
56090
  }
56036
56091
  return {
56037
- _id: value._id ?? new import_mongodb133.ObjectId(),
56092
+ _id: value._id ?? new import_mongodb134.ObjectId(),
56038
56093
  postId: value.postId ?? "",
56039
56094
  userIds: value.userIds ?? [],
56040
56095
  createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
@@ -56044,7 +56099,7 @@ function MPostFavorite(value) {
56044
56099
 
56045
56100
  // src/repositories/post-favorite.repo.ts
56046
56101
  var import_node_server_utils237 = require("@7365admin1/node-server-utils");
56047
- var import_mongodb134 = require("mongodb");
56102
+ var import_mongodb135 = require("mongodb");
56048
56103
  function usePostFavoriteRepo() {
56049
56104
  const db = import_node_server_utils237.useAtlas.getDb();
56050
56105
  if (!db) {
@@ -56066,7 +56121,7 @@ function usePostFavoriteRepo() {
56066
56121
  }
56067
56122
  async function getById(_id) {
56068
56123
  try {
56069
- _id = new import_mongodb134.ObjectId(_id);
56124
+ _id = new import_mongodb135.ObjectId(_id);
56070
56125
  } catch {
56071
56126
  throw new import_node_server_utils237.BadRequestError("Invalid favorite ID format.");
56072
56127
  }
@@ -56077,13 +56132,13 @@ function usePostFavoriteRepo() {
56077
56132
  }
56078
56133
  async function updateById(_id, userId, session) {
56079
56134
  try {
56080
- _id = new import_mongodb134.ObjectId(_id);
56135
+ _id = new import_mongodb135.ObjectId(_id);
56081
56136
  } catch {
56082
56137
  throw new import_node_server_utils237.BadRequestError("Invalid favorite ID format.");
56083
56138
  }
56084
56139
  let userObjectId;
56085
56140
  try {
56086
- userObjectId = new import_mongodb134.ObjectId(userId);
56141
+ userObjectId = new import_mongodb135.ObjectId(userId);
56087
56142
  } catch {
56088
56143
  throw new import_node_server_utils237.BadRequestError("Invalid user ID format.");
56089
56144
  }
@@ -56223,7 +56278,7 @@ function usePostFavoriteController() {
56223
56278
 
56224
56279
  // src/models/category-preloved.model.ts
56225
56280
  var import_joi137 = __toESM(require("joi"));
56226
- var import_mongodb135 = require("mongodb");
56281
+ var import_mongodb136 = require("mongodb");
56227
56282
  var schemaCategoryPreloved = import_joi137.default.object({
56228
56283
  name: import_joi137.default.string().required(),
56229
56284
  createdBy: import_joi137.default.string().hex().optional().allow("", null),
@@ -56240,14 +56295,14 @@ function MCategoryPreloved(value) {
56240
56295
  }
56241
56296
  if (value.createdBy && typeof value.createdBy === "string") {
56242
56297
  try {
56243
- value.createdBy = new import_mongodb135.ObjectId(value.createdBy);
56298
+ value.createdBy = new import_mongodb136.ObjectId(value.createdBy);
56244
56299
  } catch {
56245
56300
  throw new Error("Invalid createdBy ID.");
56246
56301
  }
56247
56302
  }
56248
56303
  if (value.site && typeof value.site === "string") {
56249
56304
  try {
56250
- value.site = new import_mongodb135.ObjectId(value.site);
56305
+ value.site = new import_mongodb136.ObjectId(value.site);
56251
56306
  } catch {
56252
56307
  throw new Error("Invalid site ID.");
56253
56308
  }
@@ -56263,7 +56318,7 @@ function MCategoryPreloved(value) {
56263
56318
 
56264
56319
  // src/repositories/category-preloved.repo.ts
56265
56320
  var import_node_server_utils240 = require("@7365admin1/node-server-utils");
56266
- var import_mongodb136 = require("mongodb");
56321
+ var import_mongodb137 = require("mongodb");
56267
56322
  function useCategoryPrelovedRepo() {
56268
56323
  const db = import_node_server_utils240.useAtlas.getDb();
56269
56324
  if (!db) {
@@ -56277,7 +56332,7 @@ function useCategoryPrelovedRepo() {
56277
56332
  } = {}) {
56278
56333
  if (site) {
56279
56334
  try {
56280
- site = new import_mongodb136.ObjectId(site);
56335
+ site = new import_mongodb137.ObjectId(site);
56281
56336
  } catch {
56282
56337
  throw new import_node_server_utils240.BadRequestError("Invalid site ID format.");
56283
56338
  }
@@ -56296,7 +56351,7 @@ function useCategoryPrelovedRepo() {
56296
56351
  async function getById(_id) {
56297
56352
  let objectId2;
56298
56353
  try {
56299
- objectId2 = new import_mongodb136.ObjectId(_id);
56354
+ objectId2 = new import_mongodb137.ObjectId(_id);
56300
56355
  } catch {
56301
56356
  throw new import_node_server_utils240.BadRequestError("Invalid category-preloved ID format.");
56302
56357
  }
@@ -56396,7 +56451,7 @@ function useCategoryPrelovedController() {
56396
56451
 
56397
56452
  // src/models/subcategory-preloved.model.ts
56398
56453
  var import_joi139 = __toESM(require("joi"));
56399
- var import_mongodb137 = require("mongodb");
56454
+ var import_mongodb138 = require("mongodb");
56400
56455
  var schemaSubcategoryPreloved = import_joi139.default.object({
56401
56456
  name: import_joi139.default.string().required(),
56402
56457
  createdBy: import_joi139.default.string().hex().optional().allow("", null),
@@ -56415,21 +56470,21 @@ function MSubcategoryPreloved(value) {
56415
56470
  }
56416
56471
  if (value.createdBy && typeof value.createdBy === "string") {
56417
56472
  try {
56418
- value.createdBy = new import_mongodb137.ObjectId(value.createdBy);
56473
+ value.createdBy = new import_mongodb138.ObjectId(value.createdBy);
56419
56474
  } catch {
56420
56475
  throw new Error("Invalid createdBy ID.");
56421
56476
  }
56422
56477
  }
56423
56478
  if (value.site && typeof value.site === "string") {
56424
56479
  try {
56425
- value.site = new import_mongodb137.ObjectId(value.site);
56480
+ value.site = new import_mongodb138.ObjectId(value.site);
56426
56481
  } catch {
56427
56482
  throw new Error("Invalid site ID.");
56428
56483
  }
56429
56484
  }
56430
56485
  if (value.category_id && typeof value.category_id === "string") {
56431
56486
  try {
56432
- value.category_id = new import_mongodb137.ObjectId(value.category_id);
56487
+ value.category_id = new import_mongodb138.ObjectId(value.category_id);
56433
56488
  } catch {
56434
56489
  throw new Error("Invalid category ID.");
56435
56490
  }
@@ -56446,7 +56501,7 @@ function MSubcategoryPreloved(value) {
56446
56501
 
56447
56502
  // src/repositories/subcategory-preloved.repo.ts
56448
56503
  var import_node_server_utils242 = require("@7365admin1/node-server-utils");
56449
- var import_mongodb138 = require("mongodb");
56504
+ var import_mongodb139 = require("mongodb");
56450
56505
  function useSubcategoryPrelovedRepo() {
56451
56506
  const db = import_node_server_utils242.useAtlas.getDb();
56452
56507
  if (!db) {
@@ -56461,14 +56516,14 @@ function useSubcategoryPrelovedRepo() {
56461
56516
  } = {}) {
56462
56517
  if (site) {
56463
56518
  try {
56464
- site = new import_mongodb138.ObjectId(site);
56519
+ site = new import_mongodb139.ObjectId(site);
56465
56520
  } catch {
56466
56521
  throw new import_node_server_utils242.BadRequestError("Invalid site ID format.");
56467
56522
  }
56468
56523
  }
56469
56524
  if (category_id) {
56470
56525
  try {
56471
- category_id = new import_mongodb138.ObjectId(category_id);
56526
+ category_id = new import_mongodb139.ObjectId(category_id);
56472
56527
  } catch {
56473
56528
  throw new import_node_server_utils242.BadRequestError("Invalid category ID format.");
56474
56529
  }
@@ -56487,7 +56542,7 @@ function useSubcategoryPrelovedRepo() {
56487
56542
  async function getById(_id) {
56488
56543
  let objectId2;
56489
56544
  try {
56490
- objectId2 = new import_mongodb138.ObjectId(_id);
56545
+ objectId2 = new import_mongodb139.ObjectId(_id);
56491
56546
  } catch {
56492
56547
  throw new import_node_server_utils242.BadRequestError("Invalid subcategory-preloved ID format.");
56493
56548
  }
@@ -56501,14 +56556,30 @@ function useSubcategoryPrelovedRepo() {
56501
56556
  throw error;
56502
56557
  }
56503
56558
  }
56504
- return { getAll, getById };
56559
+ async function addSubcategory(item, session) {
56560
+ const doc = MSubcategoryPreloved(item);
56561
+ try {
56562
+ const res = await collection.insertOne(doc, { session });
56563
+ return res.insertedId;
56564
+ } catch (error) {
56565
+ const isDuplicated = error.message?.includes("duplicate");
56566
+ if (isDuplicated)
56567
+ throw new import_node_server_utils242.BadRequestError("Subcategory already exists.");
56568
+ throw error;
56569
+ }
56570
+ }
56571
+ return { getAll, getById, addSubcategory };
56505
56572
  }
56506
56573
 
56507
56574
  // src/controllers/subcategory-preloved.controller.ts
56508
56575
  var import_node_server_utils243 = require("@7365admin1/node-server-utils");
56509
56576
  var import_joi140 = __toESM(require("joi"));
56510
56577
  function useSubcategoryPrelovedController() {
56511
- const { getAll: _getAll, getById: _getById } = useSubcategoryPrelovedRepo();
56578
+ const {
56579
+ getAll: _getAll,
56580
+ getById: _getById,
56581
+ addSubcategory: _addSubcategory
56582
+ } = useSubcategoryPrelovedRepo();
56512
56583
  async function getAll(req, res, next) {
56513
56584
  const schema2 = import_joi140.default.object({
56514
56585
  search: import_joi140.default.string().optional().allow("", null),
@@ -56552,12 +56623,30 @@ function useSubcategoryPrelovedController() {
56552
56623
  return;
56553
56624
  }
56554
56625
  }
56555
- return { getAll, getById };
56626
+ async function addSubcategory(req, res, next) {
56627
+ const { error, value } = schemaSubcategoryPreloved.validate(req.body, {
56628
+ abortEarly: false
56629
+ });
56630
+ if (error) {
56631
+ const messages = error.details.map((d) => d.message).join(", ");
56632
+ import_node_server_utils243.logger.log({ level: "error", message: messages });
56633
+ next(new import_node_server_utils243.BadRequestError(messages));
56634
+ return;
56635
+ }
56636
+ try {
56637
+ const data = await _addSubcategory(value);
56638
+ res.status(201).json(data);
56639
+ } catch (error2) {
56640
+ import_node_server_utils243.logger.log({ level: "error", message: error2.message });
56641
+ next(error2);
56642
+ }
56643
+ }
56644
+ return { getAll, getById, addSubcategory };
56556
56645
  }
56557
56646
 
56558
56647
  // src/models/online-forms-v2.model.ts
56559
56648
  var import_joi141 = __toESM(require("joi"));
56560
- var import_mongodb139 = require("mongodb");
56649
+ var import_mongodb140 = require("mongodb");
56561
56650
  var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
56562
56651
  FormEntryStatus2["ACTIVE"] = "active";
56563
56652
  FormEntryStatus2["INACTIVE"] = "inactive";
@@ -56612,21 +56701,21 @@ function MFormEntry(value) {
56612
56701
  }
56613
56702
  if (value._id && typeof value._id === "string") {
56614
56703
  try {
56615
- value._id = new import_mongodb139.ObjectId(value._id);
56704
+ value._id = new import_mongodb140.ObjectId(value._id);
56616
56705
  } catch {
56617
56706
  throw new Error("Invalid ID.");
56618
56707
  }
56619
56708
  }
56620
56709
  if (value.org && typeof value.org === "string") {
56621
56710
  try {
56622
- value.org = new import_mongodb139.ObjectId(value.org);
56711
+ value.org = new import_mongodb140.ObjectId(value.org);
56623
56712
  } catch {
56624
56713
  throw new Error("Invalid org ID.");
56625
56714
  }
56626
56715
  }
56627
56716
  if (value.site && typeof value.site === "string") {
56628
56717
  try {
56629
- value.site = new import_mongodb139.ObjectId(value.site);
56718
+ value.site = new import_mongodb140.ObjectId(value.site);
56630
56719
  } catch {
56631
56720
  throw new Error("Invalid site ID.");
56632
56721
  }